DeFi price oracles explained: sources, TWAP, manipulation
DeFi price oracles explained: push, pull and TWAP designs, the 0.5% BTC/USD threshold, the bZx and $110M Mango Markets attacks, and how to check a protocol.

Contents
- Why a blockchain needs an oracle
- Where the price comes from: three main designs
- How often an oracle updates: deviation threshold and heartbeat
- A worked example from November 23, 2026
- How oracle manipulation happens
- How protocols defend themselves
- How to check a protocol's oracle before depositing
- Common mistakes
- FAQ
DeFi price oracles are services that bring an asset's price from the outside world onto a blockchain. A smart contract cannot look at an exchange by itself, so collateral values, liquidation triggers and derivatives settlement all depend on the number an oracle writes. Manipulation becomes possible when moving that number costs less than the profit from moving it, for example by pumping the price in a shallow pool or on a few thin exchanges and then borrowing against the inflated collateral.
Why a blockchain needs an oracle
A blockchain is deterministic: every node has to reach the same result, so a contract can only see what is already recorded on-chain. The BTC/USD rate is not there until someone delivers it. Ethereum's documentation frames the "oracle problem" as two questions: how to verify that the data came from the correct source and was not tampered with, and how to ensure it is always available and regularly updated.
Almost every DeFi application depends on the answer:
- lending protocols use the oracle price to value collateral and decide when to sell it;
- perpetual futures on DEXs take an index price from the oracle for liquidations and funding;
- collateralized stablecoins check whether backing is sufficient;
- wrapped assets such as WBTC are valued through a separate price feed when posted as collateral.
An oracle error is worse than an ordinary outage, because the contract acts on it automatically and irreversibly.
Where the price comes from: three main designs
| Design | Price source | Who pays for the update | Strength | Weak point |
|---|---|---|---|---|
| Node network (push), e.g. Chainlink Data Feeds | Each operator queries several sources and aggregates the estimates; the network writes the result to a contract | The oracle network | Reflects many venues, hard to move with one trade | Does not update every second, so the on-chain price lags between writes |
| On-demand (pull), e.g. Pyth | A signed update is fetched off-chain and delivered with the transaction | The user or the app | Fresh price at the moment of the trade | The protocol must check price age and uncertainty itself |
| On-chain pool price, e.g. Uniswap v3 TWAP | The pool's own average price over a time window | Nobody separately: data accumulates as trades happen | No external provider needed | Only as robust as the pool is deep; a thin pool can be moved with a trade |
Chainlink's documentation says node operators each query several sources for the market price and aggregate those estimates, and that low market-risk feeds rely on higher volumes across multiple markets. In Pyth's model, according to the project, a signed update is verified and stored on-chain, and any contract can read it until a newer update replaces it. Uniswap v3 keeps a tick accumulator in each pool: per its docs, the oracle is updated at most once per block, and the difference between accumulator values yields a geometric mean price for the chosen period.
How often an oracle updates: deviation threshold and heartbeat
Writing a price to Ethereum every second would cost too much, so push-style feeds update on two conditions. Chainlink describes them as follows. With the deviation threshold, nodes watch the market off-chain and write a new value once the price moves beyond a set interval. With the heartbeat, if the price stays inside the threshold, an update is still written every set number of minutes or hours.
Two practical points follow. First, the price in the contract is almost always slightly different from the market price, within the threshold. Second, if a value has gone longer than the heartbeat without an update, something is broken and the value should not be used.
A worked example from November 23, 2026
The BTC/USD feed on Ethereum mainnet has a 0.5% deviation threshold and a 3,600-second heartbeat, which is one hour. The parameters are shown on the feed page, and the records themselves can be read from the contract on Etherscan via latestRoundData.
We read the contract on November 23, 2026. It was a volatile day: per our data, bitcoin ranged from $60,386 to $64,603 over 24 hours. Here is what the oracle showed:
- Between 9:52 AM and 12:41 PM ET, eight updates landed in the contract, 4 to 54 minutes apart. All arrived before the one-hour heartbeat, meaning price movement triggered them.
- The latest update came at 12:41:59 PM ET: $61,463.81. The previous one, at 11:47:35 AM ET, was $61,892.28. The gap of −0.69% exceeded the 0.5% threshold, so the network wrote a new value.
- As of 1:00 PM ET, our dashboard had BTC trading near $61,696. That is 0.38% above the number in the contract, below the threshold, and no new update had appeared by then.
So at 1:00 PM ET a lending protocol reading this feed valued bitcoin roughly $230 below the market. For collateral with a buffer of tens of percent, that is noise. For a position at the edge of liquidation, or a high-leverage protocol, it is a quantity that goes into risk parameters. For the live price and volatility, see the dashboard and the bitcoin page.
How oracle manipulation happens
In most cases nobody hacks the oracle itself. The attacker changes what the oracle faithfully measures. There are three typical patterns.
Spot price from a single pool. A protocol reads the current price from a DEX pool. The attacker takes a flash loan, moves the pool price with a large trade, borrows against the overvalued collateral in the same transaction and repays the loan. bZx was hit this way in February 2020: according to The Block, the attacker took a 7,500 ETH flash loan and pushed the sUSD price above $2 with purchases on Kyber and Uniswap; the protocol lost 2,388 ETH, nearly $645,000 at the time. For how such pools work, see our guide to liquidity pools.
An illiquid token on real exchanges. An oracle can be built properly and pull prices from several venues, but if the token itself trades thinly, the price can be moved in the market. Mango Markets was attacked this way on October 11, 2022. The CFTC said Avraham Eisenberg used two anonymous accounts to open large leveraged positions and then rapidly bought MNGO on three exchanges that were inputs for the oracle; the price jumped over 13-fold in 30 minutes, and he withdrew more than $110 million in assets against the inflated position. He later returned about $67 million. In May 2025 a federal judge vacated the convictions in the criminal case, The Block reported.
One venue instead of the market. The price on a single exchange can drift far from the global price for minutes. On November 21, 2026, the BTC/CAD pair on Kraken fell as low as C$24,250 while the rest of the market was far higher. An oracle with that pair as its only source would have passed the price to a contract as real.
Chainalysis has put a number on the problem: by its estimate, DeFi protocols lost $403.2 million in 41 oracle manipulation attacks in 2022.
How protocols defend themselves
Time averaging (TWAP). An average over a window reacts weakly to a spike, so shifting it takes time and money. Uniswap Labs' analysis from October 2022 says most protocols use a rolling 30-minute window. On the authors' September 2022 data, moving the 30-minute TWAP of the USDC/WETH pool by 20% within two blocks required a swap of 709 billion USDC. That figure is for one of the deepest pools of the period; for a small pool it is orders of magnitude lower. The same post describes a risk that appeared after Ethereum moved to proof of stake: a validator assigned several consecutive blocks can hold a shifted price without the risk of arbitrageurs pushing it back.
Multiple sources and risk categories. Chainlink sorts feeds by market risk and warns that low or inconsistent trading volume and concentration of trading on one venue make a price vulnerable. Protocols usually set lower borrowing limits for assets of that kind.
Freshness checks. The contract compares the update time with the current time and rejects a price that is too old. Pyth's SDK has getPriceNoOlderThan() for this, and the project's best practices note that each price comes with a confidence interval: when it is too wide relative to the price, protocols are advised to pause new activity.
Circuit breakers. Chainlink describes circuit breakers that monitor for stale prices, drastic price changes and prices nearing a preset minimum or maximum, and can pause a contract. Layer 2 networks add one more check: whether the sequencer is running. In the documentation example, the contract waits 3,600 seconds after a sequencer restart before trusting the price again.
A fallback source. In the AaveOracle contract, per Aave's docs, each asset has its own price source and a fallback oracle is provided for.
How to check a protocol's oracle before depositing
- Find the oracle section in the docs: which provider and which feed is used for each collateral asset.
- Look at the feed parameters: deviation threshold and heartbeat. The wider they are, the further the on-chain price can lag.
- Assess the asset itself: where it trades and how deep the market is. A thin token used as collateral is the main warning sign, however good the oracle.
- If the price comes from a DEX pool, find out whether it is spot or TWAP, the window length and the pool's liquidity.
- Check for borrow caps on risky assets, a fallback source and the ability to pause.
- Read the audit: nearly every report has a section on oracles.
Common mistakes
- Assuming a solid oracle protects against everything. An oracle reports the market price. If a token's market can be moved for a few million dollars, an honest oracle will report the moved price.
- Confusing the contract price with the exchange price. There is always a gap within the deviation threshold, plus write latency in a volatile market.
- Thinking TWAP solves the problem. Averaging makes an attack more expensive but slows the reaction: in a real crash, the protocol values collateral at a stale, higher price for a while.
- Ignoring the price type. For wrapped and yield-bearing tokens a protocol can use the market price or a calculated exchange rate to the underlying asset. With the first, a brief market dip triggers liquidations; with the second, the risk shows up only if the backing is actually gone.
- Forgetting network congestion. When gas is expensive, an update can be delayed exactly when the price is moving fastest.
FAQ
Is an oracle a separate blockchain? Not necessarily. It can be a network of independent nodes, a set of publishers signing prices, or simply a contract that computes a pool's average price.
Can Chainlink or Pyth themselves be hacked? In the well-known large cases, including Mango Markets, attackers targeted the token's market or the way a protocol used the price, not the oracle network. Provider error remains a risk, which is why protocols add freshness checks and fallback sources.
Why does the price in a protocol differ from the exchange price? A feed updates when the price deviates beyond the threshold or on the heartbeat. As of November 23, 2026, BTC/USD on Ethereum uses 0.5% and one hour, so a gap of a few tenths of a percent is normal operation.
Does this matter if I just hold bitcoin? Not directly: the Bitcoin network does not need oracles. The risk appears once coins enter DeFi as collateral, in a pool or as a wrapped token.
This is not investment advice.



Comments