BIP-21: Replant Beanstalk

Proposed: July 29, 2022

Status: Passed

Link: Snapshot


Proposer

Beanstalk Farms

Quorum

50%: 106,664,659.23 Stalk

Two-thirds supermajority: 142,219,545.64 Stalk

Summary

  1. Execute a series of transactions to Replant Beanstalk.
  2. Commit a series of upgrades to Beanstalk.
  3. Unpause Beanstalk.

Note: Any bugs found during testing will continue to be fixed throughout the BIP-21 Voting Period such that the Replant may not be delayed.

Problem

BIP-21 addresses the following issues:

1. Beanstalk must be Replanted, which involves several steps.

2. Beanstalk has improvements to the issues that have been audited for inclusion in the Replanted version of Beanstalk.

3. Beanstalk must be Unpaused.

Proposed Solution

The following solutions are proposed to the issues listed above:

1. Execute a series of steps to Replant Beanstalk.

2. Implement a series of improvements to Beanstalk.

The Curve Pipeline allows anyone to call functions in any pool registered in any of the following Curve registries.

The following functions to interact with Curve pools can be called through the Curve Pipeline:

function exchange(
        address pool, 
        address registry, 
        address fromToken, 
        address toToken, 
        uint256 amountIn, 
        uint256 minAmountOut, 
        LibTransfer.From fromMode, 
        LibTransfer.To toMode
    ) external payable nonReentrant;
    // only in Metapools
    function exchangeUnderlying(
        address pool, 
        address fromToken, 
        address toToken, 
        uint256 amountIn, 
        uint256 minAmountOut, 
        LibTransfer.From fromMode, 
        LibTransfer.To toMode
    ) external payable nonReentrant;
    function addLiquidity(
        address pool,
        address registry,
        uint256[] memory amounts,
        uint256 minAmountOut,
        LibTransfer.From fromMode,
        LibTransfer.To toMode
    ) external payable nonReentrant;
    function removeLiquidity(
        address pool,
        address registry,
        uint256 amountIn,
        uint256[] calldata minAmountsOut,
        LibTransfer.From fromMode,
        LibTransfer.To toMode
    ) external payable nonReentrant;
    function removeLiquidityImbalance(
        address pool,
        address registry,
        uint256[] calldata amountsOut,
        uint256 maxAmountIn,
        LibTransfer.From fromMode,
        LibTransfer.To toMode
    ) external payable nonReentrant;
    function removeLiquidityOneToken(
        address pool,
        address registry,
        address toToken,
        uint256 amountIn,
        uint256 minAmountOut,
        LibTransfer.From fromMode,
        LibTransfer.To toMode
    ) external payable nonReentrant;
    

3. Unpause Beanstalk.

Rationale

The following are Beanstalk Farms’ rationale for the proposed solutions above:

1. Beanstalk must be Replanted, which involves several steps.

2. Commit a series of upgrades to Beanstalk.

3. Unpause Beanstalk.

Post Audit Changes

The following changes have been made to Beanstalk, but have not been audited.

All relevant changes with the exception of CurveFacet and LibUnripeSilo can be viewed here.

File Name Changes Type
C.sol Changed constants. Parameter Change
CurveFacet.sol Most functionality—some were audited, but all have been heavily tested. Bug Fix
FertilizerFacet.sol Renamed variable; added getCurrentHumidity(). Refactor / Usability
FieldFacet.sol Moved burn token logic to LibTransfer's burnToken() function. Refactor
PauseFacet.sol Removed 2 unnecessary lines of code. Clean Up
Silo.sol Fixed an issue with the BDV of Earned Beans; removed unused variables. Bug Fix
TokenFacet.sol Removed an unnecessary variable. Clean Up
UnripeFacet.sol Renamed ripen() to chop(); renamed claimUnripe() to pick(); added Internal Balance support for pick() and chop(); added picked() function. Refactor
LibWhitelist.sol Removed BEAN_LUSD variables. Clean Up
LibTransfer.sol Added generalized burnToken() function with Internal Balance support. Refactor
LibUnripeSilo.sol Most functionality—some were audited, but all have been heavily tested. Updated to account for Barn Raise changes
LibCurveConvert.sol / LibMetaCurveConvert.sol / LibBeanMetaCurve.sol / LibCurve.sol Change the lpToPeg() function to account for Curve exchange fee. Bug Fix
FertilizerFacet.sol Added getFertilizers() function. Usability
LibCurveOracle.sol Added MetapoolOracle event. Usability
SeasonFacet.sol Moved Sunrise event call to the start of the sunrise() function instead of the end. Refactor
Weather.sol Added the Season number to Weather related events. Refactor
SiloFacet.sol Changed the updateUnripeDeposit() and updateUnripeDeposits() functions to enrootDeposit() and enrootDeposits(), respectively. Refactor

Effective

After either:

  1. A two-thirds supermajority is reached; or
  2. The Voting Period ends and more than half of the total outstanding Stalk votes in favor of the BIP,

Publius will:

After that, the BCM will:

The BCM will Unpause Beanstalk thereafter on August 6, 2022 at around 16:00 UTC.

After the Unpause transaction and thus BIP-21 is fully executed, the BCM shall follow the process for verifying proposed BIPs moving forward.