Closed code423n4 closed 3 years ago
hrkrshnn
removeToken
Caching the storage pointer tokens[_vault] will save gas.
tokens[_vault]
modified contracts/v3/Manager.sol @@ -465,12 +465,13 @@ contract Manager is IManager { notHalted onlyStrategist { - uint256 k = tokens[_vault].length; + address[] storage tokensArray = tokens[_vault]; + uint256 k = tokensArray.length; uint256 index; bool found; for (uint i = 0; i < k; i++) { - if (tokens[_vault][i] == _token) { + if (tokensArray[i] == _token) { index = i; found = true; break;
Caching tokens[_vault] will not save gas.
Personally not sure as the finding is very bare bones, will agree with sponsor due to lack of evidence
Handle
hrkrshnn
Vulnerability details
Caching storage pointer in
removeToken
Caching the storage pointer
tokens[_vault]
will save gas.