Keep3r Network: On-chain Oracle price feeds

Andre Cronje
2 min readNov 5, 2020

--

What are Oracles?

An oracle is an external data source that provides an answer to a specific question. For example; “what was the temperature in NYC over the past 24 hours”.

A subset of Oracle’s are price feeds. “what is the price in ETH for wBTC”.

Why do we need Oracles?

Not all data can be provided on-chain. And if it can be provided on-chain, not all data should be trusted. Two examples;

Bob and Alice make a wager on the outcome of a coin flip. Bob says heads, Alice says tails. They both lock in their ETH. Bob is the oracle source, and Bob inputs “heads” into the contract. Bob wins. Would Alice trust this outcome? It is important to have external, secure oracles.

Bob agrees to sell Alice 1 ETH. Bob creates a smart contract that takes DAI from Alice and gives her 1 ETH based on the price of ETH-DAI on Uniswap. The current price is 400 DAI = 1 ETH. When Alice calls the contract, it takes 4000 DAI from Alice. Bob added a flash loan into the contract to make ETH more expensive. It is important to have tamperproof oracles.

What are Uniquote Oracles?

Different end results require different products. If you are working with highly available assets (such as ETH, BTC, …) and require optimum security, you should use Chainlink Oracles

These come with a few restrictions;

  • Asset availability
  • ETH price freshness vs exchange freshness
  • Cost

For products like yearn.finance’s Uniswap LP impermanent loss hedge, or yearn.finance’s Uniswap loans, we needed a solution that had the following qualities;

  • Accepts any asset tradeable on Uniswap
  • Security vs data freshness

For full documentation you can read more here and for available feeds you can view here

To get up to date prices, you can simply call;

Uniquote.current(WETH, 1e18, WBTC);

While the above call has high data freshness, it has low security, an exploiter simply needs to manipulate 2 data points to be able to impact the feed. For higher security you can instead use;

Uniquote.consult(WETH, 1e18, WBTC, granularity);

granularity being the amount of readings, so granularity = 48 would be an average price over the last 24 hours. More secure, but the data freshness is 24 hours.

Read more

Documentation

Feeds

Github

--

--

Keep3r Fixed Forex Guide

2 min read

Sep 15, 2021

Keep3r Redeemable KP3R (rKP3R)

2 min read

Sep 15, 2021

vKP3R 101

2 min read

Sep 1, 2021

Keep3r expansion and consolidation

5 min read

Aug 27, 2021

Liquidity Mining Rewards v2

4 min read

Aug 15, 2021

Iron Bank Fixed Forex audit: Why audits are bad

2 min read

Aug 3, 2021

Fair launches, decentralized collaboration, and Fixed Forex

5 min read

Jul 25, 2021

Introducing Fixed Forex (USD, EUR, ZAR, JPY, CNY, etc)

1 min read

Jul 2, 2021

Keep3r V2 Oracles

2 min read

Mar 28, 2021

keep3r.network & unit.xyz

6 min read

Mar 10, 2021

Recommended from Medium

Lists

See more recommendations