|
1 | 1 | package rewards |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "context" |
4 | 5 | "fmt" |
5 | 6 | "math/big" |
6 | 7 | "sync" |
@@ -230,6 +231,15 @@ func SubmitRewardSnapshot(rp *rocketpool.RocketPool, submission RewardSubmission |
230 | 231 |
|
231 | 232 | // Get the event info for a rewards snapshot using the Atlas getter |
232 | 233 | func GetRewardsEvent(rp *rocketpool.RocketPool, index uint64, rocketRewardsPoolAddresses []common.Address, opts *bind.CallOpts) (bool, RewardsEvent, error) { |
| 234 | + // Check if the client is requesting interval 0 on mainnet, then return the hardcoded RewardsEvent |
| 235 | + data, ok, err := getMainnetInterval0RewardsEvent(rp, index) |
| 236 | + if err != nil { |
| 237 | + return false, RewardsEvent{}, err |
| 238 | + } |
| 239 | + if ok { |
| 240 | + return true, data, nil |
| 241 | + } |
| 242 | + |
233 | 243 | // Get contracts |
234 | 244 | rocketRewardsPool, err := getRocketRewardsPool(rp, opts) |
235 | 245 | if err != nil { |
@@ -317,6 +327,48 @@ func GetRewardsEvent(rp *rocketpool.RocketPool, index uint64, rocketRewardsPoolA |
317 | 327 | return true, eventData, nil |
318 | 328 | } |
319 | 329 |
|
| 330 | +// Check if the client is requesting interval 0 on mainnet, then return the hardcoded RewardsEvent |
| 331 | +func getMainnetInterval0RewardsEvent(rp *rocketpool.RocketPool, index uint64) (RewardsEvent, bool, error) { |
| 332 | + if index != 0 { |
| 333 | + return RewardsEvent{}, false, nil |
| 334 | + } |
| 335 | + // Check if the ec is synced to mainnet |
| 336 | + chainID, err := rp.Client.ChainID(context.Background()) |
| 337 | + if err != nil { |
| 338 | + return RewardsEvent{}, false, fmt.Errorf("error getting chainID: %w", err) |
| 339 | + } |
| 340 | + if chainID.Cmp(big.NewInt(1)) != 0 { |
| 341 | + return RewardsEvent{}, false, nil |
| 342 | + } |
| 343 | + |
| 344 | + // Hardcoded RewardsEvent for interval 0 on mainnet |
| 345 | + treasuryRPL := new(big.Int) |
| 346 | + treasuryRPL.SetString("10633670478560109530497", 10) |
| 347 | + trustedNodeRPL := new(big.Int) |
| 348 | + trustedNodeRPL.SetString("10633670478560109529794", 10) |
| 349 | + nodeRPL := new(big.Int) |
| 350 | + nodeRPL.SetString("49623795566613844471758", 10) |
| 351 | + |
| 352 | + eventDataInterval_0 := RewardsEvent{ |
| 353 | + Index: big.NewInt(0), |
| 354 | + ExecutionBlock: big.NewInt(15451078), |
| 355 | + ConsensusBlock: big.NewInt(4598879), |
| 356 | + IntervalsPassed: big.NewInt(1), |
| 357 | + TreasuryRPL: treasuryRPL, |
| 358 | + TrustedNodeRPL: []*big.Int{trustedNodeRPL}, |
| 359 | + NodeRPL: []*big.Int{nodeRPL}, |
| 360 | + NodeETH: []*big.Int{big.NewInt(0)}, |
| 361 | + UserETH: big.NewInt(0), |
| 362 | + MerkleRoot: common.HexToHash("0xb839fa0f5842bf3c8f19091361889fb0f1cb399d64b8da476d372b7de7a93463"), |
| 363 | + MerkleTreeCID: "bafybeidrck3sz24acv32h56xdb7ruarxq52oci32del7moxqtief3do73y", |
| 364 | + IntervalStartTime: time.Unix(1659591339, 0), |
| 365 | + IntervalEndTime: time.Unix(1662010539, 0), |
| 366 | + SubmissionTime: time.Unix(1662011717, 0), |
| 367 | + } |
| 368 | + |
| 369 | + return eventDataInterval_0, true, nil |
| 370 | +} |
| 371 | + |
320 | 372 | // Get contracts |
321 | 373 | var rocketRewardsPoolLock sync.Mutex |
322 | 374 |
|
|
0 commit comments