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

# Mark and Index Price

On GTE, the **Mark price** is designed to reflect the fairest measure of a token's current price given the liquidity in the underlying perps contract and the underlying token's spot price. Mark price is built from three complementary components:

* **Index Price (p1)**: the external market reference price.
* **Impact Mid Price (p2)**: a depth-adjusted mid-price.
* **Microprice (p3)**: a queue-weighted top-of-book signal.

The Mark price is then equivalent to the median of the three:

$$
\text{markPrice} = \text{median}(p_1, p_2, p_3)
$$

The system is designed to ensure robustness under all conditions: one source always anchors to external truth, while the others add depth-awareness and responsiveness. Let's break down each one.

## Index Price

The **index price serves as the external reference for fair pricing**. It is sourced through a three-layered fallback system to maximize reliability:

**1. Primary Feed (CEX Median)**

Weighted median of prices from Binance, OKX, Bybit, Gate.io, MEXC with weights $[3,2,2,1,1]$.

**2. Secondary Feed (Oracle Price)**

Chainlink oracle price smoothed with a 30s TWAP of past rounds. Used only if the primary feed is stale (admin-level staleness threshold) and spread is deviating (admin-level clip).

**3. Fallback Feed (On-Chain EMA)**

30-second EMA of the median of best bid, best ask, and last trade on GTE's onchain book. Used only if both primary and secondary feeds fail.

## Impact Mid Price

The **impact mid measures what it would cost to execute a small notional trade through the order book**. Instead of relying on the top tick, which can be spoofed or fragile, it considers book depth on both sides:

$$
\text{impactMid} = \frac{\text{vwapAskForNotional}(q_{\text{QuoteWad}}, \text{asks}) + \text{vwapBidForNotional}(q_{\text{QuoteWad}}, \text{bids})}{2}
$$

Where $q_{\text{QuoteWad}}$ is the target notional (admin-set), symmetric on both sides and $\text{vwap}\text{ForNotional}$ is the Volume-Weighted Average Price.

This ensures liquidations and mark-to-market events reflect true executable prices, not easily manipulated quotes.

## Microprice

The **microprice provides a super responsive signal of current order book balance**. It weights top-of-book quotes by queue sizes:

* Bigger bid sizes push the price higher.
* Bigger ask sizes push it lower.

This heuristic reacts instantly to top-of-book shifts, and is most useful when spreads are tight and depth is healthy.

## Exclusions

Reduce-only orders, non-firm liquidity, and IOC orders are never included in mark price calculations or liquidation triggers. This guarantees fairness and prevents manipulation from ephemeral liquidity.
