-
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
Multi Flow Pump v1.1 #127
Merged
Merged
Multi Flow Pump v1.1 #127
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
Brean0
requested changes
Feb 21, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
review
Brean0
approved these changes
Feb 25, 2024
Implement changes for review.
Brean0
force-pushed
the
multi-flow-pump-v1.1
branch
from
June 25, 2024 20:05
8360ae4
to
07b2cd2
Compare
MultiFlow Pump v1.1 (Codehawks Dive into Basin) Remediations
Brean0
approved these changes
Jul 23, 2024
Closed
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: Multi Flow v1.1.0
Author
Brendan Sanderson
Summary
Modify the cap reserves functionality in Multi Flow to have two separate caps:
This allows the Multi Flow Pump to independently control the maximum change in total tokens in a Well and the exchange rate between them.
Move all constants to Pump Data to allow customizability between Wells.
Motivation
When the BEAN:3CRV liquidity was migrated to BEAN:ETH, it took a significant time (~14 hours) for the Multi Flow capped reserves to catch up to the real balances (see EBIP-9). During this time, the ratio between the capped reserves did not change as they both increased by the max percent each Season. This introduced a problem where the exchange rates in Multi Flow Pump may not reflect the actual exchange rates in the pool. Multi Flow Pump needs a way to change the exchange rates even when the magnitude of the increase of reserves is capped.
Currently Multi Flow Pump's constants are stored in the Pump. However, different types of Wells (e.g., A Well with Stablecoins) may want to use different constants. Currently, this requires deploying different Pumps for each. By moving the constants to Pump Data, it will allow each Well to chose its own constants while using the same Pump.
Design Specification
Given Constants:
where$\delta_{ij}$ is the maximum % increase in exchange rate of exchanging $j$ for $i$ .
Given Functions
calcLpTokenSupply
- Gets the LP token supply given a list of reserves.calcReserveAtRatioSwap
- Calculates the $j$th reserve such thatcalcLPTokenUnderlying
- Calculates the amount of each reserve token underlying a given amount of LP tokens.calcRate
- Calculates the exchange rate of exchangeGiven Variables:
Solve For:
Step 1: Cap Change of Magnitude
Let:
Step 2: Cap Change of Rates
For each unique set of 2 tokens in the Well (order doesn’t matter):
Let$(i, j)$ be defined such that $x_{i,t}^{cap} > x_{j,t}^{cap}$
Let:
Technical Specification
Well Function Interface Augmentation:
1. Create a new interface
IMultiFlowPump.sol
IBeanstalkWellFunction
should now extendIMultiFlowPumpWellFunction
2. Implement
IMultiFlowPump
inConstantProduct2
The only function that needs to be added is
calcRate
.calcRate
should return the output ofreserves[i] / reserves[j]
.MultiFlowPump Modification:
1. Remove existing constants
LOG_MAX_INCREASE
LOG_MAX_DECREASE
ALPHA
2. Add new constants as Pump Data
3. Modify
_capReserve
to_capReserves
and implement_capReserves
inupdate
.4. Modify
LibLastReserveBytes
to store and returnuint256
instead ofbytes16
.