mirror of
https://github.com/vacp2p/staking-reward-streamer.git
synced 2026-01-09 21:18:01 -05:00
refactor(RewardsStreamerMP): rename functions to be appropriate
This commit is contained in:
88
.gas-report
88
.gas-report
@@ -1,9 +1,9 @@
|
||||
| script/DeployRewardsStreamerMP.s.sol:DeployRewardsStreamerMPScript contract | | | | | |
|
||||
|-----------------------------------------------------------------------------|-----------------|---------|---------|---------|---------|
|
||||
| Deployment Cost | Deployment Size | | | | |
|
||||
| 6200681 | 29704 | | | | |
|
||||
| 6200489 | 29703 | | | | |
|
||||
| Function Name | min | avg | median | max | # calls |
|
||||
| run | 5302574 | 5302574 | 5302574 | 5302574 | 63 |
|
||||
| run | 5302330 | 5302330 | 5302330 | 5302330 | 63 |
|
||||
|
||||
|
||||
| script/DeploymentConfig.s.sol:DeploymentConfig contract | | | | | |
|
||||
@@ -17,9 +17,9 @@
|
||||
| script/UpgradeRewardsStreamerMP.s.sol:UpgradeRewardsStreamerMPScript contract | | | | | |
|
||||
|-------------------------------------------------------------------------------|-----------------|---------|---------|---------|---------|
|
||||
| Deployment Cost | Deployment Size | | | | |
|
||||
| 2845816 | 14079 | | | | |
|
||||
| 2845624 | 14078 | | | | |
|
||||
| Function Name | min | avg | median | max | # calls |
|
||||
| run | 2383391 | 2383391 | 2383391 | 2383391 | 3 |
|
||||
| run | 2383214 | 2383214 | 2383214 | 2383214 | 3 |
|
||||
|
||||
|
||||
| src/RewardsStreamer.sol:RewardsStreamer contract | | | | | |
|
||||
@@ -39,77 +39,77 @@
|
||||
| src/RewardsStreamerMP.sol:RewardsStreamerMP contract | | | | | |
|
||||
|------------------------------------------------------|-----------------|--------|--------|--------|---------|
|
||||
| Deployment Cost | Deployment Size | | | | |
|
||||
| 2525879 | 11640 | | | | |
|
||||
| 2525687 | 11639 | | | | |
|
||||
| Function Name | min | avg | median | max | # calls |
|
||||
| MAX_LOCKUP_PERIOD | 349 | 349 | 349 | 349 | 6 |
|
||||
| MAX_MULTIPLIER | 251 | 251 | 251 | 251 | 33 |
|
||||
| MAX_MULTIPLIER | 273 | 273 | 273 | 273 | 33 |
|
||||
| MIN_LOCKUP_PERIOD | 297 | 297 | 297 | 297 | 15 |
|
||||
| MP_RATE_PER_YEAR | 253 | 253 | 253 | 253 | 9 |
|
||||
| STAKING_TOKEN | 428 | 2036 | 2428 | 2428 | 322 |
|
||||
| emergencyModeEnabled | 2420 | 2420 | 2420 | 2420 | 7 |
|
||||
| enableEmergencyMode | 2485 | 19392 | 24677 | 24677 | 8 |
|
||||
| getAccount | 1661 | 1661 | 1661 | 1661 | 72 |
|
||||
| getStakedBalance | 2629 | 2629 | 2629 | 2629 | 1 |
|
||||
| getUserTotalMP | 9230 | 9230 | 9230 | 9230 | 1 |
|
||||
| getUserTotalMaxMP | 3123 | 3123 | 3123 | 3123 | 1 |
|
||||
| getUserTotalStakedBalance | 15118 | 15118 | 15118 | 15118 | 1 |
|
||||
| getStakedBalance | 2607 | 2607 | 2607 | 2607 | 1 |
|
||||
| getUserTotalMaxMP | 3166 | 3166 | 3166 | 3166 | 1 |
|
||||
| getUserTotalStakedBalance | 15162 | 15162 | 15162 | 15162 | 1 |
|
||||
| getUserVaults | 5201 | 5201 | 5201 | 5201 | 4 |
|
||||
| initialize | 115611 | 115611 | 115611 | 115611 | 65 |
|
||||
| initialize | 115589 | 115589 | 115589 | 115589 | 65 |
|
||||
| lastRewardTime | 395 | 1395 | 1395 | 2395 | 2 |
|
||||
| leave | 56244 | 56244 | 56244 | 56244 | 1 |
|
||||
| lock | 12063 | 34172 | 16480 | 73975 | 3 |
|
||||
| proxiableUUID | 331 | 331 | 331 | 331 | 3 |
|
||||
| mpBalanceOfUser | 9185 | 9185 | 9185 | 9185 | 1 |
|
||||
| proxiableUUID | 376 | 376 | 376 | 376 | 3 |
|
||||
| registerVault | 55866 | 72766 | 72966 | 72966 | 257 |
|
||||
| rewardEndTime | 373 | 1373 | 1373 | 2373 | 2 |
|
||||
| rewardStartTime | 352 | 1352 | 1352 | 2352 | 2 |
|
||||
| rewardsBalanceOf | 1317 | 1317 | 1317 | 1317 | 4 |
|
||||
| rewardEndTime | 351 | 1351 | 1351 | 2351 | 2 |
|
||||
| rewardStartTime | 396 | 1396 | 1396 | 2396 | 2 |
|
||||
| rewardsBalanceOf | 1362 | 1362 | 1362 | 1362 | 4 |
|
||||
| setReward | 2583 | 50892 | 60278 | 102595 | 7 |
|
||||
| setTrustedCodehash | 24243 | 24304 | 24243 | 26243 | 65 |
|
||||
| stake | 131082 | 170202 | 177899 | 198232 | 66 |
|
||||
| totalMP | 373 | 373 | 373 | 373 | 81 |
|
||||
| totalMaxMP | 350 | 350 | 350 | 350 | 81 |
|
||||
| totalRewardsAccrued | 373 | 373 | 373 | 373 | 3 |
|
||||
| setTrustedCodehash | 24221 | 24282 | 24221 | 26221 | 65 |
|
||||
| stake | 131124 | 170244 | 177941 | 198274 | 66 |
|
||||
| totalMPAccrued | 351 | 351 | 351 | 351 | 81 |
|
||||
| totalMaxMP | 395 | 395 | 395 | 395 | 81 |
|
||||
| totalRewardsAccrued | 351 | 351 | 351 | 351 | 3 |
|
||||
| totalRewardsSupply | 960 | 1921 | 1724 | 6700 | 30 |
|
||||
| totalStaked | 396 | 396 | 396 | 396 | 82 |
|
||||
| unstake | 60382 | 60919 | 60382 | 63877 | 13 |
|
||||
| updateAccountMP | 15396 | 18474 | 17898 | 34998 | 21 |
|
||||
| totalStaked | 374 | 374 | 374 | 374 | 82 |
|
||||
| unstake | 60360 | 60897 | 60360 | 63855 | 13 |
|
||||
| updateAccountMP | 15348 | 18429 | 17854 | 34954 | 21 |
|
||||
| updateGlobalState | 11088 | 28045 | 25249 | 110284 | 21 |
|
||||
| upgradeToAndCall | 3225 | 7887 | 8426 | 10936 | 5 |
|
||||
| upgradeToAndCall | 3203 | 7892 | 8449 | 10914 | 5 |
|
||||
|
||||
|
||||
| src/StakeManagerProxy.sol:StakeManagerProxy contract | | | | | |
|
||||
|------------------------------------------------------|-----------------|-------|--------|--------|---------|
|
||||
| Deployment Cost | Deployment Size | | | | |
|
||||
| 256467 | 1263 | | | | |
|
||||
| 256445 | 1263 | | | | |
|
||||
| Function Name | min | avg | median | max | # calls |
|
||||
| MAX_LOCKUP_PERIOD | 776 | 3776 | 5276 | 5276 | 6 |
|
||||
| MAX_MULTIPLIER | 678 | 1905 | 678 | 5178 | 33 |
|
||||
| MAX_MULTIPLIER | 700 | 1927 | 700 | 5200 | 33 |
|
||||
| MIN_LOCKUP_PERIOD | 724 | 3424 | 5224 | 5224 | 15 |
|
||||
| MP_RATE_PER_YEAR | 680 | 1180 | 680 | 5180 | 9 |
|
||||
| STAKING_TOKEN | 855 | 6083 | 7355 | 7355 | 322 |
|
||||
| emergencyModeEnabled | 7347 | 7347 | 7347 | 7347 | 7 |
|
||||
| enableEmergencyMode | 28480 | 45381 | 50665 | 50665 | 8 |
|
||||
| getAccount | 2115 | 2115 | 2115 | 2115 | 72 |
|
||||
| getStakedBalance | 7559 | 7559 | 7559 | 7559 | 1 |
|
||||
| getUserTotalMP | 9660 | 9660 | 9660 | 9660 | 1 |
|
||||
| getUserTotalMaxMP | 3553 | 3553 | 3553 | 3553 | 1 |
|
||||
| getUserTotalStakedBalance | 15548 | 15548 | 15548 | 15548 | 1 |
|
||||
| getStakedBalance | 7537 | 7537 | 7537 | 7537 | 1 |
|
||||
| getUserTotalMaxMP | 3596 | 3596 | 3596 | 3596 | 1 |
|
||||
| getUserTotalStakedBalance | 15592 | 15592 | 15592 | 15592 | 1 |
|
||||
| getUserVaults | 5637 | 6762 | 5637 | 10137 | 4 |
|
||||
| implementation | 343 | 775 | 343 | 2343 | 412 |
|
||||
| lastRewardTime | 822 | 1822 | 1822 | 2822 | 2 |
|
||||
| rewardEndTime | 800 | 1800 | 1800 | 2800 | 2 |
|
||||
| rewardStartTime | 779 | 4029 | 4029 | 7279 | 2 |
|
||||
| rewardsBalanceOf | 1747 | 1747 | 1747 | 1747 | 4 |
|
||||
| mpBalanceOfUser | 9615 | 9615 | 9615 | 9615 | 1 |
|
||||
| rewardEndTime | 778 | 1778 | 1778 | 2778 | 2 |
|
||||
| rewardStartTime | 823 | 4073 | 4073 | 7323 | 2 |
|
||||
| rewardsBalanceOf | 1792 | 1792 | 1792 | 1792 | 4 |
|
||||
| setReward | 28863 | 77206 | 86636 | 128881 | 7 |
|
||||
| setTrustedCodehash | 52889 | 52889 | 52889 | 52889 | 2 |
|
||||
| totalMP | 800 | 800 | 800 | 800 | 81 |
|
||||
| totalMaxMP | 777 | 777 | 777 | 777 | 81 |
|
||||
| totalRewardsAccrued | 800 | 800 | 800 | 800 | 3 |
|
||||
| setTrustedCodehash | 52867 | 52867 | 52867 | 52867 | 2 |
|
||||
| totalMPAccrued | 778 | 778 | 778 | 778 | 81 |
|
||||
| totalMaxMP | 822 | 822 | 822 | 822 | 81 |
|
||||
| totalRewardsAccrued | 778 | 778 | 778 | 778 | 3 |
|
||||
| totalRewardsSupply | 1387 | 2498 | 2151 | 11627 | 30 |
|
||||
| totalStaked | 823 | 823 | 823 | 823 | 82 |
|
||||
| updateAccountMP | 41755 | 44833 | 44257 | 61357 | 21 |
|
||||
| totalStaked | 801 | 801 | 801 | 801 | 82 |
|
||||
| updateAccountMP | 41707 | 44788 | 44213 | 61313 | 21 |
|
||||
| updateGlobalState | 37076 | 54033 | 51237 | 136272 | 21 |
|
||||
| upgradeToAndCall | 29868 | 33720 | 33720 | 37572 | 2 |
|
||||
| upgradeToAndCall | 29846 | 33698 | 33698 | 37550 | 2 |
|
||||
|
||||
|
||||
| src/StakeVault.sol:StakeVault contract | | | | | |
|
||||
@@ -123,11 +123,11 @@
|
||||
| lock | 33245 | 60677 | 50845 | 107772 | 4 |
|
||||
| owner | 2339 | 2339 | 2339 | 2339 | 257 |
|
||||
| register | 87015 | 103915 | 104115 | 104115 | 257 |
|
||||
| stake | 33411 | 241491 | 252403 | 272784 | 67 |
|
||||
| stake | 33411 | 241532 | 252445 | 272826 | 67 |
|
||||
| stakeManager | 368 | 368 | 368 | 368 | 257 |
|
||||
| trustStakeManager | 28953 | 28953 | 28953 | 28953 | 1 |
|
||||
| unstake | 33282 | 96630 | 102062 | 109909 | 14 |
|
||||
| withdraw | 42289 | 42289 | 42289 | 42289 | 1 |
|
||||
| unstake | 33282 | 96610 | 102040 | 109887 | 14 |
|
||||
| withdraw | 42267 | 42267 | 42267 | 42267 | 1 |
|
||||
|
||||
|
||||
| src/XPNFTToken.sol:XPNFTToken contract | | | | | |
|
||||
@@ -201,7 +201,7 @@
|
||||
| test/mocks/MockToken.sol:MockToken contract | | | | | |
|
||||
|---------------------------------------------|-----------------|-------|--------|-------|---------|
|
||||
| Deployment Cost | Deployment Size | | | | |
|
||||
| 625370 | 3260 | | | | |
|
||||
| 625454 | 3260 | | | | |
|
||||
| Function Name | min | avg | median | max | # calls |
|
||||
| approve | 46330 | 46339 | 46342 | 46342 | 262 |
|
||||
| balanceOf | 558 | 989 | 558 | 2558 | 139 |
|
||||
|
||||
108
.gas-snapshot
108
.gas-snapshot
@@ -1,75 +1,75 @@
|
||||
EmergencyExitTest:test_CannotEnableEmergencyModeTwice() (gas: 92690)
|
||||
EmergencyExitTest:test_CannotLeaveBeforeEmergencyMode() (gas: 297695)
|
||||
EmergencyExitTest:test_EmergencyExitBasic() (gas: 384455)
|
||||
EmergencyExitTest:test_EmergencyExitMultipleUsers() (gas: 659275)
|
||||
EmergencyExitTest:test_EmergencyExitToAlternateAddress() (gas: 392374)
|
||||
EmergencyExitTest:test_EmergencyExitWithLock() (gas: 391762)
|
||||
EmergencyExitTest:test_EmergencyExitWithRewards() (gas: 377316)
|
||||
EmergencyExitTest:test_CannotLeaveBeforeEmergencyMode() (gas: 297737)
|
||||
EmergencyExitTest:test_EmergencyExitBasic() (gas: 384498)
|
||||
EmergencyExitTest:test_EmergencyExitMultipleUsers() (gas: 659361)
|
||||
EmergencyExitTest:test_EmergencyExitToAlternateAddress() (gas: 392416)
|
||||
EmergencyExitTest:test_EmergencyExitWithLock() (gas: 391804)
|
||||
EmergencyExitTest:test_EmergencyExitWithRewards() (gas: 377359)
|
||||
EmergencyExitTest:test_OnlyOwnerCanEnableEmergencyMode() (gas: 39426)
|
||||
IntegrationTest:testStakeFoo() (gas: 1178499)
|
||||
LeaveTest:test_LeaveShouldProperlyUpdateAccounting() (gas: 5626814)
|
||||
LeaveTest:test_RevertWhenStakeManagerIsTrusted() (gas: 294826)
|
||||
LeaveTest:test_TrustNewStakeManager() (gas: 5699451)
|
||||
LockTest:test_LockFailsWithInvalidPeriod() (gas: 309911)
|
||||
IntegrationTest:testStakeFoo() (gas: 1178590)
|
||||
LeaveTest:test_LeaveShouldProperlyUpdateAccounting() (gas: 5626489)
|
||||
LeaveTest:test_RevertWhenStakeManagerIsTrusted() (gas: 294868)
|
||||
LeaveTest:test_TrustNewStakeManager() (gas: 5699124)
|
||||
LockTest:test_LockFailsWithInvalidPeriod() (gas: 309953)
|
||||
LockTest:test_LockFailsWithNoStake() (gas: 63730)
|
||||
LockTest:test_LockWithoutPriorLock() (gas: 385915)
|
||||
MaliciousUpgradeTest:test_UpgradeStackOverflowStakeManager() (gas: 1745333)
|
||||
MathTest:test_CalcAbsoluteMaxTotalMP() (gas: 18908)
|
||||
LockTest:test_LockWithoutPriorLock() (gas: 385979)
|
||||
MaliciousUpgradeTest:test_UpgradeStackOverflowStakeManager() (gas: 1745354)
|
||||
MathTest:test_CalcAbsoluteMaxTotalMP() (gas: 18952)
|
||||
MathTest:test_CalcAccrueMP() (gas: 22207)
|
||||
MathTest:test_CalcBonusMP() (gas: 17713)
|
||||
MathTest:test_CalcInitialMP() (gas: 5395)
|
||||
MathTest:test_CalcMaxAccruedMP() (gas: 15586)
|
||||
MathTest:test_CalcMaxTotalMP() (gas: 23298)
|
||||
MultipleVaultsStakeTest:test_StakeMultipleVaults() (gas: 716776)
|
||||
MathTest:test_CalcMaxAccruedMP() (gas: 15630)
|
||||
MathTest:test_CalcMaxTotalMP() (gas: 23386)
|
||||
MultipleVaultsStakeTest:test_StakeMultipleVaults() (gas: 716945)
|
||||
NFTMetadataGeneratorSVGTest:testGenerateMetadata() (gas: 85934)
|
||||
NFTMetadataGeneratorSVGTest:testSetImageStrings() (gas: 58332)
|
||||
NFTMetadataGeneratorSVGTest:testSetImageStringsRevert() (gas: 35804)
|
||||
NFTMetadataGeneratorURLTest:testGenerateMetadata() (gas: 102512)
|
||||
NFTMetadataGeneratorURLTest:testSetBaseURL() (gas: 49555)
|
||||
NFTMetadataGeneratorURLTest:testSetBaseURLRevert() (gas: 35979)
|
||||
RewardsStreamerMP_RewardsTest:testRewardsBalanceOf() (gas: 670670)
|
||||
RewardsStreamerMP_RewardsTest:testSetRewards() (gas: 160274)
|
||||
RewardsStreamerMP_RewardsTest:testRewardsBalanceOf() (gas: 670804)
|
||||
RewardsStreamerMP_RewardsTest:testSetRewards() (gas: 160318)
|
||||
RewardsStreamerMP_RewardsTest:testSetRewards_RevertsBadAmount() (gas: 39404)
|
||||
RewardsStreamerMP_RewardsTest:testSetRewards_RevertsBadDuration() (gas: 39340)
|
||||
RewardsStreamerMP_RewardsTest:testSetRewards_RevertsNotAuthorized() (gas: 39375)
|
||||
RewardsStreamerMP_RewardsTest:testTotalRewardsSupply() (gas: 610662)
|
||||
RewardsStreamerMP_RewardsTest:testTotalRewardsSupply() (gas: 610638)
|
||||
RewardsStreamerTest:testStake() (gas: 869181)
|
||||
StakeTest:test_StakeMultipleAccounts() (gas: 494442)
|
||||
StakeTest:test_StakeMultipleAccountsAndRewards() (gas: 500380)
|
||||
StakeTest:test_StakeMultipleAccountsMPIncreasesMaxMPDoesNotChange() (gas: 830612)
|
||||
StakeTest:test_StakeMultipleAccountsWithMinLockUp() (gas: 510842)
|
||||
StakeTest:test_StakeMultipleAccountsWithRandomLockUp() (gas: 532885)
|
||||
StakeTest:test_StakeOneAccount() (gas: 276933)
|
||||
StakeTest:test_StakeOneAccountAndRewards() (gas: 282880)
|
||||
StakeTest:test_StakeOneAccountMPIncreasesMaxMPDoesNotChange() (gas: 499564)
|
||||
StakeTest:test_StakeOneAccountReachingMPLimit() (gas: 493508)
|
||||
StakeTest:test_StakeOneAccountWithMaxLockUp() (gas: 296788)
|
||||
StakeTest:test_StakeOneAccountWithMinLockUp() (gas: 298477)
|
||||
StakeTest:test_StakeOneAccountWithRandomLockUp() (gas: 298544)
|
||||
StakeTest:test_StakeMultipleAccounts() (gas: 494527)
|
||||
StakeTest:test_StakeMultipleAccountsAndRewards() (gas: 500466)
|
||||
StakeTest:test_StakeMultipleAccountsMPIncreasesMaxMPDoesNotChange() (gas: 830567)
|
||||
StakeTest:test_StakeMultipleAccountsWithMinLockUp() (gas: 510971)
|
||||
StakeTest:test_StakeMultipleAccountsWithRandomLockUp() (gas: 533014)
|
||||
StakeTest:test_StakeOneAccount() (gas: 276976)
|
||||
StakeTest:test_StakeOneAccountAndRewards() (gas: 282924)
|
||||
StakeTest:test_StakeOneAccountMPIncreasesMaxMPDoesNotChange() (gas: 499543)
|
||||
StakeTest:test_StakeOneAccountReachingMPLimit() (gas: 493483)
|
||||
StakeTest:test_StakeOneAccountWithMaxLockUp() (gas: 296831)
|
||||
StakeTest:test_StakeOneAccountWithMinLockUp() (gas: 298542)
|
||||
StakeTest:test_StakeOneAccountWithRandomLockUp() (gas: 298609)
|
||||
StakingTokenTest:testStakeToken() (gas: 10422)
|
||||
UnstakeTest:test_StakeMultipleAccounts() (gas: 494464)
|
||||
UnstakeTest:test_StakeMultipleAccountsAndRewards() (gas: 500402)
|
||||
UnstakeTest:test_StakeMultipleAccountsMPIncreasesMaxMPDoesNotChange() (gas: 830634)
|
||||
UnstakeTest:test_StakeMultipleAccountsWithMinLockUp() (gas: 510841)
|
||||
UnstakeTest:test_StakeMultipleAccountsWithRandomLockUp() (gas: 532907)
|
||||
UnstakeTest:test_StakeOneAccount() (gas: 276956)
|
||||
UnstakeTest:test_StakeOneAccountAndRewards() (gas: 282924)
|
||||
UnstakeTest:test_StakeOneAccountMPIncreasesMaxMPDoesNotChange() (gas: 499608)
|
||||
UnstakeTest:test_StakeOneAccountReachingMPLimit() (gas: 493510)
|
||||
UnstakeTest:test_StakeOneAccountWithMaxLockUp() (gas: 296788)
|
||||
UnstakeTest:test_StakeOneAccountWithMinLockUp() (gas: 298477)
|
||||
UnstakeTest:test_StakeOneAccountWithRandomLockUp() (gas: 298543)
|
||||
UnstakeTest:test_UnstakeBonusMPAndAccuredMP() (gas: 537915)
|
||||
UnstakeTest:test_UnstakeMultipleAccounts() (gas: 692599)
|
||||
UnstakeTest:test_UnstakeMultipleAccountsAndRewards() (gas: 786234)
|
||||
UnstakeTest:test_UnstakeOneAccount() (gas: 472857)
|
||||
UnstakeTest:test_UnstakeOneAccountAndAccruedMP() (gas: 494565)
|
||||
UnstakeTest:test_UnstakeOneAccountAndRewards() (gas: 404122)
|
||||
UnstakeTest:test_UnstakeOneAccountWithLockUpAndAccruedMP() (gas: 523042)
|
||||
UpgradeTest:test_RevertWhenNotOwner() (gas: 2602178)
|
||||
UpgradeTest:test_UpgradeStakeManager() (gas: 5541589)
|
||||
UnstakeTest:test_StakeMultipleAccounts() (gas: 494549)
|
||||
UnstakeTest:test_StakeMultipleAccountsAndRewards() (gas: 500488)
|
||||
UnstakeTest:test_StakeMultipleAccountsMPIncreasesMaxMPDoesNotChange() (gas: 830589)
|
||||
UnstakeTest:test_StakeMultipleAccountsWithMinLockUp() (gas: 510970)
|
||||
UnstakeTest:test_StakeMultipleAccountsWithRandomLockUp() (gas: 533036)
|
||||
UnstakeTest:test_StakeOneAccount() (gas: 276999)
|
||||
UnstakeTest:test_StakeOneAccountAndRewards() (gas: 282968)
|
||||
UnstakeTest:test_StakeOneAccountMPIncreasesMaxMPDoesNotChange() (gas: 499587)
|
||||
UnstakeTest:test_StakeOneAccountReachingMPLimit() (gas: 493485)
|
||||
UnstakeTest:test_StakeOneAccountWithMaxLockUp() (gas: 296831)
|
||||
UnstakeTest:test_StakeOneAccountWithMinLockUp() (gas: 298542)
|
||||
UnstakeTest:test_StakeOneAccountWithRandomLockUp() (gas: 298608)
|
||||
UnstakeTest:test_UnstakeBonusMPAndAccuredMP() (gas: 537916)
|
||||
UnstakeTest:test_UnstakeMultipleAccounts() (gas: 692641)
|
||||
UnstakeTest:test_UnstakeMultipleAccountsAndRewards() (gas: 786267)
|
||||
UnstakeTest:test_UnstakeOneAccount() (gas: 472866)
|
||||
UnstakeTest:test_UnstakeOneAccountAndAccruedMP() (gas: 494544)
|
||||
UnstakeTest:test_UnstakeOneAccountAndRewards() (gas: 404145)
|
||||
UnstakeTest:test_UnstakeOneAccountWithLockUpAndAccruedMP() (gas: 523087)
|
||||
UpgradeTest:test_RevertWhenNotOwner() (gas: 2601964)
|
||||
UpgradeTest:test_UpgradeStakeManager() (gas: 5541264)
|
||||
VaultRegistrationTest:test_VaultRegistration() (gas: 62013)
|
||||
WithdrawTest:test_CannotWithdrawStakedFunds() (gas: 310550)
|
||||
WithdrawTest:test_CannotWithdrawStakedFunds() (gas: 310548)
|
||||
XPNFTTokenTest:testApproveNotAllowed() (gas: 10500)
|
||||
XPNFTTokenTest:testGetApproved() (gas: 10523)
|
||||
XPNFTTokenTest:testIsApprovedForAll() (gas: 10698)
|
||||
|
||||
@@ -31,7 +31,7 @@ definition isViewFunction(method f) returns bool = (
|
||||
f.selector == sig:streamer.totalRewardsAccrued().selector ||
|
||||
f.selector == sig:streamer.rewardStartTime().selector ||
|
||||
f.selector == sig:streamer.rewardEndTime().selector ||
|
||||
f.selector == sig:streamer.getUserTotalMP(address).selector ||
|
||||
f.selector == sig:streamer.mpBalanceOfUser(address).selector ||
|
||||
f.selector == sig:streamer.getUserTotalMaxMP(address).selector ||
|
||||
f.selector == sig:streamer.getUserTotalStakedBalance(address).selector ||
|
||||
f.selector == sig:streamer.vaults(address,uint256).selector ||
|
||||
|
||||
@@ -42,7 +42,7 @@ contract RewardsStreamerMP is
|
||||
uint256 public constant MAX_MULTIPLIER = 4;
|
||||
|
||||
uint256 public totalStaked;
|
||||
uint256 public totalMP;
|
||||
uint256 public totalMPAccrued;
|
||||
uint256 public totalMaxMP;
|
||||
uint256 public rewardIndex;
|
||||
uint256 public lastMPUpdatedTime;
|
||||
@@ -57,7 +57,7 @@ contract RewardsStreamerMP is
|
||||
struct Account {
|
||||
uint256 stakedBalance;
|
||||
uint256 accountRewardIndex;
|
||||
uint256 accountMP;
|
||||
uint256 mpAccrued;
|
||||
uint256 maxMP;
|
||||
uint256 lastMPUpdateTime;
|
||||
uint256 lockUntil;
|
||||
@@ -134,13 +134,13 @@ contract RewardsStreamerMP is
|
||||
* @param user The address of the user
|
||||
* @return The total multiplier points for the user
|
||||
*/
|
||||
function getUserTotalMP(address user) external view returns (uint256) {
|
||||
function mpBalanceOfUser(address user) external view returns (uint256) {
|
||||
address[] memory userVaults = vaults[user];
|
||||
uint256 userTotalMP = 0;
|
||||
|
||||
for (uint256 i = 0; i < userVaults.length; i++) {
|
||||
Account storage account = accounts[userVaults[i]];
|
||||
userTotalMP += account.accountMP + _getAccountAccruedMP(account);
|
||||
userTotalMP += account.mpAccrued + _getAccountPendingdMP(account);
|
||||
}
|
||||
return userTotalMP;
|
||||
}
|
||||
@@ -220,8 +220,8 @@ contract RewardsStreamerMP is
|
||||
uint256 accountMaxMP = initialMP + bonusMP + potentialMP;
|
||||
uint256 accountMP = initialMP + bonusMP;
|
||||
|
||||
account.accountMP += accountMP;
|
||||
totalMP += accountMP;
|
||||
account.mpAccrued += accountMP;
|
||||
totalMPAccrued += accountMP;
|
||||
|
||||
account.maxMP += accountMaxMP;
|
||||
totalMaxMP += accountMaxMP;
|
||||
@@ -257,11 +257,11 @@ contract RewardsStreamerMP is
|
||||
|
||||
// Update account state
|
||||
account.lockUntil = block.timestamp + lockPeriod;
|
||||
account.accountMP += additionalBonusMP;
|
||||
account.mpAccrued += additionalBonusMP;
|
||||
account.maxMP += additionalBonusMP;
|
||||
|
||||
// Update global state
|
||||
totalMP += additionalBonusMP;
|
||||
totalMPAccrued += additionalBonusMP;
|
||||
totalMaxMP += additionalBonusMP;
|
||||
|
||||
account.accountRewardIndex = rewardIndex;
|
||||
@@ -292,14 +292,14 @@ contract RewardsStreamerMP is
|
||||
uint256 previousStakedBalance = account.stakedBalance;
|
||||
|
||||
// solhint-disable-next-line
|
||||
uint256 mpToReduce = Math.mulDiv(account.accountMP, amount, previousStakedBalance);
|
||||
uint256 mpToReduce = Math.mulDiv(account.mpAccrued, amount, previousStakedBalance);
|
||||
uint256 maxMPToReduce = Math.mulDiv(account.maxMP, amount, previousStakedBalance);
|
||||
|
||||
account.stakedBalance -= amount;
|
||||
account.accountMP -= mpToReduce;
|
||||
account.mpAccrued -= mpToReduce;
|
||||
account.maxMP -= maxMPToReduce;
|
||||
account.accountRewardIndex = rewardIndex;
|
||||
totalMP -= mpToReduce;
|
||||
totalMPAccrued -= mpToReduce;
|
||||
totalMaxMP -= maxMPToReduce;
|
||||
totalStaked -= amount;
|
||||
}
|
||||
@@ -344,15 +344,15 @@ contract RewardsStreamerMP is
|
||||
}
|
||||
|
||||
uint256 accruedMP = (timeDiff * totalStaked * MP_RATE_PER_YEAR) / YEAR;
|
||||
if (totalMP + accruedMP > totalMaxMP) {
|
||||
accruedMP = totalMaxMP - totalMP;
|
||||
if (totalMPAccrued + accruedMP > totalMaxMP) {
|
||||
accruedMP = totalMaxMP - totalMPAccrued;
|
||||
}
|
||||
|
||||
// Adjust rewardIndex before updating totalMP
|
||||
uint256 previousTotalWeight = totalStaked + totalMP;
|
||||
totalMP += accruedMP;
|
||||
uint256 previousTotalWeight = totalStaked + totalMPAccrued;
|
||||
totalMPAccrued += accruedMP;
|
||||
|
||||
uint256 newTotalWeight = totalStaked + totalMP;
|
||||
uint256 newTotalWeight = totalStaked + totalMPAccrued;
|
||||
|
||||
if (previousTotalWeight != 0 && newTotalWeight != previousTotalWeight) {
|
||||
rewardIndex = (rewardIndex * previousTotalWeight) / newTotalWeight;
|
||||
@@ -407,7 +407,7 @@ contract RewardsStreamerMP is
|
||||
}
|
||||
|
||||
function updateRewardIndex() internal {
|
||||
uint256 totalWeight = totalStaked + totalMP;
|
||||
uint256 totalWeight = totalStaked + totalMPAccrued;
|
||||
if (totalWeight == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -437,7 +437,7 @@ contract RewardsStreamerMP is
|
||||
return Math.mulDiv(amount, lockPeriod, YEAR);
|
||||
}
|
||||
|
||||
function _getAccountAccruedMP(Account storage account) internal view returns (uint256) {
|
||||
function _getAccountPendingdMP(Account storage account) internal view returns (uint256) {
|
||||
if (account.maxMP == 0 || account.stakedBalance == 0) {
|
||||
return 0;
|
||||
}
|
||||
@@ -449,17 +449,17 @@ contract RewardsStreamerMP is
|
||||
|
||||
uint256 accruedMP = Math.mulDiv(timeDiff * account.stakedBalance, MP_RATE_PER_YEAR, YEAR);
|
||||
|
||||
if (account.accountMP + accruedMP > account.maxMP) {
|
||||
accruedMP = account.maxMP - account.accountMP;
|
||||
if (account.mpAccrued + accruedMP > account.maxMP) {
|
||||
accruedMP = account.maxMP - account.mpAccrued;
|
||||
}
|
||||
return accruedMP;
|
||||
}
|
||||
|
||||
function _updateAccountMP(address accountAddress) internal {
|
||||
Account storage account = accounts[accountAddress];
|
||||
uint256 accruedMP = _getAccountAccruedMP(account);
|
||||
uint256 accruedMP = _getAccountPendingdMP(account);
|
||||
|
||||
account.accountMP += accruedMP;
|
||||
account.mpAccrued += accruedMP;
|
||||
account.lastMPUpdateTime = block.timestamp;
|
||||
}
|
||||
|
||||
@@ -470,7 +470,7 @@ contract RewardsStreamerMP is
|
||||
function calculateAccountRewards(address accountAddress) public view returns (uint256) {
|
||||
Account storage account = accounts[accountAddress];
|
||||
|
||||
uint256 accountWeight = account.stakedBalance + account.accountMP;
|
||||
uint256 accountWeight = account.stakedBalance + account.mpAccrued;
|
||||
uint256 deltaRewardIndex = rewardIndex - account.accountRewardIndex;
|
||||
|
||||
return Math.mulDiv(accountWeight, deltaRewardIndex, SCALE_FACTOR);
|
||||
|
||||
@@ -19,7 +19,7 @@ interface IStakeManager is ITrustedCodehashAccess {
|
||||
|
||||
function emergencyModeEnabled() external view returns (bool);
|
||||
function totalStaked() external view returns (uint256);
|
||||
function totalMP() external view returns (uint256);
|
||||
function totalMPAccrued() external view returns (uint256);
|
||||
function totalMaxMP() external view returns (uint256);
|
||||
function getStakedBalance(address _vault) external view returns (uint256 _balance);
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ contract RewardsStreamerMPTest is Test {
|
||||
|
||||
struct CheckStreamerParams {
|
||||
uint256 totalStaked;
|
||||
uint256 totalMP;
|
||||
uint256 totalMPAccrued;
|
||||
uint256 totalMaxMP;
|
||||
uint256 stakingBalance;
|
||||
uint256 rewardBalance;
|
||||
@@ -62,7 +62,7 @@ contract RewardsStreamerMPTest is Test {
|
||||
|
||||
function checkStreamer(CheckStreamerParams memory p) public view {
|
||||
assertEq(streamer.totalStaked(), p.totalStaked, "wrong total staked");
|
||||
assertEq(streamer.totalMP(), p.totalMP, "wrong total MP");
|
||||
assertEq(streamer.totalMPAccrued(), p.totalMPAccrued, "wrong total MP");
|
||||
assertEq(streamer.totalMaxMP(), p.totalMaxMP, "wrong totalMaxMP MP");
|
||||
// assertEq(rewardToken.balanceOf(address(streamer)), p.rewardBalance, "wrong reward balance");
|
||||
// assertEq(streamer.rewardIndex(), p.rewardIndex, "wrong reward index");
|
||||
@@ -74,7 +74,7 @@ contract RewardsStreamerMPTest is Test {
|
||||
uint256 stakedBalance;
|
||||
uint256 vaultBalance;
|
||||
uint256 rewardIndex;
|
||||
uint256 accountMP;
|
||||
uint256 mpAccrued;
|
||||
uint256 maxMP;
|
||||
}
|
||||
|
||||
@@ -86,20 +86,20 @@ contract RewardsStreamerMPTest is Test {
|
||||
assertEq(accountInfo.stakedBalance, p.stakedBalance, "wrong account staked balance");
|
||||
assertEq(stakingToken.balanceOf(p.account), p.vaultBalance, "wrong vault balance");
|
||||
// assertEq(accountInfo.accountRewardIndex, p.rewardIndex, "wrong account reward index");
|
||||
assertEq(accountInfo.accountMP, p.accountMP, "wrong account MP");
|
||||
assertEq(accountInfo.mpAccrued, p.mpAccrued, "wrong account MP");
|
||||
assertEq(accountInfo.maxMP, p.maxMP, "wrong account max MP");
|
||||
}
|
||||
|
||||
struct CheckUserTotalsParams {
|
||||
address user;
|
||||
uint256 totalStakedBalance;
|
||||
uint256 totalMP;
|
||||
uint256 totalMPAccrued;
|
||||
uint256 totalMaxMP;
|
||||
}
|
||||
|
||||
function checkUserTotals(CheckUserTotalsParams memory p) public view {
|
||||
assertEq(streamer.getUserTotalStakedBalance(p.user), p.totalStakedBalance, "wrong user total stake balance");
|
||||
assertEq(streamer.getUserTotalMP(p.user), p.totalMP, "wrong user total MP");
|
||||
assertEq(streamer.mpBalanceOfUser(p.user), p.totalMPAccrued, "wrong user total MP");
|
||||
assertEq(streamer.getUserTotalMaxMP(p.user), p.totalMaxMP, "wrong user total MP");
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ contract IntegrationTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 0,
|
||||
totalMP: 0,
|
||||
totalMPAccrued: 0,
|
||||
totalMaxMP: 0,
|
||||
stakingBalance: 0,
|
||||
rewardBalance: 0,
|
||||
@@ -273,7 +273,7 @@ contract IntegrationTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 10e18,
|
||||
totalMP: 10e18,
|
||||
totalMPAccrued: 10e18,
|
||||
totalMaxMP: 50e18,
|
||||
stakingBalance: 10e18,
|
||||
rewardBalance: 0,
|
||||
@@ -288,7 +288,7 @@ contract IntegrationTest is RewardsStreamerMPTest {
|
||||
stakedBalance: 10e18,
|
||||
vaultBalance: 10e18,
|
||||
rewardIndex: 0,
|
||||
accountMP: 10e18,
|
||||
mpAccrued: 10e18,
|
||||
maxMP: 50e18
|
||||
})
|
||||
);
|
||||
@@ -299,7 +299,7 @@ contract IntegrationTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 40e18,
|
||||
totalMP: 40e18,
|
||||
totalMPAccrued: 40e18,
|
||||
totalMaxMP: 200e18,
|
||||
stakingBalance: 40e18,
|
||||
rewardBalance: 0,
|
||||
@@ -314,7 +314,7 @@ contract IntegrationTest is RewardsStreamerMPTest {
|
||||
stakedBalance: 10e18,
|
||||
vaultBalance: 10e18,
|
||||
rewardIndex: 0,
|
||||
accountMP: 10e18,
|
||||
mpAccrued: 10e18,
|
||||
maxMP: 50e18
|
||||
})
|
||||
);
|
||||
@@ -326,7 +326,7 @@ contract IntegrationTest is RewardsStreamerMPTest {
|
||||
stakedBalance: 30e18,
|
||||
vaultBalance: 30e18,
|
||||
rewardIndex: 0,
|
||||
accountMP: 30e18,
|
||||
mpAccrued: 30e18,
|
||||
maxMP: 150e18
|
||||
})
|
||||
);
|
||||
@@ -338,7 +338,7 @@ contract IntegrationTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 40e18,
|
||||
totalMP: 40e18,
|
||||
totalMPAccrued: 40e18,
|
||||
totalMaxMP: 200e18,
|
||||
stakingBalance: 40e18,
|
||||
rewardBalance: 1000e18,
|
||||
@@ -353,7 +353,7 @@ contract IntegrationTest is RewardsStreamerMPTest {
|
||||
stakedBalance: 10e18,
|
||||
vaultBalance: 10e18,
|
||||
rewardIndex: 0,
|
||||
accountMP: 10e18,
|
||||
mpAccrued: 10e18,
|
||||
maxMP: 50e18
|
||||
})
|
||||
);
|
||||
@@ -365,7 +365,7 @@ contract IntegrationTest is RewardsStreamerMPTest {
|
||||
stakedBalance: 30e18,
|
||||
vaultBalance: 30e18,
|
||||
rewardIndex: 0,
|
||||
accountMP: 30e18,
|
||||
mpAccrued: 30e18,
|
||||
maxMP: 150e18
|
||||
})
|
||||
);
|
||||
@@ -378,7 +378,7 @@ contract IntegrationTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 40e18,
|
||||
totalMP: 60e18, // 6 months passed, 20 MP accrued
|
||||
totalMPAccrued: 60e18, // 6 months passed, 20 MP accrued
|
||||
totalMaxMP: 200e18,
|
||||
stakingBalance: 40e18,
|
||||
rewardBalance: 1000e18,
|
||||
@@ -394,7 +394,7 @@ contract IntegrationTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 30e18,
|
||||
totalMP: 45e18, // 60 - 15 from Alice (10 + 6 months = 5)
|
||||
totalMPAccrued: 45e18, // 60 - 15 from Alice (10 + 6 months = 5)
|
||||
totalMaxMP: 150e18, // 200e18 - (10e18 * 5) = 150e18
|
||||
stakingBalance: 30e18,
|
||||
rewardBalance: 750e18,
|
||||
@@ -409,7 +409,7 @@ contract IntegrationTest is RewardsStreamerMPTest {
|
||||
stakedBalance: 0e18,
|
||||
vaultBalance: 0e18,
|
||||
rewardIndex: 10e18,
|
||||
accountMP: 0e18,
|
||||
mpAccrued: 0e18,
|
||||
maxMP: 0e18
|
||||
})
|
||||
);
|
||||
@@ -421,7 +421,7 @@ contract IntegrationTest is RewardsStreamerMPTest {
|
||||
stakedBalance: 30e18,
|
||||
vaultBalance: 30e18,
|
||||
rewardIndex: 0,
|
||||
accountMP: 30e18,
|
||||
mpAccrued: 30e18,
|
||||
maxMP: 150e18
|
||||
})
|
||||
);
|
||||
@@ -432,7 +432,7 @@ contract IntegrationTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 60e18,
|
||||
totalMP: 75e18,
|
||||
totalMPAccrued: 75e18,
|
||||
totalMaxMP: 300e18,
|
||||
stakingBalance: 60e18,
|
||||
rewardBalance: 750e18,
|
||||
@@ -447,7 +447,7 @@ contract IntegrationTest is RewardsStreamerMPTest {
|
||||
stakedBalance: 0e18,
|
||||
vaultBalance: 0e18,
|
||||
rewardIndex: 10e18,
|
||||
accountMP: 0e18,
|
||||
mpAccrued: 0e18,
|
||||
maxMP: 0e18
|
||||
})
|
||||
);
|
||||
@@ -459,7 +459,7 @@ contract IntegrationTest is RewardsStreamerMPTest {
|
||||
stakedBalance: 30e18,
|
||||
vaultBalance: 30e18,
|
||||
rewardIndex: 0,
|
||||
accountMP: 30e18,
|
||||
mpAccrued: 30e18,
|
||||
maxMP: 150e18
|
||||
})
|
||||
);
|
||||
@@ -471,7 +471,7 @@ contract IntegrationTest is RewardsStreamerMPTest {
|
||||
stakedBalance: 30e18,
|
||||
vaultBalance: 30e18,
|
||||
rewardIndex: 10e18,
|
||||
accountMP: 30e18,
|
||||
mpAccrued: 30e18,
|
||||
maxMP: 150e18
|
||||
})
|
||||
);
|
||||
@@ -483,7 +483,7 @@ contract IntegrationTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 60e18,
|
||||
totalMP: 75e18,
|
||||
totalMPAccrued: 75e18,
|
||||
totalMaxMP: 300e18,
|
||||
stakingBalance: 60e18,
|
||||
rewardBalance: 1750e18,
|
||||
@@ -498,7 +498,7 @@ contract IntegrationTest is RewardsStreamerMPTest {
|
||||
stakedBalance: 0e18,
|
||||
vaultBalance: 0e18,
|
||||
rewardIndex: 10e18,
|
||||
accountMP: 0e18,
|
||||
mpAccrued: 0e18,
|
||||
maxMP: 0e18
|
||||
})
|
||||
);
|
||||
@@ -510,7 +510,7 @@ contract IntegrationTest is RewardsStreamerMPTest {
|
||||
stakedBalance: 30e18,
|
||||
vaultBalance: 30e18,
|
||||
rewardIndex: 0,
|
||||
accountMP: 30e18,
|
||||
mpAccrued: 30e18,
|
||||
maxMP: 150e18
|
||||
})
|
||||
);
|
||||
@@ -522,7 +522,7 @@ contract IntegrationTest is RewardsStreamerMPTest {
|
||||
stakedBalance: 30e18,
|
||||
vaultBalance: 30e18,
|
||||
rewardIndex: 10e18,
|
||||
accountMP: 30e18,
|
||||
mpAccrued: 30e18,
|
||||
maxMP: 150e18
|
||||
})
|
||||
);
|
||||
@@ -533,7 +533,7 @@ contract IntegrationTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 30e18,
|
||||
totalMP: 30e18,
|
||||
totalMPAccrued: 30e18,
|
||||
totalMaxMP: 150e18,
|
||||
stakingBalance: 30e18,
|
||||
// 1750 - (750 + 555.55) = 444.44
|
||||
@@ -549,7 +549,7 @@ contract IntegrationTest is RewardsStreamerMPTest {
|
||||
stakedBalance: 0e18,
|
||||
vaultBalance: 0e18,
|
||||
rewardIndex: 10e18,
|
||||
accountMP: 0,
|
||||
mpAccrued: 0,
|
||||
maxMP: 0
|
||||
})
|
||||
);
|
||||
@@ -568,7 +568,7 @@ contract IntegrationTest is RewardsStreamerMPTest {
|
||||
stakedBalance: 0e18,
|
||||
vaultBalance: 0e18,
|
||||
rewardIndex: 17_407_407_407_407_407_407,
|
||||
accountMP: 0,
|
||||
mpAccrued: 0,
|
||||
maxMP: 0
|
||||
})
|
||||
);
|
||||
@@ -580,7 +580,7 @@ contract IntegrationTest is RewardsStreamerMPTest {
|
||||
stakedBalance: 30e18,
|
||||
vaultBalance: 30e18,
|
||||
rewardIndex: 10e18,
|
||||
accountMP: 30e18,
|
||||
mpAccrued: 30e18,
|
||||
maxMP: 150e18
|
||||
})
|
||||
);
|
||||
@@ -599,7 +599,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 10e18,
|
||||
totalMP: 10e18,
|
||||
totalMPAccrued: 10e18,
|
||||
totalMaxMP: 50e18,
|
||||
stakingBalance: 10e18,
|
||||
rewardBalance: 0,
|
||||
@@ -613,7 +613,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
stakedBalance: 10e18,
|
||||
vaultBalance: 10e18,
|
||||
rewardIndex: 0,
|
||||
accountMP: 10e18,
|
||||
mpAccrued: 10e18,
|
||||
maxMP: 50e18
|
||||
})
|
||||
);
|
||||
@@ -625,7 +625,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 10e18,
|
||||
totalMP: 10e18,
|
||||
totalMPAccrued: 10e18,
|
||||
totalMaxMP: 50e18,
|
||||
stakingBalance: 10e18,
|
||||
rewardBalance: 0,
|
||||
@@ -640,7 +640,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
stakedBalance: 10e18,
|
||||
vaultBalance: 10e18,
|
||||
rewardIndex: 0,
|
||||
accountMP: 10e18,
|
||||
mpAccrued: 10e18,
|
||||
maxMP: 50e18
|
||||
})
|
||||
);
|
||||
@@ -648,7 +648,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 10e18,
|
||||
totalMP: 10e18,
|
||||
totalMPAccrued: 10e18,
|
||||
totalMaxMP: 50e18,
|
||||
stakingBalance: 10e18,
|
||||
rewardBalance: 1000e18,
|
||||
@@ -669,7 +669,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
CheckStreamerParams({
|
||||
totalStaked: stakeAmount,
|
||||
// 10e18 + (amount * (lockPeriod * MAX_MULTIPLIER * SCALE_FACTOR / MAX_LOCKUP_PERIOD) / SCALE_FACTOR)
|
||||
totalMP: stakeAmount + expectedBonusMP,
|
||||
totalMPAccrued: stakeAmount + expectedBonusMP,
|
||||
totalMaxMP: expectedMaxTotalMP,
|
||||
stakingBalance: stakeAmount,
|
||||
rewardBalance: 0,
|
||||
@@ -689,7 +689,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
CheckStreamerParams({
|
||||
totalStaked: stakeAmount,
|
||||
// 10 + (amount * (lockPeriod * MAX_MULTIPLIER * SCALE_FACTOR / MAX_LOCKUP_PERIOD) / SCALE_FACTOR)
|
||||
totalMP: stakeAmount + expectedBonusMP,
|
||||
totalMPAccrued: stakeAmount + expectedBonusMP,
|
||||
totalMaxMP: 90e18,
|
||||
stakingBalance: stakeAmount,
|
||||
rewardBalance: 0,
|
||||
@@ -710,7 +710,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
CheckStreamerParams({
|
||||
totalStaked: stakeAmount,
|
||||
// 10 + (amount * (lockPeriod * MAX_MULTIPLIER * SCALE_FACTOR / MAX_LOCKUP_PERIOD) / SCALE_FACTOR)
|
||||
totalMP: stakeAmount + expectedBonusMP,
|
||||
totalMPAccrued: stakeAmount + expectedBonusMP,
|
||||
totalMaxMP: expectedMaxTotalMP,
|
||||
stakingBalance: stakeAmount,
|
||||
rewardBalance: 0,
|
||||
@@ -722,14 +722,14 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
function test_StakeOneAccountMPIncreasesMaxMPDoesNotChange() public {
|
||||
uint256 stakeAmount = 15e18;
|
||||
uint256 totalMaxMP = stakeAmount * streamer.MAX_MULTIPLIER() + stakeAmount;
|
||||
uint256 totalMP = stakeAmount;
|
||||
uint256 totalMPAccrued = stakeAmount;
|
||||
|
||||
_stake(alice, stakeAmount, 0);
|
||||
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: stakeAmount,
|
||||
totalMP: stakeAmount,
|
||||
totalMPAccrued: stakeAmount,
|
||||
totalMaxMP: totalMaxMP,
|
||||
stakingBalance: stakeAmount,
|
||||
rewardBalance: 0,
|
||||
@@ -744,12 +744,12 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
streamer.updateAccountMP(vaults[alice]);
|
||||
|
||||
uint256 expectedMPIncrease = stakeAmount; // 1 year passed, 1 MP accrued per token staked
|
||||
totalMP = totalMP + expectedMPIncrease;
|
||||
totalMPAccrued = totalMPAccrued + expectedMPIncrease;
|
||||
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: stakeAmount,
|
||||
totalMP: totalMP,
|
||||
totalMPAccrued: totalMPAccrued,
|
||||
totalMaxMP: totalMaxMP,
|
||||
stakingBalance: stakeAmount,
|
||||
rewardBalance: 0,
|
||||
@@ -764,7 +764,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
stakedBalance: stakeAmount,
|
||||
vaultBalance: stakeAmount,
|
||||
rewardIndex: 0,
|
||||
accountMP: totalMP, // accountMP == totalMP because only one account is staking
|
||||
mpAccrued: totalMPAccrued, // accountMP == totalMPAccrued because only one account is staking
|
||||
maxMP: totalMaxMP
|
||||
})
|
||||
);
|
||||
@@ -776,12 +776,12 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
streamer.updateAccountMP(vaults[alice]);
|
||||
|
||||
expectedMPIncrease = stakeAmount / 2; // 1/2 year passed, 1/2 MP accrued per token staked
|
||||
totalMP = totalMP + expectedMPIncrease;
|
||||
totalMPAccrued = totalMPAccrued + expectedMPIncrease;
|
||||
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: stakeAmount,
|
||||
totalMP: totalMP,
|
||||
totalMPAccrued: totalMPAccrued,
|
||||
totalMaxMP: totalMaxMP,
|
||||
stakingBalance: stakeAmount,
|
||||
rewardBalance: 0,
|
||||
@@ -796,7 +796,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
stakedBalance: stakeAmount,
|
||||
vaultBalance: stakeAmount,
|
||||
rewardIndex: 0,
|
||||
accountMP: totalMP, // accountMP == totalMP because only one account is staking
|
||||
mpAccrued: totalMPAccrued, // accountMP == totalMPAccrued because only one account is staking
|
||||
maxMP: totalMaxMP
|
||||
})
|
||||
);
|
||||
@@ -805,14 +805,14 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
function test_StakeOneAccountReachingMPLimit() public {
|
||||
uint256 stakeAmount = 15e18;
|
||||
uint256 totalMaxMP = stakeAmount * streamer.MAX_MULTIPLIER() + stakeAmount;
|
||||
uint256 totalMP = stakeAmount;
|
||||
uint256 totalMPAccrued = stakeAmount;
|
||||
|
||||
_stake(alice, stakeAmount, 0);
|
||||
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: stakeAmount,
|
||||
totalMP: stakeAmount,
|
||||
totalMPAccrued: stakeAmount,
|
||||
totalMaxMP: totalMaxMP,
|
||||
stakingBalance: stakeAmount,
|
||||
rewardBalance: 0,
|
||||
@@ -827,13 +827,13 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
stakedBalance: stakeAmount,
|
||||
vaultBalance: stakeAmount,
|
||||
rewardIndex: 0,
|
||||
accountMP: totalMP, // accountMP == totalMP because only one account is staking
|
||||
mpAccrued: totalMPAccrued, // accountMP == totalMPAccrued because only one account is staking
|
||||
maxMP: totalMaxMP // maxMP == totalMaxMP because only one account is staking
|
||||
})
|
||||
);
|
||||
|
||||
uint256 currentTime = vm.getBlockTimestamp();
|
||||
uint256 timeToMaxMP = _calculateTimeToAccureMP(stakeAmount, totalMaxMP - totalMP);
|
||||
uint256 timeToMaxMP = _calculateTimeToAccureMP(stakeAmount, totalMaxMP - totalMPAccrued);
|
||||
vm.warp(currentTime + timeToMaxMP);
|
||||
|
||||
streamer.updateGlobalState();
|
||||
@@ -842,7 +842,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: stakeAmount,
|
||||
totalMP: totalMaxMP,
|
||||
totalMPAccrued: totalMaxMP,
|
||||
totalMaxMP: totalMaxMP,
|
||||
stakingBalance: stakeAmount,
|
||||
rewardBalance: 0,
|
||||
@@ -857,7 +857,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
stakedBalance: stakeAmount,
|
||||
vaultBalance: stakeAmount,
|
||||
rewardIndex: 0,
|
||||
accountMP: totalMaxMP,
|
||||
mpAccrued: totalMaxMP,
|
||||
maxMP: totalMaxMP
|
||||
})
|
||||
);
|
||||
@@ -873,7 +873,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: stakeAmount,
|
||||
totalMP: totalMaxMP,
|
||||
totalMPAccrued: totalMaxMP,
|
||||
totalMaxMP: totalMaxMP,
|
||||
stakingBalance: stakeAmount,
|
||||
rewardBalance: 0,
|
||||
@@ -892,7 +892,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 40e18,
|
||||
totalMP: 40e18,
|
||||
totalMPAccrued: 40e18,
|
||||
totalMaxMP: 200e18,
|
||||
stakingBalance: 40e18,
|
||||
rewardBalance: 0,
|
||||
@@ -907,7 +907,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
stakedBalance: 10e18,
|
||||
vaultBalance: 10e18,
|
||||
rewardIndex: 0,
|
||||
accountMP: 10e18,
|
||||
mpAccrued: 10e18,
|
||||
maxMP: 50e18
|
||||
})
|
||||
);
|
||||
@@ -919,7 +919,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
stakedBalance: 30e18,
|
||||
vaultBalance: 30e18,
|
||||
rewardIndex: 0,
|
||||
accountMP: 30e18,
|
||||
mpAccrued: 30e18,
|
||||
maxMP: 150e18
|
||||
})
|
||||
);
|
||||
@@ -935,7 +935,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 40e18,
|
||||
totalMP: 40e18,
|
||||
totalMPAccrued: 40e18,
|
||||
totalMaxMP: 200e18,
|
||||
stakingBalance: 40e18,
|
||||
rewardBalance: 0,
|
||||
@@ -950,7 +950,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
stakedBalance: 10e18,
|
||||
vaultBalance: 10e18,
|
||||
rewardIndex: 0,
|
||||
accountMP: 10e18,
|
||||
mpAccrued: 10e18,
|
||||
maxMP: 50e18
|
||||
})
|
||||
);
|
||||
@@ -962,7 +962,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
stakedBalance: 30e18,
|
||||
vaultBalance: 30e18,
|
||||
rewardIndex: 0,
|
||||
accountMP: 30e18,
|
||||
mpAccrued: 30e18,
|
||||
maxMP: 150e18
|
||||
})
|
||||
);
|
||||
@@ -970,7 +970,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 40e18,
|
||||
totalMP: 40e18,
|
||||
totalMPAccrued: 40e18,
|
||||
totalMaxMP: 200e18,
|
||||
stakingBalance: 40e18,
|
||||
rewardBalance: 1000e18,
|
||||
@@ -1001,7 +1001,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: sumOfStakeAmount,
|
||||
totalMP: sumOfStakeAmount + sumOfExpectedBonusMP,
|
||||
totalMPAccrued: sumOfStakeAmount + sumOfExpectedBonusMP,
|
||||
totalMaxMP: expectedMaxTotalMP,
|
||||
stakingBalance: sumOfStakeAmount,
|
||||
rewardBalance: 0,
|
||||
@@ -1033,7 +1033,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: sumOfStakeAmount,
|
||||
totalMP: sumOfStakeAmount + sumOfExpectedBonusMP,
|
||||
totalMPAccrued: sumOfStakeAmount + sumOfExpectedBonusMP,
|
||||
totalMaxMP: expectedMaxTotalMP,
|
||||
stakingBalance: sumOfStakeAmount,
|
||||
rewardBalance: 0,
|
||||
@@ -1051,7 +1051,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
uint256 bobMP = bobStakeAmount;
|
||||
uint256 bobMaxMP = bobStakeAmount * streamer.MAX_MULTIPLIER() + bobMP;
|
||||
|
||||
uint256 totalMP = aliceStakeAmount + bobStakeAmount;
|
||||
uint256 totalMPAccrued = aliceStakeAmount + bobStakeAmount;
|
||||
uint256 totalStaked = aliceStakeAmount + bobStakeAmount;
|
||||
uint256 totalMaxMP = aliceMaxMP + bobMaxMP;
|
||||
|
||||
@@ -1061,7 +1061,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: totalStaked,
|
||||
totalMP: totalMP,
|
||||
totalMPAccrued: totalMPAccrued,
|
||||
totalMaxMP: totalMaxMP,
|
||||
stakingBalance: totalStaked,
|
||||
rewardBalance: 0,
|
||||
@@ -1076,7 +1076,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
stakedBalance: aliceStakeAmount,
|
||||
vaultBalance: aliceStakeAmount,
|
||||
rewardIndex: 0,
|
||||
accountMP: aliceMP,
|
||||
mpAccrued: aliceMP,
|
||||
maxMP: aliceMaxMP
|
||||
})
|
||||
);
|
||||
@@ -1087,7 +1087,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
stakedBalance: bobStakeAmount,
|
||||
vaultBalance: bobStakeAmount,
|
||||
rewardIndex: 0,
|
||||
accountMP: bobMP,
|
||||
mpAccrued: bobMP,
|
||||
maxMP: bobMaxMP
|
||||
})
|
||||
);
|
||||
@@ -1105,12 +1105,12 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
|
||||
aliceMP = aliceMP + aliceExpectedMPIncrease;
|
||||
bobMP = bobMP + bobExpectedMPIncrease;
|
||||
totalMP = totalMP + totalExpectedMPIncrease;
|
||||
totalMPAccrued = totalMPAccrued + totalExpectedMPIncrease;
|
||||
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: totalStaked,
|
||||
totalMP: totalMP,
|
||||
totalMPAccrued: totalMPAccrued,
|
||||
totalMaxMP: totalMaxMP,
|
||||
stakingBalance: totalStaked,
|
||||
rewardBalance: 0,
|
||||
@@ -1125,7 +1125,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
stakedBalance: aliceStakeAmount,
|
||||
vaultBalance: aliceStakeAmount,
|
||||
rewardIndex: 0,
|
||||
accountMP: aliceMP,
|
||||
mpAccrued: aliceMP,
|
||||
maxMP: aliceMaxMP
|
||||
})
|
||||
);
|
||||
@@ -1136,7 +1136,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
stakedBalance: bobStakeAmount,
|
||||
vaultBalance: bobStakeAmount,
|
||||
rewardIndex: 0,
|
||||
accountMP: bobMP,
|
||||
mpAccrued: bobMP,
|
||||
maxMP: bobMaxMP
|
||||
})
|
||||
);
|
||||
@@ -1154,12 +1154,12 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
|
||||
aliceMP = aliceMP + aliceExpectedMPIncrease;
|
||||
bobMP = bobMP + bobExpectedMPIncrease;
|
||||
totalMP = totalMP + totalExpectedMPIncrease;
|
||||
totalMPAccrued = totalMPAccrued + totalExpectedMPIncrease;
|
||||
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: totalStaked,
|
||||
totalMP: totalMP,
|
||||
totalMPAccrued: totalMPAccrued,
|
||||
totalMaxMP: totalMaxMP,
|
||||
stakingBalance: totalStaked,
|
||||
rewardBalance: 0,
|
||||
@@ -1174,7 +1174,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
stakedBalance: aliceStakeAmount,
|
||||
vaultBalance: aliceStakeAmount,
|
||||
rewardIndex: 0,
|
||||
accountMP: aliceMP,
|
||||
mpAccrued: aliceMP,
|
||||
maxMP: aliceMaxMP
|
||||
})
|
||||
);
|
||||
@@ -1185,7 +1185,7 @@ contract StakeTest is RewardsStreamerMPTest {
|
||||
stakedBalance: bobStakeAmount,
|
||||
vaultBalance: bobStakeAmount,
|
||||
rewardIndex: 0,
|
||||
accountMP: bobMP,
|
||||
mpAccrued: bobMP,
|
||||
maxMP: bobMaxMP
|
||||
})
|
||||
);
|
||||
@@ -1205,7 +1205,7 @@ contract UnstakeTest is StakeTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 2e18,
|
||||
totalMP: 2e18,
|
||||
totalMPAccrued: 2e18,
|
||||
totalMaxMP: 10e18,
|
||||
stakingBalance: 2e18,
|
||||
rewardBalance: 0,
|
||||
@@ -1220,7 +1220,7 @@ contract UnstakeTest is StakeTest {
|
||||
stakedBalance: 2e18,
|
||||
vaultBalance: 2e18,
|
||||
rewardIndex: 0,
|
||||
accountMP: 2e18,
|
||||
mpAccrued: 2e18,
|
||||
maxMP: 10e18
|
||||
})
|
||||
);
|
||||
@@ -1230,7 +1230,7 @@ contract UnstakeTest is StakeTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 0,
|
||||
totalMP: 0,
|
||||
totalMPAccrued: 0,
|
||||
totalMaxMP: 0,
|
||||
stakingBalance: 0,
|
||||
rewardBalance: 0,
|
||||
@@ -1252,7 +1252,7 @@ contract UnstakeTest is StakeTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 10e18,
|
||||
totalMP: 20e18, // total MP must have been doubled
|
||||
totalMPAccrued: 20e18, // total MP must have been doubled
|
||||
totalMaxMP: 50e18,
|
||||
stakingBalance: 10e18,
|
||||
rewardBalance: 0,
|
||||
@@ -1266,7 +1266,7 @@ contract UnstakeTest is StakeTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 5e18, // 10 - 5
|
||||
totalMP: 10e18, // 20 - 10 (5 initial + 5 accrued)
|
||||
totalMPAccrued: 10e18, // 20 - 10 (5 initial + 5 accrued)
|
||||
totalMaxMP: 25e18,
|
||||
stakingBalance: 5e18,
|
||||
rewardBalance: 0,
|
||||
@@ -1295,7 +1295,7 @@ contract UnstakeTest is StakeTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: stakeAmount,
|
||||
totalMP: (stakeAmount + expectedBonusMP) + stakeAmount, // we do `+ stakeAmount` we've accrued
|
||||
totalMPAccrued: (stakeAmount + expectedBonusMP) + stakeAmount, // we do `+ stakeAmount` we've accrued
|
||||
// `stakeAmount` after 1 year
|
||||
totalMaxMP: _calculateMaxTotalMP(stakeAmount, lockUpPeriod),
|
||||
stakingBalance: 10e18,
|
||||
@@ -1312,7 +1312,7 @@ contract UnstakeTest is StakeTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: newBalance,
|
||||
totalMP: expectedTotalMP,
|
||||
totalMPAccrued: expectedTotalMP,
|
||||
totalMaxMP: _calculateMaxTotalMP(newBalance, lockUpPeriod),
|
||||
stakingBalance: newBalance,
|
||||
rewardBalance: 0,
|
||||
@@ -1329,7 +1329,7 @@ contract UnstakeTest is StakeTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 2e18,
|
||||
totalMP: 2e18,
|
||||
totalMPAccrued: 2e18,
|
||||
totalMaxMP: 10e18,
|
||||
stakingBalance: 2e18,
|
||||
rewardBalance: 0, // rewards are all paid out to alice
|
||||
@@ -1344,7 +1344,7 @@ contract UnstakeTest is StakeTest {
|
||||
stakedBalance: 2e18,
|
||||
vaultBalance: 2e18,
|
||||
rewardIndex: 50e18, // alice reward index has been updated
|
||||
accountMP: 2e18,
|
||||
mpAccrued: 2e18,
|
||||
maxMP: 10e18
|
||||
})
|
||||
);
|
||||
@@ -1410,11 +1410,11 @@ contract UnstakeTest is StakeTest {
|
||||
{
|
||||
RewardsStreamerMP.Account memory accountInfo = streamer.getAccount(vaults[alice]);
|
||||
assertEq(accountInfo.stakedBalance, totalStaked[stage], "stage 1: wrong account staked balance");
|
||||
assertEq(accountInfo.accountMP, predictedTotalMP[stage], "stage 1: wrong account MP");
|
||||
assertEq(accountInfo.mpAccrued, predictedTotalMP[stage], "stage 1: wrong account MP");
|
||||
assertEq(accountInfo.maxMP, predictedTotalMaxMP[stage], "stage 1: wrong account max MP");
|
||||
|
||||
assertEq(streamer.totalStaked(), totalStaked[stage], "stage 1: wrong total staked");
|
||||
assertEq(streamer.totalMP(), predictedTotalMP[stage], "stage 1: wrong total MP");
|
||||
assertEq(streamer.totalMPAccrued(), predictedTotalMP[stage], "stage 1: wrong total MP");
|
||||
assertEq(streamer.totalMaxMP(), predictedTotalMaxMP[stage], "stage 1: wrong totalMaxMP MP");
|
||||
}
|
||||
}
|
||||
@@ -1426,11 +1426,11 @@ contract UnstakeTest is StakeTest {
|
||||
{
|
||||
RewardsStreamerMP.Account memory accountInfo = streamer.getAccount(vaults[alice]);
|
||||
assertEq(accountInfo.stakedBalance, totalStaked[stage], "stage 2: wrong account staked balance");
|
||||
assertEq(accountInfo.accountMP, predictedTotalMP[stage], "stage 2: wrong account MP");
|
||||
assertEq(accountInfo.mpAccrued, predictedTotalMP[stage], "stage 2: wrong account MP");
|
||||
assertEq(accountInfo.maxMP, predictedTotalMaxMP[stage], "stage 2: wrong account max MP");
|
||||
|
||||
assertEq(streamer.totalStaked(), totalStaked[stage], "stage 2: wrong total staked");
|
||||
assertEq(streamer.totalMP(), predictedTotalMP[stage], "stage 2: wrong total MP");
|
||||
assertEq(streamer.totalMPAccrued(), predictedTotalMP[stage], "stage 2: wrong total MP");
|
||||
assertEq(streamer.totalMaxMP(), predictedTotalMaxMP[stage], "stage 2: wrong totalMaxMP MP");
|
||||
}
|
||||
|
||||
@@ -1439,11 +1439,11 @@ contract UnstakeTest is StakeTest {
|
||||
{
|
||||
RewardsStreamerMP.Account memory accountInfo = streamer.getAccount(vaults[alice]);
|
||||
assertEq(accountInfo.stakedBalance, totalStaked[stage], "stage 3: wrong account staked balance");
|
||||
assertEq(accountInfo.accountMP, predictedTotalMP[stage], "stage 3: wrong account MP");
|
||||
assertEq(accountInfo.mpAccrued, predictedTotalMP[stage], "stage 3: wrong account MP");
|
||||
assertEq(accountInfo.maxMP, predictedTotalMaxMP[stage], "stage 3: wrong account max MP");
|
||||
|
||||
assertEq(streamer.totalStaked(), totalStaked[stage], "stage 3: wrong total staked");
|
||||
assertEq(streamer.totalMP(), predictedTotalMP[stage], "stage 3: wrong total MP");
|
||||
assertEq(streamer.totalMPAccrued(), predictedTotalMP[stage], "stage 3: wrong total MP");
|
||||
assertEq(streamer.totalMaxMP(), predictedTotalMaxMP[stage], "stage 3: wrong totalMaxMP MP");
|
||||
}
|
||||
}
|
||||
@@ -1457,7 +1457,7 @@ contract UnstakeTest is StakeTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 20e18,
|
||||
totalMP: 20e18,
|
||||
totalMPAccrued: 20e18,
|
||||
totalMaxMP: 100e18,
|
||||
stakingBalance: 20e18,
|
||||
rewardBalance: 0,
|
||||
@@ -1472,7 +1472,7 @@ contract UnstakeTest is StakeTest {
|
||||
stakedBalance: 0,
|
||||
vaultBalance: 0,
|
||||
rewardIndex: 0,
|
||||
accountMP: 0,
|
||||
mpAccrued: 0,
|
||||
maxMP: 0
|
||||
})
|
||||
);
|
||||
@@ -1484,7 +1484,7 @@ contract UnstakeTest is StakeTest {
|
||||
stakedBalance: 20e18,
|
||||
vaultBalance: 20e18,
|
||||
rewardIndex: 0,
|
||||
accountMP: 20e18,
|
||||
mpAccrued: 20e18,
|
||||
maxMP: 100e18
|
||||
})
|
||||
);
|
||||
@@ -1498,7 +1498,7 @@ contract UnstakeTest is StakeTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 30e18,
|
||||
totalMP: 30e18,
|
||||
totalMPAccrued: 30e18,
|
||||
totalMaxMP: 150e18,
|
||||
stakingBalance: 30e18,
|
||||
// alice owned a 25% of the pool, so 25% of the rewards are paid out to alice (250)
|
||||
@@ -1514,7 +1514,7 @@ contract UnstakeTest is StakeTest {
|
||||
stakedBalance: 0,
|
||||
vaultBalance: 0,
|
||||
rewardIndex: 125e17,
|
||||
accountMP: 0,
|
||||
mpAccrued: 0,
|
||||
maxMP: 0
|
||||
})
|
||||
);
|
||||
@@ -1524,7 +1524,7 @@ contract UnstakeTest is StakeTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 20e18,
|
||||
totalMP: 20e18,
|
||||
totalMPAccrued: 20e18,
|
||||
totalMaxMP: 100e18,
|
||||
stakingBalance: 20e18,
|
||||
rewardBalance: 0, // bob should've now gotten the rest of the rewards
|
||||
@@ -1539,7 +1539,7 @@ contract UnstakeTest is StakeTest {
|
||||
stakedBalance: 20e18,
|
||||
vaultBalance: 20e18,
|
||||
rewardIndex: 125e17,
|
||||
accountMP: 20e18,
|
||||
mpAccrued: 20e18,
|
||||
maxMP: 100e18
|
||||
})
|
||||
);
|
||||
@@ -1549,7 +1549,7 @@ contract UnstakeTest is StakeTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 0,
|
||||
totalMP: 0,
|
||||
totalMPAccrued: 0,
|
||||
totalMaxMP: 0,
|
||||
stakingBalance: 0,
|
||||
rewardBalance: 0,
|
||||
@@ -1564,7 +1564,7 @@ contract UnstakeTest is StakeTest {
|
||||
stakedBalance: 0,
|
||||
vaultBalance: 0,
|
||||
rewardIndex: 125e17,
|
||||
accountMP: 0,
|
||||
mpAccrued: 0,
|
||||
maxMP: 0
|
||||
})
|
||||
);
|
||||
@@ -1598,7 +1598,7 @@ contract LockTest is RewardsStreamerMPTest {
|
||||
stakedBalance: stakeAmount,
|
||||
vaultBalance: stakeAmount,
|
||||
rewardIndex: 0,
|
||||
accountMP: initialAccountMP,
|
||||
mpAccrued: initialAccountMP,
|
||||
maxMP: initialMaxMP
|
||||
})
|
||||
);
|
||||
@@ -1617,7 +1617,7 @@ contract LockTest is RewardsStreamerMPTest {
|
||||
stakedBalance: stakeAmount,
|
||||
vaultBalance: stakeAmount,
|
||||
rewardIndex: 0,
|
||||
accountMP: initialAccountMP + expectedBonusMP,
|
||||
mpAccrued: initialAccountMP + expectedBonusMP,
|
||||
maxMP: initialMaxMP + expectedBonusMP
|
||||
})
|
||||
);
|
||||
@@ -1677,7 +1677,7 @@ contract EmergencyExitTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 10e18,
|
||||
totalMP: 10e18,
|
||||
totalMPAccrued: 10e18,
|
||||
totalMaxMP: 50e18,
|
||||
stakingBalance: 0,
|
||||
rewardBalance: 0,
|
||||
@@ -1692,7 +1692,7 @@ contract EmergencyExitTest is RewardsStreamerMPTest {
|
||||
stakedBalance: 10e18,
|
||||
vaultBalance: 0,
|
||||
rewardIndex: 0,
|
||||
accountMP: 10e18,
|
||||
mpAccrued: 10e18,
|
||||
maxMP: 50e18
|
||||
})
|
||||
);
|
||||
@@ -1714,7 +1714,7 @@ contract EmergencyExitTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 10e18,
|
||||
totalMP: 10e18,
|
||||
totalMPAccrued: 10e18,
|
||||
totalMaxMP: 50e18,
|
||||
stakingBalance: 10e18,
|
||||
rewardBalance: 1000e18,
|
||||
@@ -1760,7 +1760,7 @@ contract EmergencyExitTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 40e18,
|
||||
totalMP: 40e18,
|
||||
totalMPAccrued: 40e18,
|
||||
totalMaxMP: 200e18,
|
||||
stakingBalance: 40e18,
|
||||
rewardBalance: 1000e18,
|
||||
@@ -1775,7 +1775,7 @@ contract EmergencyExitTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 40e18,
|
||||
totalMP: 40e18,
|
||||
totalMPAccrued: 40e18,
|
||||
totalMaxMP: 200e18,
|
||||
stakingBalance: 40e18,
|
||||
rewardBalance: 1000e18,
|
||||
@@ -1790,7 +1790,7 @@ contract EmergencyExitTest is RewardsStreamerMPTest {
|
||||
stakedBalance: 10e18,
|
||||
vaultBalance: 0,
|
||||
rewardIndex: 0,
|
||||
accountMP: 10e18,
|
||||
mpAccrued: 10e18,
|
||||
maxMP: 50e18
|
||||
})
|
||||
);
|
||||
@@ -1802,7 +1802,7 @@ contract EmergencyExitTest is RewardsStreamerMPTest {
|
||||
stakedBalance: 30e18,
|
||||
vaultBalance: 0,
|
||||
rewardIndex: 0,
|
||||
accountMP: 30e18,
|
||||
mpAccrued: 30e18,
|
||||
maxMP: 150e18
|
||||
})
|
||||
);
|
||||
@@ -1835,7 +1835,7 @@ contract EmergencyExitTest is RewardsStreamerMPTest {
|
||||
stakedBalance: 10e18,
|
||||
vaultBalance: 0,
|
||||
rewardIndex: 0,
|
||||
accountMP: 10e18,
|
||||
mpAccrued: 10e18,
|
||||
maxMP: 50e18
|
||||
})
|
||||
);
|
||||
@@ -1870,7 +1870,7 @@ contract UpgradeTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 10e18,
|
||||
totalMP: 10e18,
|
||||
totalMPAccrued: 10e18,
|
||||
totalMaxMP: 50e18,
|
||||
stakingBalance: 10e18,
|
||||
rewardBalance: 0,
|
||||
@@ -1885,7 +1885,7 @@ contract UpgradeTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 10e18,
|
||||
totalMP: 10e18,
|
||||
totalMPAccrued: 10e18,
|
||||
totalMaxMP: 50e18,
|
||||
stakingBalance: 10e18,
|
||||
rewardBalance: 0,
|
||||
@@ -1916,7 +1916,7 @@ contract LeaveTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 100e18,
|
||||
totalMP: 100e18,
|
||||
totalMPAccrued: 100e18,
|
||||
totalMaxMP: 500e18,
|
||||
stakingBalance: 100e18,
|
||||
rewardBalance: 0,
|
||||
@@ -1931,7 +1931,7 @@ contract LeaveTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 0,
|
||||
totalMP: 0,
|
||||
totalMPAccrued: 0,
|
||||
totalMaxMP: 0,
|
||||
stakingBalance: 0,
|
||||
rewardBalance: 0,
|
||||
@@ -1947,7 +1947,7 @@ contract LeaveTest is RewardsStreamerMPTest {
|
||||
stakedBalance: 0,
|
||||
vaultBalance: 0,
|
||||
rewardIndex: 0,
|
||||
accountMP: 0,
|
||||
mpAccrued: 0,
|
||||
maxMP: 0
|
||||
})
|
||||
);
|
||||
@@ -2000,7 +2000,7 @@ contract MaliciousUpgradeTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 100e18,
|
||||
totalMP: 100e18,
|
||||
totalMPAccrued: 100e18,
|
||||
totalMaxMP: 500e18,
|
||||
stakingBalance: 100e18,
|
||||
rewardBalance: 0,
|
||||
@@ -2177,7 +2177,7 @@ contract MultipleVaultsStakeTest is RewardsStreamerMPTest {
|
||||
checkStreamer(
|
||||
CheckStreamerParams({
|
||||
totalStaked: 90e18,
|
||||
totalMP: 90e18,
|
||||
totalMPAccrued: 90e18,
|
||||
totalMaxMP: 450e18,
|
||||
stakingBalance: 90e18,
|
||||
rewardBalance: 0,
|
||||
@@ -2186,7 +2186,7 @@ contract MultipleVaultsStakeTest is RewardsStreamerMPTest {
|
||||
);
|
||||
|
||||
checkUserTotals(
|
||||
CheckUserTotalsParams({ user: alice, totalStakedBalance: 90e18, totalMP: 90e18, totalMaxMP: 450e18 })
|
||||
CheckUserTotalsParams({ user: alice, totalStakedBalance: 90e18, totalMPAccrued: 90e18, totalMaxMP: 450e18 })
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ contract StackOverflowStakeManager is
|
||||
uint256 public constant MAX_MULTIPLIER = 4;
|
||||
|
||||
uint256 public totalStaked;
|
||||
uint256 public totalMP;
|
||||
uint256 public totalMPAccrued;
|
||||
uint256 public totalMaxMP;
|
||||
uint256 public rewardIndex;
|
||||
uint256 public accountedRewards;
|
||||
|
||||
Reference in New Issue
Block a user