refactor(StakeManager): account initialize in currentEpoch

This commit is contained in:
Ricardo Guilherme Schmidt 2024-02-24 16:34:15 -03:00
parent 6082399e83
commit 92ff9bff21
3 changed files with 18 additions and 18 deletions

View File

@ -1,7 +1,7 @@
| contracts/StakeManager.sol:StakeManager contract | | | | | |
|--------------------------------------------------|-----------------|--------|--------|--------|---------|
| Deployment Cost | Deployment Size | | | | |
| 2012229 | 10266 | | | | |
| 2011229 | 10261 | | | | |
| Function Name | min | avg | median | max | # calls |
| MAX_LOCKUP_PERIOD | 405 | 405 | 405 | 405 | 2 |
| MIN_LOCKUP_PERIOD | 264 | 264 | 264 | 264 | 3 |
@ -15,12 +15,12 @@
| owner | 2341 | 2341 | 2341 | 2341 | 8 |
| pendingReward | 2386 | 2386 | 2386 | 2386 | 8 |
| setVault | 22606 | 22606 | 22606 | 22606 | 10 |
| stake | 2638 | 142484 | 208380 | 209064 | 13 |
| stake | 2638 | 128658 | 188409 | 189093 | 13 |
| stakedToken | 260 | 260 | 260 | 260 | 22 |
| totalSupply | 561 | 561 | 561 | 561 | 8 |
| totalSupplyBalance | 362 | 1592 | 2362 | 2362 | 13 |
| totalSupplyMP | 384 | 1984 | 2384 | 2384 | 10 |
| unstake | 1730 | 13754 | 5176 | 83235 | 8 |
| unstake | 1730 | 18924 | 8964 | 107445 | 8 |
| contracts/StakeVault.sol:StakeVault contract | | | | | |
@ -31,9 +31,9 @@
| acceptMigration | 1726 | 1726 | 1726 | 1726 | 2 |
| leave | 1712 | 1712 | 1712 | 1712 | 1 |
| owner | 362 | 362 | 362 | 362 | 10 |
| stake | 3433 | 170519 | 239155 | 239839 | 13 |
| stake | 3433 | 156693 | 219184 | 219868 | 13 |
| stakedToken | 212 | 212 | 212 | 212 | 2 |
| unstake | 2588 | 18674 | 9497 | 87556 | 7 |
| unstake | 2588 | 24583 | 14285 | 111766 | 7 |
| contracts/VaultFactory.sol:VaultFactory contract | | | | | |
@ -60,9 +60,9 @@
| script/Deploy.s.sol:Deploy contract | | | | | |
|-------------------------------------|-----------------|---------|---------|---------|---------|
| Deployment Cost | Deployment Size | | | | |
| 5096726 | 26763 | | | | |
| 5095726 | 26758 | | | | |
| Function Name | min | avg | median | max | # calls |
| run | 4791797 | 4791797 | 4791797 | 4791797 | 30 |
| run | 4790797 | 4790797 | 4790797 | 4790797 | 30 |
| script/DeploymentConfig.s.sol:DeploymentConfig contract | | | | | |
@ -86,9 +86,9 @@
| test/script/DeployBroken.s.sol:DeployBroken contract | | | | | |
|------------------------------------------------------|-----------------|---------|---------|---------|---------|
| Deployment Cost | Deployment Size | | | | |
| 3869460 | 20561 | | | | |
| 3868460 | 20556 | | | | |
| Function Name | min | avg | median | max | # calls |
| run | 3631620 | 3631620 | 3631620 | 3631620 | 1 |
| run | 3630620 | 3630620 | 3630620 | 3630620 | 1 |

View File

@ -1,15 +1,15 @@
CreateVaultTest:testDeployment() (gas: 9774)
CreateVaultTest:test_createVault() (gas: 692923)
ExecuteAccountTest:testDeployment() (gas: 26335)
ExecuteAccountTest:test_RevertWhen_InvalidLimitEpoch() (gas: 1071591)
ExecuteAccountTest:test_RevertWhen_InvalidLimitEpoch() (gas: 1051620)
LeaveTest:testDeployment() (gas: 26335)
LeaveTest:test_RevertWhen_NoPendingMigration() (gas: 1072210)
LeaveTest:test_RevertWhen_NoPendingMigration() (gas: 1052239)
LeaveTest:test_RevertWhen_SenderIsNotVault() (gas: 10794)
LockTest:testDeployment() (gas: 26335)
LockTest:test_RevertWhen_InvalidLockupPeriod() (gas: 865463)
LockTest:test_RevertWhen_SenderIsNotVault() (gas: 10630)
MigrateTest:testDeployment() (gas: 26335)
MigrateTest:test_RevertWhen_NoPendingMigration() (gas: 1069817)
MigrateTest:test_RevertWhen_NoPendingMigration() (gas: 1049846)
MigrateTest:test_RevertWhen_SenderIsNotVault() (gas: 10794)
SetStakeManagerTest:testDeployment() (gas: 9774)
SetStakeManagerTest:test_RevertWhen_InvalidStakeManagerAddress() (gas: 20481)
@ -19,13 +19,13 @@ StakeTest:testDeployment() (gas: 26335)
StakeTest:test_RevertWhen_InvalidLockupPeriod() (gas: 883366)
StakeTest:test_RevertWhen_SenderIsNotVault() (gas: 10650)
StakeTest:test_RevertWhen_StakeTokenTransferFails() (gas: 175040)
StakeTest:test_StakeWithoutLockUpTimeMintsMultiplierPoints() (gas: 963789)
StakeTest:test_StakeWithoutLockUpTimeMintsMultiplierPoints() (gas: 948606)
StakedTokenTest:testStakeToken() (gas: 7616)
UnstakeTest:testDeployment() (gas: 26357)
UnstakeTest:test_RevertWhen_FundsLocked() (gas: 1071749)
UnstakeTest:test_RevertWhen_FundsLocked() (gas: 1051778)
UnstakeTest:test_RevertWhen_SenderIsNotVault() (gas: 10631)
UnstakeTest:test_UnstakeShouldReturnFunds() (gas: 961918)
UnstakeTest:test_UnstakeShouldReturnFunds() (gas: 946735)
UserFlowsTest:testDeployment() (gas: 26335)
UserFlowsTest:test_StakeWithLockUpTimeLocksStake() (gas: 1042001)
UserFlowsTest:test_StakedSupplyShouldIncreaseAndDecreaseAgain() (gas: 1857747)
UserFlowsTest:test_StakeWithLockUpTimeLocksStake() (gas: 1026340)
UserFlowsTest:test_StakedSupplyShouldIncreaseAndDecreaseAgain() (gas: 1825381)
VaultFactoryTest:testDeployment() (gas: 9774)

View File

@ -137,7 +137,7 @@ contract StakeManager is Ownable {
if (account.lockUntil == 0) {
// account not initialized
account.lockUntil = block.timestamp;
account.epoch = currentEpoch + 1; //starts next epoch
account.epoch = currentEpoch; //starts in current epoch
account.rewardAddress = StakeVault(msg.sender).owner();
} else {
_processAccount(account, currentEpoch);