- Blockchain oracles bring real-world information to the blockchain network.
- Price oracles are widely used in DeFi and hold a hierarchical power in the execution of smart contracts.
- While price oracles enable many application use cases, it is also the single point of failure that faces latency, attack, manipulation, and technical risks.
What are price oracles?
Blockchain oracles are a bridge that connects the real world and the blockchain network, providing the information needed for smart contract execution. In particular, price oracles fetch the real-time price of assets and feed them into a smart contract. Although oracles act as a data source for smart contracts, they are not a direct source of data but rather a tool to query, retrieve, verify and provide off-chain data and feed them to the blockchain network.
Blockchain oracles are necessary for decentralized finance (DeFi) because blockchains do not have on-chain data saved in their ecosystems. To refer to these data, this information has to be sourced from other places.
Types of oracles
Oracles can be classified in multiple ways. In this article, let’s categorize oracles from three views:
Source of information –Hardware oracles and Software oracles
- Hardware oracles: Hardware oracles, also called off-chain oracles, collect data from the physical world, convert them to digital values, and feed them into a smart contract. One example of a hardware oracle can be given in the food supply chain where if one type of food moves through the supply chain, then the information is automatically relayed to the smart contracts handling it, and then the smart contract will take proper action based on the information.
- Software oracles: Software oracles, also called on-chain oracles, take information from online sources and send the information to the blockchain. Online information can come from anywhere including websites, servers, and online databases as long as they are on the web. For blockchains, this information usually comes from cryptocurrency exchanges.
The direction of information – Outbound oracles and Inbound oracles
Inbound oracles use external sources to transmit data to the smart contracts, while outbound oracles send the information generated by smart contracts to the outside world.
The degree of trust – Centralized oracles and Decentralized oracles
- Centralized oracles rely on a single entity to provide information from an external source to a smart contract. There is only one single node responsible for the information provided, therefore it is less secure and more vulnerable to being corrupted and attacked by malicious data being fed into the smart contract.
- Decentralized oracles, on the other hand, have multiple external sources to provide external information to feed to the smart contracts. The multiple sources in decentralized oracles work on the Schelling points game theory where all data are provided without colliding with each other, and the Schelling game determines whether the data point or amendments proposed are valid and acceptable. Because there is no centralized authority that controls the oracles, the data transmitted using decentralized oracles can be verified and trusted. The best-known decentralized oracle network is Chainlink, whose smart contracts provide validated information from various data sources.
How are price oracles used in DeFi?
Price oracles introduce several blockchain use cases by connecting the chain with the outside data. They are especially important for DeFi projects because, without oracles, smart contracts would be limited to the scope of information within their own networks. The following are examples of several use cases of price oracles in DeFi.
Derivative platforms use price oracles to calculate the value of assets. For example, SynFutures pulls the spot price of each asset from Chainlink, Uniswap v1, Sushiswap, and Pancake swap, depending on the network used. The spot price is used as a guide for futures traders to make decisions and it also serves as the trading price at expiration.
Lending protocols rely on price oracles to maintain collateral ratios. For example, when a collateral asset’s price drops, the price oracles provide the value of the asset to the protocol, so the protocol knows the value of the collateral drops, and therefore may make the decision of liquidating the position. For example, AAVE leverages Chainlink’s oracle to determine the threshold for the liquidation of crypto-backed loans.
Crypto-back stablecoins like DAI use a similar principle as lending protocols as DAI’s peg to USD is maintained using collateralized assets. Price oracles are used to determine the value of the collateralized asset and determine if DAI is sufficiently collateralized or not.
Index services use price oracles to inquire about index component prices.
Insurance protocols need price oracles to verify claims and to prevent fraud. For example, Nexus Mutual uses price oracles to evaluate its multi-currency capital pool and rebalance the minimum capital requirement.
Prediction markets rely on oracles to get the outcomes of off-chain events.
All these applications would be impossible without oracles as smart contracts have no access to the sources outside of the blockchain.
Risks of using oracles
For DeFi applications, an oracle is the source of information that triggers a smart contract to do certain actions. Therefore, an oracle controls how a smart contract is executed. If an oracle goes down, produces incorrect values, is manipulated, or has a vulnerability, the whole system could be compromised. This is often referred to as “The Oracle Problem”.
In June 2020, Synthetix, a synthetic asset issuance protocol, suffered a loss of over 37 million sETH, worth over $1 billion at that time, due to an oracle misreporting price information. The oracle input a price 1000x higher than the actual rate for Korean Won (KRW) and a trading bot simply took advantage of it. While the system was reporting the incorrect information, the bot conducted several transactions, making over $1 billion in profit. While oracle attacks do not happen often or easily, it is important to realize the risk exists and DeFi operators should pay attention to avoid these risks from happening.
There are several types of risks related to oracles:
- Price delays: There are many reasons that can cause price delays and as a result, price deviations. Network congestion is one of the common reasons, and intentional control of the oracles could also cause price delays. Another factor contributing to the problem is that on-chain prices update on block time while off-chain events follow linear time. Price delays could lead to serious consequences at times.
- Majority attack: Oracles can only function properly if there is proper trust among the involved parties. The majority attack happens when a single entity owns a majority of nodes. It can report false data but still be in the majority, thus control the smart contract execution.
- Mirroring attack: When one node shares information with others in a set of decentralized oracles, the other nodes may choose to report the same data. If the data is false information, this then becomes an issue. This type of attack is called mirroring.
- Data manipulation: If an oracle sources data from an unprotected source or is manipulated by a third party, the information could be easily manipulated.
- Oracle bug: The oracle itself could have bugs that can be exploited. If an oracle isn’t secure in itself, how can it be relied on to provide information to the smart contracts?
Price oracles are critical to the operations of many DeFi protocols because they provide off-chain data to smart contracts. While oracles have enabled many use cases in DeFi, unsafe oracles and oracle manipulation could cause huge losses to applications. DeFi protocols should choose price oracles and weight aspects like security, timeliness, and decentralization.
Explore open, trustless Bitcoin Hash Rate Oracles with SynFutures. Learn more.
Disclaimer: SynFutures Academy does not guarantee the reliability of the site content and shall not be held liable for any errors, omissions, or inaccuracies. The opinions and views expressed in any SynFutures Academy article are solely those of the author(s) and do not reflect the opinions of SynFutures. The SynFutures Academy articles are for educational purposes or information only. SynFutures Academy has no relationship to the projects mentioned in the articles, and there is no endorsement for these projects. The information provided on the site does not constitute an endorsement of any of the products and services discussed or investment, financial, or trading advice. A qualified professional should be consulted prior to making financial decisions.