TradeLabs AILearn

Oracles

Oracles bring outside data like prices and event results onto blockchains. Learn how Chainlink feeds and UMA's optimistic oracle work, and how attacks happen.

Advanced3 min readUpdated 3 Oct 2026
Markdown
Read firstDeFi Basics
Lesson 18 of 24

Blockchains are closed systems: smart contracts can read data on the chain, but they cannot see the outside world. They do not know the price of Bitcoin on exchanges, the result of an election or the temperature in Chicago. Oracles solve this problem by bringing external data onto the blockchain in a form contracts can use. Lending protocols use oracles to value collateral, derivatives use them to settle, and prediction markets such as Polymarket use them to resolve outcomes. Because so much money depends on oracle data, oracles are critical infrastructure and a frequent target of attacks.

Why oracles are needed#

ApplicationData needed
Lending protocolsCollateral prices to decide liquidations. See DeFi Basics
Perpetual DEXsIndex prices for funding and liquidations
StablecoinsCollateral values
Prediction marketsEvent outcomes and asset prices
InsuranceWeather data, flight delays

Types of oracles#

TypeHow it worksExamples
Decentralised price feedsMany independent node operators report prices from multiple sources; the contract uses an aggregateChainlink, Pyth
Optimistic oraclesSomeone proposes an answer with a bond; it becomes final unless disputed during a challenge windowUMA
On chain DEX pricesPrices taken from on chain trading pools, often averaged over time (TWAP)Uniswap TWAP
Centralised oraclesA single trusted provider posts dataExchange or company feeds

Chainlink is the most widely used oracle network. Independent node operators fetch prices from data aggregators and exchanges, and an aggregation contract combines their reports. Feeds update when prices move beyond a set threshold or after a set time. Chainlink Data Streams provide lower latency prices for derivatives and fast markets.

Polymarket's short crypto up or down rounds, such as 5 minute and 15 minute Bitcoin rounds, settle on Chainlink price data, which is why the price to beat and final price come from Chainlink rather than any single exchange. See Price to Beat and How Rounds Settle and Up or Down Markets Explained.

UMA's optimistic oracle#

For questions that are not simple prices, such as "Did this event happen?", UMA uses an optimistic design:

  1. A proposer submits an answer and posts a bond.
  2. A challenge period follows, often two hours for many Polymarket markets.
  3. If no one disputes, the answer becomes final.
  4. If disputed, the question goes to a vote by UMA token holders, and the losing side forfeits its bond.

This lets many markets resolve cheaply, relying on economic incentives to keep proposers honest. Disputes have occurred over ambiguous wording, which is why reading market rules matters. See How Polymarket Works.

Oracle attacks#

Defences#

  • Multiple data sources and node operators.
  • Time weighted averages to resist short spikes.
  • Deviation thresholds and circuit breakers.
  • Using deep, liquid markets for price sources.
  • Dispute mechanisms with economic penalties.

Why traders should care#

  • Liquidation triggers depend on oracle prices, not the last trade on your exchange. See Mark Price vs Index Price.
  • Settlement sources determine prediction market and option payoffs.
  • Oracle delays during fast markets can create gaps between oracle and exchange prices.
  • Oracle failures are a source of smart contract risk. See Bridge and Smart Contract Risk.

Frequently asked questions#

What is a blockchain oracle?#

A service that brings external data, such as prices or event results, onto a blockchain so smart contracts can use it.

Independent node operators report data from multiple sources, and an on chain contract aggregates their reports into a single price feed.

What is an optimistic oracle?#

A system where a proposed answer is accepted unless someone disputes it within a challenge period, as used by UMA for Polymarket resolutions.

Next, learn how transaction ordering creates profit and risk in MEV.

Check your understanding

3 quick questions on this lesson. Get them all right to finish it.

Turn on JavaScript to take the quiz.

Finished this lesson?Sign in to save your progress across devices.
Next lessonMEVMEV is value extracted by reordering or inserting blockchain transactions. Learn sandwich attacks, arbitrage and liquidation MEV, and how to protect trades.

Mentioned in