Open code423n4 opened 2 years ago
Meta0xNull
The Pool size is known which is 0 to 3. Thus, SLOAD pools.length for Every Loop is Waste of Gas
https://github.com/Badger-Finance/ibbtc/blob/d8b95e8d145eb196ba20033267a9ba43a17be02c/contracts/Zap.sol#L70
Manual Review
Before: for (uint i = 0; i < pools.length; i++)
After: for (uint i = 0; i < 4; i++)
Agree with finding
Handle
Meta0xNull
Vulnerability details
Impact
The Pool size is known which is 0 to 3. Thus, SLOAD pools.length for Every Loop is Waste of Gas
Proof of Concept
https://github.com/Badger-Finance/ibbtc/blob/d8b95e8d145eb196ba20033267a9ba43a17be02c/contracts/Zap.sol#L70
Tools Used
Manual Review
Recommended Mitigation Steps
Before: for (uint i = 0; i < pools.length; i++)
After: for (uint i = 0; i < 4; i++)