mirror of https://github.com/logos-co/staking.git
fix: adorno and workaroud test
This commit is contained in:
parent
6744ce19ec
commit
7bf91d45b2
93
.gas-report
93
.gas-report
|
@ -1,37 +1,50 @@
|
|||
| contracts/StakeManager.sol:StakeManager contract | | | | | |
|
||||
|--------------------------------------------------|-----------------|--------|--------|--------|---------|
|
||||
| Deployment Cost | Deployment Size | | | | |
|
||||
| 2520217 | 12803 | | | | |
|
||||
| 3080753 | 15624 | | | | |
|
||||
| Function Name | min | avg | median | max | # calls |
|
||||
| EPOCH_SIZE | 285 | 285 | 285 | 285 | 55 |
|
||||
| EPOCH_SIZE | 263 | 263 | 263 | 263 | 55 |
|
||||
| MAX_BOOST | 285 | 285 | 285 | 285 | 1 |
|
||||
| MAX_LOCKUP_PERIOD | 405 | 405 | 405 | 405 | 4 |
|
||||
| MAX_LOCKUP_PERIOD | 361 | 361 | 361 | 361 | 4 |
|
||||
| MIN_LOCKUP_PERIOD | 287 | 287 | 287 | 287 | 10 |
|
||||
| YEAR | 285 | 285 | 285 | 285 | 1 |
|
||||
| accounts | 1539 | 1539 | 1539 | 1539 | 3565 |
|
||||
| calculateMPToMint | 718 | 718 | 718 | 718 | 2 |
|
||||
| currentEpoch | 364 | 1697 | 2364 | 2364 | 27 |
|
||||
| YEAR | 263 | 263 | 263 | 263 | 1 |
|
||||
| accounts | 1619 | 1619 | 1619 | 1619 | 3453 |
|
||||
| calculateMPToMint | 741 | 741 | 741 | 741 | 2 |
|
||||
| currentEpoch | 406 | 1739 | 2406 | 2406 | 27 |
|
||||
| epochEnd | 649 | 677 | 649 | 4649 | 283 |
|
||||
| epochReward | 1391 | 2891 | 1391 | 5891 | 3 |
|
||||
| executeAccount | 1311 | 14580 | 10670 | 147584 | 1890 |
|
||||
| executeEpoch | 394 | 132794 | 135587 | 159487 | 223 |
|
||||
| isVault | 517 | 798 | 517 | 2517 | 142 |
|
||||
| lock | 2658 | 18188 | 4778 | 104477 | 7 |
|
||||
| migrateTo | 1019 | 1691 | 1019 | 2699 | 5 |
|
||||
| migration | 415 | 1415 | 1415 | 2415 | 4 |
|
||||
| migrationInitialize | 582 | 8217 | 10413 | 11463 | 4 |
|
||||
| owner | 2364 | 2364 | 2364 | 2364 | 13 |
|
||||
| epochReward | 1403 | 2903 | 1403 | 5903 | 3 |
|
||||
| executeAccount | 1325 | 13878 | 10708 | 148364 | 1778 |
|
||||
| executeEpoch | 384 | 133575 | 136331 | 160231 | 223 |
|
||||
| isVault | 540 | 1873 | 2540 | 2540 | 30 |
|
||||
| lock | 2636 | 18294 | 4780 | 105233 | 7 |
|
||||
| migrateTo | 1009 | 1676 | 1009 | 2677 | 5 |
|
||||
| migration | 439 | 1439 | 1439 | 2439 | 4 |
|
||||
| migrationInitialize | 642 | 13254 | 17109 | 18159 | 4 |
|
||||
| owner | 2432 | 2432 | 2432 | 2432 | 13 |
|
||||
| pendingMPToBeMinted | 386 | 386 | 386 | 386 | 2 |
|
||||
| pendingReward | 364 | 1398 | 2364 | 2364 | 29 |
|
||||
| previousManager | 263 | 263 | 263 | 263 | 13 |
|
||||
| setVault | 22628 | 22628 | 22628 | 22628 | 20 |
|
||||
| stake | 2661 | 176334 | 164635 | 283172 | 144 |
|
||||
| stakedToken | 283 | 283 | 283 | 283 | 158 |
|
||||
| startMigration | 52778 | 55844 | 57378 | 57378 | 3 |
|
||||
| previousManager | 275 | 275 | 275 | 275 | 13 |
|
||||
| setVault | 22640 | 22640 | 22640 | 22640 | 20 |
|
||||
| stake | 2639 | 222868 | 270638 | 291575 | 32 |
|
||||
| stakeRewardEstimate | 436 | 602 | 436 | 2436 | 12 |
|
||||
| stakedToken | 273 | 273 | 273 | 273 | 46 |
|
||||
| startMigration | 68717 | 77983 | 82617 | 82617 | 3 |
|
||||
| totalSupply | 740 | 1921 | 2740 | 2740 | 22 |
|
||||
| totalSupplyBalance | 362 | 1762 | 2362 | 2362 | 20 |
|
||||
| totalSupplyMP | 362 | 1579 | 2362 | 2362 | 23 |
|
||||
| unstake | 1708 | 31132 | 6245 | 151744 | 11 |
|
||||
| totalSupplyBalance | 385 | 1785 | 2385 | 2385 | 20 |
|
||||
| totalSupplyMP | 385 | 1602 | 2385 | 2385 | 23 |
|
||||
| unstake | 1720 | 31879 | 7201 | 153448 | 11 |
|
||||
|
||||
|
||||
| contracts/StakeManager.sol:StakeRewardEstimate contract | | | | | |
|
||||
|---------------------------------------------------------|-----------------|-------|--------|-------|---------|
|
||||
| Deployment Cost | Deployment Size | | | | |
|
||||
| 249010 | 1251 | | | | |
|
||||
| Function Name | min | avg | median | max | # calls |
|
||||
| decrementExpiredMP | 814 | 814 | 814 | 814 | 7 |
|
||||
| deleteExpiredMP | 543 | 543 | 543 | 543 | 3 |
|
||||
| getExpiredMP | 427 | 2405 | 2427 | 2427 | 278 |
|
||||
| incrementExpiredMP | 836 | 12442 | 2836 | 24736 | 58 |
|
||||
| transferOwnership | 2301 | 5901 | 7101 | 7101 | 4 |
|
||||
|
||||
|
||||
| contracts/StakeVault.sol:StakeVault contract | | | | | |
|
||||
|
@ -39,13 +52,13 @@
|
|||
| Deployment Cost | Deployment Size | | | | |
|
||||
| 635445 | 3370 | | | | |
|
||||
| Function Name | min | avg | median | max | # calls |
|
||||
| acceptMigration | 1704 | 1704 | 1704 | 1704 | 2 |
|
||||
| leave | 1690 | 1690 | 1690 | 1690 | 1 |
|
||||
| lock | 3731 | 21633 | 5635 | 105334 | 6 |
|
||||
| owner | 362 | 362 | 362 | 362 | 144 |
|
||||
| stake | 3433 | 206875 | 195410 | 313947 | 144 |
|
||||
| acceptMigration | 1694 | 1694 | 1694 | 1694 | 2 |
|
||||
| leave | 1680 | 1680 | 1680 | 1680 | 1 |
|
||||
| lock | 3733 | 21761 | 5637 | 106090 | 6 |
|
||||
| owner | 362 | 362 | 362 | 362 | 32 |
|
||||
| stake | 3433 | 252588 | 301413 | 322350 | 32 |
|
||||
| stakedToken | 212 | 212 | 212 | 212 | 2 |
|
||||
| unstake | 2566 | 39255 | 10566 | 156065 | 10 |
|
||||
| unstake | 2578 | 40078 | 11522 | 157769 | 10 |
|
||||
|
||||
|
||||
| contracts/VaultFactory.sol:VaultFactory contract | | | | | |
|
||||
|
@ -53,7 +66,7 @@
|
|||
| Deployment Cost | Deployment Size | | | | |
|
||||
| 1043406 | 5305 | | | | |
|
||||
| Function Name | min | avg | median | max | # calls |
|
||||
| createVault | 670977 | 671490 | 670977 | 675477 | 145 |
|
||||
| createVault | 670967 | 673224 | 672967 | 675467 | 33 |
|
||||
| setStakeManager | 2518 | 5317 | 4644 | 8790 | 3 |
|
||||
| stakeManager | 368 | 1868 | 2368 | 2368 | 4 |
|
||||
|
||||
|
@ -63,26 +76,26 @@
|
|||
| Deployment Cost | Deployment Size | | | | |
|
||||
| 649818 | 3562 | | | | |
|
||||
| Function Name | min | avg | median | max | # calls |
|
||||
| approve | 24603 | 24603 | 24603 | 24603 | 142 |
|
||||
| balanceOf | 561 | 580 | 561 | 2561 | 4496 |
|
||||
| approve | 24603 | 24603 | 24603 | 24603 | 30 |
|
||||
| balanceOf | 561 | 581 | 561 | 2561 | 4272 |
|
||||
| transfer | 3034 | 3175 | 3034 | 22934 | 1731 |
|
||||
| transferFrom | 27530 | 27530 | 27530 | 27530 | 143 |
|
||||
| transferFrom | 27530 | 27530 | 27530 | 27530 | 31 |
|
||||
|
||||
|
||||
| script/Deploy.s.sol:Deploy contract | | | | | |
|
||||
|-------------------------------------|-----------------|---------|---------|---------|---------|
|
||||
| Deployment Cost | Deployment Size | | | | |
|
||||
| 5604853 | 29300 | | | | |
|
||||
| 6169892 | 32121 | | | | |
|
||||
| Function Name | min | avg | median | max | # calls |
|
||||
| run | 5300380 | 5300380 | 5300380 | 5300380 | 54 |
|
||||
| run | 5861599 | 5861599 | 5861599 | 5861599 | 54 |
|
||||
|
||||
|
||||
| script/DeployMigrationStakeManager.s.sol:DeployMigrationStakeManager contract | | | | | |
|
||||
|-------------------------------------------------------------------------------|-----------------|---------|---------|---------|---------|
|
||||
| Deployment Cost | Deployment Size | | | | |
|
||||
| 2954241 | 16068 | | | | |
|
||||
| 3519135 | 18889 | | | | |
|
||||
| Function Name | min | avg | median | max | # calls |
|
||||
| run | 2557915 | 2557915 | 2557915 | 2557915 | 9 |
|
||||
| run | 2838769 | 2838769 | 2838769 | 2838769 | 9 |
|
||||
|
||||
|
||||
| script/DeploymentConfig.s.sol:DeploymentConfig contract | | | | | |
|
||||
|
@ -106,9 +119,9 @@
|
|||
| test/script/DeployBroken.s.sol:DeployBroken contract | | | | | |
|
||||
|------------------------------------------------------|-----------------|---------|---------|---------|---------|
|
||||
| Deployment Cost | Deployment Size | | | | |
|
||||
| 4377537 | 23098 | | | | |
|
||||
| 4942510 | 25919 | | | | |
|
||||
| Function Name | min | avg | median | max | # calls |
|
||||
| run | 4140202 | 4140202 | 4140202 | 4140202 | 1 |
|
||||
| run | 4701420 | 4701420 | 4701420 | 4701420 | 1 |
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,33 +1,55 @@
|
|||
CreateVaultTest:testDeployment() (gas: 9774)
|
||||
CreateVaultTest:test_createVault() (gas: 692923)
|
||||
ExecuteAccountTest:testDeployment() (gas: 26335)
|
||||
ExecuteAccountTest:test_ExecuteAccountMintMP() (gas: 3633587)
|
||||
ExecuteAccountTest:test_RevertWhen_InvalidLimitEpoch() (gas: 1051631)
|
||||
LeaveTest:testDeployment() (gas: 26335)
|
||||
LeaveTest:test_RevertWhen_NoPendingMigration() (gas: 1052239)
|
||||
LeaveTest:test_RevertWhen_SenderIsNotVault() (gas: 10794)
|
||||
LockTest:testDeployment() (gas: 26335)
|
||||
LockTest:test_RevertWhen_InvalidLockupPeriod() (gas: 865463)
|
||||
CreateVaultTest:test_createVault() (gas: 692936)
|
||||
ExecuteAccountTest:testDeployment() (gas: 28720)
|
||||
ExecuteAccountTest:test_ExecuteAccountMintMP() (gas: 3857663)
|
||||
ExecuteAccountTest:test_MintMPLimit() (gas: 187)
|
||||
ExecuteAccountTest:test_PayRewards() (gas: 165)
|
||||
ExecuteAccountTest:test_RevertWhen_InvalidLimitEpoch() (gas: 1155029)
|
||||
ExecuteAccountTest:test_ShouldNotMintMoreThanCap() (gas: 77572759)
|
||||
ExecuteAccountTest:test_UpdateEpoch() (gas: 164)
|
||||
ExecuteEpochTest:testDeployment() (gas: 28720)
|
||||
ExecuteEpochTest:testNewDeployment() (gas: 30815)
|
||||
ExecuteEpochTest:test_ExecuteEpochShouldIncreaseEpoch() (gas: 94832)
|
||||
ExecuteEpochTest:test_ExecuteEpochShouldIncreasePendingReward() (gas: 253059)
|
||||
ExecuteEpochTest:test_ExecuteEpochShouldNotIncreaseEpochBeforeEnd() (gas: 17994)
|
||||
ExecuteEpochTest:test_ExecuteEpochShouldNotIncreaseEpochInMigration() (gas: 105720)
|
||||
LeaveTest:testDeployment() (gas: 28720)
|
||||
LeaveTest:test_RevertWhen_NoPendingMigration() (gas: 1155154)
|
||||
LeaveTest:test_RevertWhen_SenderIsNotVault() (gas: 10750)
|
||||
LockTest:testDeployment() (gas: 28720)
|
||||
LockTest:test_NewLockupPeriod() (gas: 1144004)
|
||||
LockTest:test_RevertWhen_InvalidNewLockupPeriod() (gas: 1135598)
|
||||
LockTest:test_RevertWhen_InvalidUpdateLockupPeriod() (gas: 1231954)
|
||||
LockTest:test_RevertWhen_SenderIsNotVault() (gas: 10630)
|
||||
MigrateTest:testDeployment() (gas: 26335)
|
||||
MigrateTest:test_RevertWhen_NoPendingMigration() (gas: 1049846)
|
||||
MigrateTest:test_RevertWhen_SenderIsNotVault() (gas: 10794)
|
||||
LockTest:test_ShouldIncreaseBonusMP() (gas: 1124126)
|
||||
LockTest:test_UpdateLockupPeriod() (gas: 1281364)
|
||||
MigrateTest:testDeployment() (gas: 28720)
|
||||
MigrateTest:test_RevertWhen_NoPendingMigration() (gas: 1152793)
|
||||
MigrateTest:test_RevertWhen_SenderIsNotVault() (gas: 10750)
|
||||
MigrationInitializeTest:testDeployment() (gas: 28720)
|
||||
MigrationInitializeTest:test_RevertWhen_MigrationPending() (gas: 5775900)
|
||||
MigrationStakeManagerTest:testDeployment() (gas: 28720)
|
||||
MigrationStakeManagerTest:testNewDeployment() (gas: 30859)
|
||||
MigrationStakeManagerTest:test_ExecuteEpochShouldNotIncreaseEpochInMigration() (gas: 105708)
|
||||
SetStakeManagerTest:testDeployment() (gas: 9774)
|
||||
SetStakeManagerTest:test_RevertWhen_InvalidStakeManagerAddress() (gas: 20481)
|
||||
SetStakeManagerTest:test_SetStakeManager() (gas: 19869)
|
||||
StakeManagerTest:testDeployment() (gas: 26107)
|
||||
StakeTest:testDeployment() (gas: 26335)
|
||||
StakeTest:test_RevertWhen_InvalidLockupPeriod() (gas: 883366)
|
||||
StakeTest:test_RevertWhen_SenderIsNotVault() (gas: 10650)
|
||||
StakeManagerTest:testDeployment() (gas: 28492)
|
||||
StakeTest:testDeployment() (gas: 28720)
|
||||
StakeTest:test_RevertWhen_InvalidLockupPeriod() (gas: 983235)
|
||||
StakeTest:test_RevertWhen_SenderIsNotVault() (gas: 10680)
|
||||
StakeTest:test_RevertWhen_StakeTokenTransferFails() (gas: 175040)
|
||||
StakeTest:test_StakeWithoutLockUpTimeMintsMultiplierPoints() (gas: 948728)
|
||||
StakeTest:test_StakeWithoutLockUpTimeMintsMultiplierPoints() (gas: 1029690)
|
||||
StakedTokenTest:testStakeToken() (gas: 7616)
|
||||
UnstakeTest:testDeployment() (gas: 26357)
|
||||
UnstakeTest:test_RevertWhen_FundsLocked() (gas: 1051813)
|
||||
UnstakeTest:testDeployment() (gas: 28742)
|
||||
UnstakeTest:test_RevertWhen_AmountMoreThanBalance() (gas: 1129703)
|
||||
UnstakeTest:test_RevertWhen_FundsLocked() (gas: 1158878)
|
||||
UnstakeTest:test_RevertWhen_SenderIsNotVault() (gas: 10653)
|
||||
UnstakeTest:test_UnstakeShouldBurnMultiplierPoints() (gas: 3573382)
|
||||
UnstakeTest:test_UnstakeShouldReturnFunds() (gas: 946825)
|
||||
UserFlowsTest:testDeployment() (gas: 26335)
|
||||
UserFlowsTest:test_StakeWithLockUpTimeLocksStake() (gas: 1046480)
|
||||
UserFlowsTest:test_StakedSupplyShouldIncreaseAndDecreaseAgain() (gas: 1825625)
|
||||
UnstakeTest:test_UnstakeShouldBurnMultiplierPoints() (gas: 5498772)
|
||||
UnstakeTest:test_UnstakeShouldReturnFund_NoLockUp() (gas: 1027090)
|
||||
UnstakeTest:test_UnstakeShouldReturnFund_WithLockUp() (gas: 1115940)
|
||||
UserFlowsTest:testDeployment() (gas: 28720)
|
||||
UserFlowsTest:test_PendingMPToBeMintedCannotBeGreaterThanTotalSupplyMP(uint8) (runs: 1000, μ: 91515315, ~: 58125657)
|
||||
UserFlowsTest:test_StakeWithLockUpTimeLocksStake() (gas: 1116828)
|
||||
UserFlowsTest:test_StakedSupplyShouldIncreaseAndDecreaseAgain() (gas: 1951960)
|
||||
VaultFactoryTest:testDeployment() (gas: 9774)
|
|
@ -7,7 +7,6 @@ import { Math } from "@openzeppelin/contracts/utils/math/Math.sol";
|
|||
|
||||
import { StakeVault } from "./StakeVault.sol";
|
||||
|
||||
|
||||
contract StakeRewardEstimate is Ownable {
|
||||
mapping(uint256 epochId => uint256 balance) public expiredMPPerEpoch;
|
||||
|
||||
|
@ -26,7 +25,6 @@ contract StakeRewardEstimate is Ownable {
|
|||
function deleteExpiredMP(uint256 epochId) public onlyOwner {
|
||||
delete expiredMPPerEpoch[epochId];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
contract StakeManager is Ownable {
|
||||
|
@ -143,7 +141,7 @@ contract StakeManager is Ownable {
|
|||
if (block.timestamp >= epochEnd() && address(migration) == address(0)) {
|
||||
//mp estimation
|
||||
uint256 expiredMP = stakeRewardEstimate.getExpiredMP(currentEpoch);
|
||||
if(expiredMP > 0){
|
||||
if (expiredMP > 0) {
|
||||
totalMPPerEpoch -= expiredMP;
|
||||
stakeRewardEstimate.deleteExpiredMP(currentEpoch);
|
||||
}
|
||||
|
@ -167,7 +165,7 @@ contract StakeManager is Ownable {
|
|||
epochs[0].startTime = block.timestamp;
|
||||
previousManager = StakeManager(_previousManager);
|
||||
stakedToken = ERC20(_stakedToken);
|
||||
if(address(previousManager) != address(0)){
|
||||
if (address(previousManager) != address(0)) {
|
||||
stakeRewardEstimate = previousManager.stakeRewardEstimate();
|
||||
} else {
|
||||
stakeRewardEstimate = new StakeRewardEstimate();
|
||||
|
@ -214,27 +212,26 @@ contract StakeManager is Ownable {
|
|||
|
||||
//mp estimation
|
||||
uint256 mpPerEpoch = _getMPToMint(_amount, EPOCH_SIZE);
|
||||
if(mpPerEpoch < 1){
|
||||
if (mpPerEpoch < 1) {
|
||||
revert StakeManager__StakeIsTooLow();
|
||||
}
|
||||
uint256 thisEpochExpiredMP = mpPerEpoch - _getMPToMint(_amount, epochEnd() - block.timestamp);
|
||||
currentEpochExpiredMP += thisEpochExpiredMP;
|
||||
currentEpochExpiredMP += thisEpochExpiredMP;
|
||||
totalMPPerEpoch += mpPerEpoch;
|
||||
uint256 maxMpToMint = _getMPToMint(_amount, MAX_BOOST * YEAR) + thisEpochExpiredMP;
|
||||
uint256 mpMaxBoostLimitEpochCount = (maxMpToMint) / mpPerEpoch;
|
||||
uint256 mpMaxBoostLimitEpoch = currentEpoch + mpMaxBoostLimitEpochCount;
|
||||
uint256 lastEpochAmountToMint = ((mpPerEpoch * (mpMaxBoostLimitEpochCount+1)) - maxMpToMint);
|
||||
|
||||
uint256 lastEpochAmountToMint = ((mpPerEpoch * (mpMaxBoostLimitEpochCount + 1)) - maxMpToMint);
|
||||
|
||||
stakeRewardEstimate.incrementExpiredMP(mpMaxBoostLimitEpoch, lastEpochAmountToMint);
|
||||
stakeRewardEstimate.incrementExpiredMP(mpMaxBoostLimitEpoch+1, mpPerEpoch - lastEpochAmountToMint);
|
||||
|
||||
stakeRewardEstimate.incrementExpiredMP(mpMaxBoostLimitEpoch + 1, mpPerEpoch - lastEpochAmountToMint);
|
||||
|
||||
account.mpMaxBoostLimitEpoch = mpMaxBoostLimitEpoch;
|
||||
|
||||
|
||||
//update storage
|
||||
totalSupplyBalance += _amount;
|
||||
account.balance += _amount;
|
||||
account.lockUntil += _timeToIncrease;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -261,8 +258,9 @@ contract StakeManager is Ownable {
|
|||
|
||||
//mp estimation
|
||||
uint256 mpPerEpoch = _getMPToMint(account.balance, EPOCH_SIZE);
|
||||
stakeRewardEstimate.decrementExpiredMP(account.mpMaxBoostLimitEpoch, mpPerEpoch); // some staked amount from the past
|
||||
if(account.mpMaxBoostLimitEpoch < currentEpoch) {
|
||||
stakeRewardEstimate.decrementExpiredMP(account.mpMaxBoostLimitEpoch, mpPerEpoch); // some staked amount from the
|
||||
// past
|
||||
if (account.mpMaxBoostLimitEpoch < currentEpoch) {
|
||||
totalMPPerEpoch -= mpPerEpoch;
|
||||
}
|
||||
|
||||
|
@ -535,7 +533,6 @@ contract StakeManager is Ownable {
|
|||
//mp estimation
|
||||
epoch.estimatedMP -= mpToMint;
|
||||
pendingMPToBeMinted -= mpToMint;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -583,6 +580,7 @@ contract StakeManager is Ownable {
|
|||
* @param _deltaTime time difference
|
||||
* @return multiplier points to mint
|
||||
*/
|
||||
|
||||
function calculateMPToMint(uint256 _balance, uint256 _deltaTime) public pure returns (uint256) {
|
||||
return _getMPToMint(_balance, _deltaTime);
|
||||
}
|
||||
|
@ -591,11 +589,11 @@ contract StakeManager is Ownable {
|
|||
* and the pending MPs that would be minted if all accounts were processed
|
||||
* @return _totalSupply current total supply
|
||||
*/
|
||||
|
||||
function totalSupply() public view returns (uint256 _totalSupply) {
|
||||
return totalSupplyMP + totalSupplyBalance + pendingMPToBeMinted;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notice Returns total of multiplier points and balance
|
||||
* @return _totalSupply current total supply
|
||||
|
|
|
@ -7,7 +7,7 @@ import { Test, console } from "forge-std/Test.sol";
|
|||
import { Deploy } from "../script/Deploy.s.sol";
|
||||
import { DeployMigrationStakeManager } from "../script/DeployMigrationStakeManager.s.sol";
|
||||
import { DeploymentConfig } from "../script/DeploymentConfig.s.sol";
|
||||
import { StakeManager } from "../contracts/StakeManager.sol";
|
||||
import { StakeManager, StakeRewardEstimate } from "../contracts/StakeManager.sol";
|
||||
import { StakeVault } from "../contracts/StakeVault.sol";
|
||||
import { VaultFactory } from "../contracts/VaultFactory.sol";
|
||||
|
||||
|
@ -485,10 +485,15 @@ contract MigrationInitializeTest is StakeManagerTest {
|
|||
vm.startPrank(deployer);
|
||||
StakeManager secondStakeManager = new StakeManager(stakeToken, address(stakeManager));
|
||||
StakeManager thirdStakeManager = new StakeManager(stakeToken, address(secondStakeManager));
|
||||
vm.stopPrank();
|
||||
|
||||
// first, ensure `secondStakeManager` is in migration mode itself
|
||||
StakeRewardEstimate db = stakeManager.stakeRewardEstimate();
|
||||
vm.prank(address(stakeManager));
|
||||
db.transferOwnership(address(secondStakeManager));
|
||||
|
||||
vm.prank(address(deployer));
|
||||
secondStakeManager.startMigration(thirdStakeManager);
|
||||
vm.stopPrank();
|
||||
|
||||
uint256 currentEpoch = stakeManager.currentEpoch();
|
||||
uint256 totalMP = stakeManager.totalSupplyMP();
|
||||
|
@ -498,7 +503,7 @@ contract MigrationInitializeTest is StakeManagerTest {
|
|||
// in migration itself, should revert
|
||||
vm.prank(address(stakeManager));
|
||||
vm.expectRevert(StakeManager.StakeManager__PendingMigration.selector);
|
||||
secondStakeManager.migrationInitialize(currentEpoch, totalMP, totalBalance, 0);
|
||||
secondStakeManager.migrationInitialize(currentEpoch, totalMP, totalBalance, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -572,40 +577,40 @@ contract ExecuteAccountTest is StakeManagerTest {
|
|||
}
|
||||
|
||||
function test_ShouldNotMintMoreThanCap() public {
|
||||
uint256 stakeAmount = 10000000000;
|
||||
|
||||
uint256 stakeAmount = 10_000_000_000;
|
||||
|
||||
// (MAX_BOOST * YEARS_IN_SECONDS)/EPOCH_SIZE_SECONDS
|
||||
// (4 * (604800*52))/604800
|
||||
//uint256 epochsAmountToReachCap = 208;
|
||||
uint256 epochsAmountToReachCap = stakeManager.calculateMPToMint(stakeAmount, stakeManager.MAX_BOOST() * stakeManager.YEAR()) / stakeManager.calculateMPToMint(stakeAmount, stakeManager.EPOCH_SIZE());
|
||||
uint256 epochsAmountToReachCap = stakeManager.calculateMPToMint(
|
||||
stakeAmount, stakeManager.MAX_BOOST() * stakeManager.YEAR()
|
||||
) / stakeManager.calculateMPToMint(stakeAmount, stakeManager.EPOCH_SIZE());
|
||||
|
||||
deal(stakeToken, testUser, stakeAmount);
|
||||
|
||||
|
||||
userVaults.push(_createStakingAccount(makeAddr("testUser"), stakeAmount, 0));
|
||||
|
||||
vm.warp(stakeManager.epochEnd() - (stakeManager.EPOCH_SIZE()-1));
|
||||
vm.warp(stakeManager.epochEnd() - (stakeManager.EPOCH_SIZE() - 1));
|
||||
userVaults.push(_createStakingAccount(makeAddr("testUser2"), stakeAmount, 0));
|
||||
|
||||
vm.warp(stakeManager.epochEnd() - (stakeManager.EPOCH_SIZE()-2));
|
||||
vm.warp(stakeManager.epochEnd() - (stakeManager.EPOCH_SIZE() - 2));
|
||||
userVaults.push(_createStakingAccount(makeAddr("testUser3"), stakeAmount, 0));
|
||||
|
||||
vm.warp(stakeManager.epochEnd() - ((stakeManager.EPOCH_SIZE()/4)*3));
|
||||
vm.warp(stakeManager.epochEnd() - ((stakeManager.EPOCH_SIZE() / 4) * 3));
|
||||
userVaults.push(_createStakingAccount(makeAddr("testUser4"), stakeAmount, 0));
|
||||
|
||||
vm.warp(stakeManager.epochEnd() - ((stakeManager.EPOCH_SIZE()/4)*2));
|
||||
vm.warp(stakeManager.epochEnd() - ((stakeManager.EPOCH_SIZE() / 4) * 2));
|
||||
userVaults.push(_createStakingAccount(makeAddr("testUser5"), stakeAmount, 0));
|
||||
|
||||
vm.warp(stakeManager.epochEnd() - ((stakeManager.EPOCH_SIZE()/4)*1));
|
||||
vm.warp(stakeManager.epochEnd() - ((stakeManager.EPOCH_SIZE() / 4) * 1));
|
||||
userVaults.push(_createStakingAccount(makeAddr("testUser6"), stakeAmount, 0));
|
||||
|
||||
|
||||
vm.warp(stakeManager.epochEnd() - 2);
|
||||
userVaults.push(_createStakingAccount(makeAddr("testUser7"), stakeAmount, 0));
|
||||
userVaults.push(_createStakingAccount(makeAddr("testUser7"), stakeAmount, 0));
|
||||
|
||||
vm.warp(stakeManager.epochEnd() - 1);
|
||||
userVaults.push(_createStakingAccount(makeAddr("testUser8"), stakeAmount, 0));
|
||||
|
||||
|
||||
|
||||
//userVaults.push(_createStakingAccount(makeAddr("testUser4"), stakeAmount, stakeManager.MAX_LOCKUP_PERIOD()));
|
||||
//userVaults.push(_createStakingAccount(makeAddr("testUser5"), stakeAmount, stakeManager.MIN_LOCKUP_PERIOD()));
|
||||
|
||||
|
@ -661,7 +666,6 @@ contract ExecuteAccountTest is StakeManagerTest {
|
|||
}
|
||||
|
||||
contract UserFlowsTest is StakeManagerTest {
|
||||
|
||||
StakeVault[] private userVaults;
|
||||
|
||||
function test_StakedSupplyShouldIncreaseAndDecreaseAgain() public {
|
||||
|
@ -712,11 +716,9 @@ contract UserFlowsTest is StakeManagerTest {
|
|||
|
||||
for (uint256 i = 0; i <= accountNum; i++) {
|
||||
// deal(stakeToken, testUser, stakeAmount);
|
||||
userVaults.push(_createStakingAccount(makeAddr(
|
||||
string(abi.encode(keccak256(abi.encode(accountNum))))),
|
||||
stakeAmount,
|
||||
0
|
||||
));
|
||||
userVaults.push(
|
||||
_createStakingAccount(makeAddr(string(abi.encode(keccak256(abi.encode(accountNum))))), stakeAmount, 0)
|
||||
);
|
||||
}
|
||||
|
||||
uint256 epochsAmountToReachCap = 1;
|
||||
|
@ -738,7 +740,6 @@ contract UserFlowsTest is StakeManagerTest {
|
|||
assertEq(pendingMPToBeMintedAfter, 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
contract MigrationStakeManagerTest is StakeManagerTest {
|
||||
|
|
Loading…
Reference in New Issue