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

`++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

Summary

Using an unchecked block saves 30-40 gas per loop iteration.

There are 2 instances of this issue:

File: src/DSCEngine.sol
118: for (uint256 i = 0; i < tokenAddresses.length; i++) {
353: for (uint256 i = 0; i < s_collateralTokens.length; i++) {

This can be fixed by adding an unchecked block:

for (unit i; i < length;) {
// logic
unchecked {
++i;
}
}

Support

FAQs

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