In most DeFi lending protocols, users must collateralize assets to borrow funds. For example, a user may collateralize ETH to borrow stablecoins. The system calculates the value of collateral based on market prices provided by oracles and determines whether the account is in a safe state.
When the price of collateralized assets drops below a certain threshold, the system triggers the liquidation mechanism, selling the collateral to repay debt. This process almost entirely relies on timely price updates from oracles, so the accuracy and speed of oracle data directly determine whether the liquidation system operates normally.
If price updates are too slow, the system may fail to trigger liquidation in time, resulting in bad debt risk for the protocol. Conversely, if prices suddenly fluctuate abnormally, it could cause unnecessary mass liquidations. To reduce such risks, DeFi protocols typically combine several mechanisms for risk control:
These designs form the basic framework of DeFi liquidation systems, with oracles serving as the core prerequisite for their operation.
While oracles aim to provide reliable data, attackers often try to manipulate price data to gain improper profits within DeFi protocols—these attacks are commonly known as oracle attacks.
A typical method is manipulating decentralized exchange prices. For instance, if a protocol uses a DEX’s spot price as oracle data, an attacker can conduct large trades to briefly change market prices and then profit from this abnormal price in lending or derivatives protocols.
Similar incidents have occurred multiple times in the DeFi ecosystem over recent years. These attacks usually share several characteristics: attackers first obtain large funds through flash loans, then manipulate prices in low-liquidity trading pairs, and finally use abnormal prices to arbitrage across other protocols. Because the entire process can be completed within a single block, the system often cannot react in time.
These cases reveal a key issue: if an oracle relies excessively on a single market’s data, its prices can be manipulated over short periods. As a result, many DeFi projects have started redesigning their oracle systems to reduce attack risks.
To mitigate price manipulation risks, DeFi protocols generally do not use market prices at a single moment but adopt more robust data processing methods. One of the most common solutions is the time-weighted average price (TWAP).
The core idea of TWAP is to average prices over a period rather than relying on spot prices. This makes it difficult for attackers to decisively influence final data by changing market prices for a short time; manipulating prices requires sustained effort and much higher cost.
Beyond time-weighted mechanisms, many oracle systems also employ multi-source data designs. That is, the system does not rely on a single exchange or market but collects price information from multiple trading platforms and aggregates it. This reduces the impact of fluctuations in any single market.
In more complex systems, oracles may also combine additional security strategies:
These mechanisms together form the security architecture of modern DeFi oracles, enabling systems to maintain stable operation amid market volatility and potential attacks.