Skip to content

Commit

Permalink
chore(spec): Fix missing view functions
Browse files Browse the repository at this point in the history
chore(lint): Fix grammar
  • Loading branch information
3esmit committed Jan 13, 2025
1 parent 93c077e commit a031b71
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 77 deletions.
48 changes: 24 additions & 24 deletions .gas-report
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
| Deployment Cost | Deployment Size | | | | |
| 6598274 | 31554 | | | | |
| Function Name | min | avg | median | max | # calls |
| run | 5673508 | 5673508 | 5673508 | 5673508 | 63 |
| run | 5673530 | 5673530 | 5673530 | 5673530 | 63 |


| script/DeploymentConfig.s.sol:DeploymentConfig contract | | | | | |
Expand All @@ -19,7 +19,7 @@
| Deployment Cost | Deployment Size | | | | |
| 3243299 | 15929 | | | | |
| Function Name | min | avg | median | max | # calls |
| run | 2754435 | 2754435 | 2754435 | 2754435 | 3 |
| run | 2754392 | 2754392 | 2754392 | 2754392 | 3 |


| src/RewardsStreamerMP.sol:RewardsStreamerMP contract | | | | | |
Expand All @@ -28,46 +28,46 @@
| 2923354 | 13490 | | | | |
| Function Name | min | avg | median | max | # calls |
| MAX_LOCKUP_PERIOD | 360 | 360 | 360 | 360 | 4 |
| MAX_MULTIPLIER | 262 | 262 | 262 | 262 | 9 |
| MAX_MULTIPLIER | 284 | 284 | 284 | 284 | 9 |
| MIN_LOCKUP_PERIOD | 286 | 286 | 286 | 286 | 15 |
| STAKING_TOKEN | 395 | 2003 | 2395 | 2395 | 322 |
| emergencyModeEnabled | 2442 | 2442 | 2442 | 2442 | 7 |
| enableEmergencyMode | 2485 | 19392 | 24677 | 24677 | 8 |
| getAccount | 1661 | 1661 | 1661 | 1661 | 72 |
| getStakedBalance | 2596 | 2596 | 2596 | 2596 | 1 |
| getUserTotalMaxMP | 3155 | 3155 | 3155 | 3155 | 1 |
| getUserTotalStakedBalance | 15129 | 15129 | 15129 | 15129 | 1 |
| getStakedBalance | 2618 | 2618 | 2618 | 2618 | 1 |
| getUserTotalMaxMP | 3177 | 3177 | 3177 | 3177 | 1 |
| getUserTotalStakedBalance | 15151 | 15151 | 15151 | 15151 | 1 |
| getUserVaults | 5201 | 5201 | 5201 | 5201 | 4 |
| initialize | 115632 | 115632 | 115632 | 115632 | 65 |
| lastRewardTime | 428 | 1428 | 1428 | 2428 | 2 |
| initialize | 115654 | 115654 | 115654 | 115654 | 65 |
| lastRewardTime | 362 | 1362 | 1362 | 2362 | 2 |
| leave | 59951 | 59951 | 59951 | 59951 | 1 |
| lock | 12063 | 35736 | 16480 | 78666 | 3 |
| mpBalanceOfUser | 10309 | 10309 | 10309 | 10309 | 1 |
| proxiableUUID | 365 | 365 | 365 | 365 | 3 |
| mpBalanceOfUser | 10331 | 10331 | 10331 | 10331 | 1 |
| proxiableUUID | 387 | 387 | 387 | 387 | 3 |
| registerVault | 55844 | 72744 | 72944 | 72944 | 257 |
| rewardEndTime | 407 | 1407 | 1407 | 2407 | 2 |
| rewardEndTime | 362 | 1362 | 1362 | 2362 | 2 |
| rewardStartTime | 407 | 1407 | 1407 | 2407 | 2 |
| rewardsBalanceOf | 2920 | 6973 | 7529 | 7750 | 8 |
| setReward | 2606 | 58415 | 86507 | 105754 | 7 |
| rewardsBalanceOf | 2942 | 6995 | 7551 | 7772 | 8 |
| setReward | 2561 | 58370 | 86462 | 105709 | 7 |
| setTrustedCodehash | 24199 | 24260 | 24199 | 26199 | 65 |
| stake | 136750 | 174361 | 181143 | 201617 | 66 |
| totalMPAccrued | 406 | 406 | 406 | 406 | 81 |
| totalMaxMP | 428 | 428 | 428 | 428 | 81 |
| totalRewardsAccrued | 363 | 363 | 363 | 363 | 3 |
| stake | 136772 | 174383 | 181165 | 201639 | 66 |
| totalMPAccrued | 428 | 428 | 428 | 428 | 81 |
| totalMaxMP | 362 | 362 | 362 | 362 | 81 |
| totalRewardsAccrued | 385 | 385 | 385 | 385 | 3 |
| totalRewardsSupply | 1036 | 1995 | 1817 | 6776 | 30 |
| totalStaked | 405 | 405 | 405 | 405 | 82 |
| totalStaked | 427 | 427 | 427 | 427 | 82 |
| unstake | 64233 | 65099 | 64635 | 68456 | 13 |
| updateAccountMP | 11757 | 17631 | 18323 | 18323 | 19 |
| updateAccountMP | 11712 | 17586 | 18278 | 18278 | 19 |
| updateGlobalState | 14317 | 26758 | 28737 | 28737 | 19 |
| upgradeToAndCall | 3246 | 7927 | 8481 | 10946 | 5 |
| upgradeToAndCall | 3181 | 7875 | 8438 | 10881 | 5 |


| src/StakeManagerProxy.sol:StakeManagerProxy contract | | | | | |
|------------------------------------------------------|-----------------|------|--------|--------|---------|
| Deployment Cost | Deployment Size | | | | |
| 256488 | 1231 | | | | |
| 256510 | 1231 | | | | |
| Function Name | min | avg | median | max | # calls |
| fallback | 689 | 7201 | 2115 | 132112 | 785 |
| fallback | 711 | 7197 | 2115 | 132067 | 785 |
| implementation | 343 | 775 | 343 | 2343 | 412 |


Expand All @@ -82,11 +82,11 @@
| lock | 33245 | 61849 | 50845 | 112463 | 4 |
| owner | 2339 | 2339 | 2339 | 2339 | 257 |
| register | 86993 | 103893 | 104093 | 104093 | 257 |
| stake | 33411 | 245660 | 255647 | 276169 | 67 |
| stake | 33411 | 245682 | 255669 | 276191 | 67 |
| stakeManager | 368 | 368 | 368 | 368 | 257 |
| trustStakeManager | 28953 | 28953 | 28953 | 28953 | 1 |
| unstake | 33282 | 100401 | 106478 | 114162 | 14 |
| withdraw | 42256 | 42256 | 42256 | 42256 | 1 |
| withdraw | 42278 | 42278 | 42278 | 42278 | 1 |


| src/XPNFTToken.sol:XPNFTToken contract | | | | | |
Expand Down
98 changes: 49 additions & 49 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,74 +1,74 @@
EmergencyExitTest:test_CannotEnableEmergencyModeTwice() (gas: 92713)
EmergencyExitTest:test_CannotLeaveBeforeEmergencyMode() (gas: 300961)
EmergencyExitTest:test_EmergencyExitBasic() (gas: 387797)
EmergencyExitTest:test_EmergencyExitMultipleUsers() (gas: 668471)
EmergencyExitTest:test_EmergencyExitToAlternateAddress() (gas: 395619)
EmergencyExitTest:test_EmergencyExitWithLock() (gas: 395169)
EmergencyExitTest:test_CannotLeaveBeforeEmergencyMode() (gas: 301005)
EmergencyExitTest:test_EmergencyExitBasic() (gas: 387819)
EmergencyExitTest:test_EmergencyExitMultipleUsers() (gas: 668429)
EmergencyExitTest:test_EmergencyExitToAlternateAddress() (gas: 395663)
EmergencyExitTest:test_EmergencyExitWithLock() (gas: 395213)
EmergencyExitTest:test_EmergencyExitWithRewards() (gas: 380725)
EmergencyExitTest:test_OnlyOwnerCanEnableEmergencyMode() (gas: 39470)
IntegrationTest:testStakeFoo() (gas: 1221399)
LeaveTest:test_LeaveShouldProperlyUpdateAccounting() (gas: 6401627)
LeaveTest:test_RevertWhenStakeManagerIsTrusted() (gas: 298048)
LeaveTest:test_TrustNewStakeManager() (gas: 6469293)
LockTest:test_LockFailsWithInvalidPeriod() (gas: 313177)
EmergencyExitTest:test_OnlyOwnerCanEnableEmergencyMode() (gas: 39427)
IntegrationTest:testStakeFoo() (gas: 1221267)
LeaveTest:test_LeaveShouldProperlyUpdateAccounting() (gas: 6401584)
LeaveTest:test_RevertWhenStakeManagerIsTrusted() (gas: 298092)
LeaveTest:test_TrustNewStakeManager() (gas: 6469294)
LockTest:test_LockFailsWithInvalidPeriod() (gas: 313221)
LockTest:test_LockFailsWithNoStake() (gas: 63752)
LockTest:test_LockWithoutPriorLock() (gas: 394095)
MaliciousUpgradeTest:test_UpgradeStackOverflowStakeManager() (gas: 1753013)
MathTest:test_CalcAbsoluteMaxTotalMP() (gas: 4997)
LockTest:test_LockWithoutPriorLock() (gas: 394161)
MaliciousUpgradeTest:test_UpgradeStackOverflowStakeManager() (gas: 1752948)
MathTest:test_CalcAbsoluteMaxTotalMP() (gas: 4974)
MathTest:test_CalcAccrueMP() (gas: 8033)
MathTest:test_CalcBonusMP() (gas: 18653)
MathTest:test_CalcInitialMP() (gas: 5395)
MathTest:test_CalcMaxAccruedMP() (gas: 4643)
MathTest:test_CalcMaxTotalMP() (gas: 19427)
MultipleVaultsStakeTest:test_StakeMultipleVaults() (gas: 732621)
MathTest:test_CalcBonusMP() (gas: 18610)
MathTest:test_CalcInitialMP() (gas: 5330)
MathTest:test_CalcMaxAccruedMP() (gas: 4665)
MathTest:test_CalcMaxTotalMP() (gas: 19383)
MultipleVaultsStakeTest:test_StakeMultipleVaults() (gas: 732731)
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: 491030)
RewardsStreamerMP_RewardsTest:testSetRewards() (gas: 160970)
RewardsStreamerMP_RewardsTest:testSetRewards_RevertsBadAmount() (gas: 39427)
RewardsStreamerMP_RewardsTest:testSetRewards_RevertsBadDuration() (gas: 39363)
RewardsStreamerMP_RewardsTest:testSetRewards_RevertsNotAuthorized() (gas: 39420)
RewardsStreamerMP_RewardsTest:testTotalRewardsSupply() (gas: 621029)
StakeTest:test_StakeMultipleAccounts() (gas: 503518)
RewardsStreamerMP_RewardsTest:testRewardsBalanceOf() (gas: 491205)
RewardsStreamerMP_RewardsTest:testSetRewards() (gas: 160703)
RewardsStreamerMP_RewardsTest:testSetRewards_RevertsBadAmount() (gas: 39317)
RewardsStreamerMP_RewardsTest:testSetRewards_RevertsBadDuration() (gas: 39340)
RewardsStreamerMP_RewardsTest:testSetRewards_RevertsNotAuthorized() (gas: 39375)
RewardsStreamerMP_RewardsTest:testTotalRewardsSupply() (gas: 620983)
StakeTest:test_StakeMultipleAccounts() (gas: 503497)
StakeTest:test_StakeMultipleAccountsAndRewards() (gas: 509532)
StakeTest:test_StakeMultipleAccountsMPIncreasesMaxMPDoesNotChange() (gas: 848664)
StakeTest:test_StakeMultipleAccountsWithMinLockUp() (gas: 518495)
StakeTest:test_StakeMultipleAccountsWithRandomLockUp() (gas: 540462)
StakeTest:test_StakeMultipleAccountsMPIncreasesMaxMPDoesNotChange() (gas: 848506)
StakeTest:test_StakeMultipleAccountsWithMinLockUp() (gas: 518539)
StakeTest:test_StakeMultipleAccountsWithRandomLockUp() (gas: 540506)
StakeTest:test_StakeOneAccount() (gas: 280320)
StakeTest:test_StakeOneAccountAndRewards() (gas: 286398)
StakeTest:test_StakeOneAccountMPIncreasesMaxMPDoesNotChange() (gas: 511087)
StakeTest:test_StakeOneAccountReachingMPLimit() (gas: 500648)
StakeTest:test_StakeOneAccountAndRewards() (gas: 286353)
StakeTest:test_StakeOneAccountMPIncreasesMaxMPDoesNotChange() (gas: 510997)
StakeTest:test_StakeOneAccountReachingMPLimit() (gas: 500558)
StakeTest:test_StakeOneAccountWithMaxLockUp() (gas: 300551)
StakeTest:test_StakeOneAccountWithMinLockUp() (gas: 301113)
StakeTest:test_StakeOneAccountWithRandomLockUp() (gas: 301202)
StakeTest:test_StakeOneAccountWithRandomLockUp() (gas: 301224)
StakingTokenTest:testStakeToken() (gas: 10422)
UnstakeTest:test_StakeMultipleAccounts() (gas: 503519)
UnstakeTest:test_StakeMultipleAccounts() (gas: 503496)
UnstakeTest:test_StakeMultipleAccountsAndRewards() (gas: 509576)
UnstakeTest:test_StakeMultipleAccountsMPIncreasesMaxMPDoesNotChange() (gas: 848641)
UnstakeTest:test_StakeMultipleAccountsWithMinLockUp() (gas: 518494)
UnstakeTest:test_StakeMultipleAccountsWithRandomLockUp() (gas: 540461)
UnstakeTest:test_StakeMultipleAccountsMPIncreasesMaxMPDoesNotChange() (gas: 848483)
UnstakeTest:test_StakeMultipleAccountsWithMinLockUp() (gas: 518538)
UnstakeTest:test_StakeMultipleAccountsWithRandomLockUp() (gas: 540505)
UnstakeTest:test_StakeOneAccount() (gas: 280320)
UnstakeTest:test_StakeOneAccountAndRewards() (gas: 286397)
UnstakeTest:test_StakeOneAccountMPIncreasesMaxMPDoesNotChange() (gas: 511086)
UnstakeTest:test_StakeOneAccountReachingMPLimit() (gas: 500650)
UnstakeTest:test_StakeOneAccountMPIncreasesMaxMPDoesNotChange() (gas: 510996)
UnstakeTest:test_StakeOneAccountReachingMPLimit() (gas: 500560)
UnstakeTest:test_StakeOneAccountWithMaxLockUp() (gas: 300573)
UnstakeTest:test_StakeOneAccountWithMinLockUp() (gas: 301135)
UnstakeTest:test_StakeOneAccountWithRandomLockUp() (gas: 301202)
UnstakeTest:test_UnstakeBonusMPAndAccuredMP() (gas: 547949)
UnstakeTest:test_StakeOneAccountWithRandomLockUp() (gas: 301224)
UnstakeTest:test_UnstakeBonusMPAndAccuredMP() (gas: 547817)
UnstakeTest:test_UnstakeMultipleAccounts() (gas: 709855)
UnstakeTest:test_UnstakeMultipleAccountsAndRewards() (gas: 806161)
UnstakeTest:test_UnstakeOneAccount() (gas: 483001)
UnstakeTest:test_UnstakeOneAccountAndAccruedMP() (gas: 506313)
UnstakeTest:test_UnstakeOneAccountAndRewards() (gas: 412012)
UnstakeTest:test_UnstakeOneAccountWithLockUpAndAccruedMP() (gas: 531745)
UpgradeTest:test_RevertWhenNotOwner() (gas: 3000250)
UpgradeTest:test_UpgradeStakeManager() (gas: 6314208)
UnstakeTest:test_UnstakeMultipleAccountsAndRewards() (gas: 806095)
UnstakeTest:test_UnstakeOneAccount() (gas: 482979)
UnstakeTest:test_UnstakeOneAccountAndAccruedMP() (gas: 506246)
UnstakeTest:test_UnstakeOneAccountAndRewards() (gas: 411968)
UnstakeTest:test_UnstakeOneAccountWithLockUpAndAccruedMP() (gas: 531656)
UpgradeTest:test_RevertWhenNotOwner() (gas: 3000185)
UpgradeTest:test_UpgradeStakeManager() (gas: 6314078)
VaultRegistrationTest:test_VaultRegistration() (gas: 62058)
WithdrawTest:test_CannotWithdrawStakedFunds() (gas: 313770)
WithdrawTest:test_CannotWithdrawStakedFunds() (gas: 313836)
XPNFTTokenTest:testApproveNotAllowed() (gas: 10500)
XPNFTTokenTest:testGetApproved() (gas: 10523)
XPNFTTokenTest:testIsApprovedForAll() (gas: 10698)
Expand Down
4 changes: 4 additions & 0 deletions certora/specs/EmergencyMode.spec
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ definition isViewFunction(method f) returns bool = (
f.selector == sig:streamer.STAKING_TOKEN().selector ||
f.selector == sig:streamer.SCALE_FACTOR().selector ||
f.selector == sig:streamer.MP_APY().selector ||
f.selector == sig:streamer.MP_APY_ABSOLUTE().selector ||
f.selector == sig:streamer.ACCRUE_RATE().selector ||
f.selector == sig:streamer.MIN_BALANCE().selector ||
f.selector == sig:streamer.MAX_BALANCE().selector ||
f.selector == sig:streamer.MIN_LOCKUP_PERIOD().selector ||
f.selector == sig:streamer.MAX_LOCKUP_PERIOD().selector ||
f.selector == sig:streamer.MAX_MULTIPLIER().selector ||
Expand Down
6 changes: 3 additions & 3 deletions src/math/MultiplierPointMath.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ abstract contract MultiplierPointMath is IStakeConstants {
/// @notice Multiplier points absolute maximum percentage yield.
uint256 public constant MP_MPY_ABSOLUTE = 100 + (2 * (MAX_MULTIPLIER * MP_APY));
/// @notice The accrue rate period of time over which multiplier points are calculated.
uint256 public constant ACCURE_RATE = 12 seconds;
uint256 public constant ACCRUE_RATE = 12 seconds;
/// @notice Minimal value to generate 1 multiplier point in the accrue rate period (rounded up).
uint256 public constant MIN_BALANCE = (((YEAR * 100) - 1) / (MP_APY * ACCURE_RATE)) + 1;
uint256 public constant MIN_BALANCE = (((YEAR * 100) - 1) / (MP_APY * ACCRUE_RATE)) + 1;
/// @notice Maximum value to not overflow unsigned integer of 256 bits.
uint256 public constant MAX_BALANCE = type(uint256).max / (MP_APY * ACCURE_RATE);
uint256 public constant MAX_BALANCE = type(uint256).max / (MP_APY * ACCRUE_RATE);

/**
* @notice Calculates the accrued multiplier points (MPs) over a time period Δt, based on the account balance
Expand Down
2 changes: 1 addition & 1 deletion src/math/StakeMath.sol
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ abstract contract StakeMath is MultiplierPointMath {
returns (uint256 _deltaMpTotal)
{
uint256 dt = _processTime - _lastAccrualTime;
if (dt < ACCURE_RATE) {
if (dt < ACCRUE_RATE) {
revert StakeManager__AccrueTimeNotReached();
}
if (_currentTotalMP < _currentMaxMP) {
Expand Down

0 comments on commit a031b71

Please sign in to comment.