Quant Memo
Core

Oracles and Price Feeds

Smart contracts can't see off-chain prices on their own, so they rely on oracles to import that data — and because so much money depends on the number being right, oracles are one of the most attacked links in DeFi.

Prerequisites: Blockchains and Consensus

A smart contract can only see data that already lives on its own blockchain. It cannot reach out to a stock exchange or a currency market to check a price — everything it knows must be pushed to it. An oracle is the piece of infrastructure that does that pushing: it fetches real-world data (most often an asset's price) off-chain and delivers it on-chain in a form a contract can read.

This matters enormously for DeFi lending and derivatives, where a contract needs a trustworthy price to decide, for example, whether a loan is under-collateralized and should be liquidated. If the price feed is wrong even briefly, contracts will act on the wrong number with real money at stake.

An oracle is a trust bottleneck: however decentralized the blockchain underneath it is, a contract's behavior is only as reliable as the price it was fed, which is why serious oracle designs pull from many independent sources and aggregate them rather than trusting one.

Worked example. A lending protocol liquidates borrowers whose collateral value falls below 110% of their loan. An attacker manipulates a single, thinly traded exchange's price of a token upward for a few seconds — long enough for the oracle reading that single source to report an inflated collateral value — then borrows far more than the token is actually worth against that phantom price before the number corrects. This exact pattern, called an oracle manipulation attack, is why robust oracles (like Chainlink's node networks) aggregate median prices across many exchanges and multiple independent reporters rather than reading one venue directly, making a momentary price spike on any single source far less able to move the reported feed.

Related concepts

Further reading

  • Chainlink documentation, 'What Is a Blockchain Oracle?'
ShareTwitterLinkedIn