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: 17/37
Findings: 1
Award: $358.43
🌟 Selected for report: 1
🚀 Solo Findings: 0
11.8662 USDC - $11.87
Jujic
Here you could use unchecked{++i} to save gas since it is more efficient then i++.
for (uint256 i; i < _tokens.length; i++)
Remix
#0 - jack-the-pug
2022-03-26T07:45:33Z
Dup #253
Jujic
Loading length of array costs gas. Therefore, the length should be cached, if the length of the array doesn't change inside the loop.
for (uint256 i; i < _tokens.length; i++)
Remix
#0 - jack-the-pug
2022-03-26T06:53:40Z
Dup #231
53.5879 USDC - $53.59
Jujic
There is an unnecessary copy from calldata to memory. In the proposed patch, this unnecessary copy is avoided and value IS directly read from calldata by using calldataload(...) instead of going via calldatacopy(...), then mload(...)). Saves memory expansion cost, and cost of copying from calldata to memory.
function sweepTokens(IERC20[] memory _tokens) external {...}
Remix
Change to:
function sweepTokens(IERC20[] calldata _tokens) external {...}
#0 - jack-the-pug
2022-03-26T07:15:11Z
Dup #249
🌟 Selected for report: Jujic
Jujic
uint256 internal constant SHER_STEPS = 10**16; // Allows stakeRate and buyRate with steps of 0.01 USDC uint256 internal constant RATE_STEPS = 10**4; // SHER has 18 decimals uint256 internal constant SHER_DECIMALS = 10**18;
Can be changed to:
uint256 internal constant SHER_STEPS = 1e16; // Allows stakeRate and buyRate with steps of 0.01 USDC uint256 internal constant RATE_STEPS = 1e4; // SHER has 18 decimals uint256 internal constant SHER_DECIMALS = 1e18;
Remix
89.3132 USDC - $89.31
Jujic
Avoid unnecessary arithmetic operations in constant can save gas.
uint256 public constant ARB_RESTAKE_MAX_PERCENTAGE = (10**18 / 100) * 20; // 20%
Remix
#0 - jack-the-pug
2022-03-26T12:31:30Z
Dup #113