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

++i preincrement is cheaper

Summary

Preincrement costs less gas than Post Increment

Vulnerability Details

Lines 118, 353 in DSCEngine use the post increment i++ in the loop iterations. This is more expensive than the preincrement form ++i.

Impact

Gas Savings: Preincrement ++i saves 5 less gas compared to i++. Therefore each loop iteration saves 5 gas which multiples with number times loop called and instances of for loops leading to significant gas savings.

Tools Used

Manual Analysis

Recommendations

DSCEngine.sol line 118 i++ replaced with ++i
DSCEngine.sol line 353 i++ replaced with ++i

Support

FAQs

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