# 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.

Source: https://learn.tradelabsai.com/crypto/oracles/  
Track: Crypto · Level: Advanced · Updated: 2026-10-03  
Publisher: TradeLabs AI (https://tradelabsai.com). Education, not financial advice.  
Cite as: TradeLabs Learn, "Oracles", https://learn.tradelabsai.com/crypto/oracles/

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

| Application | Data needed |
|---|---|
| Lending protocols | Collateral prices to decide liquidations. See [DeFi Basics](https://learn.tradelabsai.com/crypto/defi-basics/) |
| Perpetual DEXs | Index prices for funding and liquidations |
| Stablecoins | Collateral values |
| Prediction markets | Event outcomes and asset prices |
| Insurance | Weather data, flight delays |

## Types of oracles

| Type | How it works | Examples |
|---|---|---|
| Decentralised price feeds | Many independent node operators report prices from multiple sources; the contract uses an aggregate | Chainlink, Pyth |
| Optimistic oracles | Someone proposes an answer with a bond; it becomes final unless disputed during a challenge window | UMA |
| On chain DEX prices | Prices taken from on chain trading pools, often averaged over time (TWAP) | Uniswap TWAP |
| Centralised oracles | A single trusted provider posts data | Exchange or company feeds |

## Chainlink price 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](https://learn.tradelabsai.com/prediction-markets/price-to-beat/) and [Up or Down Markets Explained](https://learn.tradelabsai.com/prediction-markets/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](https://learn.tradelabsai.com/prediction-markets/how-polymarket-works/).

## Oracle attacks

**Example: A price manipulation exploit**
A lending protocol values a small token using the price on a single thin DEX pool. An attacker takes a large flash loan (borrowed and repaid within one transaction), buys the token in that pool to push its price up tenfold, deposits the inflated token as collateral, borrows far more than it is worth from the protocol, then lets the price crash. The protocol is left with bad debt. Attacks like this have cost DeFi protocols hundreds of millions of dollars, including the Mango Markets exploit in October 2022, which drained over $100 million. See [Market Manipulation](https://learn.tradelabsai.com/industry/market-manipulation/).

## 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](https://learn.tradelabsai.com/crypto/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](https://learn.tradelabsai.com/crypto/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.

### How does Chainlink work?

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](https://learn.tradelabsai.com/crypto/mev/).

## Continue learning

- Next lesson: [MEV](https://learn.tradelabsai.com/crypto/mev/)
- Previous lesson: [DeFi Basics](https://learn.tradelabsai.com/crypto/defi-basics/)
- Related: [DeFi Basics](https://learn.tradelabsai.com/crypto/defi-basics/): DeFi offers trading, lending and borrowing through smart contracts instead of banks. Learn the building blocks, where yields come from and the risks.
- Related: [How Polymarket Works](https://learn.tradelabsai.com/prediction-markets/how-polymarket-works/): A clear guide to how Polymarket works: Yes and No shares, the order book, USDC, fees, how markets resolve through UMA and Chainlink, and the risks to know.
- Related: [Price to Beat and How Rounds Settle](https://learn.tradelabsai.com/prediction-markets/price-to-beat/): The price to beat is the start price an up or down round must match or beat for Up to win. Learn where it comes from and why it differs from your exchange.
- Related: [Mark Price vs Index Price](https://learn.tradelabsai.com/crypto/mark-price-vs-index-price/): Crypto derivatives use three prices: last, index and mark. Learn how each is calculated, why mark price triggers liquidations and why gaps between them matter.
- Related: [Bridge and Smart Contract Risk](https://learn.tradelabsai.com/crypto/bridge-and-smart-contract-risk/): Smart contract bugs and cross chain bridge hacks have cost crypto users billions. Learn how bridges work, famous exploits, warning signs and how to reduce your risk.
