MIP10c3-SP#: 34 Author(s): Niklas Kunkel (@NiklasKunkel) Contributors: Type: Process Component Oracle Team Name: Green Status: RFC Date Proposed: 2020-05-27 Date Ratified: <yyyy-mm-dd>
This Oracle would provide the SLP-V2-USDC-ETH/USD price as part of the collateral onboarding process for the SLP-V2-USDC-ETH LP token.
A smart contract utilizes SushiSwap primitives and liquidity reserves to calculate the price of a Uniswap Liquidity Provider (LP) token.
The reserves of the SushiSwap pool, and the supply of the SushiSwap LP token are used as inputs to the model. This model utilizes MakerDAO Oracles to price the underlying assets.
This model utilizes the following base assumptions:
Invariant k = reserve_x * reserve_y
reserve_x * price_x = reserve_y * price_y (only holds true at steady-state)
Combining (1) and (2) allows us to derive the formulas for calculating the “normalized” reserve balances of the underlying assets given the invariant k and prices of the underlying assets.
reserve_x = sqrt(k * price_y / price_x)
reserve_y = sqrt*(k * price_x / price_y)
Alternatively given one calculated normalized reserve, one can calculate the other using a mutation of (1).
This is useful for optimizing gas since calculating the square root is an expensive operation.
reserve_x = k / reserve_y
reserve_y = k / reserve_x
Once the normalized reserve balances have been calculated, the price of the LP token can be derived:
price_lp = ( (reserve_x * price_x) + (reserve_y * price_y) ) / supply_lp
Substitution of (3), (4) and (7) gives us the following model for calculating the price of a SushiSwap LP token:
price_lp = ( (sqrt(k * price_y / price_x) * price_x) + (sqrt(k * price_x / price_y) * price_y) ) / supply_lp
This can be simplified to:
price_lp = 2 * sqrt(k * price_x * price_y) / supply_lp
k can be re-expressed in terms of the current pool reserves reserve_x and reserve_y:
price_lp = 2 * sqrt(reserve_x * price_x * reserve_1 * price_1) / supply_lp
| Source | Asset Pair | Feed Model | | :------------ | :------------ | :----------: | | Binance | ETH/USD | Median | | Bitfinex | ETH/USDT | | | Bitstamp | ETH/USD | | | Coinbase | ETH/USD | | | Gemini | ETH/USD | | | Kraken | ETH/USD | |
- Mainnet - SushiV2LpOracle - TBD
- Deploy Oracle from Factory Contract
The SushiSwap V2 USDC-ETH pair is one of the most liquid SushiSwap pairs with over $400 million of liquidity at time of publishing.
The Uniswap V2 LP Oracle was architected from the outset to be generalizable to both Uniswap V2 and Sushiswap V2 LP tokens. Since their introduction into the Maker Protocol 5 months ago, the LP Oracles have proven themselves to be both resilient and secure. The smart contracts have also completed a final audit by ABDK, who to their credit were also selected to audit Uniswap V3. That said, significant smart contract changes were recently introduced as a result of the audit and further gas-optimizations. Therefore the Oracle Domain Team is recommending that the debt ceiling starts low and be raised iteratively over time. This conservative strategy is further supported by the introduction of a
cropJoin adapter contract which needs to prove itself in a production capacity.
This Oracle utilizes the existing ETH/USD Oracle Medianizer for the ETH component of the Oracle and a DSValue with a static $1 price for the USDC component. This protects against flash-loan attacks which attempt to manipulate the reserve ratios of the pool.