[GUNI DAI-USDC] Collateral Onboarding Oracle Assessment (MIP10c3-SP41)

Preamble

MIP10c3-SP#: 41
Author(s): Niklas Kunkel (@NiklasKunkel)
Contributors:
Type: Process Component
Status: RFC
Date Proposed: 2020-09-10
Date Ratified: <yyyy-mm-dd>

Specification

Introduction

This Oracle would provide the GUNI-DAI-USDC/USD price as part of the collateral onboarding process for the GUNI-DAI-USDC LP token.

Oracle Data Model

A smart contract which utilizes the Uniswap V3 and Gelato Network primitives and liquidity reserves to calculate the price of a GUNI LP token.

The reserves of the underlying Uniswap V3 pool, and the supply of the Uniswap LP token are used as inputs to the model. The MakerDAO MakerDAO Oracles are used to price the underlying assets in a manner that is resistant to price manipulation of the liquidity pool.

Let:

p0 = price of token0 in USD
p1 = price of token1 in USD
UNITS_0 = decimals of token0
UNITS_1 = decimals of token1
Then:

token1/token0 = (p0 / 10^UNITS_0) / (p1 / 10^UNITS_1)               [Conversion from Maker's price ratio into Uniswap's format]
              = (p0 * 10^UNITS_1) / (p1 * 10^UNITS_0)
sqrtPriceX96 = sqrt(token1/token0) * 2^96                           [From Uniswap's definition]
             = sqrt((p0 * 10^UNITS_1) / (p1 * 10^UNITS_0)) * 2^96
             = sqrt((p0 * 10^UNITS_1) / (p1 * 10^UNITS_0)) * 2^48 * 2^48
             = sqrt((p0 * 10^UNITS_1 * 2^96) / (p1 * 10^UNITS_0)) * 2^48
Let: 

r0 = reserve balance of token0 in Uniswap V3 pool
r1 = reserve balance of token1 in Uniswap V3 pool
totalSupply = total number of LP tokens in the static price range

The reserve balance of each token in the GUNI static price range can be called via the method: getUnderlyingBalancesAtPrice(uint160 sqrtPriceX96) using the sqrtPriceX96 as a parameter. This in turns calls the underlying Uniswap V3 method getAmountsForLiquidity(…).

(r0, r1) = getUnderlyingBalancesAtPrice(sqrtPriceX96);

With the underlying reserves in the static price range determined in a manipulation-resistant manner, the price of the LP token can be computed as follows. Note that this is the same formula as equation (7) in the Uniswap V2 LP Oracle Data Model.

Token Price = TVL / totalSupply
            = (r0 * p0) + (r1 * p1) / totalSupply

There are some drawbacks to this model that need to be acknowledged. Liquidity in Uniswap V3 tends to be non-fungible because it is fragmented across different price ranges. Fungibility is necessary for the Maker Protocol to onboard collateral in a uniform and scale-able manner. In order to achieve fungibility of liquidity, the price range, or in other words spread, needs to be static.

This particular Oracle is for the GUNI-DAI-USDC LP Token which provides concentrated DAI liquidity against USDC in the price range 0.9994 and 1.0014.

Oracle Supporting Data Model(s)

DAI/USD (canonical)

|    Source     |  Asset Pair   |  Feed Model  |
| :------------ | :------------ | :----------: | 
|      1        |    DAI/USD    |   constant   |

USDC/USD (canonical)

|    Source     |  Asset Pair   |  Feed Model  |
| :------------ | :------------ | :----------: | 
|      1        |    USDC/USD   |   constant   | 

Oracle Address

  • Mainnet - GUniLPOracle - TBD

Supported Tools

GUniLPOracle - Source Code
GUniLPOracle - Tests

Remaining Work

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

Summary

This proposal would create an Oracle for GUNI-DAI-USDC/USD as part of the collateral onboarding process. It uses the existing DAI/USD and USDC/USD Oracles to price the pair component tokens. These are both static DSValue Oracles with values of 1 DAI/USD and 1 USDC/USD respectively.

Note that this Oracle does not take into account the trading fees generated by the underlying Uniswap V3 DAI/USDC LP token on its own. The compounding of these fees into the underlying LP tokens is handled by the Gelato Network. It must be noted that Gelato Network could theoretically stop compounding these trading fees. However, participants in the Gelato Network generate fees through executions actions such as the aforementioned rebalancing. Hence ultimately incentives are aligned between the Maker Protocol and the Gelato Network to efficiently compound trading fees. In the unlikely event that there is an outage on the Gelato Network, the Oracle value of the LP token should remain relatively unaffected as fees over short periods of time represent but a tiny fraction of the value of the LP token.

The majority of the code (~97%) for the GUniLPOracle has been recycled from the previous UniV2LPOracle, which was audited by ABDK and is in active use in the Maker Protocol. However while the number of changes that were made were small, they are significant changes which affect the methodology used to calculate the price of the LP token. This is the first time the Maker Protocol is utilizing both Uniswap V3 and the Gelato Network, and so it behooves the community to act cautiously with respect to the deployment and utilization of the Oracle and its corresponding GUNI-DAI-USDC collateral.

Therefore the Oracle Core Unit recommends that the debt ceiling be limited at first and progressively raised as the risk of a smart-contracts exploit diminishes over time. The Oracle Core Unit recommends an initial debt ceiling of 10,000,000 Dai.

This debt ceiling is high enough to attract the attention of hackers, while small enough for the Maker Protocol to absorb the losses due to a size-able surplus buffer. It also correlates with the risk management used for the Uniswap V2 LP Oracle launch which initially had 3 LP Oracles each with a debt ceiling of 3M. This debt ceiling recommendation is exclusively from the Oracle scope, and should not supersede debt ceiling recommendations from other Core Units that may be lower.

7 Likes