20,000 USDC
View results
Submission Details
Severity: gas
Valid

Place iteration increment (i++) in an unchecked block

Summary

i++ can be placed in unchecked blocks to save on gas as the bounds are already enforced.

Vulnerability Details

i++ can be placed in unchecked blocks to save on gas as the bounds are already enforced.

Impact

Gas

Tools Used

Manual Review

Recommendation

Place i++ in unchecked block. Consider the snippet below:

for (uint256 i; i < bound;) {
...Do stuff...
unchecked {
i++;
}
}

With this change made to all the loops in Lender.sol except the one in Lender.refinance(), a gas saving of ~110 gas was observed across tests. With a total gas saving of 1556 gas across all tests.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.