HTX LearnLearned by 69 usersPublished on 2023.08.07 Last updated on 2024.02.18
Blockchain
3 lessons in total
Key takeaways
Blockchain oracle, a technology that brings real-world data onto blockchains, didn't attract much attention when it first emerged. However, it has become increasingly important with its growing use cases.
In the last bullish market, Chainlink, an oracle leader, enjoyed a surge mainly attributed to the popularity of DeFi Summer. The RWA sector has recently gained traction, with various real-world assets being tokenized, further raising the demand for oracles.
How oracles work can be explained in these steps: data retrieval, data validation, submission to blockchains, and contract execution. It is important to note that oracles are not smart contracts on blockchains.
Oracles bridge real-world data and blockchain smart contracts, with security and data credibility as the major challenges. Additionally, oracle manipulation differs from price manipulation in nature.
What is an oracle?
Blockchain oracle is a technology used to bring real-world data onto blockchains and serve as a tool for obtaining and verifying external data on blockchains. In the world of blockchain, a typical smart contract can only access its internal data without the ability to retrieve information from the real world, such as stock prices, weather data, and sports results. Oracles can bring these data onto blockchains, enabling smart contracts to execute based on accurate real-world data.
Due to a lack of use cases, oracles didn't receive much attention when they first emerged. However, with the wider adoption of smart contracts, various DeFi and NFTFi applications have sprung up, meaning that an increasing number of use cases need to interact with the real world. In the last bullish market, Chainlink, an oracle leader, enjoyed a surge partly attributed to the popularity of DeFi Summer. Recently, the RWA sector has gained traction, with various real-world assets being tokenized, such as US Treasuries, stocks, and real estate. These assets need oracles to provide price feeds for their DeFi applications, further raising the demand for oracles.
Note: RWA holders and asset change (Source: Dune)
How do oracles work?
Why does the internet, which also needs "offline" data, not face the oracle problem? This is because data on blockchains must go through consensus, meaning that the data uploaded by oracles must also be trustworthy. On the other hand, data on the internet (Web2) are centralized. Fundamentally, what oracles address is the trust problem in data sources, data processing, and price feeds, rather than the data itself.
The following steps explain how oracles work:
Data retrieval: Oracles retrieve the required data from external sources. These data can be any information from the real world, such as weather conditions, stock prices, and match results.
Data validation: After retrieving the data, oracles will validate their accuracy and authenticity. This process may involve several steps, including the validation of data sources, data authenticity, and data transmission integrity.
Submission to blockchains: Once the data are validated, oracles will submit them to the smart contracts on blockchains. Typically, a smart contract provides an interface that allows the oracle to send the data to the specified location in it.
Contract execution: After receiving the data, smart contracts will execute the pre-programmed logic and conditions accordingly. Smart contracts can make decisions, trigger events, or perform corresponding functions based on these data.
It is important to note that oracles are not smart contracts on blockchains; they bridge real-world data and blockchain smart contracts. The role of oracles is to provide real-world information for smart contracts, making them more intelligent and practical.
How oracle manipulation differs from price manipulation?
As mentioned earlier, an oracle serves as a bridge between real-world data and blockchain smart contracts. Therefore, oracle manipulation in DeFi protocols, such as those involving currencies, options, synthetic assets, algorithmic stablecoins, and automated asset management, can lead to a series of negative consequences, including stablecoin de-pegging, malicious arbitrage trading, forced liquidations, and protocol liquidity depletion. Oracle manipulation may arise from intentional attacks or accidental errors made by the oracle, or caused by issues with the oracle's data sources. Particularly, data source credibility is the most critical issue in oracle's trustworthiness, as many of these data are off-chain and cannot be fully verified. Occasionally, hacks resulting from oracle failures are reported in the crypto market.
In November 2020, due to an oracle sending incorrect prices, Compound's smart contracts accepted the feed and executed liquidations (selling loans at a discount), causing users to lose $89 million. The oracle retrieved a DAI price of $1.3, whereas the normal price was around $1. In March 2022, Deus Finance suffered a hack, losing about $3 million. According to KnownSec Blockchain Lab's monitoring analysis, the attacker borrowed about 9.7 million DEI through flash loans from SPIRIT-LP_USDC_DEI before using another flash loan to obtain 24.77 million DEI from sAMM-USDC/DEI to manipulate the price oracle, eventually leading to the liquidation of ordinary users' assets.
It is worth noting the difference between oracle manipulation and price manipulation. Although both involve manipulating price feeds to make prices deviate from the actual market supply and demand, their mechanisms are quite distinct. Price manipulation, or market manipulation, alters asset prices, while oracle manipulation uploads incorrect or invalid price feeds to blockchains, which do not reflect actual asset prices. Market manipulation essentially changes the asset's underlying supply and demand, causing its price to deviate from normal levels. On the other hand, when an oracle is manipulated, the market price still reflects the actual supply and demand, but the oracle will provide the wrong price, intentionally or unintentionally.