·5 min read
DeFiOracleSolanaEthereumTechnical

Crypto Oracles Explained: Chainlink, Pyth, and How DeFi Gets Real-World Data

DeFi protocols need real-world price data to function — oracles provide it. Learn how Chainlink and Pyth work, why oracle security matters, and how bad oracles have caused major exploits.

Smart contracts on blockchains can only access data that's on-chain. But DeFi protocols need real-world information — current asset prices, interest rates, event outcomes. Oracles bridge this gap, bringing external data on-chain in a trustworthy way.

Why Oracles Are Critical

Consider a lending protocol: to know if a borrower's collateral is sufficient, it needs the current price of their collateral asset. If that price data is wrong or manipulated, the protocol could be exploited — either by preventing legitimate liquidations or by triggering false ones.

Oracle security is one of the most important (and most attacked) aspects of DeFi. Multiple major exploits have been caused by oracle manipulation:

  • Mango Markets ($114M, 2022) — price oracle manipulated via spot market
  • Cream Finance ($130M, 2021) — flash loan + oracle manipulation
  • Multiple smaller protocols via flash loan price attacks

How Oracles Work

Price feed oracles — Report the price of an asset (ETH/USD, SOL/USDC) at regular intervals. These aggregate prices from multiple sources (CEXes, DEXes) to produce a reference price.

Event oracles — Report the outcome of real-world events (sports results, election outcomes) for prediction markets.

Randomness oracles — Provide verifiable random numbers for NFT mints and gaming applications.

Chainlink: The Ethereum Standard

Chainlink is the dominant oracle network on Ethereum and EVM chains. It works through a decentralized network of node operators:

  1. Chainlink nodes independently fetch price data from multiple sources
  2. Nodes submit their answers on-chain
  3. A smart contract aggregates the answers (typically median) and publishes the result
  4. Node operators are paid LINK tokens for their service and penalized for inaccurate data

Chainlink price feeds are used by Aave, Compound, Synthetix, and hundreds of other protocols. They update when the price moves more than a threshold (e.g., 0.5%) or after a heartbeat interval.

On Base, Chainlink price feeds are the standard for SovereignSwap's ERC-20 token staking contract price references.

Pyth Network: The Solana Standard

Pyth Network was built specifically for Solana and high-frequency financial data. Key differences from Chainlink:

First-party data — Pyth's price publishers are the actual market participants (Jump Trading, Jane Street, Cboe). They publish their own proprietary price data directly to Pyth, not from aggregated public sources. This means the data quality is high and comes from entities with real skin in the game.

Push vs. pull — Traditional oracles push price updates on-chain periodically. Pyth uses a pull model: consumers fetch the latest price and submit it alongside their transaction. This allows sub-second updates without the gas cost of constant on-chain writes.

Cross-chain — Pyth is deployed via Wormhole across 30+ chains. The same price feed works on Solana, Ethereum, Base, BNB Chain, and others.

Pyth is used by Mango Markets, Drift Protocol, Kamino Finance, and most major Solana DeFi protocols.

The Oracle Attack Taxonomy

Spot price manipulation — An attacker uses flash loans to temporarily manipulate the price in a DEX pool that a protocol uses as its oracle. The protocol acts on the manipulated price. Mitigated by using time-weighted average prices (TWAP) instead of spot prices.

Oracle delay exploitation — An oracle updates infrequently. An attacker exploits the gap between the oracle price and the real market price during extreme volatility.

Centralized oracle failure — A single-source oracle can be corrupted by compromising that one source. Decentralized oracle networks with many independent sources mitigate this.

Best Practices for Protocol Security

Well-designed DeFi protocols:

  • Use decentralized, multi-source oracles (Chainlink, Pyth) rather than single DEX spot prices
  • Use TWAP (time-weighted average price) over short windows rather than spot price
  • Implement circuit breakers that halt the protocol if oracle price deviates suspiciously
  • Apply conservative liquidation parameters to give time for oracle updates

Pyth and AI Signals

Pyth's high-frequency data feeds are what enable real-time price signals in DeFi applications. SovereignSwap's AI signal dashboard uses DexScreener (on-chain aggregated data) for token price feeds — a complementary data source for assets not covered by Chainlink or Pyth.

Read: On-chain analytics guide →

Read: DeFi risk management →

$SOVAI Presale — Q2 2026

15M tokens at $0.0005 — 50% below DEX listing

Real yield from AI trading revenue. Fixed supply. No emissions. Join the waitlist for early access.

By joining you agree to our Terms of Service and Privacy Policy.

built by gruesøme · Powered by SovereignAI