Skip to content

Commit

Permalink
feat(RewardsStreamerMP): stream rewards for a period without checking…
Browse files Browse the repository at this point in the history
… a real reward token balance
  • Loading branch information
gravityblast committed Dec 3, 2024
1 parent 9acb04f commit 2108d88
Show file tree
Hide file tree
Showing 5 changed files with 239 additions and 151 deletions.
67 changes: 36 additions & 31 deletions .gas-report
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,45 @@
| updateRewardIndex | 23374 | 45581 | 39585 | 73785 | 3 |


| src/RewardsStreamerMP.sol:RewardsStreamerMP contract | | | | | |
|------------------------------------------------------|-----------------|-------|--------|-------|---------|
| Deployment Cost | Deployment Size | | | | |
| 1425736 | 6528 | | | | |
| Function Name | min | avg | median | max | # calls |
| MAX_LOCKUP_PERIOD | 228 | 228 | 228 | 228 | 23 |
| MAX_MULTIPLIER | 274 | 274 | 274 | 274 | 30 |
| MIN_LOCKUP_PERIOD | 275 | 275 | 275 | 275 | 11 |
| MP_RATE_PER_YEAR | 231 | 231 | 231 | 231 | 3 |
| SCALE_FACTOR | 295 | 295 | 295 | 295 | 41 |
| STAKING_TOKEN | 273 | 273 | 273 | 273 | 172 |
| accountedRewards | 351 | 906 | 351 | 2351 | 72 |
| emergencyModeEnabled | 2377 | 2377 | 2377 | 2377 | 7 |
| enableEmergencyMode | 23504 | 40411 | 45696 | 45696 | 8 |
| getAccount | 1596 | 1596 | 1596 | 1596 | 71 |
| isTrustedCodehash | 496 | 996 | 496 | 2496 | 172 |
| rewardIndex | 373 | 400 | 373 | 2373 | 72 |
| setTrustedCodehash | 47926 | 47926 | 47926 | 47926 | 43 |
| totalMP | 330 | 330 | 330 | 330 | 75 |
| totalMaxMP | 351 | 351 | 351 | 351 | 75 |
| totalStaked | 330 | 330 | 330 | 330 | 75 |
| updateAccountMP | 36758 | 38996 | 39260 | 39260 | 19 |
| updateGlobalState | 32134 | 60366 | 49513 | 82460 | 28 |
| src/RewardsStreamerMP.sol:RewardsStreamerMP contract | | | | | |
|------------------------------------------------------|-----------------|-------|--------|--------|---------|
| Deployment Cost | Deployment Size | | | | |
| 1372929 | 6195 | | | | |
| Function Name | min | avg | median | max | # calls |
| MAX_LOCKUP_PERIOD | 273 | 273 | 273 | 273 | 23 |
| MAX_MULTIPLIER | 252 | 252 | 252 | 252 | 30 |
| MIN_LOCKUP_PERIOD | 275 | 275 | 275 | 275 | 11 |
| MP_RATE_PER_YEAR | 231 | 231 | 231 | 231 | 3 |
| SCALE_FACTOR | 229 | 229 | 229 | 229 | 41 |
| STAKING_TOKEN | 273 | 273 | 273 | 273 | 196 |
| emergencyModeEnabled | 2399 | 2399 | 2399 | 2399 | 7 |
| enableEmergencyMode | 23526 | 40433 | 45718 | 45718 | 8 |
| getAccount | 1596 | 1596 | 1596 | 1596 | 71 |
| isTrustedCodehash | 563 | 1063 | 563 | 2563 | 196 |
| lastRewardTime | 352 | 1352 | 1352 | 2352 | 2 |
| rewardEndTime | 330 | 1330 | 1330 | 2330 | 2 |
| rewardStartTime | 330 | 1330 | 1330 | 2330 | 2 |
| rewardsBalanceOf | 1291 | 1291 | 1291 | 1291 | 4 |
| setReward | 23865 | 72222 | 81652 | 123891 | 7 |
| setTrustedCodehash | 47897 | 47897 | 47897 | 47897 | 49 |
| totalMP | 374 | 374 | 374 | 374 | 75 |
| totalMaxMP | 373 | 373 | 373 | 373 | 75 |
| totalRewardsAccrued | 374 | 374 | 374 | 374 | 3 |
| totalRewardsSupply | 986 | 1950 | 1754 | 6725 | 30 |
| totalStaked | 352 | 352 | 352 | 352 | 75 |
| updateAccountMP | 36802 | 39880 | 39304 | 56404 | 21 |
| updateGlobalState | 32134 | 49173 | 46395 | 131387 | 21 |


| src/StakeVault.sol:StakeVault contract | | | | | |
|----------------------------------------|-----------------|--------|--------|--------|---------|
| Deployment Cost | Deployment Size | | | | |
| 1095864 | 5202 | | | | |
| Function Name | min | avg | median | max | # calls |
| emergencyExit | 31410 | 43924 | 43160 | 60260 | 7 |
| lock | 38362 | 60516 | 42741 | 100445 | 3 |
| stake | 199213 | 236948 | 242906 | 263435 | 55 |
| unstake | 84988 | 113999 | 103434 | 146128 | 13 |
| emergencyExit | 31432 | 43946 | 43182 | 60282 | 7 |
| lock | 38384 | 59498 | 42763 | 97349 | 3 |
| stake | 195236 | 234745 | 242047 | 262576 | 57 |
| unstake | 81851 | 91854 | 99513 | 99513 | 13 |


| src/XPNFTToken.sol:XPNFTToken contract | | | | | |
Expand Down Expand Up @@ -121,10 +126,10 @@
| Deployment Cost | Deployment Size | | | | |
| 639406 | 3369 | | | | |
| Function Name | min | avg | median | max | # calls |
| approve | 46334 | 46343 | 46346 | 46346 | 220 |
| balanceOf | 561 | 1381 | 561 | 2561 | 334 |
| mint | 51284 | 58817 | 51284 | 68384 | 236 |
| transfer | 34390 | 48859 | 51490 | 51490 | 13 |
| approve | 46334 | 46343 | 46346 | 46346 | 201 |
| balanceOf | 561 | 948 | 561 | 2561 | 129 |
| mint | 51284 | 56561 | 51284 | 68384 | 217 |
| transfer | 34390 | 42940 | 42940 | 51490 | 2 |


| test/mocks/XPProviderMock.sol:XPProviderMock contract | | | | | |
Expand Down
92 changes: 49 additions & 43 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,53 +1,59 @@
EmergencyExitTest:test_CannotEnableEmergencyModeTwice() (gas: 79829)
EmergencyExitTest:test_CannotLeaveBeforeEmergencyMode() (gas: 283234)
EmergencyExitTest:test_EmergencyExitBasic() (gas: 379874)
EmergencyExitTest:test_EmergencyExitMultipleUsers() (gas: 788714)
EmergencyExitTest:test_EmergencyExitToAlternateAddress() (gas: 517455)
EmergencyExitTest:test_EmergencyExitWithLock() (gas: 370304)
EmergencyExitTest:test_EmergencyExitWithRewards() (gas: 507361)
EmergencyExitTest:test_OnlyOwnerCanEnableEmergencyMode() (gas: 34607)
IntegrationTest:testStakeFoo() (gas: 1490300)
LockTest:test_LockFailsWithInvalidPeriod() (gas: 290178)
LockTest:test_LockFailsWithNoStake() (gas: 53357)
LockTest:test_LockWithoutPriorLock() (gas: 383272)
EmergencyExitTest:test_CannotEnableEmergencyModeTwice() (gas: 82805)
EmergencyExitTest:test_CannotLeaveBeforeEmergencyMode() (gas: 282431)
EmergencyExitTest:test_EmergencyExitBasic() (gas: 363444)
EmergencyExitTest:test_EmergencyExitMultipleUsers() (gas: 622385)
EmergencyExitTest:test_EmergencyExitToAlternateAddress() (gas: 372519)
EmergencyExitTest:test_EmergencyExitWithLock() (gas: 372012)
EmergencyExitTest:test_EmergencyExitWithRewards() (gas: 356429)
EmergencyExitTest:test_OnlyOwnerCanEnableEmergencyMode() (gas: 34657)
IntegrationTest:testStakeFoo() (gas: 1099285)
LockTest:test_LockFailsWithInvalidPeriod() (gas: 289341)
LockTest:test_LockFailsWithNoStake() (gas: 53423)
LockTest:test_LockWithoutPriorLock() (gas: 367501)
NFTMetadataGeneratorSVGTest:testGenerateMetadata() (gas: 92874)
NFTMetadataGeneratorSVGTest:testSetImageStrings() (gas: 60081)
NFTMetadataGeneratorSVGTest:testSetImageStringsRevert() (gas: 35818)
NFTMetadataGeneratorURLTest:testGenerateMetadata() (gas: 109345)
NFTMetadataGeneratorURLTest:testSetBaseURL() (gas: 50653)
NFTMetadataGeneratorURLTest:testSetBaseURLRevert() (gas: 35993)
RewardsStreamerMP_RewardsTest:testRewardsBalanceOf() (gas: 628332)
RewardsStreamerMP_RewardsTest:testSetRewards() (gas: 148031)
RewardsStreamerMP_RewardsTest:testSetRewards_RevertsBadAmount() (gas: 34350)
RewardsStreamerMP_RewardsTest:testSetRewards_RevertsBadDuration() (gas: 34372)
RewardsStreamerMP_RewardsTest:testSetRewards_RevertsNotAuthorized() (gas: 34402)
RewardsStreamerMP_RewardsTest:testTotalRewardsSupply() (gas: 578711)
RewardsStreamerTest:testStake() (gas: 869874)
StakeTest:test_StakeMultipleAccounts() (gas: 493279)
StakeTest:test_StakeMultipleAccountsAndRewards() (gas: 640763)
StakeTest:test_StakeMultipleAccountsMPIncreasesMaxMPDoesNotChange() (gas: 818252)
StakeTest:test_StakeMultipleAccountsWithMinLockUp() (gas: 499381)
StakeTest:test_StakeMultipleAccountsWithRandomLockUp() (gas: 520783)
StakeTest:test_StakeOneAccount() (gas: 284277)
StakeTest:test_StakeOneAccountAndRewards() (gas: 431756)
StakeTest:test_StakeOneAccountMPIncreasesMaxMPDoesNotChange() (gas: 498901)
StakeTest:test_StakeOneAccountReachingMPLimit() (gas: 494078)
StakeTest:test_StakeOneAccountWithMaxLockUp() (gas: 298175)
StakeTest:test_StakeOneAccountWithMinLockUp() (gas: 298187)
StakeTest:test_StakeOneAccountWithRandomLockUp() (gas: 298298)
UnstakeTest:test_StakeMultipleAccounts() (gas: 493323)
UnstakeTest:test_StakeMultipleAccountsAndRewards() (gas: 640807)
UnstakeTest:test_StakeMultipleAccountsMPIncreasesMaxMPDoesNotChange() (gas: 818251)
UnstakeTest:test_StakeMultipleAccountsWithMinLockUp() (gas: 499380)
UnstakeTest:test_StakeMultipleAccountsWithRandomLockUp() (gas: 520827)
UnstakeTest:test_StakeOneAccount() (gas: 284300)
UnstakeTest:test_StakeOneAccountAndRewards() (gas: 431800)
UnstakeTest:test_StakeOneAccountMPIncreasesMaxMPDoesNotChange() (gas: 498945)
UnstakeTest:test_StakeOneAccountReachingMPLimit() (gas: 494080)
UnstakeTest:test_StakeOneAccountWithMaxLockUp() (gas: 298132)
UnstakeTest:test_StakeOneAccountWithMinLockUp() (gas: 298187)
UnstakeTest:test_StakeOneAccountWithRandomLockUp() (gas: 298298)
UnstakeTest:test_UnstakeBonusMPAndAccuredMP() (gas: 508511)
UnstakeTest:test_UnstakeMultipleAccounts() (gas: 688755)
UnstakeTest:test_UnstakeMultipleAccountsAndRewards() (gas: 1014239)
UnstakeTest:test_UnstakeOneAccount() (gas: 480152)
UnstakeTest:test_UnstakeOneAccountAndAccruedMP() (gas: 496638)
UnstakeTest:test_UnstakeOneAccountAndRewards() (gas: 585964)
UnstakeTest:test_UnstakeOneAccountWithLockUpAndAccruedMP() (gas: 518574)
StakeTest:test_StakeMultipleAccounts() (gas: 472415)
StakeTest:test_StakeMultipleAccountsAndRewards() (gas: 477319)
StakeTest:test_StakeMultipleAccountsMPIncreasesMaxMPDoesNotChange() (gas: 771106)
StakeTest:test_StakeMultipleAccountsWithMinLockUp() (gas: 487107)
StakeTest:test_StakeMultipleAccountsWithRandomLockUp() (gas: 508591)
StakeTest:test_StakeOneAccount() (gas: 265401)
StakeTest:test_StakeOneAccountAndRewards() (gas: 270336)
StakeTest:test_StakeOneAccountMPIncreasesMaxMPDoesNotChange() (gas: 461347)
StakeTest:test_StakeOneAccountReachingMPLimit() (gas: 456345)
StakeTest:test_StakeOneAccountWithMaxLockUp() (gas: 283609)
StakeTest:test_StakeOneAccountWithMinLockUp() (gas: 283620)
StakeTest:test_StakeOneAccountWithRandomLockUp() (gas: 283687)
UnstakeTest:test_StakeMultipleAccounts() (gas: 472437)
UnstakeTest:test_StakeMultipleAccountsAndRewards() (gas: 477341)
UnstakeTest:test_StakeMultipleAccountsMPIncreasesMaxMPDoesNotChange() (gas: 771128)
UnstakeTest:test_StakeMultipleAccountsWithMinLockUp() (gas: 487129)
UnstakeTest:test_StakeMultipleAccountsWithRandomLockUp() (gas: 508613)
UnstakeTest:test_StakeOneAccount() (gas: 265424)
UnstakeTest:test_StakeOneAccountAndRewards() (gas: 270358)
UnstakeTest:test_StakeOneAccountMPIncreasesMaxMPDoesNotChange() (gas: 461369)
UnstakeTest:test_StakeOneAccountReachingMPLimit() (gas: 456325)
UnstakeTest:test_StakeOneAccountWithMaxLockUp() (gas: 283609)
UnstakeTest:test_StakeOneAccountWithMinLockUp() (gas: 283620)
UnstakeTest:test_StakeOneAccountWithRandomLockUp() (gas: 283731)
UnstakeTest:test_UnstakeBonusMPAndAccuredMP() (gas: 500656)
UnstakeTest:test_UnstakeMultipleAccounts() (gas: 651532)
UnstakeTest:test_UnstakeMultipleAccountsAndRewards() (gas: 735685)
UnstakeTest:test_UnstakeOneAccount() (gas: 442490)
UnstakeTest:test_UnstakeOneAccountAndAccruedMP() (gas: 460794)
UnstakeTest:test_UnstakeOneAccountAndRewards() (gas: 379981)
UnstakeTest:test_UnstakeOneAccountWithLockUpAndAccruedMP() (gas: 486610)
XPNFTTokenTest:testApproveNotAllowed() (gas: 10507)
XPNFTTokenTest:testGetApproved() (gas: 10531)
XPNFTTokenTest:testIsApprovedForAll() (gas: 10705)
Expand Down
Loading

0 comments on commit 2108d88

Please sign in to comment.