BIP-49: Misc. Improvements
Proposer
Beanstalk Farms, Brendan Sanderson, Ben Weintraub
Proposer Wallet: 0x4a24e54a090b0fa060f7faaf561510775d314e84
Summary
- Migrate the Fertilizer metadata hosted at fert.bean.money on-chain;
- When the cumulative deltaB over the previous Season is less than 0, change Soil issued at
gmto 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; - Implement an Anti λ → λ Convert type that allows any user to decrease a Deposit’s BDV if the Recorded BDV (the BDV stored on-chain with the Deposit) is greater than the Current BDV (the number of tokens in the Deposit × the current BDV of the token);
- Change the Chop Rate calculation from the [% recapitalized × % of Sprouts that have become Rinsable] to the [% recapitalized]^2;
- Update the Locked Beans calculation to account for the change to the Chop Rate; and
- Decrease the recapitalization amount upon Chop per BIR-14.
Links
- BIP-49 GitHub PR
- GitHub Commit Hash: 10c50916acdd1a2ea8c3699217779cbbe549389e
- Safe Transaction
Problem
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.
Proposed Solution
On-Chain Fert Metadata
We propose to migrate the Fertilizer metadata hosted at fert.bean.money on-chain.
Specification
- Create a new contract called
FertilizerImage.solto dynamically assemble the SVG image for Active, Used and Available Fertilizer; and - Modify
uriinInternalizer.solto (1) assemble the required on-chain data, (2) generate the correct Fertilizer image URI usingimageUrifromFertilizerImage.soland (3) return the final metadata URI to be consumed.
Soil Issuance Update
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.
Specification
In SeasonFacet/Sun.sol:
- Implement
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; and - Update the P < 1 case in
stepSunto usesetSoilBelowPeg.
BDV Decrease
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.
Specification
See the full Arweave upload of BIP-49 to read the BDV Decrease Specification section.
Chop Changes
We propose to:
- Change the Chop Rate calculation from the [% recapitalized × % of Sprouts that have become Rinsable] to the [% recapitalized]^2;
- Change the Locked Beans calculation to assume that up to 75% of Unripe assets are Chopped within a single Season; and
- Decrease the recapitalization amount upon Chop per BIR-14.
Specification
See the full Arweave upload of BIP-49 to read the Chop Changes Specification section.
Technical Rationale
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.
Economic Rationale
Soil Issuance Update
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.
BDV Decrease
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.
Chop Changes
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.
Contract Changes
See the full Arweave upload of BIP-49 to read the Contract Changes section.
Beans Minted
None.
Audit
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.
Post Audit Changes
The following changes have been made to the BIP-49 code, but have not been audited:
- Updated the constants in
LibLockedUnderlyingto reflect the change in the Locked Beans calculation; - Updated the Beans per Fertilizer remaining calculation in
Fertilizer/Internalizer.solused by the Fertilizer SVGs; and - Updated
SeasonGettersFacet.getTotalDeltaB()to calculate the cumulative deltaB across all whitelisted Wells.
Effective
Immediately upon commitment.
| Voter | Cast Power | Vote & Rationale |
|---|---|---|
0xCbC7...8AE493 | 4.828M | For |
0x15F5...1499E3 | 4.199M | For |
0xbC4d...8bB0FB | 3.573M | For |
0xB9F1...7232fA | 2.94M | For |
0x3743...e2494B | 2.816M | For |
VOTE POWER
Proposal Status
- Mon July 29 2024, 04:00 pmVoting Period Starts
- Mon August 05 2024, 04:00 pmEnd Voting Period
Current Results
1-For
58.267M
2-Against
53,216.785
