-
Notifications
You must be signed in to change notification settings - Fork 79
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
EBIP-19: Misc Bug Fixes 2 #1148
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
❌ Deploy Preview for beanstalk-ui failed.
|
✅ Deploy Preview for basin ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
BeanstalkFarmsOperations
changed the title
EBIP-19: Misc Bug Fixes #2
EBIP-19: Misc Bug Fixes 2
Oct 14, 2024
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.
EBIP-19: Misc Bug Fixes 2
Submitter
Beanstalk Community Multisig
Summary
getAmountOut
to return the correct value when Converting Unripe LP to Unripe Bean;Math
library to increase precision in operations in thecalcRate
function.Links
Per the process outlined in the BCM Emergency Response Procedures, the BCM can take swift action to protect Beanstalk in the event of a bug or security vulnerability.
Problem
The Morning Auction and Generalized Convert used
block.number
to determine how much time had passed and Convert capacity (the amount of assets that can be Converted within 1 L2 block), respectively. On Arbitrum,block.number
returns the L1 block number rather than the latest block number on Arbitrum. As a result, the Morning Auction had been lasting longer than its intended duration (the entire Season) and the Convert capacity was accrued over multiple blocks rather a single block.The
getAmountOut
view function is used in order to return the amount of tokens returned from a Convert. This function returned an incorrect value when attempting to fetch the amount returned from Converting Unripe LP to Unripe Bean.Previously, if a whitelisted Well had fewer than 1000 Beans, Beanstalk assumed manipulation was occurring in the Well. When this manipulation was detected, the LP Gauge System did not change the Gauge Points nor Seeds of any whitelisted LP token. This creates liveness issues when new Wells are whitelisted, such as in BIP-50.
The Multi Flow Pump v1.2 (deployed for BIP-50) stored incorrect reserves when a Well went from non-zero to zero reserves.
The
calcRate
function in the Constant Product 2 Well Function failed when reserves were set to the max value.No funds were at risk as a result of these bugs.
Solution
Update Morning Auction and Generalized Convert to fetch the L2 block number.
Update
getAmountOut
to return the correct value when Converting Unripe LP to Unripe Bean.Upgrade the Gauge System to update Gauge Points and Seeds for whitelisted LP tokens regardless of the number of Beans in each Well.
Update the whitelisted Wells to use Multi Flow Pump v1.2.1, which properly resets the reserves in the Well when the reserves go from non-zero to zero.
Update the whitelisted Wells that use the Constant Product 2 Well Function to use Constant Product 2 v1.2.1, which uses the
Math
library to increase precision in operations in thecalcRate
function.Contract Changes
Initialization Contract
The
init
function on the followingInitMultiFlowPumpUpgrade
contract is called:0xF48B9F669EB7b40e46CDDCf04B1c6f07E2458C1F
Season Facet
The following
SeasonFacet
is being removed from Beanstalk:0x40c8688969c91290311314fbB2f10156b43Fbe4B
The following
SeasonFacet
is added to Beanstalk:0x64504c8b23350FEEebd5BB978633C0CfFfb9D536
SeasonFacet
Function ChangesgetShipmentRoutes
0xfd497a68
setShipmentRoutes
0xf1e2dfb0
gm
0x64ee4b80
seasonTime
0xca7b7d7b
sunrise
0xfc06d2a6
Season Getters Facet
The following
SeasonGettersFacet
is being removed from Beanstalk:0xfe15fe467d06Ce19d20709eAE9E24B3bD8309132
The following
SeasonGettersFacet
is added to Beanstalk:0xdB9882aaAC47Fc1D62942951311704FDDf531ebd
SeasonGettersFacet
Function ChangescumulativeCurrentDeltaB
0x89a218d2
getAbsBeanToMaxLpRatioChangeFromCaseId
0xe53b479e
getAbsTemperatureChangeFromCaseId
0x3cee5dea
getCaseData
0x8097f0ca
getCases
0x065cb594
getChangeFromCaseId
0x43e0156a
getDeltaPodDemandLowerBound
0x57801d87
getDeltaPodDemandUpperBound
0x70fd1b06
getEvaluationParameters
0xda61af62
getExcessivePriceThreshold
0x44fb7cc3
getLpToSupplyRatioUpperBound
0x1eedbfbb
getLpToSupplyRatioOptimal
0x1f48a553
getLpToSupplyRatioLowerBound
0x11a8d895
getMaxBeanMaxLpGpPerBdvRatio
0xab843b34
getMinBeanMaxLpGpPerBdvRatio
0xb3c39ce5
getPodRateLowerBound
0xfd6d1483
getPodRateOptimal
0xdd9330d2
getPodRateUpperBound
0x08fa96d3
getRelBeanToMaxLpRatioChangeFromCaseId
0x35870a7a
getRelTemperatureChangeFromCaseId
0x4d65f762
getSeasonStruct
0x738ad142
getSeasonTimestamp
0xf07f0760
getTargetSeasonsToCatchUp
0xcb677411
getWellsByDeltaB
0xbf170533
poolCurrentDeltaB
0x8223eac8
abovePeg
0x2a27c499
getLargestLiqWell
0xd1943f7f
getTotalUsdLiquidity
0xbbf459a7
getTotalWeightedUsdLiquidity
0xf788b47c
getTwaLiquidityForWell
0xa13a3742
getWeightedTwaLiquidityForWell
0x93c9e531
l2BlockNumber
0x8b85902b
paused
0x5c975abb
plentyPerRoot
0x3fccd20c
poolDeltaB
0x471bcdbe
rain
0x43def26e
season
0xc50b0fb0
sunriseBlock
0x3b2ecb70
time
0x16ada547
totalDeltaB
0x06c499d8
weather
0x686b6159
wellOracleSnapshot
0x597490c0
Convert Facet
The following
ConvertFacet
is being removed from Beanstalk:0x242A339C73d3b373a91C157865B36a1480ec3b09
The following
ConvertFacet
is added to Beanstalk:0xcE333Cc99C477A7d96FDe73905e0B3576e86b321
ConvertFacet
Function Changesconvert
0xb362a6e8
Convert Getters Facet
The following
ConvertGettersFacet
is being removed from Beanstalk:0x999A04B54a386b1C68A9Be926AF0200F2C49A47A
The following
ConvertGettersFacet
is added to Beanstalk:0x6eF9cC52Eb37e0dE9592960c0c894a1000ac7dDf
ConvertGettersFacet
Function ChangescalculateDeltaBFromReserves
0xd052f0d5
calculateStalkPenalty
0xb325d2ef
cappedReservesDeltaB
0x6842f2b3
getAmountOut
0x4aa06652
getMaxAmountIn
0x24dd285c
getOverallConvertCapacity
0xf66d5589
getWellConvertCapacity
0xb905065b
getUsedConvertCapacity
0xb8ff0f01
overallCappedDeltaB
0x3e8b56f1
overallCurrentDeltaB
0xb267ea07
scaledDeltaB
0x24568abf
Pipeline Convert Facet
The following
PipelineConvertFacet
is being removed from Beanstalk:0x6B1B5E5cef71f0cC65d32B67D8794F58faD491a3
The following
PipelineConvertFacet
is added to Beanstalk:0xA047EAD9719dE8B030a10dd3d152518db7cf0099
PipelineConvertFacet
Function ChangespipelineConvert
0xbb25c1c2
Field Facet
The following
FieldFacet
is being removed from Beanstalk:0xa9085918d5632EA12BA91709F819B800fa8B3726
The following
FieldFacet
is added to Beanstalk:0xa80A1F63bb8d5cece044E4e12480dB3930E9885C
FieldFacet
Function ChangesactiveField
0xd1eba544
addField
0xb94e871c
balanceOfPods
0x9a337c1d
fieldCount
0xbb485bbd
getPlotIndexesFromAccount
0x253fcfb5
getPlotsFromAccount
0x91b24284
isHarvesting
0x4bea67c4
setActiveField
0x057c571b
totalHarvestableForActiveField
0x237dbac5
harvest
0xe9bbb033
harvestableIndex
0xb511654d
maxTemperature
0x7907091f
plot
0x9ee7ea12
podIndex
0xccda40b9
remainingPods
0x56ba3e24
sow
0x32ab68ce
sowWithMin
0x553030d0
temperature
0xadccea12
totalHarvestable
0x2e76f597
totalHarvested
0x352525a6
totalPods
0xf1e0a211
totalSoil
0x3285008a
totalUnharvestable
0xf29ffe94
Beans Minted
None.
Effective
Effective immediately upon commitment, which has already happened.