> For the complete documentation index, see [llms.txt](https://docs.afx.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.afx.xyz/glossary/oracle-price.md).

# What Is Oracle Price in Crypto? Definition & How It Works

**Oracle price is an externally sourced reference price fed into a smart contract or on-chain trading system to represent the fair value of an asset. On AFX, the oracle price anchors each perpetual contract to its real-world underlying — whether that is Bitcoin, gold, crude oil, or SpaceX's private market valuation — and is used to calculate mark price, which drives PnL and liquidation thresholds.**

### Why Perpetual DEXes Need Oracles

A perpetual contract on a DEX only sees prices from its own order book. If a trader places a large order that moves the SPCX-PERP last traded price by 5%, the contract has no way to know whether that move reflects a real change in SpaceX's valuation or a thin-book manipulation.

The oracle solves this by bringing an external price reference on-chain. Instead of using the last traded price in the AFX book, the protocol derives mark price from the oracle — which aggregates data from multiple external sources and is far harder to manipulate with a single order.

This is especially critical for assets like [XAU-PERP](https://app.afx.xyz/trade/XAUUSDC), [CL-PERP](https://app.afx.xyz/trade/CLUSDC), and [SPCX-PERP](https://app.afx.xyz/trade/SPCXUSDC), where the underlying asset trades in a completely separate market (commodity exchanges, private equity platforms) that has no direct connection to the AFX order book.

### How Oracle Price Works on AFX

On AFX, each perpetual pair displays both a **last traded price** (the most recent fill in the AFX order book) and an **oracle price** (the external reference). You can see both in the trading interface.

The oracle price feeds into the mark price formula:

```
Mark Price ≈ Oracle Price × (1 + Funding Basis)
```

The funding basis is a short-window moving average of the premium or discount between the last traded price and the oracle price. This means:

* If SPCX-PERP is trading at a premium to oracle (buyers pushing the price up), the funding basis is positive, longs pay shorts, and the price is pushed back toward oracle
* If it is trading at a discount, shorts pay longs, and the price is pulled back up

This mechanism keeps each AFX perpetual anchored to its real-world reference without requiring an expiry date.

### Oracle Sources by Asset Type

Different AFX pairs use different types of oracle data, depending on where the underlying asset trades:

| Pair                                            | Underlying               | Oracle Data Source                                |
| ----------------------------------------------- | ------------------------ | ------------------------------------------------- |
| [BTC-PERP](https://app.afx.xyz/trade/BTCUSDC)   | Bitcoin                  | Aggregated spot prices across major crypto venues |
| [ETH-PERP](https://app.afx.xyz/trade/ETHUSDC)   | Ethereum                 | Aggregated spot prices across major crypto venues |
| [XAU-PERP](https://app.afx.xyz/trade/XAUUSDC)   | Gold (XAU/USD)           | Commodity market reference data                   |
| [CL-PERP](https://app.afx.xyz/trade/CLUSDC)     | WTI Crude Oil            | Commodity market reference data                   |
| [SPCX-PERP](https://app.afx.xyz/trade/SPCXUSDC) | SpaceX private valuation | Private market reference data                     |

For crypto pairs (BTC, ETH), the oracle aggregates prices across multiple liquid spot exchanges — making it resistant to manipulation on any single venue. For commodity and private asset pairs, the oracle draws from specialist data sources covering those markets.

### Oracle Price vs Last Traded Price vs Mark Price

These three prices are visible in the AFX interface and each serves a different purpose:

| Price                 | What It Is                                              | Used For                                      |
| --------------------- | ------------------------------------------------------- | --------------------------------------------- |
| **Last Traded Price** | The price of the most recent fill in the AFX order book | Displayed on charts; used for order execution |
| **Oracle Price**      | External reference aggregated from real-world sources   | Anchor for mark price calculation             |
| **Mark Price**        | Oracle price + funding basis adjustment                 | Unrealized PnL display; liquidation threshold |

Your position is **never liquidated based on last traded price**. A temporary wick — a large order that briefly moves the last traded price far from oracle — does not trigger liquidation because mark price stays anchored to oracle.

The gap between last traded price and oracle price tells you the current market sentiment: a positive gap (last > oracle) means buyers are paying a premium and funding will flow from longs to shorts at the next settlement.

### What Happens When Oracle and Market Price Diverge

Persistent divergence between oracle price and last traded price triggers the funding rate mechanism to close the gap over time. If the AFX SPCX-PERP price climbs significantly above the oracle reference — because traders are bullish on SpaceX — longs pay shorts every 4 hours until the price converges back toward oracle.

For large, sudden divergences caused by breaking news (a Starship launch result, a Fed decision affecting gold prices), the oracle update and last traded price may temporarily diverge sharply before converging as market participants absorb the new information.

Traders should monitor the oracle price alongside the last traded price, particularly on non-crypto pairs where the underlying market may be closed (e.g., gold on weekends), causing the oracle to update less frequently while AFX continues trading.

### FAQ

#### Can the oracle price be manipulated?

Oracles aggregate data from multiple external sources, making manipulation significantly harder than manipulating a single order book. Moving the oracle price for a liquid asset like gold or Bitcoin would require moving prices across multiple large external markets simultaneously — an extremely high bar. For private assets like SpaceX, the oracle draws from available private market reference data, which updates less frequently but is not directly controllable by any single AFX participant.

#### Why does my unrealized PnL sometimes differ from what I calculate using the last traded price?

Because unrealized PnL on AFX is calculated using mark price, not last traded price. If the last traded price is temporarily above or below the oracle reference — due to a large order, thin liquidity, or market sentiment — mark price will differ from last traded price. As the two converge (driven by the funding rate mechanism), your displayed unrealized PnL adjusts accordingly.

#### Is the oracle price the same as the index price I see on other platforms?

They serve the same function but may differ in implementation. "Index price" and "oracle price" are often used interchangeably — both refer to an external reference price anchoring the perpetual contract. On AFX, the term "oracle price" is used in the interface. The calculation methodology may vary by platform.

***

### Keep Learning

* [What Is a Funding Rate?](/basics/what-is-funding-rate.md) — how funding keeps the perpetual price anchored to oracle over time
* [SpaceX Perpetuals on AFX (SPCX)](/markets-assets/spacex-perpetuals-spcx.md) — oracle pricing for a private-company perpetual

***

*This article is for informational and educational purposes only. It does not constitute financial or investment advice. Not Financial Advice (NFA).*


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.afx.xyz/glossary/oracle-price.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
