Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create oracle adapters for each Funding instance #140

Open
1 of 8 tasks
dapp-whisperer opened this issue May 5, 2022 · 4 comments
Open
1 of 8 tasks

Create oracle adapters for each Funding instance #140

dapp-whisperer opened this issue May 5, 2022 · 4 comments
Assignees

Comments

@dapp-whisperer
Copy link
Contributor

dapp-whisperer commented May 5, 2022

Funding Assets

  • wBTC
  • renBTC
  • Badger ibBTC LP Vault
  • ETH
  • FRAX
  • USDC
  • CVX
  • Badger
@dapp-whisperer
Copy link
Contributor Author

After this is complete, will spawn new issues to integrate through the rest of the project:

  • testing
  • param dump script
  • monitoring website
  • oracle price bot watcher

@shuklaayush
Copy link
Contributor

shuklaayush commented May 24, 2022

CTDL-WBTC

CTDL-renBTC

CTDL-ETH

CTDL-X [USDC/FRAX/CVX/BADGER]

ibBTC LP vault

@sajanrajdev
Copy link
Contributor

Adapters logic review:

CTDL-WBTC - LGTM

  • Fetches price from Curve's pool's price_oracle() directly

CTDL-renBTC - LGTM

  • Fetches wBTC/BTC price from Chainlink feed
  • Fetches wBTC/CTDL price from Curve's pool price_oracle()
  • (wBTC/CTDL)/(wBTC/BTC) = BTC/CTDL

CTDL-ETH - LGTM
From https://github.com/Citadel-DAO/citadel-contracts/blob/d8c3dceb0e665f9f9e95ad962537c6156192e69d/src/oracles/CtdlEthChainlinkProvider.sol by:

  • Fetches wBTC/BTC price from Chainlink feed
  • Fetches BTC/ETH price from Chainlink feed
  • wBTC/BTC * BTC/ETH = wBTC/ETH
  • Fetches wBTC/CTDL price from Curve's pool price_oracle()
  • (wBTC/CTDL)/(wBTC/ETH) = ETH/CTDL

From https://github.com/Citadel-DAO/citadel-contracts/blob/8dfa7bc46652d4770f4fb14a8a08ebca01cd5e2b/src/oracles/CtdlAssetChainlinkProvider.sol by:
(With Asset = ETH, Base = USD)

  • Fetches wBTC/BTC price from Chainlink feed
  • Fetches BTC/USD price from Chainlink feed
  • Fetches ETH/USD price from Chainlink feed
  • wBTC/ETH = wBTC/BTC * ((BTC/USDC)/(ETH/USD))
  • Fetches wBTC/CTDL price from Curve's pool price_oracle()
  • (wBTC/CTDL)/(wBTC/ETH) = ETH/CTDL

CTDL-X [USDC/FRAX/CVX/BADGER] - LGTM
(With Asset = X, Base = USD)

  • Fetches wBTC/BTC price from Chainlink feed
  • Fetches BTC/USD price from Chainlink feed
  • Fetches X/USD price from Chainlink feed
  • wBTC/X = wBTC/BTC * ((BTC/USD)/(X/USD))
  • Fetches wBTC/CTDL price from Curve's pool price_oracle()
  • (wBTC/CTDL)/(wBTC/X) = X/CTDL

(With Asset = X, Base = ETH)

  • Fetches wBTC/BTC price from Chainlink feed
  • Fetches BTC/ETH price from Chainlink feed
  • Fetches X/ETH price from Chainlink feed
  • wBTC/X = wBTC/BTC * ((BTC/ETH)/(X/ETH))
  • Fetches wBTC/CTDL price from Curve's pool price_oracle()
  • (wBTC/CTDL)/(wBTC/X) = X/CTDL

ibBTC LP vault - LGTM

  • Fetches wBTC/BTC price from Chainlink feed
  • ibBTCCrv/BTC = ibBTCCrv.ppfs() * ibBTCCrv_Curve_pool.get_virtual_price()
  • Fetches wBTC/CTDL price from Curve's pool price_oracle()
  • ibBTCCrv/CTDL
  • ibBTCCrv/BTC * (wBTC/CTDL)/(wBTC/BTC) = ibBTCCrv/CTDL

Chainlink Data Feeds required:
wBTC/BTC: https://data.chain.link/ethereum/mainnet/crypto-other/wbtc-btc
BTC/ETH: https://data.chain.link/ethereum/mainnet/crypto-eth/btc-eth
BTC/USD: https://data.chain.link/ethereum/mainnet/crypto-usd/btc-usd
ETH/USD: https://data.chain.link/ethereum/mainnet/crypto-usd/eth-usd
USDC/USD: https://data.chain.link/ethereum/mainnet/stablecoins/usdc-usd
FRAX/USD: https://data.chain.link/ethereum/mainnet/stablecoins/frax-usd
CVX/USD: https://data.chain.link/ethereum/mainnet/crypto-usd/cvx-usd
BADGER/USD: Non
USDC/ETH: https://data.chain.link/ethereum/mainnet/stablecoins/usdc-eth
FRAX/ETH: https://data.chain.link/ethereum/mainnet/crypto-eth/frax-eth
CVX/ETH: https://data.chain.link/ethereum/mainnet/crypto-eth/cvx-eth
BADGER/ETH: Non

Notes:

  • All Chainlink price feeds are fetches through a wrapper that integrates several safety checks (staleness, 0 price..) - LGTM
  • There doesn't seem to be any active Chainlink feeds for BADGER - Could alternatively fetch on-chain from its different LPs

Adapters LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants