code-423n4 / 2022-01-timeswap-findings

2 stars 0 forks source link

.length should be extracted into a variable #149

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

PPrieditis

Vulnerability details

Impact

TimeswapPair.pay(...) is using ids.length twice in a require statement and also in a loop. Caching would save storage reads.

Recommended Mitigation Steps

Use a local variable in place of ids.length for lines: 1) https://github.com/code-423n4/2022-01-timeswap/blob/5960e07d39f2b4a60cfabde1bd51f4b1e62e7e85/Timeswap/Timeswap-V1-Core/contracts/TimeswapPair.sol#L351 2) https://github.com/code-423n4/2022-01-timeswap/blob/5960e07d39f2b4a60cfabde1bd51f4b1e62e7e85/Timeswap/Timeswap-V1-Core/contracts/TimeswapPair.sol#L359

amateur-dev commented 2 years ago

Similar issue reported over here #151 and hence closing this