wise-foundation / lending-audit

5 stars 4 forks source link

[WSH-04C] Loop Iterator Optimizations #60

Open vm06007 opened 1 year ago

vm06007 commented 1 year ago

WSH-04C: Loop Iterator Optimizations

Type Severity Location
Gas Optimization WiseSecurityHelper.sol:L26, L68, L101, L136, L321, L348, L380, L430

Description:

The linked for loops increment / decrement their iterator "safely" due to Solidity's built - in safe arithmetics (post-0.8.X).

Example:

for (uint256 i = 0; i < WISE_LENDING.getPositionLendingTokenLength(_nftId); ++i) {

Recommendation:

We advise the increment / decrement operations to be performed in an unchecked code block as the last statement within each for loop to optimize their execution cost.

vm06007 commented 1 year ago

Should be addressed as part of: https://github.com/wise-foundation/lending-audit/pull/51