Skip to content

Commit

Permalink
refactor(StakeManager): Use maxMP instead of totalMP
Browse files Browse the repository at this point in the history
  • Loading branch information
3esmit committed Nov 12, 2024
1 parent 0aa3f2e commit 9306257
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 156 deletions.
42 changes: 21 additions & 21 deletions .gas-report
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
| contracts/StakeManager.sol:StakeManager contract | | | | | |
|--------------------------------------------------|-----------------|--------|--------|--------|---------|
| Deployment Cost | Deployment Size | | | | |
| 2600451 | 13644 | | | | |
| 2605863 | 13669 | | | | |
| Function Name | min | avg | median | max | # calls |
| ACCURE_RATE | 328 | 328 | 328 | 328 | 1546 |
| MAX_LOCKUP_PERIOD | 405 | 405 | 405 | 405 | 4 |
Expand All @@ -10,14 +10,14 @@
| REWARD_TOKEN | 317 | 317 | 317 | 317 | 744 |
| YEAR | 308 | 308 | 308 | 308 | 685 |
| acceptUpdate | 23633 | 23633 | 23633 | 23633 | 1 |
| accounts | 1572 | 1572 | 1572 | 1572 | 154869 |
| calculateMP | 798 | 798 | 798 | 798 | 1372 |
| accounts | 1572 | 1572 | 1572 | 1572 | 155271 |
| calculateMP | 798 | 798 | 798 | 798 | 1371 |
| currentEpoch | 384 | 1050 | 384 | 2384 | 54 |
| epochEnd | 627 | 627 | 627 | 2627 | 25441 |
| epochEnd | 627 | 627 | 627 | 2627 | 25508 |
| epochReward | 1381 | 2881 | 1381 | 5881 | 3 |
| executeAccount(address) | 33469 | 110665 | 149264 | 149264 | 3 |
| executeAccount(address,uint256) | 26562 | 72195 | 74101 | 199919 | 152455 |
| executeEpoch() | 23435 | 120639 | 121820 | 900335 | 25330 |
| executeAccount(address) | 33469 | 110371 | 148822 | 148822 | 3 |
| executeAccount(address,uint256) | 26562 | 71632 | 73548 | 195495 | 152857 |
| executeEpoch() | 23435 | 120644 | 121820 | 900335 | 25397 |
| executeEpoch(uint256) | 23861 | 24497 | 23861 | 26090 | 7 |
| expiredStakeStorage | 416 | 2325 | 2416 | 2416 | 22 |
| isTrustedCodehash | 541 | 944 | 541 | 2541 | 728 |
Expand All @@ -28,13 +28,13 @@
| newEpoch | 463 | 463 | 463 | 463 | 5 |
| owner | 2432 | 2432 | 2432 | 2432 | 13 |
| pendingReward | 408 | 1442 | 2408 | 2408 | 29 |
| potentialMP | 408 | 408 | 408 | 408 | 49964 |
| potentialMP | 408 | 408 | 408 | 408 | 50098 |
| previousManager | 297 | 297 | 297 | 297 | 13 |
| setTrustedCodehash | 47982 | 47982 | 47982 | 47982 | 147 |
| stake | 24047 | 24047 | 24047 | 24047 | 1 |
| startMigration | 103624 | 103632 | 103636 | 103636 | 3 |
| startTime | 306 | 306 | 306 | 306 | 21 |
| totalMP | 385 | 385 | 385 | 2385 | 49985 |
| totalMP | 385 | 385 | 385 | 2385 | 50119 |
| totalStaked | 386 | 1786 | 2386 | 2386 | 20 |
| totalSupply | 784 | 1965 | 2784 | 2784 | 22 |
| unstake | 23841 | 23841 | 23841 | 23841 | 1 |
Expand All @@ -48,10 +48,10 @@
| STAKING_TOKEN | 193 | 193 | 193 | 193 | 2 |
| acceptMigration | 35141 | 35141 | 35141 | 35141 | 2 |
| leave | 35196 | 35196 | 35196 | 35196 | 1 |
| lock | 43196 | 71076 | 62042 | 162843 | 7 |
| lock | 43196 | 71013 | 62042 | 162400 | 7 |
| owner | 318 | 318 | 318 | 318 | 727 |
| stake | 27291 | 282802 | 266296 | 351880 | 732 |
| unstake | 40179 | 88236 | 78765 | 184769 | 11 |
| stake | 27291 | 283772 | 266970 | 352542 | 732 |
| unstake | 40179 | 88155 | 78765 | 184327 | 11 |


| contracts/VaultFactory.sol:VaultFactory contract | | | | | |
Expand All @@ -69,24 +69,24 @@
| Deployment Cost | Deployment Size | | | | |
| 0 | 0 | | | | |
| Function Name | min | avg | median | max | # calls |
| getExpiredMP | 2427 | 2427 | 2427 | 2427 | 25486 |
| getExpiredMP | 2427 | 2427 | 2427 | 2427 | 25553 |
| transferOwnership | 28533 | 28533 | 28533 | 28533 | 1 |


| script/Deploy.s.sol:Deploy contract | | | | | |
|-------------------------------------|-----------------|---------|---------|---------|---------|
| Deployment Cost | Deployment Size | | | | |
| 6220738 | 29931 | | | | |
| 6226159 | 29956 | | | | |
| Function Name | min | avg | median | max | # calls |
| run | 5420174 | 5420174 | 5420174 | 5420174 | 66 |
| run | 5425181 | 5425181 | 5425181 | 5425181 | 66 |


| script/DeployMigrationStakeManager.s.sol:DeployMigrationStakeManager contract | | | | | |
|-------------------------------------------------------------------------------|-----------------|---------|---------|---------|---------|
| Deployment Cost | Deployment Size | | | | |
| 3412741 | 16827 | | | | |
| 3418160 | 16852 | | | | |
| Function Name | min | avg | median | max | # calls |
| run | 2427736 | 2427736 | 2427736 | 2427736 | 19 |
| run | 2432743 | 2432743 | 2432743 | 2432743 | 19 |


| script/DeploymentConfig.s.sol:DeploymentConfig contract | | | | | |
Expand All @@ -111,16 +111,16 @@
| Deployment Cost | Deployment Size | | | | |
| 0 | 0 | | | | |
| Function Name | min | avg | median | max | # calls |
| approve | 46175 | 46235 | 46199 | 46367 | 727 |
| balanceOf | 561 | 2127 | 2561 | 2561 | 32612 |
| approve | 46175 | 46233 | 46199 | 46367 | 727 |
| balanceOf | 561 | 2128 | 2561 | 2561 | 32679 |


| test/script/DeployBroken.s.sol:DeployBroken contract | | | | | |
|------------------------------------------------------|-----------------|---------|---------|---------|---------|
| Deployment Cost | Deployment Size | | | | |
| 4918894 | 23867 | | | | |
| 4924318 | 23892 | | | | |
| Function Name | min | avg | median | max | # calls |
| run | 4266410 | 4266410 | 4266410 | 4266410 | 1 |
| run | 4271418 | 4271418 | 4271418 | 4271418 | 1 |



Expand Down
112 changes: 56 additions & 56 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
CreateVaultTest:testDeployment() (gas: 9774)
CreateVaultTest:test_createVault() (gas: 700333)
ExecuteAccountTest:testDeployment() (gas: 28875)
ExecuteAccountTest:test_ExecuteAccountLimit() (gas: 1559514)
ExecuteAccountTest:test_ExecuteAccountMintMP() (gas: 5232040)
ExecuteAccountTest:test_RevertWhen_InvalidLimitEpoch() (gas: 1769214)
ExecuteAccountTest:test_ShouldNotMintMoreThanCap() (gas: 320225995)
ExecuteEpochTest:testDeployment() (gas: 28876)
ExecuteEpochTest:testNewDeployment() (gas: 30948)
ExecuteEpochTest:test_ExecuteEpochExecuteAccountAfterEpochEnd() (gas: 1350443)
ExecuteEpochTest:test_ExecuteEpochExecuteAccountAfterManyEpochsJumoMany() (gas: 1367228)
ExecuteEpochTest:test_ExecuteEpochExecuteAccountAfterManyEpochsWithBrokenTime() (gas: 1613317)
ExecuteEpochTest:test_ExecuteEpochExecuteAccountAfterManyEpochsWithBrokenTimeJumpMany() (gas: 1377593)
ExecuteEpochTest:test_ExecuteEpochExecuteEpochAfterEnd() (gas: 1910717)
ExecuteEpochTest:test_ExecuteEpochExecuteEpochExecuteAccountAfterManyEpochs() (gas: 2492323)
ExecuteEpochTest:test_ExecuteEpochExecuteEpochExecuteAccountAfterManyEpochsJumoMany() (gas: 1460710)
ExecuteEpochTest:test_ExecuteEpochExecuteEpochExecuteAccountAfterManyEpochsWithBrokenTime() (gas: 2502709)
ExecuteEpochTest:test_ExecuteEpochExecuteEpochExecuteAccountAfterManyEpochsWithBrokenTimeJumpMany() (gas: 1471052)
ExecuteAccountTest:testDeployment() (gas: 28853)
ExecuteAccountTest:test_ExecuteAccountLimit() (gas: 1559565)
ExecuteAccountTest:test_ExecuteAccountMintMP() (gas: 5229838)
ExecuteAccountTest:test_RevertWhen_InvalidLimitEpoch() (gas: 1769243)
ExecuteAccountTest:test_ShouldNotMintMoreThanCap() (gas: 319099087)
ExecuteEpochTest:testDeployment() (gas: 28898)
ExecuteEpochTest:testNewDeployment() (gas: 31015)
ExecuteEpochTest:test_ExecuteEpochExecuteAccountAfterEpochEnd() (gas: 1351146)
ExecuteEpochTest:test_ExecuteEpochExecuteAccountAfterManyEpochsJumoMany() (gas: 1367601)
ExecuteEpochTest:test_ExecuteEpochExecuteAccountAfterManyEpochsWithBrokenTime() (gas: 1613976)
ExecuteEpochTest:test_ExecuteEpochExecuteAccountAfterManyEpochsWithBrokenTimeJumpMany() (gas: 1377966)
ExecuteEpochTest:test_ExecuteEpochExecuteEpochAfterEnd() (gas: 1909295)
ExecuteEpochTest:test_ExecuteEpochExecuteEpochExecuteAccountAfterManyEpochs() (gas: 2489731)
ExecuteEpochTest:test_ExecuteEpochExecuteEpochExecuteAccountAfterManyEpochsJumoMany() (gas: 1460839)
ExecuteEpochTest:test_ExecuteEpochExecuteEpochExecuteAccountAfterManyEpochsWithBrokenTime() (gas: 2500073)
ExecuteEpochTest:test_ExecuteEpochExecuteEpochExecuteAccountAfterManyEpochsWithBrokenTimeJumpMany() (gas: 1471203)
ExecuteEpochTest:test_ExecuteEpochNewEpoch() (gas: 1083615)
ExecuteEpochTest:test_ExecuteEpochShouldIncreaseEpoch() (gas: 92277)
ExecuteEpochTest:test_ExecuteEpochShouldIncreasePendingReward() (gas: 252659)
ExecuteEpochTest:test_ExecuteEpochShouldNotIncreaseEpochBeforeEnd() (gas: 38961)
ExecuteEpochTest:test_ExecuteEpochShouldIncreaseEpoch() (gas: 92233)
ExecuteEpochTest:test_ExecuteEpochShouldIncreasePendingReward() (gas: 252720)
ExecuteEpochTest:test_ExecuteEpochShouldNotIncreaseEpochBeforeEnd() (gas: 38962)
ExecuteEpochTest:test_ExecuteEpochShouldNotIncreaseEpochInMigration() (gas: 149703)
LeaveTest:testDeployment() (gas: 28853)
LeaveTest:test_RevertWhen_NoPendingMigration() (gas: 1311974)
LeaveTest:test_RevertWhen_SenderIsNotVault() (gas: 31740)
LockTest:testDeployment() (gas: 28853)
LockTest:test_NewLockupPeriod() (gas: 1310978)
LockTest:test_RevertWhen_InvalidNewLockupPeriod() (gas: 1285586)
LockTest:test_RevertWhen_InvalidUpdateLockupPeriod() (gas: 1406860)
LockTest:test_RevertWhen_SenderIsNotVault() (gas: 31834)
LockTest:test_ShouldIncreaseBonusMP() (gas: 1293620)
LockTest:test_UpdateLockupPeriod() (gas: 1470415)
MigrateTest:testDeployment() (gas: 28853)
MigrateTest:test_RevertWhen_NoPendingMigration() (gas: 1276097)
MigrateTest:test_RevertWhen_SenderIsNotVault() (gas: 31739)
MigrationInitializeTest:testDeployment() (gas: 28853)
MigrationInitializeTest:test_RevertWhen_MigrationPending() (gas: 5451158)
MigrationStakeManagerTest:testDeployment() (gas: 28853)
MigrationStakeManagerTest:testNewDeployment() (gas: 30992)
MigrationStakeManagerTest:test_ExecuteEpochShouldNotIncreaseEpochInMigration() (gas: 149668)
LeaveTest:testDeployment() (gas: 28831)
LeaveTest:test_RevertWhen_NoPendingMigration() (gas: 1312647)
LeaveTest:test_RevertWhen_SenderIsNotVault() (gas: 31763)
LockTest:testDeployment() (gas: 28831)
LockTest:test_NewLockupPeriod() (gas: 1311618)
LockTest:test_RevertWhen_InvalidNewLockupPeriod() (gas: 1286248)
LockTest:test_RevertWhen_InvalidUpdateLockupPeriod() (gas: 1407167)
LockTest:test_RevertWhen_SenderIsNotVault() (gas: 31857)
LockTest:test_ShouldIncreaseMaxMP() (gas: 1294282)
LockTest:test_UpdateLockupPeriod() (gas: 1470744)
MigrateTest:testDeployment() (gas: 28831)
MigrateTest:test_RevertWhen_NoPendingMigration() (gas: 1276770)
MigrateTest:test_RevertWhen_SenderIsNotVault() (gas: 31762)
MigrationInitializeTest:testDeployment() (gas: 28831)
MigrationInitializeTest:test_RevertWhen_MigrationPending() (gas: 5462037)
MigrationStakeManagerTest:testDeployment() (gas: 28831)
MigrationStakeManagerTest:testNewDeployment() (gas: 30948)
MigrationStakeManagerTest:test_ExecuteEpochShouldNotIncreaseEpochInMigration() (gas: 149713)
SetStakeManagerTest:testDeployment() (gas: 9774)
SetStakeManagerTest:test_RevertWhen_InvalidStakeManagerAddress() (gas: 63105)
SetStakeManagerTest:test_SetStakeManager() (gas: 41301)
StakeManagerTest:testDeployment() (gas: 28625)
StakeManagerTest:testDeployment() (gas: 28603)
StakeTest:testDeployment() (gas: 28831)
StakeTest:test_RevertWhen_InvalidLockupPeriod() (gas: 1057656)
StakeTest:test_RevertWhen_Restake() (gas: 1301092)
StakeTest:test_RevertWhen_RestakeWithLock() (gas: 1304525)
StakeTest:test_RevertWhen_SenderIsNotVault() (gas: 32082)
StakeTest:test_RevertWhen_StakeIsTooLow() (gas: 803915)
StakeTest:test_RevertWhen_InvalidLockupPeriod() (gas: 1057645)
StakeTest:test_RevertWhen_Restake() (gas: 1301832)
StakeTest:test_RevertWhen_RestakeWithLock() (gas: 1305220)
StakeTest:test_RevertWhen_SenderIsNotVault() (gas: 32104)
StakeTest:test_RevertWhen_StakeIsTooLow() (gas: 803959)
StakeTest:test_RevertWhen_StakeTokenTransferFails() (gas: 207758)
StakeTest:test_StakeWithLockBonusMP() (gas: 2323783)
StakeTest:test_StakeWithoutLockUpTimeMintsMultiplierPoints() (gas: 1297379)
StakeTest:test_StakeWithLockMaxMP() (gas: 2325472)
StakeTest:test_StakeWithoutLockUpTimeMintsMultiplierPoints() (gas: 1298474)
StakedTokenTest:testStakeToken() (gas: 7597)
UnstakeTest:testDeployment() (gas: 28875)
UnstakeTest:test_RevertWhen_AmountMoreThanBalance() (gas: 1281609)
UnstakeTest:test_RevertWhen_FundsLocked() (gas: 1325777)
UnstakeTest:test_RevertWhen_SenderIsNotVault() (gas: 31879)
UnstakeTest:test_UnstakeShouldBurnMultiplierPoints() (gas: 6432067)
UnstakeTest:test_UnstakeShouldReturnFund_NoLockUp() (gas: 1303800)
UnstakeTest:test_UnstakeShouldReturnFund_WithLockUp() (gas: 1387208)
UserFlowsTest:testDeployment() (gas: 28853)
UserFlowsTest:test_PendingMPToBeMintedCannotBeGreaterThanTotalSupplyMP(uint8,uint128) (runs: 114, μ: 130857603, ~: 130246926)
UserFlowsTest:test_StakeWithLockUpTimeLocksStake() (gas: 1425816)
UserFlowsTest:test_StakedSupplyShouldIncreaseAndDecreaseAgain() (gas: 2461484)
UnstakeTest:testDeployment() (gas: 28853)
UnstakeTest:test_RevertWhen_AmountMoreThanBalance() (gas: 1282314)
UnstakeTest:test_RevertWhen_FundsLocked() (gas: 1326462)
UnstakeTest:test_RevertWhen_SenderIsNotVault() (gas: 31857)
UnstakeTest:test_UnstakeShouldBurnMultiplierPoints() (gas: 6413830)
UnstakeTest:test_UnstakeShouldReturnFund_NoLockUp() (gas: 1304463)
UnstakeTest:test_UnstakeShouldReturnFund_WithLockUp() (gas: 1387562)
UserFlowsTest:testDeployment() (gas: 28831)
UserFlowsTest:test_PendingMPToBeMintedCannotBeGreaterThanTotalSupplyMP(uint8,uint128) (runs: 114, μ: 130456714, ~: 129540928)
UserFlowsTest:test_StakeWithLockUpTimeLocksStake() (gas: 1426181)
UserFlowsTest:test_StakedSupplyShouldIncreaseAndDecreaseAgain() (gas: 2462875)
VaultFactoryTest:testDeployment() (gas: 9774)
Loading

0 comments on commit 9306257

Please sign in to comment.