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

The increment in `for` and `while` loops can be made unchecked

Summary

++i/i++ should be unchecked{++i}/unchecked{i++} when it is not possible for them to overflow, as is the case when used in for and while loops. This saves 30-40 gas per loop iteration.

Vulnerability Details

There are 6 instances of this issue.

View 6 Instances
File: src/Lender.sol
233: for (uint256 i = 0; i < borrows.length; i++) {
293: for (uint256 i = 0; i < loanIds.length; i++) {
359: for (uint256 i = 0; i < loanIds.length; i++) {
438: for (uint256 i = 0; i < loanIds.length; i++) {
549: for (uint256 i = 0; i < loanIds.length; i++) {
592: for (uint256 i = 0; i < refinances.length; i++) {
File Link Instance Count Instance Links
Lender.sol 6 233,293,359,438,549,592

Impact

360 gas

Tools Used

baudit: a custom static code analysis tool; manual review

Recommendations

++i/i++ should be unchecked{++i}/unchecked{i++} in for and while loops.

Support

FAQs

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