What is a Price Feed?
A price feed is a data service that provides asset prices to smart contracts. Since blockchains cannot natively access off-chain data, price feeds bridge this gap, enabling DeFi protocols to function with accurate market information.
Why Price Feeds Matter
DeFi operations depend on accurate prices for:
- Lending: Collateral valuations and liquidations
- Derivatives: Settlement and margin calculations
- Stablecoins: Peg maintenance mechanisms
- Yield: APY calculations and rebalancing
Price Feed Providers
Chainlink: Market leader with extensive network- Decentralized node operators
- Multiple data sources aggregated
- Wide asset coverage
Price Feed Mechanics
Pull Model: Contracts request prices when needed Push Model: Prices published on schedule or deviationUpdate triggers:
- Deviation threshold (e.g., 0.5% price change)
- Heartbeat interval (e.g., every hour)
- On-demand requests
Price Feed Quality Factors
Freshness: How recently was the price updated? Accuracy: Does it reflect true market price? Reliability: Uptime and availability Decentralization: How many independent sources? Latency: Time between market price and feed updateOn-Chain vs Off-Chain Oracles
On-Chain (TWAP):- Uses DEX trading data
- Manipulation resistant over time
- Limited to on-chain pairs
- May lag spot prices
- Aggregates from exchanges
- Real-time accuracy
- Requires trust in operators
- Broader asset coverage
Price Feed Risks
Stale Prices: Outdated data leading to incorrect operations Manipulation: Artificial price distortions Downtime: Feed unavailability Front-running: Exploiting pending updatesBest Practices for Protocols
- Use multiple price sources
- Implement staleness checks
- Add circuit breakers for extreme moves
- Fallback mechanisms for outages
- Regular monitoring and alerting
Evaluating Price Feed Safety
Check:
- Provider reputation and track record
- Update frequency and freshness
- Number of data sources
- Historical accuracy and uptime
- Protocol's fallback mechanisms