[UNI-V2-AAVE-ETH] Collateral Onboarding Oracle Assessment (MIP10c3-SP26)

Preamble

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

Specification

Introduction

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

Oracle Data Model

A smart contract utilizes Uniswap primitives and liquidity reserves to calculate the price of a Uniswap Liquidity Provider (LP) token.
The reserves of the Uniswap pool, and the supply of the Uniswap 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

Substitute of (3), (4) and (7) gives us the following model for calculating the price of a Uniswap V2 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_lo = 2 * sqrt(k * price_x * price_y) / supply_lp

Oracle Supporting Data Model(s)

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    |              |

AAVE/USD (canonical)

|    Source     |  Asset Pair   | Feed Model  |
| :------------ | :------------ | :---------: |
|    Balancer   |   AAVE/USD    |    Median   |
|    Binance    |   AAVE/BTC    | 
|     Gemini    |   AAVE/USD    |
|     Huobi     |   AAVE/USDT   |
|      OKEx     |   AAVE/USDT   |
|    Uniswap    |   AAVE/ETH    |

Oracle Address

  • Mainnet - UniV2LpOracle - TBD

Supported Tools

UniV2LpOracle - Source Code
UniV2LpOracle - Tests

Remaining Work

  • Deploy Oracle from Factory Contract
  • Update MegaPoker to poke UniV2LpOracle

Summary

The Uniswap V2 AAVE-ETH pair has ~$66M of liquidity and relative to it’s daily trading volume is returning ~37% APY to LPs. This makes it an attractive candidate for LPs looking to leverage their yield.

This Oracle utilizes the existing ETH/USD and AAVE/USD Oracle Medianizers for the ETH and AAVE collateral types respectively, to price the components tokens of the pair. This protects against flash-loan attacks which attempt to manipulate the reserve ratios of the pool.

Though there is likely ample demand, the Oracle Domain Team nonetheless recommends that the initial debt ceiling be limited to 3M Dai. This is a precautionary measure to limit the Maker Protocol’s exposure to the Uniswap V2 LP Oracle smart contract until audits have completed successfully.

2 Likes

Just to calibrate expectations - when is this due? Are we talking weeks or months ?

The audit should be back before the end of the month. Then we need to fix the issues cited in the audit. Then redeploy the Oracles for the existing LP collateral types.

1 Like