Platform: Code4rena
Start Date: 20/01/2022
Pot Size: $80,000 USDC
Total HM: 5
Participants: 37
Period: 7 days
Judge: Jack the Pug
Total Solo HM: 1
Id: 76
League: ETH
Rank: 22/37
Findings: 1
Award: $106.37
🌟 Selected for report: 1
🚀 Solo Findings: 0
Fitraldys
In the addCallback() this function will check by loop through all of the _callback that was available inside claimCallbacks, to check if the _callback that will be add is already added or not, it cheaper to save the claimCallback.length to a variable then use that variable in the loop.
function addCallback(ISherlockClaimManagerCallbackReceiver _callback) external onlyOwner nonReentrant { uint256 callbackLength = claimCallbacks.length; if (address(_callback) == address(0)) revert ZeroArgument(); // Checks to see if the max amount of callback contracts has been reached if (callbackLength == MAX_CALLBACKS) revert InvalidState(); // Checks to see if this callback contract already exists for (uint256 i; i < callbackLength; i++) { if (claimCallbacks[i] == _callback) revert InvalidArgument(); } claimCallbacks.push(_callback); emit CallbackAdded(_callback); }
#0 - jack-the-pug
2022-03-26T07:51:51Z
Dup #231
11.8662 USDC - $11.87
Fitraldys
in line https://github.com/code-423n4/2022-01-sherlock/blob/main/contracts/managers/SherlockClaimManager.sol#L285 and line https://github.com/code-423n4/2022-01-sherlock/blob/main/contracts/managers/SherlockClaimManager.sol#L417 is cheaper use negation (!) require
https://github.com/code-423n4/2022-01-sherlock/blob/main/contracts/managers/SherlockClaimManager.sol#L285 https://github.com/code-423n4/2022-01-sherlock/blob/main/contracts/managers/SherlockClaimManager.sol#L417
#0 - jack-the-pug
2022-03-26T07:21:47Z
Dup #132
Fitraldys
In the https://github.com/code-423n4/2022-01-sherlock/blob/main/contracts/Sherlock.sol#L545 the initialStake() function do the transfer then calculate the stakeShares however the stakeShares is calculated with the totalTokenBalanceStakers() before the transfer happened by subtract it with _amount, this additional subtraction is expensive than do the calculation of stakeShared first then do the transfer.
https://github.com/code-423n4/2022-01-sherlock/blob/main/contracts/Sherlock.sol#L545
uint256 stakeShares_; uint256 totalStakeShares_ = totalStakeShares; // _amount of tokens divided by the "before" total amount of tokens, multiplied by the "before" amount of stake shares if (totalStakeShares_ != 0) stakeShares_ = (_amount * totalStakeShares_) / totalTokenBalanceStakers() ; // If this is the first stake ever, we just mint stake shares equal to the amount of USDC staked else stakeShares_ = _amount; token.safeTransferFrom(msg.sender, address(this), _amount);