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: 27/37
Findings: 2
Award: $59.91
🌟 Selected for report: 1
🚀 Solo Findings: 0
11.8662 USDC - $11.87
Afanasyevich
For example in line 106 of Sherlock.sol contract:
for (uint256 i; i < _initialstakingPeriods.length; i++) {
A more efficient loop would be:
for (uint256; i < _initialstakingPeriods.lengt; unchecked{++i}) {
It not possible to reach uint256 max value so this is overflow safe
#0 - jack-the-pug
2022-03-15T01:08:34Z
Dup #253
11.8662 USDC - $11.87
Afanasyevich
In all the loops, the variable i is incremented using i++. It is known that using ++i costs less gas per iteration than i++ (only inside loops)
Sherlock.sol:106: for (uint256 i; i < _initialstakingPeriods.length; i++) {
SherBuy.sol:186: for (uint256 i; i < _tokens.length; i++) {
managers/SherlockClaimManager.sol:234: for (uint256 i; i < claimCallbacks.length; i++) {
managers/SherlockClaimManager.sol:505: for (uint256 i; i < claimCallbacks.length; i++) {
managers/Manager.sol:47: for (uint256 i; i < _extraTokens.length; i++) {
managers/SherlockProtocolManager.sol:729: for (uint256 i; i < _protocol.length; i++) {
None
Use ++i in all the loops instead of i++ to increment the value of an uint variable.
#0 - jack-the-pug
2022-03-15T01:09:20Z
Dup #111
🌟 Selected for report: Afanasyevich
Also found by: sirhashalot, wuwe1, ye0lde
Afanasyevich
The following if condition can be removed from SherlockClaimManager.cleanUp()
function as that condition will never be met:
if (_setState(claimIdentifier, State.NonExistent) != State.Cleaned) revert InvalidState();
None
Remove the referred if condition.
#0 - jack-the-pug
2022-03-26T12:03:39Z
I believe this is valid and I wonder what's the initial intention of this?