Beanstalk Farms, Brendan Sanderson, Ben Weintraub
Proposer Wallet: 0x4a24e54a090b0fa060f7faaf561510775d314e84
gm to be the minimum of (1) the absolute value of cumulative deltaB calculated using the instantaneous reserves from Multi Flow and (2) the absolute value of the cumulative deltaB over the previous Season;Currently, Fertilizer metadata (the SVG image, traits, etc.) is hosted on centralized infrastructure. In addition to being fundamentally misaligned with the ethos of Beanstalk, any data hosted on centralized infrastructure requires maintenance and is subject to downtime.
Beanstalk is prone to overissuing Soil at gm call because Soil issuance below peg is solely based on the absolute value of the cumulative deltaB over the previous Season.
Currently, the Recorded BDV of a Deposit is not necessarily equal to its Current BDV. For example, if a user Deposits BEANETH into the Silo and the USD price of ETH falls significantly (and thus the BDV of BEANETH decreases), the Recorded BDV does not decrease. In practice this means Farmers "lock in" the higher BDV at the time of Deposit such that Beanstalk is over crediting BDV to Deposits relative to their value being contributed to it. Beanstalk only supports Convert types that do not decrease the BDV of the Deposit making it impossible for the BDV associated with a Deposit to ever be corrected.
Currently, Beanstalk offers a conservative Chop Rate of ~1.33% (22.49% recapitalization * 5.9012% of debt repaid to Fertilizer) to Unripe holders. Chopping is beneficial to Beanstalk as its obligations and the amount needed to fully recapitalize Unripe assets decreases. Although the current model is likely to result in the least volatility as Beanstalk is recapitalized (as a result of Unripe holders Chopping later on average), Beanstalk can be more aggressive given its healthy position in terms of L2SR.
Locked Beans are calculated under the extremely conservative assumption that all Unripe LP is Chopped within a single Season.
Currently, when Unripe LP holders Chop, s.recapitalized is unchanged as demonstrated in BIR-14. As a result, the Barn Raise ends earlier than intended, i.e., Beanstalk will not sell enough Fertilizer to fully recapitalize all Unripe LP.
We propose to migrate the Fertilizer metadata hosted at fert.bean.money on-chain.
FertilizerImage.sol to dynamically assemble the SVG image for Active, Used and Available Fertilizer; anduri in Internalizer.sol to (1) assemble the required on-chain data, (2) generate the correct Fertilizer image URI using imageUri from FertilizerImage.sol and (3) return the final metadata URI to be consumed.We propose to change Soil issued at gm when the cumulative deltaB over the previous Season is less than 0 to be the minimum of (1) the absolute value of cumulative deltaB calculated using the instantaneous reserves from Multi Flow and (2) the absolute value of the cumulative deltaB over the previous Season.
In SeasonFacet/Sun.sol:
setSoilBelowPeg, which calculates the cumulative deltaB across all whitelisted Wells using the instantaneous reserves in Multi Flow, compares it to its time weighted counterpart and picks the minimum of those two values; andstepSun to use setSoilBelowPeg.Implement a new ANTI_LAMBDA_LAMBDA Convert type, callable by anyone, that Converts on behalf of a Farmer and can decrease a Deposit's BDV.
See the full Arweave upload of BIP-49 to read the BDV Decrease Specification section.
We propose to:
See the full Arweave upload of BIP-49 to read the Chop Changes Specification section.
The Fertilizer Facet must be updated due to changes to the ERC-1155 token metadata. Hosting the metadata on-chain instead of on centralized infrastructure eliminates any risks associated with uptime.
The Season Facet must be updated due to changes to the deltaB calculation introduced by the Soil issuance change below peg.
The Convert Facet must be updated due to the introduction of ANTI_LAMBDA_LAMBDA.
The Unripe Facet must be updated due to changes to the chop function.
Consider an example where Beanstalk is at -300k deltaB for the first 58 minutes of a Season. At the 58th minute, i.e., 10 blocks before the next gm call, a Farmer buys and Sows 200k Beans, bringing the current deltaB to -100k.
Assuming no other trades in the final 2 minutes of the Season, the Soil issued at gm will be slightly less than 300k, despite Beanstalk only needing 100k Beans to be bought to return to peg. Before Multi Flow, this was necessary for sufficient manipulation resistance. However, thanks to Multi Flow it is now possible for Beanstalk to issue less Soil in these instances without being subject to manipulation.
In general, Beanstalk does not need to be particularly aggressive when issuing Soil—it does not want to issue debt if it doesn't have to and would prefer to spend an extra Season below peg over issuing a lot of excess Soil.
Thus, using the inter-block MEV manipulation resistant instantaneous reserves in Multi Flow to calculate deltaB below peg is preferred.
The ability to decrease a Deposit's BDV is necessary to prevent Beanstalk from over crediting BDV to Deposits relative to their value currently being contributed to the system. There is no incentive for a Farmer to decrease their own BDV. Thus, the Anti λ → λ Convert is callable by any user.
Beanstalk can be more aggressive given its healthy position in terms of L2SR. Chopping is beneficial to Beanstalk as its obligations and the amount needed to fully recapitalize Unripe assets decreases.
The Locked Beans calculation must be updated to account for the new Chop Rate calculation. Changing the assumption from 100% to 75% of Unripe assets Chopping within a single Season is still conservative but more realistic.
Ensuring the chop function is implemented as intended is essential to the structure of the Barn approved by the DAO.
See the full Arweave upload of BIP-49 to read the Contract Changes section.
None.
The commit hash of this BIP is 10c50916acdd1a2ea8c3699217779cbbe549389e.
An audit competition of this upgrade was held via Codehawks using commit hash 662d26f12ee219ee92dc485c06e01a4cb5ee8dfb. The final report can be read here.
Audit remediations were committed and documented in PR #943. All changes were reviewed by Cyfrin.
The following changes have been made to the BIP-49 code, but have not been audited:
LibLockedUnderlying to reflect the change in the Locked Beans calculation;Fertilizer/Internalizer.sol used by the Fertilizer SVGs; andSeasonGettersFacet.getTotalDeltaB() to calculate the cumulative deltaB across all whitelisted Wells.Immediately upon commitment.