[SLP-V2-YFI-ETH] Collateral Onboarding Oracle Assessment (MIP10c3-SP36)

Preamble

MIP10c3-SP#: 36
Author(s): Niklas Kunkel (@NiklasKunkel)
Contributors:
Type: Process Component
Oracle Team Name: Green
Status: RFC
Date Proposed: 2020-06-06
Date Ratified: <yyyy-mm-dd>

Specification

Introduction

This Oracle would provide the SLP-V2-YFI-ETH/USD price as part of the collateral onboarding process for the SLP-V2-YFI-ETH LP token.

Oracle Data Model

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:

(1) Invariant k = reserve_x * reserve_y

(2) 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.

(3) reserve_x = sqrt(k * price_y / price_x)

(4) 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.

(5) reserve_x = k / reserve_y

(6) reserve_y = k / reserve_x

Once the normalized reserve balances have been calculated, the price of the LP token can be derived:

(7) 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:

(8) 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:

(9) 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:

(10) price_lp = 2 * sqrt(reserve_x * price_x * reserve_1 * price_1) / supply_lp

Oracle Supporting Data Model(s)

YFI/USD (canonical)

|    Source     |  Asset Pair   |  Feed Model  |
| :------------ | :------------ | :----------: | 
|   Binance     |    YFI/USDT   |    Median    |
|   Coinbase    |    YFI/USD    |              |
|      FTX      |    YFI/USD    |              |
|   Gemini      |    YFI/USD    |              |
|    Huobi      |    YFI/USDT   |              |
|    Uniswap    |     YFI/ETH   |

ETH/USD (canonical)

|    Source     |  Asset Pair   |  Feed Model  |
| :------------ | :------------ | :----------: | 
|   Binance     |    ETH/USD    |    Median    |
|   Bitfinex    |    ETH/USDT   |              |
|   Bitstamp    |    ETH/USD    |              |
|   Coinbase    |    ETH/USD    |              |
|   Gemini      |    ETH/USD    |              |
|   Kraken      |    ETH/USD    |              |

Oracle Address

  • Mainnet - SushiV2LpOracle - TBD

Supported Tools

UniV2LpOracle - Source Code
UniV2LpOracle - Tests
UniV2LpOracle - ABDK Audit

Remaining Work

  • Deploy Oracle from Factory Contract
  • Update OmegaPoker to poke SushiV2LpOracle instance

Summary

The SushiSwap V2 YFI-ETH pair has a fair amount of liquidity with $217 million 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 acropJoin adapter contract which needs to prove itself in a production capacity.

This Oracle utilizes the existing YFI/USD Oracle Medianizer for the YFI component of the Oracle and the ETH/USD Oracle Medianizer for the ETH component. This protects against flash-loan attacks which attempt to manipulate the reserve ratios of the pool.

5 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.