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

Add unchecked blocks in for loops

Summary

Adding unchecked blocks for loop variable increment can save GAS

Vulnerability Details

Adding unchecked blocks for loop variable increment can save GAS

The following code

for (uint256 i = 0; i < borrows.length; i++) {
......
}

can be changed to

for (uint256 i = 0; i < borrows.length;) {
......
unchecked { i++; }
}

This is because there will never be a condition where i overflows, since
before that the operation will run out of GAS

Impact

GAS usage high

Tools Used

Manual Review

Recommendations

Add unchecked block for loop increment variables.

Support

FAQs

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