-
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
RFC: Multi Flow v1.1.0 #126
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
ALPHA
MAX_LP_TOKENS_INCREASE
MAX_LP_TOKENS_DECREASE
MAX_PERCENT_PRICE_CHANGE
The text was updated successfully, but these errors were encountered: