#41688 [SC-Insight] Code can be optimized to to save a significant amount of gas.
Description
Brief/Intro
Vulnerability Details
IERC20 public token; function claim() external {
uint256 amountEarned = getClaimableAmount(msg.sender);
require(amountEarned != 0, "Nothing to claim");
require(token.balanceOf(address(this)) >= amountEarned, "Not enough tokens in contract");
lastClaimedForEpoch[msg.sender] = currentEpoch - 1; // This should be the fix.
token.transfer(msg.sender, amountEarned);
emit Rewarded(msg.sender, amountEarned, block.timestamp);
}Impact Details
References
Proof of Concept
Proof of Concept
Previous#41689 [SC-Insight] Blacklisting a Kodiak vault unintentionally whitelists a previously blacklisted tokenNext#41695 [SC-Critical] StakeV2 leaks user tokens as rewards and eventually will become insolvent.
Was this helpful?