Length is read multiple times. The length can be saved to a variable to avoid reading it repeatedly and waste gas.
Proof of Concept
Provide direct links to all referenced code in GitHub. Add screenshots, logs, or any other relevant proof that illustrates the concept.
Occurences
'''
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++) {
'''
Handle
0x0x0x
Vulnerability details
Impact
Length is read multiple times. The length can be saved to a variable to avoid reading it repeatedly and waste gas.
Proof of Concept
Provide direct links to all referenced code in GitHub. Add screenshots, logs, or any other relevant proof that illustrates the concept.
Occurences
''' 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++) { '''
Tools Used
Grep
Recommended Mitigation Steps
Cache .length to and int before going into loop.