Price Feed
A price feed is a data stream that provides real-time or near-real-time asset prices to smart contracts, DeFi protocols, and trading systems.
Key Takeaways
- Price feeds deliver external market data to blockchains: because smart contracts cannot access off-chain information natively, price feeds bridge this gap by aggregating prices from exchanges and data providers and publishing them on-chain through oracle networks.
- Two update models dominate: push-based feeds (like Chainlink) automatically post updates on-chain when a deviation threshold or heartbeat timer is hit, while pull-based feeds (like Pyth) let applications fetch the latest price on demand, trading lower gas costs for consumer-side complexity.
- Feed accuracy is critical for DeFi security: price feeds trigger liquidations, value collateral, and set swap rates. Manipulated or stale feeds have caused hundreds of millions of dollars in losses through oracle manipulation attacks.
What Is a Price Feed?
A price feed is a data service that supplies real-time or near-real-time asset prices to on-chain applications. Blockchains are deterministic, isolated systems with no native ability to query external APIs, databases, or market data. This limitation, known as the oracle problem, means that any smart contract needing to know the price of ETH, BTC, a stablecoin, or any other asset must rely on an external data pipeline to deliver that information on-chain.
Price feeds solve this by aggregating quotes from multiple sources (centralized exchanges, decentralized exchanges, OTC desks, and market makers), computing a consensus price, and making it available to smart contracts through standardized interfaces. The feed acts as the bridge between real-world markets and on-chain logic.
Virtually every major DeFi protocol depends on price feeds. Lending platforms use them to determine when to liquidate undercollateralized positions. Decentralized exchanges use them to set mark prices for perpetual contracts. Stablecoin protocols use them to value collateral and maintain their peg. The accuracy and reliability of these feeds is not optional: it is the foundation of protocol solvency.
How It Works
Price feed systems have three layers: data collection, aggregation, and on-chain delivery. Each layer introduces design choices that affect freshness, cost, and security.
Data Collection
Feed providers source price data from multiple venues to prevent any single exchange from being a point of manipulation. Typical sources include major centralized exchanges (Binance, Coinbase), decentralized exchanges (Uniswap, Curve), and institutional trading desks. Some providers rely on independent node operators who each fetch data from these sources. Others use first-party publishers: the exchanges and market makers themselves submit prices directly.
Aggregation
Raw data from individual sources gets aggregated into a single reference price. Common aggregation methods include median calculation (resistant to outliers), volume-weighted averages, and outlier removal. The aggregation step is critical: it ensures that a single compromised or illiquid source cannot skew the reported price.
On-Chain Delivery
The aggregated price must reach the blockchain where consuming contracts live. Two models dominate:
- Push model: the oracle network automatically submits price updates on-chain when certain conditions are met. Chainlink, the largest push-based provider, triggers updates when the price deviates beyond a set threshold (e.g., 0.5% for ETH/USD) or when a heartbeat timer expires (e.g., every 3,600 seconds). Whichever condition is met first triggers the update.
- Pull model: prices are computed and signed off-chain but only posted on-chain when an application requests them. Pyth Network and RedStone use this approach. The consumer includes the signed price data in their transaction, and the on-chain contract verifies the signature before accepting it. This avoids paying gas for updates nobody consumes.
Reading a Price Feed On-Chain
Chainlink established the standard interface for consuming price feeds in Solidity. Most protocols interact with feeds through the AggregatorV3Interface, calling latestRoundData() to retrieve the current price:
// Solidity example: reading a Chainlink price feed
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
contract PriceConsumer {
AggregatorV3Interface internal priceFeed;
constructor() {
// ETH/USD on Ethereum mainnet
priceFeed = AggregatorV3Interface(
0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419
);
}
function getLatestPrice() public view returns (int256) {
(
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
) = priceFeed.latestRoundData();
// Check for stale data
require(
updatedAt > block.timestamp - 3600,
"Price feed is stale"
);
return answer; // 8 decimals for USD pairs
}
}The updatedAt timestamp is essential for production use. Protocols must check this value against the feed's known heartbeat period to detect stale data. On Layer 2 networks like Arbitrum or Optimism, contracts should also verify the L2 Sequencer Uptime Feed to ensure the sequencer is operational.
Major Providers
Chainlink
Chainlink operates the largest oracle network with over 2,000 price feeds across 40+ blockchains, securing over $100 billion in total value as of 2025. Its Decentralized Oracle Network (DON) uses Off-Chain Reporting (OCR): node operators independently fetch prices, a leader aggregates observations into a single report, followers validate and co-sign, and a single transaction posts the median on-chain. This design reduces gas costs compared to one transaction per node. Chainlink holds roughly 63-67% of the oracle market overall and over 83% on Ethereum.
Pyth Network
Pyth takes a pull-based, first-party approach. Over 120 institutional data publishers (exchanges, market makers, and trading firms) stream prices directly to Pythnet, a dedicated Solana-based appchain. Pyth aggregates these inputs into a price plus a confidence interval that reflects publisher agreement. Applications fetch signed prices on demand across 40+ chains, achieving sub-second update latency at roughly 300-400ms. Pyth reports over 3,000 price feeds and claims 60%+ market share in the derivatives sector.
RedStone
RedStone uses a modular architecture that separates data collection from delivery. In its Core (pull) model, signed data packages are injected directly into transaction calldata. The on-chain contract verifies signatures at execution time, reducing oracle costs by up to 90% compared to traditional push feeds. RedStone supports over 1,250 asset feeds across 70+ chains and has secured $8.5+ billion in total value locked.
Other Providers
Additional oracle networks serve specialized niches. API3 runs first-party oracles where API providers operate their own nodes (Airnodes) rather than relying on intermediaries. Band Protocol operates BandChain, an independent Cosmos-based blockchain where validators reach consensus on external data. Chronicle (formerly Maker Oracles) serves Sky/MakerDAO with feeds sourced exclusively from Tier 1 primary sources. Tellor uses a dispute-based model where reporters stake tokens and anyone can challenge inaccurate submissions.
Use Cases
Lending and Liquidations
Lending protocols like Aave and Compound rely on price feeds to continuously value collateral and determine borrowing capacity. Each position has a health factor calculated as total collateral value times the liquidation threshold divided by total borrowed value. When the health factor falls below 1, the position becomes eligible for liquidation. Without accurate price feeds, protocols cannot distinguish solvent positions from insolvent ones, and bad debt accumulates.
Stablecoin Peg Maintenance
Collateralized stablecoin systems (like Sky/MakerDAO's DAI) need continuous price feeds for every accepted collateral type. If ETH drops 20% in an hour, the protocol must know immediately so it can liquidate undercollateralized vaults before the stablecoin loses its peg. Stablecoin protocols like USDB and other peg mechanisms depend on reliable oracle infrastructure for collateral management.
Perpetual Futures and Derivatives
On-chain perpetual futures platforms (GMX, dYdX, Hyperliquid) use price feeds as mark prices for position valuation and funding rate calculations. These platforms require low-latency feeds, often sub-second, to prevent traders from exploiting stale on-chain prices against more current off-chain markets. Pyth and RedStone have captured significant market share in this segment due to their pull-based, low-latency designs.
Synthetic Assets
Protocols like Synthetix mint synthetic assets (sUSD, sBTC, sETH) that track real-world prices. Oracles update on-chain when prices deviate by 1% or more, or at minimum once per hour, ensuring every trade executes at the correct market price with zero slippage against the oracle.
Risks and Considerations
Oracle Manipulation Attacks
Oracle manipulation remains one of the most damaging attack vectors in DeFi. The basic pattern: an attacker uses flash loans to temporarily distort prices on the venues a price feed sources from, then exploits the mispriced data to extract value from a protocol before the distortion reverts.
Notable incidents include the bZx attacks in February 2020 (the first major flash loan oracle exploits, costing roughly $954,000), the Harvest Finance attack in October 2020 ($34 million drained in 7 minutes by manipulating Curve pool prices), the Cream Finance exploit in October 2021 ($130 million), and the Mango Markets manipulation in October 2022 ($110+ million). In 2022 alone, oracle manipulation caused an estimated $403 million in losses across 41 separate incidents.
Stale Data
When a price feed stops updating (due to network congestion, oracle node failures, or L2 sequencer downtime), protocols continue operating on outdated prices. Stale feeds can prevent necessary liquidations, allowing bad debt to accumulate, or trigger incorrect liquidations on positions that are actually healthy. Production contracts must check the updatedAt timestamp against the feed's heartbeat period and implement circuit breakers for extreme staleness.
Freshness vs. Cost Tradeoffs
Push-based feeds face an inherent tension: more frequent updates improve accuracy but increase gas costs. A 0.1% deviation threshold on Ethereum mainnet would cost orders of magnitude more in gas than a 1% threshold during volatile markets. Pull-based feeds shift this cost to consumers but require every application to include price update logic in their transactions. Neither model is strictly superior: the right choice depends on the protocol's latency requirements, gas budget, and trust assumptions.
Centralization Concerns
Even decentralized oracle networks carry trust assumptions. Chainlink's feed proxy contracts are controlled by a 4-of-9 multisig that can update any feed's aggregator address. First-party publisher models (Pyth, API3) rely on the data providers themselves acting honestly. Dispute-based systems (Tellor) depend on active community monitoring. As the BTC DeFi ecosystem expands, understanding these trust models becomes increasingly important for evaluating protocol risk.
Oracle Extractable Value
When oracle price updates appear in the mempool, MEV searchers can front-run the update to capture MEV. For example, if a price drop will trigger a liquidation, a searcher can position their liquidation transaction immediately after the oracle update to capture the liquidation bonus. Several solutions are emerging: Chainlink SVR routes liquidation priority through Flashbots MEV-Share auctions, API3's OEV Network lets searchers bid for oracle update rights, and Pyth Express Relay uses sealed-bid auctions. These systems aim to return captured value to the protocols rather than leaving it with MEV extractors.
Price Feeds and Bitcoin
While price feeds are most commonly associated with smart contract platforms like Ethereum and Solana, they play a growing role in the Bitcoin ecosystem as well. Bitcoin Layer 2 networks and protocols that support stablecoins on Bitcoin need reliable price data for collateral valuation and liquidation triggers. Solutions like Spark that enable stablecoin transfers on Bitcoin benefit from the broader oracle infrastructure that keeps USDB and other stablecoins properly collateralized. Discreet log contracts (DLCs) represent Bitcoin's native approach to oracle-dependent financial contracts, using cryptographic attestations rather than on-chain feed contracts.
This glossary entry is for informational purposes only and does not constitute financial or investment advice. Always do your own research before using any protocol or technology.