Platform: Code4rena
Start Date: 30/10/2021
Pot Size: $35,000 ETH
Total HM: 2
Participants: 16
Period: 3 days
Judge: alcueca
Total Solo HM: 1
Id: 48
League: ETH
Rank: 11/16
Findings: 1
Award: $129.69
🌟 Selected for report: 1
🚀 Solo Findings: 0
🌟 Selected for report: 0x0x0x
75.3985 USDC - $75.40
0x0x0x
!= 0
is a cheaper operation compared to > 0
, when dealing with uint
.
contracts/Slingshot.sol:74: require(finalAmountMin > 0, "Slingshot: finalAmountMin cannot be zero"); contracts/Slingshot.sol:75: require(trades.length > 0, "Slingshot: trades cannot be empty"); contracts/module/IUniswapModule.sol:28: require(path.length > 0, "UniswapModule: path length must be >0");
grep
33.9293 USDC - $33.93
0x0x0x
Gas optimization
Provide direct links to all referenced code in GitHub. Add screenshots, logs, or any other relevant proof that illustrates the concept.
At ModuleRegistry.setSlingshot(), old slingshot adress is saved to variable oldAdress. oldAdress is only used to emit the change of slingshot adress. It is not required to save the oldAdress to a variable. L71-73:
address oldAddress = slingshot; slingshot = _slingshot; emit NewSlingshot(oldAddress, _slingshot);
Replace with:
emit NewSlingshot(slingshot, _slingshot); slingshot = _slingshot;
Manual analysis
#0 - tommyz7
2021-11-04T18:29:07Z
Duplicate of #69
20.3576 USDC - $20.36
0x0x0x
Length is read multiple times. The length can be saved to a variable to avoid reading it repeatedly and waste gas.
Provide direct links to all referenced code in GitHub. Add screenshots, logs, or any other relevant proof that illustrates the concept.
''' contracts/Executioner.sol: for(uint256 i = 0; i < trades.length; i++) { contracts/ModuleRegistry.sol: for (uint256 i = 0; i < _moduleAddresses.length; i++) { contracts/ModuleRegistry.sol: for (uint256 i = 0; i < _moduleAddresses.length; i++) { contracts/Slingshot.sol: for(uint256 i = 0; i < trades.length; i++) { '''
Grep
Cache .length to and int before going into loop.
#0 - tommyz7
2021-11-04T18:28:16Z
Duplicate of #63