What Can We Learn From Oracles on Ethereum?
What kind of oracle solution would support the Tezos ecosystem in the best way? Currently there are multiple options available on Ethereum. On Tezos the development is still limited, but I believe having more oracle solutions on Tezos could stimulate DeFi development.
So what is available on Ethereum right now?
MakerDAO uses a custom oracle managed by a group of 14 pseudonymous individuals and public organizations to determine asset prices and exchange rates for supported assets. The group of 14 participating feeds are determined by a DAO governance vote, and is subject to change.
The oracle itself consists of two modules, a broadcaster and relayer. Each feed runs a broadcaster which pulls asset prices, signs them with their private key, and broadcasts them through a secure network. A relayer monitors the broadcaster messages, ensures they are within a predetermined spread (1%), aggregates the data, and submits it to Ethereum as a single transaction. Before the Maker system updates with the new price, however, a time period enforced by the Oracle Security Module (OSM) must be waited. This ensures that new price values propagated by the system are not taken up until a specified time in the future.
Maker does not have an incentive structure for relayers or feeds, but has proposed one such model which would compensate feeds, relayers, and other participants for their contributions to the system. The current design also maintains a whitelist of specific addresses who can access the oracle’s data.
ChainLink’s reference price feeds rely on a set of trusted parties to provide asset prices to the Ethereum blockchain. ChainLink also offers a service that allows users to request alternate off-chain price data from trusted oracle providers or, alternatively, set up a network of oracles themselves. ChainLink provides free access to reference price feeds for the ETH/USD and BTC/USD pairs (as well as many others). These feeds rely on a set of 21 trusted parties to submit reference price data. The ETH/USD pair updates every 0.5% deviation in price and has a heartbeat of 2 hours. The BTC/USD pair updates every 1% deviation in price and also has a heartbeat of 2 hours. Unlike MakerDAO, ChainLink does not have a decentralized governance process to determine participating parties in its reference price feeds. ChainLink itself is responsible for adding/removing parties from the system, centralizing control of the reference oracles.
ChainLink allows application developers to run their own ChainLink node or request other off-chain data, but requires payment in the LINK token. LINK is an ERC-667 token that implements a custom function that allows for the transfer of data along with token transfers. This mechanism is used to query and transfer resulting data from ChainLink nodes to on-chain smart contracts. If an application developer wishes to query non-reference data using Chainlink, they can either run their own ChainLink node, or query one of ChainLink’s trusted nodes. Each node that is queried charges the requester a predetermined amount of LINK. Requesters can call multiple nodes to achieve the desired degree of decentralization, but are charged for each query they make.
ChainLink gives developers the option to run their own ChainLink node that responds to requests, but requires these developers to buy and send the LINK token to themselves for each request they make. ChainLink will also be establishing a whitelist for all on-chain reference price data (although it is currently free). The ChainLink organization will control all changes (additions/deletions) to this list.
The decentralized lending platform Compound uses a custom application-specific price oracle.
Compound’s oracle relies on a single, centralized poster (price gathering script) to pull the price of a basket of assets relative to Ether from many different exchange sources. This trusted party then posts price updates to the blockchain each time it detects a 1% deviation in price. The newly reported price must be within a 10% bound of an anchor price that is updated every hour. Large price movements (>10%) must be set manually using a corresponding, specific hardware key. This key is currently controlled by the Compound team.
Compound has also developed a second oracle design they call the Compound Open Oracle System. Using the Open Oracle system, anyone wishing to report a price can do so. This report is then propagated via a p2p network to all other nodes in the system. Anyone with gas and a connection to the Ethereum network can then post the signed price data on-chain. A single on-chain contract, known as the Data Contract, is responsible for holding and validating all price data. This contract sorts the reported information by price reporter. Any on-chain application can request to view price data by selecting a subset of the reported price feeds. While Compound expects to productionize this oracle in the near future (still completing audits), it has yet to be launched on the Ethereum mainnet.
Uniswap is a constant-product automated market maker (or constant-product AMM), that allows users to exchange asset pairs on the Ethereum blockchain as long as a predetermined product of the reserves remains constant. Uniswap exists entirely on the Ethereum blockchain, and is completely decentralized, with no single party having control of the asset pool or prices. Uniswap’s reserve balances are public and viewable by any party at any time, thus Uniswap can be used as a price oracle to determine the marginal price of an asset.
Uniswap relies on arbitrageurs to ensure its quoted asset prices are close to the reference market price. If the price quoted by Uniswap differs from the true market price of the traded pair, arbitrageurs can always make a profit from executing a trade with this oracle. Thus, it is always likely to trade close to a reference market price.
Using Uniswap as an oracle does have downsides, however, as low liquidity asset pools are vulnerable to relatively inexpensive manipulation as was demonstrated in the bZx attack. Thus, Uniswap should only be used as an oracle if the service using it does not depend on relatively small changes in market price, or over a very short period of time.
Uniswap v2 will incorporate price feeds focused on solving both of the above problems. Each traded pair measures the current Uniswap market price at the beginning of each block. This price iis set by the last transaction in a previous block, and is thus expensive to manipulate. Uniswap V2 adds this end-of-block price to a cumulative-price variable in the contract that is weighted by the time this price has existed. This variable represents a sum of the Uniswap price for every second in the entire history of the contract. External contracts seeking a manipulation resistant price from Uniswap can read this variable and calculate their required price.
Dfusion is a decentralized exchange that uses batch auctions and a multi-dimensional order book to set prices for asset pairs. Unlike Constant-Function Market Makers or traditional exchanges that maintain separate liquidity pools/order books for individual asset pairs, Dfusion aggregates all orders into a single multi-dimensional order book that consists of multiple different token pairs. It then uses a time-based batch auction to set cleaning prices for each token exchanged in a batch. Batch auction settlement prices can be used as an oracle service by projects seeking access to an on-chain oracle service.
Dfusion’s settlement times occur approximately every 5 minutes. All orders submitted before a batch is settled can be included in the final settlement. The auction accepts settlement proposals from anyone. Solutions are simply checked for validity and if they are ‘better’ than existing solutions. If a solutions is judged to be ‘better’ than another, it replaces the previous solution. All trades are finalized after 5 minutes.
The Coinbase Oracle is a verifiable price feed for the BTC/USD and ETH/USD markets that anyone can publish on-chain. The price feed is accessible through a centralized API, and is updated every minute with data sourced from Coinbase Pro.
All posted prices are signed using the Oracle’s public key. This allows anyone to post price data on-chain, without trusting the poster of the data. The Oracle implements a filtering mechanism that automatically rejects price points that significantly deviate from the reported asset’s expected volatility. The result is a trusted, but reliable feed that any DeFi protocol can integrate easily.
What do you want to see on Tezos?
While the Tezos defi ecosystem evolves, I think current and upcoming projects could benefit from an oracle solution that has a novel architecture and works in a semi-trustless manner.
A decentralized oracle network could be a goal to achieve as more DeFi projects start and volume increases in Tezos, but there are some obstacles such as incentivising node operators (without a seperate token distribution), accuracy and validation of feed, resistance from various social and technical attacks etc. At Tezsure we would love to have a trusted and verified oracle system to build on.
I would really like to see an open discussion in regards to oracles on Tezos. It is still early, so it is still pretty much an open canvas. Let’s paint together!