-
Notifications
You must be signed in to change notification settings - Fork 22
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
Stable2 + WellUpgradeable #135
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
Conflicts: test/TestHelper.sol
Update wellUpgradable Implementation
…' into stableswapWF
`notDelegatedOrIsMinimalProxy` modifier fix [#26]
Stable2 `decimal1` fix [#17]
Add check for new well tokens in `authorizeUpgrade` [#23]
Add explicit reverts in functions that use Newton's method after non-convergence [#19]
Misc QA Fixes.
S2 upgr well remediations 2
Stable2 Well Function and Upgradeable Well Remediations.
nickkatsios
approved these changes
Sep 6, 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.
RFC: Stable2 Well Function
Author
bean, deadmanwalking
Summary
Motivation
Technical Specification
Beanstalk requires that a Well Function inherit
IBeanstalkWellFunction
, which requires an additional 2 functions to be implemented:calcReserveAtRatioSwap
calculates a reserve with a target ratio, reached through executing a swap.calcReserveAtRatioLiquidity
calculates a reserve with a target ratio, reached through adding/removing liquidity.This is done using newton method, by iteratively adjusting reserves until a target ratio is found. Given the computational complexity of doing this on chain, a Lookup table is implemented in order to provide an initial guess and step size, such that the function converges within an reasonable amount of iterations.
Stable2 Lookup Tables must Inherit
ILookupTable
, which requires the following functions:getAParameter()
Returns the A parameter this lookup table was written for. A Stable2 Well Function must have the same A parameter as its Lookup Table in order to ensure an accurate initial guess and step size.getRatiosFromPriceSwap(uint256)
Given a price, returns the ratios of a pool with a price slightly higher and lower than the input price, through a swap.getRatiosFromPriceLiquidity(uint256)
Given a price, returns the ratios of a pool with a price slightly higher and lower than the input price, through adding or removing liquidity.Given the ratios at the price higher and lower than the target price, The Well function is able to assume that the target ratio is within the bounds of the higher and lower ratios, and thus the initial guess and step size is relatively close to the final reserve (and can converge within 1-2 iterations in most cases). Future development can be done to optimize the Lookup Table values (such that most prices converge within 1 iteration), with a tighter price spread (Currently set to 0.01%)
RFC: Upgradeable Well
Author
deadmanwalking, brean
Summary
WellUpgradeble.sol
) that supports ownership and upgradeability. This Well Implementation allows for Well Owners to adjust its Well components (adding/removing Pumps, changing Well Functions or Implementation).Motivation
Technical Specification
WellUpgradeble.sol
is EIP-1822 Universal Upgradeable Proxy Standard (UUPS) compatible in order to support upgradeability of the Well.Because Wells bored by an Aquifer requires that the Well is initialized, the Upgradeable Well Implementation provides 2 initialization functions:
-
initNoWellToken()
has no logic other than the initializer modifier. This should be used when initially boring the well with immutable data.init()
performs the standard initialization seen inWell.sol
, with the addition of__Ownable_init()
. This reinitializes the well with value of2
. Users using upgradeable Wells should verify that the initializer is set to2
prior to use.In order to upgrade the Well, the new implementation must also be a Well that was bored by an Aquifer. The UUPS
proxiableUUID
does not support proxy contracts out of box, given that a proxy could infinitely point to additional proxies and brick the contract. However, Wells are minimal proxy clones, which are immutable and thus do not have this issue. Thus,proxiableUUID
was updated to support minimal proxy clones.