Sun.setSoilBelowPeg()
might use an unintended soil amount when below peg.
During the improvements, setSoilBelowPeg()
uses a minimum amount of twaDeltaB
and instDeltaB
to prevent unnecessary minting of Soil.
Here is a detailed explanation of Soil Issuance Update.
But there is an exceptional case.
As the above example, -300K deltaB
for the first 58 minutes.
At the 58th minute, a farmer buys and sows 400k Beans(instead of 200K).
During gm
, twaDeltaB
will be around -300k as the recent change won't affect twa much. And instDeltaB
will be a positive vaulue: 100k.
In this case, the protocol's intention is not to mint new Soil at all as it doesn't want to issue debt if possible.
But with the implementation, Math.min(uint256(-twaDeltaB), uint256(-instDeltaB))
will be 300k as uint256(-instDeltaB) = uint256(-100k) = 2^256 - 100k
.
So it will issue 300k Soil unexpectedly.
setSoilBelowPeg()
might issue more Soil than intended for some cases.
Manual Review
setSoilBelowPeg()
shouldn't issue Soil if instDeltaB
is positive already.
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.