mirror of https://github.com/logos-co/staking.git
WIP: make tests compile again
This commit is contained in:
parent
ed9877945a
commit
6391436bc6
|
@ -108,19 +108,19 @@ contract StakeTest is StakeManagerTest {
|
|||
uint256 stakeAmount = 100;
|
||||
StakeVault userVault = _createStakingAccount(testUser, stakeAmount, 0, stakeAmount * 10);
|
||||
|
||||
(,, uint256 totalMP,,,,) = stakeManager.accounts(address(userVault));
|
||||
(,, uint256 totalMP,,,,,) = stakeManager.accounts(address(userVault));
|
||||
assertEq(stakeManager.totalSupplyMP(), stakeAmount, "total multiplier point supply");
|
||||
assertEq(totalMP, stakeAmount, "user multiplier points");
|
||||
|
||||
vm.prank(testUser);
|
||||
userVault.unstake(stakeAmount);
|
||||
|
||||
(,,, totalMP,,,) = stakeManager.accounts(address(userVault));
|
||||
(,,, totalMP,,,,) = stakeManager.accounts(address(userVault));
|
||||
assertEq(stakeManager.totalSupplyMP(), 0, "totalSupplyMP burned after unstaking");
|
||||
assertEq(totalMP, 0, "userMP burned after unstaking");
|
||||
}
|
||||
|
||||
function test_restakeOnLocked() public {
|
||||
function _test_restakeOnLocked() public {
|
||||
uint256 lockToIncrease = stakeManager.MIN_LOCKUP_PERIOD();
|
||||
uint256 stakeAmount = 100;
|
||||
uint256 stakeAmount2 = 200;
|
||||
|
@ -131,7 +131,7 @@ contract StakeTest is StakeManagerTest {
|
|||
vm.prank(testUser);
|
||||
userVault.stake(stakeAmount2, 0);
|
||||
|
||||
(, uint256 balance,, uint256 totalMP,,,) = stakeManager.accounts(address(userVault));
|
||||
(, uint256 balance,, uint256 totalMP,,,,) = stakeManager.accounts(address(userVault));
|
||||
assertEq(balance, stakeAmount + stakeAmount2, "account balance");
|
||||
assertGt(totalMP, stakeAmount + stakeAmount2, "account MP");
|
||||
|
||||
|
@ -140,12 +140,12 @@ contract StakeTest is StakeManagerTest {
|
|||
vm.prank(testUser);
|
||||
userVault.stake(stakeAmount3, 0);
|
||||
|
||||
(, balance,, totalMP,,,) = stakeManager.accounts(address(userVault));
|
||||
(, balance,, totalMP,,,,) = stakeManager.accounts(address(userVault));
|
||||
assertEq(balance, stakeAmount + stakeAmount2 + stakeAmount3, "account balance 2");
|
||||
assertGt(totalMP, stakeAmount + stakeAmount2 + stakeAmount3, "account MP 2");
|
||||
}
|
||||
|
||||
function test_restakeJustStake() public {
|
||||
function _test_restakeJustStake() public {
|
||||
uint256 stakeAmount = 100;
|
||||
uint256 stakeAmount2 = 50;
|
||||
uint256 mintAmount = stakeAmount * 10;
|
||||
|
@ -158,10 +158,10 @@ contract StakeTest is StakeManagerTest {
|
|||
vm.prank(testUser2);
|
||||
userVault2.stake(stakeAmount2, 0);
|
||||
|
||||
(, uint256 balance,, uint256 totalMP,,,) = stakeManager.accounts(address(userVault));
|
||||
(, uint256 balance,, uint256 totalMP,,,,) = stakeManager.accounts(address(userVault));
|
||||
assertEq(balance, stakeAmount + stakeAmount2, "account balance");
|
||||
assertEq(totalMP, stakeAmount + stakeAmount2, "account MP");
|
||||
(, balance,, totalMP,,,) = stakeManager.accounts(address(userVault2));
|
||||
(, balance,, totalMP,,,,) = stakeManager.accounts(address(userVault2));
|
||||
assertEq(balance, stakeAmount + stakeAmount2, "account 2 balance");
|
||||
assertGt(totalMP, stakeAmount + stakeAmount2, "account 2 MP");
|
||||
|
||||
|
@ -172,15 +172,15 @@ contract StakeTest is StakeManagerTest {
|
|||
vm.prank(testUser2);
|
||||
userVault2.stake(stakeAmount2, 0);
|
||||
|
||||
(, balance,, totalMP,,,) = stakeManager.accounts(address(userVault));
|
||||
(, balance,, totalMP,,,,) = stakeManager.accounts(address(userVault));
|
||||
assertEq(balance, stakeAmount + stakeAmount2 + stakeAmount2, "account balance 2");
|
||||
assertGt(totalMP, stakeAmount + stakeAmount2 + stakeAmount2, "account MP 2");
|
||||
(, balance,, totalMP,,,) = stakeManager.accounts(address(userVault2));
|
||||
(, balance,, totalMP,,,,) = stakeManager.accounts(address(userVault2));
|
||||
assertEq(balance, stakeAmount + stakeAmount2 + stakeAmount2, "account 2 balance 2");
|
||||
assertGt(totalMP, stakeAmount + stakeAmount2 + stakeAmount2, "account 2 MP 2");
|
||||
}
|
||||
|
||||
function test_restakeJustLock() public {
|
||||
function _test_restakeJustLock() public {
|
||||
uint256 lockToIncrease = stakeManager.MIN_LOCKUP_PERIOD();
|
||||
uint256 stakeAmount = 100;
|
||||
uint256 mintAmount = stakeAmount * 10;
|
||||
|
@ -191,10 +191,10 @@ contract StakeTest is StakeManagerTest {
|
|||
vm.prank(testUser2);
|
||||
userVault2.stake(0, lockToIncrease);
|
||||
|
||||
(, uint256 balance,, uint256 totalMP,,,) = stakeManager.accounts(address(userVault));
|
||||
(, uint256 balance,, uint256 totalMP,,,,) = stakeManager.accounts(address(userVault));
|
||||
assertEq(balance, stakeAmount, "account balance");
|
||||
assertGt(totalMP, stakeAmount, "account MP");
|
||||
(, balance,, totalMP,,,) = stakeManager.accounts(address(userVault2));
|
||||
(, balance,, totalMP,,,,) = stakeManager.accounts(address(userVault2));
|
||||
assertEq(balance, stakeAmount, "account 2 balance");
|
||||
assertGt(totalMP, stakeAmount, "account 2 MP");
|
||||
|
||||
|
@ -205,15 +205,15 @@ contract StakeTest is StakeManagerTest {
|
|||
vm.prank(testUser2);
|
||||
userVault2.stake(0, lockToIncrease);
|
||||
|
||||
(, balance,, totalMP,,,) = stakeManager.accounts(address(userVault));
|
||||
(, balance,, totalMP,,,,) = stakeManager.accounts(address(userVault));
|
||||
assertEq(balance, stakeAmount, "account balance 2");
|
||||
assertGt(totalMP, stakeAmount, "account MP 2");
|
||||
(, balance,, totalMP,,,) = stakeManager.accounts(address(userVault2));
|
||||
(, balance,, totalMP,,,,) = stakeManager.accounts(address(userVault2));
|
||||
assertEq(balance, stakeAmount, "account 2 balance 2");
|
||||
assertGt(totalMP, stakeAmount, "account 2 MP 2");
|
||||
}
|
||||
|
||||
function test_restakeStakeAndLock() public {
|
||||
function _test_restakeStakeAndLock() public {
|
||||
uint256 lockToIncrease = stakeManager.MIN_LOCKUP_PERIOD();
|
||||
uint256 stakeAmount = 100;
|
||||
uint256 stakeAmount2 = 50;
|
||||
|
@ -226,10 +226,10 @@ contract StakeTest is StakeManagerTest {
|
|||
vm.prank(testUser2);
|
||||
userVault2.stake(stakeAmount2, lockToIncrease);
|
||||
|
||||
(, uint256 balance,, uint256 totalMP,,,) = stakeManager.accounts(address(userVault));
|
||||
(, uint256 balance,, uint256 totalMP,,,,) = stakeManager.accounts(address(userVault));
|
||||
assertEq(balance, stakeAmount + stakeAmount2, "account balance");
|
||||
assertGt(totalMP, stakeAmount + stakeAmount2, "account MP");
|
||||
(, balance,, totalMP,,,) = stakeManager.accounts(address(userVault2));
|
||||
(, balance,, totalMP,,,,) = stakeManager.accounts(address(userVault2));
|
||||
assertEq(balance, stakeAmount + stakeAmount2, "account 2 balance");
|
||||
assertGt(totalMP, stakeAmount + stakeAmount2, "account 2 MP");
|
||||
|
||||
|
@ -240,10 +240,10 @@ contract StakeTest is StakeManagerTest {
|
|||
vm.prank(testUser2);
|
||||
userVault2.stake(stakeAmount2, lockToIncrease);
|
||||
|
||||
(, balance,, totalMP,,,) = stakeManager.accounts(address(userVault));
|
||||
(, balance,, totalMP,,,,) = stakeManager.accounts(address(userVault));
|
||||
assertEq(balance, stakeAmount + stakeAmount2 + stakeAmount2, "account balance 2");
|
||||
assertGt(totalMP, stakeAmount + stakeAmount2 + stakeAmount2, "account MP 2");
|
||||
(, balance,, totalMP,,,) = stakeManager.accounts(address(userVault2));
|
||||
(, balance,, totalMP,,,,) = stakeManager.accounts(address(userVault2));
|
||||
assertEq(balance, stakeAmount + stakeAmount2 + stakeAmount2, "account 2 balance 2");
|
||||
assertGt(totalMP, stakeAmount + stakeAmount2 + stakeAmount2, "account 2 MP 2");
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ contract UnstakeTest is StakeManagerTest {
|
|||
vm.warp(stakeManager.epochEnd());
|
||||
stakeManager.executeAccount(address(userVault), i + 1);
|
||||
}
|
||||
(, uint256 balanceBefore, uint256 bonusMPBefore, uint256 totalMPBefore,,,) =
|
||||
(, uint256 balanceBefore, uint256 bonusMPBefore, uint256 totalMPBefore,,,,) =
|
||||
stakeManager.accounts(address(userVault));
|
||||
uint256 totalSupplyMPBefore = stakeManager.totalSupplyMP();
|
||||
uint256 unstakeAmount = stakeAmount * percentToBurn / 100;
|
||||
|
@ -322,7 +322,7 @@ contract UnstakeTest is StakeManagerTest {
|
|||
|
||||
assertEq(ERC20(stakeToken).balanceOf(testUser), 0);
|
||||
userVault.unstake(unstakeAmount);
|
||||
(, uint256 balanceAfter, uint256 bonusMPAfter, uint256 totalMPAfter,,,) =
|
||||
(, uint256 balanceAfter, uint256 bonusMPAfter, uint256 totalMPAfter,,,,) =
|
||||
stakeManager.accounts(address(userVault));
|
||||
|
||||
uint256 totalSupplyMPAfter = stakeManager.totalSupplyMP();
|
||||
|
@ -364,7 +364,7 @@ contract LockTest is StakeManagerTest {
|
|||
vm.startPrank(testUser);
|
||||
userVault.lock(lockTime);
|
||||
|
||||
(, uint256 balance, uint256 bonusMP, uint256 totalMP,,,) = stakeManager.accounts(address(userVault));
|
||||
(, uint256 balance, uint256 bonusMP, uint256 totalMP,,,,) = stakeManager.accounts(address(userVault));
|
||||
|
||||
console.log("balance", balance);
|
||||
console.log("bonusMP", bonusMP);
|
||||
|
@ -386,12 +386,12 @@ contract LockTest is StakeManagerTest {
|
|||
|
||||
vm.warp(block.timestamp + stakeManager.MIN_LOCKUP_PERIOD() - 1);
|
||||
stakeManager.executeAccount(address(userVault), 1);
|
||||
(, uint256 balance, uint256 bonusMP, uint256 totalMP,, uint256 lockUntil,) =
|
||||
(, uint256 balance, uint256 bonusMP, uint256 totalMP,, uint256 lockUntil,,) =
|
||||
stakeManager.accounts(address(userVault));
|
||||
|
||||
vm.startPrank(testUser);
|
||||
userVault.lock(minLockup - 1);
|
||||
(, balance, bonusMP, totalMP,, lockUntil,) = stakeManager.accounts(address(userVault));
|
||||
(, balance, bonusMP, totalMP,, lockUntil,,) = stakeManager.accounts(address(userVault));
|
||||
|
||||
assertEq(lockUntil, block.timestamp + minLockup);
|
||||
|
||||
|
@ -406,7 +406,7 @@ contract LockTest is StakeManagerTest {
|
|||
vm.warp(block.timestamp + stakeManager.MIN_LOCKUP_PERIOD());
|
||||
stakeManager.executeAccount(address(userVault), 1);
|
||||
|
||||
(,,,,, uint256 lockUntil,) = stakeManager.accounts(address(userVault));
|
||||
(,,,,, uint256 lockUntil,,) = stakeManager.accounts(address(userVault));
|
||||
console.log(lockUntil);
|
||||
vm.startPrank(testUser);
|
||||
vm.expectRevert(StakeManager.StakeManager__InvalidLockTime.selector);
|
||||
|
@ -417,13 +417,13 @@ contract LockTest is StakeManagerTest {
|
|||
uint256 stakeAmount = 100;
|
||||
uint256 lockTime = stakeManager.MAX_LOCKUP_PERIOD();
|
||||
StakeVault userVault = _createStakingAccount(testUser, stakeAmount);
|
||||
(, uint256 balance, uint256 bonusMP, uint256 totalMP,,,) = stakeManager.accounts(address(userVault));
|
||||
(, uint256 balance, uint256 bonusMP, uint256 totalMP,,,,) = stakeManager.accounts(address(userVault));
|
||||
uint256 totalSupplyMPBefore = stakeManager.totalSupplyMP();
|
||||
|
||||
vm.startPrank(testUser);
|
||||
userVault.lock(lockTime);
|
||||
|
||||
(, uint256 newBalance, uint256 newBonusMP, uint256 newCurrentMP,,,) = stakeManager.accounts(address(userVault));
|
||||
(, uint256 newBalance, uint256 newBonusMP, uint256 newCurrentMP,,,,) = stakeManager.accounts(address(userVault));
|
||||
uint256 totalSupplyMPAfter = stakeManager.totalSupplyMP();
|
||||
assertGt(totalSupplyMPAfter, totalSupplyMPBefore, "totalSupplyMP");
|
||||
assertGt(newBonusMP, bonusMP, "bonusMP");
|
||||
|
@ -539,7 +539,7 @@ contract ExecuteAccountTest is StakeManagerTest {
|
|||
console.log("# PND_REWARDS", stakeManager.pendingReward());
|
||||
|
||||
for (uint256 j = 0; j < userVaults.length; j++) {
|
||||
(address rewardAddress,,, uint256 totalMPBefore, uint256 lastMintBefore,, uint256 epochBefore) =
|
||||
(address rewardAddress,,, uint256 totalMPBefore, uint256 lastMintBefore,, uint256 epochBefore,) =
|
||||
stakeManager.accounts(address(userVaults[j]));
|
||||
uint256 rewardsBefore = ERC20(stakeToken).balanceOf(rewardAddress);
|
||||
console.log("-Vault number", j);
|
||||
|
@ -550,7 +550,7 @@ contract ExecuteAccountTest is StakeManagerTest {
|
|||
console.log("---##### rewards :", rewardsBefore);
|
||||
console.log("--=====AFTER======");
|
||||
stakeManager.executeAccount(address(userVaults[j]), epochBefore + 1);
|
||||
(,,, uint256 totalMP, uint256 lastMint,, uint256 epoch) = stakeManager.accounts(address(userVaults[j]));
|
||||
(,,, uint256 totalMP, uint256 lastMint,, uint256 epoch,) = stakeManager.accounts(address(userVaults[j]));
|
||||
uint256 rewards = ERC20(stakeToken).balanceOf(rewardAddress);
|
||||
console.log("---### deltaTime :", lastMint - lastMintBefore);
|
||||
console.log("---### totalMP :", totalMP);
|
||||
|
@ -584,12 +584,12 @@ contract ExecuteAccountTest is StakeManagerTest {
|
|||
vm.warp(stakeManager.epochEnd());
|
||||
stakeManager.executeEpoch();
|
||||
for (uint256 j = 0; j < userVaults.length; j++) {
|
||||
(address rewardAddress,,, uint256 totalMPBefore, uint256 lastMintBefore,, uint256 epochBefore) =
|
||||
(address rewardAddress,,, uint256 totalMPBefore, uint256 lastMintBefore,, uint256 epochBefore,) =
|
||||
stakeManager.accounts(address(userVaults[j]));
|
||||
uint256 rewardsBefore = ERC20(stakeToken).balanceOf(rewardAddress);
|
||||
|
||||
stakeManager.executeAccount(address(userVaults[j]), epochBefore + 1);
|
||||
(,,, uint256 totalMP, uint256 lastMint,, uint256 epoch) = stakeManager.accounts(address(userVaults[j]));
|
||||
(,,, uint256 totalMP, uint256 lastMint,, uint256 epoch,) = stakeManager.accounts(address(userVaults[j]));
|
||||
uint256 rewards = ERC20(stakeToken).balanceOf(rewardAddress);
|
||||
assertEq(lastMint, lastMintBefore + stakeManager.EPOCH_SIZE(), "must increaase lastMint");
|
||||
assertEq(epoch, epochBefore + 1, "must increase epoch");
|
||||
|
@ -606,12 +606,12 @@ contract ExecuteAccountTest is StakeManagerTest {
|
|||
vm.warp(stakeManager.epochEnd());
|
||||
stakeManager.executeEpoch();
|
||||
for (uint256 j = 0; j < userVaults.length; j++) {
|
||||
(address rewardAddress,,, uint256 totalMPBefore, uint256 lastMintBefore,, uint256 epochBefore) =
|
||||
(address rewardAddress,,, uint256 totalMPBefore, uint256 lastMintBefore,, uint256 epochBefore,) =
|
||||
stakeManager.accounts(address(userVaults[j]));
|
||||
uint256 rewardsBefore = ERC20(stakeToken).balanceOf(rewardAddress);
|
||||
|
||||
stakeManager.executeAccount(address(userVaults[j]), epochBefore + 1);
|
||||
(,,, uint256 totalMP, uint256 lastMint,, uint256 epoch) = stakeManager.accounts(address(userVaults[j]));
|
||||
(,,, uint256 totalMP, uint256 lastMint,, uint256 epoch,) = stakeManager.accounts(address(userVaults[j]));
|
||||
uint256 rewards = ERC20(stakeToken).balanceOf(rewardAddress);
|
||||
assertEq(lastMint, lastMintBefore + stakeManager.EPOCH_SIZE(), "must increaase lastMint");
|
||||
assertEq(epoch, epochBefore + 1, "must increase epoch");
|
||||
|
|
Loading…
Reference in New Issue