# What is an oracle in smart contracts?

URL: https://shield.quillaudits.com/learn/glossary/oracle/

An oracle is the source a contract trusts for data it can't work out on its own, most often the price of an asset. Lending markets use it to value collateral, perpetual exchanges to settle positions and vaults to price what they hold, so a wrong answer from the oracle becomes a wrong loan, liquidation or share price.

Last updated 3 December 2026. 2 minute read. By the QuillAudits Team.

## What kinds of price oracles do contracts use?

| Source | How it works | Typical failure |
| --- | --- | --- |
| Push feed | An off-chain network writes the price on chain when it moves past a threshold or a set time passes | Stale answers, wrong decimals, or a feed for the wrong asset |
| Pool spot price | The contract divides one pool reserve by the other | One large swap or a flash loan moves it within a transaction |
| TWAP | An average of the price in a pool over a time window | A short window over a thin pool moves within a few blocks |
| Your own contracts | The share price of an [ERC-4626](https://shield.quillaudits.com/learn/glossary/erc-4626/) vault, or the value of an LP token | Donations and rounding while the vault or pool is young |

Chainlink describes its feeds as updating when the off-chain price deviates from the last on-chain price, or after a heartbeat period passes ([Chainlink](https://chain.link/article/deviation-thresholds)). Its `latestRoundData` returns the answer with `startedAt` and `updatedAt` timestamps, and marks `answeredInRound` as deprecated ([Chainlink](https://docs.chain.link/data-feeds/api-reference)).

## What should a contract check when it reads a price?

- The answer is positive and scaled by the `decimals()` of that feed, not an assumed 8 or 18.
- `updatedAt` falls within the heartbeat of the feed, and older answers revert.
- The feed prices the asset you mean, not a related token or a ratio between two.
- On a rollup, the L2 sequencer uptime feed says the sequencer is up, as the Chainlink example checks ([Chainlink](https://docs.chain.link/data-feeds/using-data-feeds)).
- Moving the price costs more than the borrowing it would allow.
- There is a plan for when the oracle stops: pause, fall back or reject.

The [oracle price manipulation](https://shield.quillaudits.com/learn/vulnerabilities/oracle-price-manipulation/) page has vulnerable and fixed code for a lender that reads a price, and the [TWAP](https://shield.quillaudits.com/learn/glossary/twap/) entry covers averaged prices.

A stale price is a typical oracle finding: `latestRoundData()` is called but `updatedAt` is never compared with the heartbeat, so if the feed stops updating, the market keeps lending against the last price it saw. The fix reverts on a stale answer and stops new borrowing until the feed recovers.

## FAQ

### What is the oracle problem?

A blockchain can only check data that is already on chain, so any outside fact, such as a price, has to be brought in by someone the contract trusts. The design question is how to make abusing that trust cost more than it pays.

## Sources

- [What is a deviation threshold?, Chainlink](https://chain.link/article/deviation-thresholds) · checked 3 December 2026
- [Data Feeds API reference, Chainlink docs](https://docs.chain.link/data-feeds/api-reference) · checked 3 December 2026
- [Using Data Feeds on EVM chains, Chainlink docs](https://docs.chain.link/data-feeds/using-data-feeds) · checked 3 December 2026
