In DSCEngine's constructor
you are pushing tokenAddresses
array items one by one in the s_collateralTokens
array but pushing them one by one into storage cost too much gas, you should set s_collateralTokens
to tokenAddresses
array in one go.
here is a simple example to see how much gas each one will use
If I pass [1,2,3]
array to this function execution cost will be 80255 gas
And if I pass [1,2,3]
array to this function execution cost will be 35251 gas
So it means you gonna save about 45000 gas for creation of this contract, Your code should look like this:
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.