Currently there are two for
loops in the DSCEngine.sol contract - one in the constructor and one during the collateral value calculation.
Both for loops can be optimized to reduce gas costs during deployment and during calculation of the user healthFactor which is done on most external calls to the DSCEngine.sol.
Unnecessary gas consumption
Manual Review
Store the loop end variable as a local variable before the actual for
loop.
Increment can be added in a unchecked block as overflow is almost impossible.
Old Loop in Constructor:
Optimized Loop in Constructor:
Old Loop in collateral value calculation:
Optimized Loop in collateral value calculation:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.