#41949 [SC-Insight] Optimize StakeV2::startUnstake with `unchecked` block to reduce gas costs
Description
Description
function startUnstake(uint256 unStakeAmount) external {
...
uint256 amount = balanceOf[msg.sender];
=> require(amount >= unStakeAmount, "Insufficient balance");
balanceOf[msg.sender] -= unStakeAmount;
totalSupply -= unStakeAmount;
uint256 start = block.timestamp;
uint256 end = start + VESTING_PERIOD;
...
}Recommendation
Proof of Concept
Proof of Concept
Previous#41938 [SC-Critical] Unstake process manipulation and reward distribution vulnerabilityNext#41952 [SC-Insight] Reduce storage costs by eliminating stakedTimes in StakeV2::startUnstake
Was this helpful?