diff --git a/contracts/StakeManager.sol b/contracts/StakeManager.sol index efb9f8b..cbb7c6b 100644 --- a/contracts/StakeManager.sol +++ b/contracts/StakeManager.sol @@ -175,11 +175,20 @@ contract StakeManager is Ownable { /** * Increases balance of msg.sender; * @param _amount Amount of balance to be decreased. - * @param _timeToIncrease Seconds to increase in locked time. If stake is unlocked, increases from block.timestamp. + * @param _timeToIncrease Seconds to increase in locked time. If stake is unlocked, increases from + * block.timestamp. * * @dev Reverts when resulting locked time is not in range of [MIN_LOCKUP_PERIOD, MAX_LOCKUP_PERIOD] */ - function stake(uint256 _amount, uint256 _timeToIncrease) external onlyVault noPendingMigration finalizeEpoch { + function stake( + uint256 _amount, + uint256 _timeToIncrease + ) + external + onlyVault + noPendingMigration + finalizeEpoch + { Account storage account = accounts[msg.sender]; if (account.balance > 0) { revert StakeManager__AlreadyStaked(); @@ -258,7 +267,8 @@ contract StakeManager is Ownable { //mp estimation uint256 mpPerEpoch = _getMPToMint(account.balance, EPOCH_SIZE); - stakeRewardEstimate.decrementExpiredMP(account.mpMaxBoostLimitEpoch, mpPerEpoch); // some staked amount from the + stakeRewardEstimate.decrementExpiredMP(account.mpMaxBoostLimitEpoch, mpPerEpoch); // some staked + // amount from the // past if (account.mpMaxBoostLimitEpoch < currentEpoch) { totalMPPerEpoch -= mpPerEpoch; @@ -274,7 +284,8 @@ contract StakeManager is Ownable { /** * @notice Locks entire balance for more amount of time. - * @param _timeToIncrease Seconds to increase in locked time. If stake is unlocked, increases from block.timestamp. + * @param _timeToIncrease Seconds to increase in locked time. If stake is unlocked, increases from + * block.timestamp. * * @dev Reverts when resulting locked time is not in range of [MIN_LOCKUP_PERIOD, MAX_LOCKUP_PERIOD] */ @@ -428,7 +439,14 @@ contract StakeManager is Ownable { * @param _account Account data * @param _acceptMigration If account should be stored or its MP/balance supply reduced */ - function migrateFrom(address _vault, bool _acceptMigration, Account memory _account) external onlyPreviousManager { + function migrateFrom( + address _vault, + bool _acceptMigration, + Account memory _account + ) + external + onlyPreviousManager + { if (_acceptMigration) { accounts[_vault] = _account; } else { diff --git a/foundry.toml b/foundry.toml index 90bcfa8..e6df3af 100644 --- a/foundry.toml +++ b/foundry.toml @@ -35,7 +35,7 @@ [fmt] bracket_spacing = true int_types = "long" - line_length = 120 + line_length = 110 multiline_func_header = "all" number_underscore = "thousands" quote_style = "double" diff --git a/test/StakeManager.t.sol b/test/StakeManager.t.sol index 25ab8dc..0379c50 100644 --- a/test/StakeManager.t.sol +++ b/test/StakeManager.t.sol @@ -545,8 +545,15 @@ 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,) = - stakeManager.accounts(address(userVaults[j])); + ( + address rewardAddress, + , + , + uint256 totalMPBefore, + uint256 lastMintBefore, + , + uint256 epochBefore, + ) = stakeManager.accounts(address(userVaults[j])); uint256 rewardsBefore = ERC20(stakeToken).balanceOf(rewardAddress); console.log("-Vault number", j); console.log("--=====BEFORE====="); @@ -613,16 +620,25 @@ contract ExecuteAccountTest is StakeManagerTest { 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())); + //userVaults.push(_createStakingAccount(makeAddr("testUser4"), stakeAmount, + // stakeManager.MAX_LOCKUP_PERIOD())); + //userVaults.push(_createStakingAccount(makeAddr("testUser5"), stakeAmount, + // stakeManager.MIN_LOCKUP_PERIOD())); for (uint256 i = 0; i <= epochsAmountToReachCap; i++) { deal(stakeToken, address(stakeManager), 100 ether); vm.warp(stakeManager.epochEnd()); stakeManager.executeEpoch(); for (uint256 j = 0; j < userVaults.length; j++) { - (address rewardAddress,,, uint256 totalMPBefore, uint256 lastMintBefore,, uint256 epochBefore,) = - stakeManager.accounts(address(userVaults[j])); + ( + 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); @@ -644,8 +660,15 @@ 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,) = - stakeManager.accounts(address(userVaults[j])); + ( + 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); @@ -721,7 +744,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) + _createStakingAccount( + makeAddr(string(abi.encode(keccak256(abi.encode(accountNum))))), stakeAmount, 0 + ) ); } @@ -733,8 +758,15 @@ contract UserFlowsTest is StakeManagerTest { uint256 pendingMPToBeMintedBefore = stakeManager.pendingMPToBeMinted(); uint256 totalSupplyMP = stakeManager.totalSupplyMP(); for (uint256 j = 0; j < userVaults.length; j++) { - (address rewardAddress,,, uint256 totalMPBefore, uint256 lastMintBefore,, uint256 epochBefore,) = - stakeManager.accounts(address(userVaults[j])); + ( + address rewardAddress, + , + , + uint256 totalMPBefore, + uint256 lastMintBefore, + , + uint256 epochBefore, + ) = stakeManager.accounts(address(userVaults[j])); stakeManager.executeAccount(address(userVaults[j]), epochBefore + 1); } @@ -751,7 +783,8 @@ contract MigrationStakeManagerTest is StakeManagerTest { function setUp() public virtual override { super.setUp(); - DeployMigrationStakeManager deployment = new DeployMigrationStakeManager(address(stakeManager), stakeToken); + DeployMigrationStakeManager deployment = + new DeployMigrationStakeManager(address(stakeManager), stakeToken); newStakeManager = deployment.run(); }