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

# Oracles

Price oracles are data feeds that provide a reliable reference price for a perp asset. Combined with funding rates, they serve to align the perp price with the reference price of the asset.

***

### Oracle Architecture

Perpetuals constructs and publishes oracle prices for each currency pair using **Pyth**, a first-party oracle aggregating real-time price data from 80+ institutional market participants including major forex market makers, global exchanges, and leading financial institutions.

**Data sources include:**

* Top-tier forex market makers (Virtu Financial, Jane Street, Jump Trading)
* Global FX liquidity venues
* Institutional trading desks
* Multi-publisher aggregation for redundancy

Pyth data updates every **400 milliseconds** and incorporates a variety of inputs from institutional publishers to create a robust, manipulation-resistant price feed.

***

### Mark Price Calculation

The **mark price** is used for margining, liquidations, stop/limit triggers, and unrealized PnL.

Perpetuals calculates mark price as the **median of three components**:

1. **Pyth Oracle Price** - The spot FX rate from institutional sources
2. **EMA-Adjusted Price** - Oracle price + 150-second EMA of (Mark - Oracle basis)
3. **Impact Price** - Median of orderbook depth (bid/ask impact for notional trade volumes)

**The combined value is pushed on-chain as the mark price**, used in funding rate calculations and margin requirements.

#### Example Calculation

If the Pyth oracle price for EUR/USD is $1.0950, the perpetual mid-price is $1.0965, and orderbook impact price is $1.0960, then the mark price calculation would be:

```
Component 1 (Oracle): 1.0950
Component 2 (EMA-adjusted): 1.0950 + 0.0008 = 1.0958
Component 3 (Impact): 1.0960

Mark Price = Median(1.0950, 1.0958, 1.0960) = 1.0958
```

***

### Why this approach?

Perpetuals approaches the oracle price for FX pairs differently than typical crypto perps.

Unlike crypto assets like BTC that have highly liquid spot markets trading 24/7, FX markets have unique characteristics:

* Traditional FX markets close on weekends
* Liquidity varies significantly by timezone (Asian/London/NY sessions)
* Multiple liquidity venues with varying spreads

**Our goal for the Perpetuals price oracle is to:**

1. Incorporate real-world institutional pricing via Pyth
2. Allow for on-chain price discovery through the perpetual market
3. Protect against manipulation via multi-component mark price

This creates a robust pricing mechanism that tracks real FX markets while enabling continuous 24/7 perpetual trading.

***

### Safeguards

#### Mark Price Deviation Limits

To prevent extreme oracle manipulation, the mark price is clamped within bounds:

```
Maximum Deviation = 1 / Max Leverage
```

For a pair with 50x max leverage, mark price cannot deviate more than ±2% from the oracle price.

#### Staleness Detection

If Pyth oracle data becomes stale:

* Trading pauses automatically
* Existing positions safe (no liquidations during outage)
* Funding rates set to 0%
* Trading resumes once oracle recovers

***

### Weekend & Holiday Pricing

Traditional FX markets close Friday 5pm ET and reopen Sunday 5pm ET.

**During weekends, Perpetuals continues operating:**

* Pyth publishers continue providing prices based on available liquidity
* Offshore FX markets and institutional liquidity remain active
* Mark price bands may widen slightly due to lower liquidity
* Recommended to reduce leverage before weekends

This allows true 24/7 trading without the weekend gaps that plague traditional forex.

***

### Oracle Transparency

All oracle updates are:

* Cryptographically signed by Pyth publishers
* Verifiable on-chain via Hyperliquid
* Publicly auditable at [pyth.network](https://pyth.network)

Users can independently verify prices in real-time.

***

Last updated
