In Solidity 0.8+, there’s a default overflow check on unsigned integers, which we can skip when iterating over loops and therefore save gas. The risk of overflow is non-existent for uint256 here.
Here we loop through all the tokens, which are valid for collateral.
As the project is a template for a stable coin, which other developers could use as a ready solution, we are not sure about the size of the collateral array, so the optimization could save a good amount of gas.
Gas usage
Manual Review
Consider wrapping with an unchecked block (around 25 gas saved per instance).
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.