Cache basketAsERC20.totalSupply() #88
Labels
bug
Warden finding
G (Gas Optimization)
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Handle
pauliax
Vulnerability details
Impact
Here basketAsERC20.totalSupply() does not change inside the loop so it can be called outside the loop to avoid multiple duplicate external calls:
uint256 tokensNeeded = basketAsERC20.totalSupply() * pendingWeights[i] * newRatio / BASE / BASE;
Recommended Mitigation Steps
Cache basketAsERC20.totalSupply() in a temporary variable and re-use it.
The text was updated successfully, but these errors were encountered: