#41952 [SC-Insight] Reduce storage costs by eliminating stakedTimes in StakeV2::startUnstake
Description
Description
function startUnstake(uint256 unStakeAmount) external {
require(unStakeAmount > 0, "Amount must be greater than 0");
=> require(stakedTimes[msg.sender] < STAKING_LIMIT, "Amount must be less then the STAKING_LIMIT constant");
...
vestings[msg.sender].push(Vesting(unStakeAmount, start, end));
=> stakedTimes[msg.sender]++;
emit VestingStarted(msg.sender, unStakeAmount, vestings[msg.sender].length - 1);
}Recommendation
Proof of Concept
Proof of Concept
Previous#41949 [SC-Insight] Optimize StakeV2::startUnstake with `unchecked` block to reduce gas costsNext#41974 [SC-Critical] Reducing `totalSupply` in `startUnstake` leads to protocol insolvency
Was this helpful?