Open code423n4 opened 2 years ago
cmichel
The two loops in StablesConverter.expected can be avoided by using the indices mapping.
StablesConverter.expected
indices
Instead of the for loop, simply get the index i by doing:
for
i
if (_output == address(token3CRV)) { uint256 i = indices[_input]; amounts[i] = _inputAmount; } else if (_input == address(token3CRV)) { uint256 i = indices[_output]; return stableSwap3Pool.calc_withdraw_one_coin(_inputAmount, i); }
This replaces all the tokens[i] sloads with a single one.
tokens[i]
Similarly to #123 , sponsor mitigated, LG
Handle
cmichel
Vulnerability details
The two loops in
StablesConverter.expected
can be avoided by using theindices
mapping.Recommended Mitigation Steps
Instead of the
for
loop, simply get the indexi
by doing:This replaces all the
tokens[i]
sloads with a single one.