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

`uncheck` ++i in for loops to save gas

Summary

In DSCEngine.sol, line 359 can be optimized to improve the loop's efficiency. If you uncheck ++i you can save gas and not risk overflow due to it not being possible.

Tools Used

Manual review.

Recommendations

for (uint256 i = 0; i < s_collateralTokens.length; ) {
address token = s_collateralTokens[i];
uint256 amount = s_collateralDeposited[user][token];
totalCollateralValueInUsd += getUsdValue(token, amount);
unchecked{
i++;
}
})

Support

FAQs

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