-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BIP-38: Migrate urBEAN3CRV to urBEANETH #655
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…of USDC + Bean:3Crv Curve pool
- add urBEANETH support - remove urBEAN3CRV - rename deposit token names to better standardize
Ur bean eth metadata
- add urBEANETH support - remove urBEAN3CRV - rename deposit token names to better standardize
- additionally, changed generate image from `view` to `pure`.
- this allows users of NFT marketplaces to filter NFTs by criteria's.
✅ Deploy Preview for basin canceled.
|
✅ Deploy Preview for beanstalk-ui canceled.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
BIP-38: Migrate urBEAN3CRV to urBEANETH
Proposer
Beanstalk Farms, Brendan Sanderson, Ben Weintraub
Proposer Wallet: 0x87c5e5413d60e1419fd70b17c6d299aa107efb49
Summary
Links
Problem
As of writing, over 98% of liquidity for Beans is currently in the BEAN3CRV pool.
BEAN3CRV:
Beanstalk currently does not support multiple Unripe LP tokens.
BDV that has not been migrated to Silo V3 is not included in
s.siloBalances[token].depositedBdv
. For Beanstalk to support a Grown Stalk Gauge System, it is necessary to track the total Deposited BDV for each whitelisted token.Proposed Solution
Migration Process
Migrate the BEAN3CRV LP tokens that underly the urBEAN3CRV token to BEANETH Well LP tokens. In doing so, the liquidity underlying urBEAN3CRV is migrated to the BEANETH Well and the urBEAN3CRV token becomes the urBEANETH token (albeit, with the same token address).
Perform the following actions by the Beanstalk Community Multisig (BCM):
In order to minimize the risk of the swap being frontrun (for example, immediately after the passage of the BIP), authorize the BCM to begin the migration process at any point within 30 days of the passage of this BIP.
During the migration process, attempts to Deposit, Convert or Chop Unripe assets will revert. After the migration process is complete, Conversions between urBEAN and urBEANETH will Convert in/out of the BEANETH Well instead of the BEAN3CRV pool.
The cost of slippage during Step (3) is passed onto the Unripe LP holders.
addMigratedUnderlying
is added to the Unripe Facet to migrate the underlying token of an Unripe token to a new token.Due to the multi-step nature of this BIP, BCM Signers are only expected to submit Etherscan verified messages for the initial Diamond Cut transaction.
Fertilizer Changes
Upgrade the Barn to add liquidity to the BEANETH Well instead of the BEAN3CRV pool upon each Fertilizer purchase.
As a result:
mintFertilizer
function contains aminFertilizerOut
parameter to protect against substantial movement in the ETH price; andaddFertilizerOwner
function is removed.Silo V3 Unmigrated BDV
A two step process is required to start properly tracking the total Deposited BDV of each whitelisted token. Implement the first step by adding a counter (
s.migratedBdvs
) that tracks the amount of BDV that has been migrated to Silo V3 for each token.In the second step, the total Deposited BDV for each token is incremented by the remaining unmigrated BDV at the BIP-38 commitment block subtracted by the BDV that has been migrated since that block as stored on-chain. This second step must be implemented in a future BIP.
Technical Rationale
Given that the migration process cannot be executed atomically and Unripe asset functionality will be in a broken state during it, attempts to Deposit, Convert or Chop Unripe assets during the migration process will revert.
The Unripe Facet must be updated to add support for migrating the Unripe LP token to a new underlying asset.
The
mintFertilizer
function must be updated to include theminFertilizerOut
parameter to account for potential movement in the ETH price between transaction submission and execution. TheaddFertilizerOwner
function is removed given that it would need to be updated to reflect the migration to urBEANETH, however it was only expected to be called once during the Replant.The Convert Facet and Convert Getters Facet must be updated due to function changes in
LibUnripeConvert.sol
andLibWellConvert.sol
.The Metadata Facet must be updated in order to update the ERC-1155 metadata for urBEANETH Deposits.
The BDV Facet must be updated due to
unripeLPToBDV
being changed to reflect the migration to BEANETH.The Migration Facet must be updated due to the introduction of the migrated BDV counter.
Economic Rationale
Beans primarily trade against 3CRV which is a significant centralization vector for Beanstalk. Ether is the most decentralized, censorship resistant and liquid asset on the Ethereum network.
For as long as most liquidity for Beans is in the BEAN3CRV pool, Beanstalk is still subject to inter-block MEV manipulation. The Multi Flow Pump on the BEANETH Well is the first Ethereum-native oracle for Ethereum-native data that offers inter-block MEV manipulation resistance in a post-Merge environment.
For as long as most volume for Beans is in the BEAN3CRV pool, most trades with Beans are still subject to an unnecessary trading fee in the pool, which results in worse prices for Farmers and worse peg maintenance for Beanstalk. The Constant Product 2 Well Function used by the BEANETH Well has no trading fee.
The price of 3CRV is dependent on the worst of the prices of USDC, USDT and DAI. ETH is not subject to the same risk.
Contract Changes
Initialization Contract
The
init
function on the followingInitMigrateUnripeBean3CrvToBeanEth
contract is called:0x810468cbC28ecb522C10cB53FEC9e387F1ebc84D
Unripe Facet
The following
UnripeFacet
is removed from Beanstalk:0x261b3ae660504537fbfe15b6c1c664976344eb0a
The following
UnripeFacet
is added to Beanstalk:0xAa8c44D0B89864b467C3776a7Dd367ff2aB6992A
UnripeFacet
Function Changes_getPenalizedUnderlying
0xa84643e4
balanceOfPenalizedUnderlying
0x1acc0a47
balanceOfUnderlying
0x1acc0a47
getPenalizedUnderlying
0x6de45df2
getPenalty
0x014a8a49
getPercentPenalty
0xbb7de478
getRecapFundedPercent
0x43cc4ee0
getRecapPaidPercent
0xab434eb7
getTotalUnderlying
0xadef4533
getUnderlying
0x9f06b3fa
getUnderlyingPerUnripeToken
0xb8a04d1b
getUnderlyingToken
0x691bcc88
isUnripe
0xfc6a19df
picked
0xd3c73ec8
addMigratedUnderlying
0x787cee99
addUnripeToken
0xfa345569
chop
0x9a516cad
pick
0x13ed3cea
switchUnderlyingToken
0xa33fa99f
Fertilizer Facet
The following
FertilizerFacet
is removed from Beanstalk:0xFC7Ed192a24FaB3093c8747c3DDBe6Cacd335B6C
The following
FertilizerFacet
is added to Beanstalk:0x3FA7ECcfbFDF4407932D2318401d20464189C5F1
FertilizerFacet
Function ChangesbalanceOfBatchFertilizer
0x304ec65d
balanceOfFertilized
0xb6f42085
balanceOfFertilizer
0x1799b3b2
balanceOfUnfertilized
0x1edb6be1
beansPerFertilizer
0x9bb4e35a
getActiveFertilizer
0xdc6ba285
getCurrentHumidity
0x39448802
getEndBpf
0xc85951a1
getFertilizer
0x9c45a1d5
getFertilizers
0x34af5416
getFirst
0x1e223143
getHumidity
0x29130a66
getLast
0x4d622831
getMintFertilizerOut
0x69744dd0
getNext
0xf4a057e2
isFertilizing
0x6ae1c014
remainingRecapitalization
0x4a16607c
totalFertilizedBeans
0x4f9a9678
totalFertilizerBeans
0xf9c4ebde
totalUnfertilizedBeans
0xa3ef48c9
addFertilizerOwner
0x8cd31ca0
claimFertilized
0x83e08888
mintFertilizer
0x0bfca7e3
mintFertilizer
0xbb02e10b
payFertilizer
0xd47aee59
Convert Facet
The following
ConvertFacet
is removed from Beanstalk:0xC2f8F1412d10E4DC79D34a46ab1d3d862517f939
The following
ConvertFacet
is added to Beanstalk:0xDc6B4ef6bA55706B19Bd389eA446d232eFb4E5D4
ConvertFacet
Function Changesconvert
0xb362a6e8
Convert Getters Facet
The following
ConvertGettersFacet
is removed from Beanstalk:0x912f505ecD6536733da22BB4349595aA36806918
The following
ConvertGettersFacet
is added to Beanstalk:0x789e37096Fb0abbD4f64A86B51D720b371853a70
ConvertGettersFacet
Function ChangesgetAmountOut
0x4aa06652
getMaxAmountIn
0x24dd285c
Metadata Facet
The following
MetadataFacet
is removed from Beanstalk:0x5e6991aFa1352822e769c873200954B4dE6c6E48
The following
MetadataFacet
is added to Beanstalk:0x8aD8dfC3303469A8c2d14763199a99363bF580cc
MetadataFacet
Function ChangesimageURI
0xc20b8071
name
0x06fdde03
symbol
0x95d89b41
uri
0x0e89341c
BDV Facet
The following
BDVFacet
is removed from Beanstalk:0x9Cb54A8eAcD4d295dd02833cd2bdD385173c7fF5
The following
BDVFacet
is added to Beanstalk:0xC1Bbee46EcB6445B176F7f172F91976ADF4e21D9
BDVFacet
Function ChangesbeanToBDV
0x5a049a47
curveToBDV
0xf984019b
unripeBeanToBDV
0xc8cda2a0
unripeLPToBDV
0xb0c22bb1
wellBdv
0xc84c7727
Migration Facet
The following
MigrationFacet
is removed from Beanstalk:0x141209527f95540e0b018e56edf5a59e1339437f
The following
MigrationFacet
is added to Beanstalk:0x9F2444e6cFAAB6ea16Fc05B989f1017508F84A41
MigrationFacet
Function ChangesbalanceOfGrownStalkUpToStemsDeployment
0x505f43ea
balanceOfLegacySeeds
0x1be2cfd8
getDepositLegacy
0xa9be1acb
mowAndMigrate
0x1f4f3d55
mowAndMigrateNoDeposits
0xaed942e9
totalMigratedBdv
0x2b8cde0d
Event Changes
SwitchUnderlyingToken
Beans Minted
None.
Audit
The commit hash of this BIP is 76066733bcddb944b9af8f29acf150c02a5b8437.
Cyfrin has performed an audit of commit hash 12c608a22535e3a1fe379db1153185fe43851ea7 and then reviewed remediations included in commit hash 76066733bcddb944b9af8f29acf150c02a5b8437.
The final audit report can be found here.
Effective
No upgrades are necessarily executed by the BCM immediately upon the passage of this BIP.
The BCM has up to 30 days after the passage of this BIP to start the migration outlined in Migration Process.