IIP: 47
Title: Upgrade FLI to use Chainlink oracles
Status: Proposed
Author: Noah Citron (@ncitron), Richard Liang (@richard)
Created: 2021-5-28
Simple Summary
Update both ETH2x-FLI and BTC2x-FLI to use Chainlink’s oracles for price feeds rather than Compound’s.
Abstract
The Flexible Leverage Index uses a smart contract called FlexibleLeverageStrategyAdapter to execute rebalances. This contract uses Compound’s Open Price Feed as a source of truth for the prices of ETH, BTC, and USDC. We propose upgrading this contract to use Chainlink for these price feeds.
Motivation
On May 19th, the prices of Ether and Bitcoin experienced a severe crash. Gas prices peaked at around 1800 gwei during the worst of it, and exposed weaknesses in Compound’s oracles. Due to the high gas prices, Keepers stopped updating the oracles. This meant that Compound believed the price of Ether and Bitcoin was significantly higher than what they were actually trading for. The FlexibleLeverageStrategyAdapter uses these oracles to determine suitable slippage values for rebalancing trades on Sushiswap. Since Compound was reporting artificially high prices, the FLI’s Sushiswap trades would fail. During this event, the FLI was never at any risk of liquidation. Additionally, since Compound uses its own oracles for liquidations, it would have not been possible to liquidate our position had prices continued to decline. Had we been using a more lively oracle, there would have been no mismatch between the oracle price and the on-chain price, preventing these issues from happening.
Specification
Overview
The FlexibleLeverageStrategyAdapter is responsible for checking prices and executing rebalances. This change will require deploying two new versions of this contract (one for each FLI product) that uses Chainlink. Additionally, the Index Coop multisig will have to add these contracts to the respective FLI managers and remove the older versions.
Technical Specification
The proposed changes to the contract can be viewed on GitHub here:
Additionally, we will have to execute a total of six transactions from the Index Coop multisig to enable these adapters. A table detailing them is provided below:
| To | Description |
| -------- | -------- | -------- |
| BaseManager (ETH2x) | Add adapter to BaseManager |
| BaseManager (BTC2x) | Add adapter to BaseManager |
| New FLI Strategy Adapter (ETH2x) |Whitelist the following keeper bots: 0x1a0e49631D8fF32bfD8141748582e75E7e40e928, 0x0663456cf49b753c8694a17cf8a53e75246cb2ca |
| New FLI Strategy Adapter (BTC2x) |Whitelist the following keeper bots: 0x0663456cf49b753c8694a17cf8a53e75246cb2ca, 0xf303FdE05c53b4545edD8568DAea56Dd10794b7F|
| BaseManager (ETH2x) | Remove old FLI Strategy Adapter (ETH2x) |
| BaseManager (BTC2x) | Remove old FLI Strategy Adapter (BTC2x) |