Remove storing only 2 addresses in dynamic array
There are only 2 addresses for collateral asset. There will only ever be 2 as no way to update. There is no need to use more costly data structure dynamic array "s_collateralTokens" which increases gas costs. Each address must be stored in its own slot
Gas: Dynamic arrays in storage require lots of computation to hash slot, to set and find where actual values are stored. At the actual slot of array, the length is stored which is an additional gas cost. By having values in address we only have 2 slots and remove more complex dynamic array computation.
Additionally in DSCEngine.sol functions line 353 we will not need to use a for loop
Manual Analysis
Intitial
address[] private s_collateralTokens;
Change To
address wbtc
address weth
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.