> ## Documentation Index
> Fetch the complete documentation index at: https://docs.calabi.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Fair Price Marking

# Oracle Price

The oracle price is the external spot reference for a market and is used to accurately value positions, determine funding rates and act as a component in the calculation of the mark price (below).

### Calculation

Validators are responsible for sourcing external price references from external venues and publishing them onchain. Prices are collected every 3s, passed through a price filter which removes stale and spurious updates, and the final price is calculated as a weighted median. The external venues and weights for each are below:

| Venue | Weight |
| - | - |
| Binance | 3 |
| Bybit | 2 |
| OKX | 1 |

# Mark Price

The mark price is the reference used for margining, liquidation triggers, and PnL. It has two core invariants: it must represent an unbiased and fair price of the perpetual contract, and be resistant to market manipulation.

### Calculation

Mark price is calculated as the median of the following components:

#### 1. Premium-Adjusted Oracle Price

$$
\text{raw\_premium}_t = \text{impact\_mid}_t - \text{oracle}_t
$$

$$
\text{clamped\_premium}_t = \text{clamp}\big(\text{raw\_premium}_t,\; -0.005\cdot\text{oracle}_t,\; +0.005\cdot\text{oracle}_t\big)
$$

$$
\text{premium}_t = \alpha_{10s} \cdot \text{clamped\_premium}_t + (1-\alpha_{10s})\cdot \text{premium}_{t-1}
$$

where $\alpha_{10s}$ corresponds to a 10-second half-life (or decay window) EMA.

#### 2. Impact Price

$$
\text{notional} = \text{500}/\text{Initial Margin Fraction}
$$

$$
\text{impact\_mid}_t = \frac{\text{impact\_bid}_t(\text{notional}) + \text{impact\_ask}_t(\text{notional})}{2}
$$

Undefined if either side lacks sufficient depth for this notional.

### Final Calculation

$$
\text{price}_1 = \text{oracle}_t + \text{premium}_t
$$

$$
\text{raw\_mark}_t = \begin{cases} \operatorname{median}\big(\text{impact\_mid}_t,\ \text{price}_1,\ \text{oracle}_t\big) & \text{if impact\_mid defined} \\[4pt] \text{price}_1 & \text{otherwise} \end{cases}
$$

$$
\text{mark}_t = \operatorname{clamp}\big(\text{raw\_mark}_t,\; 0.98\cdot\text{oracle}_t,\; 1.02\cdot\text{oracle}_t\big)
$$


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.