Closed code423n4 closed 2 years ago
0x0x0x
The for loop inside validateWeights is as follows:
validateWeights
for (uint i = 0; i < length; i++) { require(_tokens[i] != address(0)); require(_weights[i] > 0); for (uint256 x = 0; x < tokenList.length; x++) { require(_tokens[i] != tokenList[x]); } tokenList[i] = _tokens[i]; }
_tokens[i] is used three times at each iteration. Gas can be saved by caching _tokens[i].
_tokens[i]
_tokens is already loaded in as memory. This does not save gas.
_tokens
Handle
0x0x0x
Vulnerability details
The for loop inside
validateWeights
is as follows:_tokens[i]
is used three times at each iteration. Gas can be saved by caching_tokens[i]
.