In Witch.buy there's the possibility to do one multiplication instead of two divisions: Instead of computing the ink price as 1 / artPrice and then dividing by it to get the ink amount as ink = art / price, just keep the art price and multiply it by the art amount.
These lines need to be changed:
price = term1.wmul(term2); // this is the art price in terms of ink now, instead of ink price
ink = uint256(art).wmulup(price); // can just multiply by art price
Impact
One saves gas by doing one multiplication instead of two divisions which seems to be an important goal of Yield v2.
Handle
cmichel
Vulnerability details
In
Witch.buy
there's the possibility to do one multiplication instead of two divisions: Instead of computing the ink price as1 / artPrice
and then dividing by it to get the ink amount asink = art / price
, just keep the art price and multiply it by theart
amount. These lines need to be changed:Impact
One saves gas by doing one multiplication instead of two divisions which seems to be an important goal of Yield v2.