# Pricing Mechanisms

The Dexodus protocol ensures fair, transparent, and efficient perpetual trading through its unique pricing mechanisms. These mechanics rely on three critical components: the **Index Price**, the **Perpetual Price**, and the **Mark Price**, each playing a vital role in trade execution, funding rates, and liquidations.

#### **1. Index Price**

The **Index Price** represents the underlying market price of the asset or index being traded. It is sourced from **Chainlink Data Streams**, ensuring accuracy and reliability.

* **Definition:**\
  The Index Price is derived from real-time market data, representing the fair price of the underlying asset or custom index.
* **Purpose:**
  * Acts as the benchmark price for the market.
  * Provides a stable and manipulation-resistant reference point for traders.
  * Forms the foundation for calculating the **Mark Price** and **Perpetual Price**.

#### **2. Perpetual Price**

The **Perpetual Price** reflects the dynamic demand-supply balance within the Dexodus perpetual market. It adjusts the Index Price based on the proportion of **open interest (OI)** between long and short positions.

* **Definition:**\
  The Perpetual Price is influenced by the relative size of **long** and **short OI**:
  * If long positions dominate, the Perpetual Price may rise above the Index Price.
  * If short positions dominate, the Perpetual Price may fall below the Index Price.
* **Calculation:**\
  The Perpetual Price is calculated based on the open interest distribution, ensuring it dynamically reflects market conditions.
* **Purpose:**
  * Used to calculate **unrealized PnL**, ensuring that profits and losses accurately reflect internal market conditions.
  * Determines **funding rates**, encouraging balance between longs and shorts.
  * Used as the primary price for evaluating positions.

#### **3. Mark Price**

The **Mark Price** is a weighted combination of the Index Price and the Perpetual Price. It is primarily used to trigger **limit orders** and **liquidations**, ensuring fairness and stability.

* **Definition:**\
  The Mark Price combines the stability of the Index Price and the responsiveness of the Perpetual Price:
  * **75% weight** comes from the Index Price, ensuring stability and resistance to manipulation.
  * **25% weight** comes from the Perpetual Price, incorporating internal market dynamics.
* **Formula:**\
  Mark Price = (0.75 \* Index Price) + (0.25 \* Perpetual Price)
* **Purpose:**
  * **Triggering Limit Orders:** The Mark Price is used to determine when limit orders are executed.
  * **Liquidations:** It serves as the reference price for triggering liquidations, balancing market dynamics with external stability.

#### **Why This System?**

Dexodus’ pricing mechanics are designed to balance external accuracy and internal market dynamics:

1. **Fair Liquidations and Order Execution:**\
   By basing the Mark Price largely on the Index Price, liquidations and order execution are insulated from short-term market manipulation.
2. **Dynamic Market Feedback:**\
   The Perpetual Price introduces responsiveness to market activity, ensuring the protocol adapts to real-time demand and supply.
3. **Transparency and Reliability:**\
   The clear separation of roles between the Index Price, Perpetual Price, and Mark Price ensures transparency and a fair trading environment.

#### **How They Work Together**

1. **Trading and PnL:**
   * The **Perpetual Price** is the primary reference for calculating **unrealized PnL** and evaluating active positions.
   * It also determines **funding rates**, encouraging balance between long and short positions.
2. **Triggering Orders and Liquidations:**
   * The **Mark Price** is used exclusively to determine when **limit orders** and **liquidations** are triggered. This ensures traders are protected from sudden price manipulation within the market.
3. **Market Stability:**
   * The **Index Price** provides the foundation for pricing, ensuring traders have a stable reference unaffected by internal market conditions.
