> For the complete documentation index, see [llms.txt](https://xtrading.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xtrading.gitbook.io/docs/developer-docs/whitepaper.md).

# Whitepaper

## Abstract 📝

Xtrading is an AI-powered Perpetual DEX designed to simplify and enhance on-chain trading across multiple asset classes—from cryptocurrencies and meme tokens to NFT-based indexes and even real-world assets (RWA). The platform leverages cutting-edge AI tools, voice-enabled trading, and robust risk management features to deliver an intuitive, efficient, and secure environment for both novice and professional traders. By uniting advanced technology with user-centric design, Xtrading aims to redefine perpetual trading in the decentralized finance space.

## Introduction 📖

### **The Rising Need for Perpetual Trading**

Perpetual futures have emerged as a dominant force within decentralized finance (DeFi), providing **leveraged exposure**, **market hedging**, and **efficient capital utilization**. Yet, most existing solutions lack **accessible UI** and **intelligent tooling**, leaving many potential participants behind. Traders must juggle multiple platforms, face liquidity fragmentation, and cope with the steep learning curve of on-chain order books.

In response, **Xtrading** has constructed a **general-purpose AI-driven Perpetual DEX**, enabling:

• **Effortless Trading** via natural language commands and a clean user interface, bridging the gap between complicated DeFi protocols and mainstream adoption.

• **High-Performance Order Book** with up to **10× leverage** while maintaining decentralized transparency and security.

### **The Role of AI**

Artificial intelligence is **fundamentally changing** how users interact with technology. In a decentralized exchange setting, AI can:

• **Enhance User Experience**: Voice and chat commands minimize manual errors and accelerate order placement.

• **Provide Personalized Support**: RAG-based AI systems operate 24×7, delivering instant educational tips, platform guidance, and risk insights tailored to each trader’s needs.

By integrating AI deeply into the user journey, Xtrading aims to **democratize** access to advanced trading tools—lowering the entry barrier and improving financial literacy for the next wave of DeFi participants.

### Xtrading’s AI-Driven Perpetual DEX

### **Overview of Platform Advantages**

Below is an **at-a-glance** summary of the key pillars that make **Xtrading** unique:

#### 1. **AI-Powered Perpetual DEX**

* AI features for strategy optimization, user onboarding, and seamless interactions.

#### 2. **Voice & Chat Commands**

* Execute trades or request market data via natural language, eliminating typical UI frictions.

#### 3. **Lite & Pro Modes**

* **Lite**: Mobile-focused, up to 6× leverage for quick trades.
* **Pro**: Desktop-optimized with advanced charting, up to 10× leverage, and custom layouts.

#### 4. **Fat-Finger Protection**

* One-click order-fill reduces input errors, ensuring accurate price and quantity selection.

#### 5. **Multi-Currency Margin**

* Accepts various tokens (USDC, USDT, WETH, etc.) with an internal swap engine to unify collateral.

#### 6. **Cross-Margin (Coming Soon)**

* Maximize capital usage across multiple positions, simplifying margin management.

#### 7. **SuperNova (SNV) Index**

* Our original NFT floor-price perpetual for collections like **BAYC, MAYC, Azuki, Doodles, and CloneX**—still relevant for those seeking NFT exposure.

#### 8. **Beyond NFTs**

* Extended coverage for **crypto assets**, **Ordinals**, **RWA**, and **meme tokens**—making Xtrading a versatile platform for diverse trading interests.

#### 9. **AI-Enabled Customer Support**

* 24×7 intelligent assistants providing personalized guidance, from basic queries to advanced trading tips.

#### 10. **Telegram Notifications**

* Real-time updates on order fills, margin calls, and liquidation alerts sent directly to your Telegram.

#### 11. **Desktop-Optimized Pro Mode**

* Advanced order book, keyboard shortcuts, powerful charting, and layout customization for power users.

#### 12. **Staking & Token Utility**

* Lock or stake $XTRA tokens to unlock premium AI features, reduced fees, or governance privileges.

#### 13. **Referral & Ambassador Programs**

* Earn additional revenue by inviting new traders. Specialized roles (Knights, Squires) reward proactive community support.

#### 14. **Security & Insurance**

* Audited smart contracts, robust liquidation mechanisms, and an upcoming insurance fund for asset protection.

#### 15. **Forward-Looking Roadmap**

* Plans to integrate **Uniswap v4 hooks**, **AVS**, and eventually deploy an **XTrading app-chain** for superior scalability and user experience.

### Core Architecture

**XTrading** runs on a **central limit order book (CLOB)** approach for **fair, transparent** price discovery. Key components include:

* **On-Chain Smart Contracts**: Handling margin logic, custody, and settlement.
* **AI Off-Chain Services**: Voice-to-text, natural language processing, and RAG-based customer support.
* **Security Framework**: Ongoing audits, multi-sig governance, and future insurance protections.

## **Why XTrading Stands Out**

1. **Intuitive Experience**: Innovations like voice commands and fat-finger protection drastically reduce friction, appealing to both DeFi newcomers and veterans.
2. **Versatile Market Coverage**: From stablecoins and mainstream cryptos to NFT-based indexes and emerging meme or Ordinal tokens, XTrading consolidates these markets under one roof.
3. **AI-Assisted Risk Management**: Dynamic alerts, customizable margin monitoring, and real-time support empower traders to make confident, data-driven decisions.
4. **Community-Centric Growth**: Inclusive referral and ambassador programs that reward ecosystem participation.

## Core Protocol ( Protocol Specs )

### **1) Funding Payments**

#### **Funding Rate**

The **Funding Rate** is the main factor that aligns the **Mark Price** (the perpetual contract’s trading price) with the **Index Price** (the underlying reference price). It is computed as:

```
FundingRate = (MarkPriceTwap - IndexPriceTwap) / IndexPriceTwap
```

* **Funding Amount** = FundingRate \* PositionSize
* The funding rate at XTrading is **capped between -0.75% and +0.75%** at the protocol level, preventing excessive fees for either side.

#### **Global Index (G)**

Instead of distributing funding payments on a strictly hourly basis, XTrading **accumulates** each user’s funding in a global accumulator, settling it whenever they interact with the protocol (e.g., by placing or closing a trade).

* A **global accumulator** Gt is maintained according to:

```
Gt = Gt-1 + (Δt) * (Mark - Index) / 86400
```

where:

* Δt = time in seconds between Gt and Gt-1
* (Mark - Index) = difference between the mark price and index price
* 86400 = number of seconds in a day
* For example, if Δt = 300 seconds (5 minutes), you have:

```
Gt = Gt-1 + (Mark - Index) / 288
```

* Internally, the protocol calculates a **per-account relative accumulator**. Whenever a user executes an action (place an order, close a position, etc.), the system **settles** the funding owed:

```
Funding = (Gi - Ii) * PositionSize
```

where:

* Gi = current value of the global index
* Ii = the user’s last cached index
* PositionSize = number of contracts or tokens in the user’s position

This design **streamlines** funding settlement, minimizing gas fees and on-chain overhead.

### **2) Liquidation**

#### **Liquidation Trigger**

A position becomes eligible for liquidation when its **Margin Ratio (MR)** falls below the **Maintenance Margin Fraction (MMF)**. The current MMF is set at **0.0625** (or 6.25%).

#### **Liquidation Price**

**Liquidation Price** depends on whether you are long or short:

* **Long Positions**

```
LiquidationPrice = (| EscrowedAmount - InitialPositionValue |)
                   / ((1 - MMF) * Quantity)
```

* **Short Positions**

```
LiquidationPrice = (| EscrowedAmount + InitialPositionValue |)
                   / ((1 + MMF) * Quantity)
```

where:

* EscrowedAmount = net collateral remaining in the user’s margin account (initial deposits minus any withdrawals and realized PnL)
* InitialPositionValue = notional value at the time the position was opened
* Quantity = size of the position, in contracts or tokens

#### **Liquidation Penalty**

If liquidation occurs:

* **80%** of the penalty (remaining margin) goes to the protocol
* **20%** is allocated to the liquidator as an incentive

**Example**

1. **Trader Alice** deposits **$100** in USDC and opens a **short** position worth **$1,000** (10x leverage) on an asset priced at **$10** each (so position size = 100 tokens).
2. **Initial Margin Ratio**: 100 / 1000 = 0.1 (which is above 0.0625, so Alice is initially safe).
3. Suppose the asset’s price rises to **$10.36**. The notional value of Alice’s short position is now **$1,036**, reducing her collateral effectively to **$64** (due to unrealized losses of $36).
4. **Margin Ratio** = 64 / 1036 ≈ 0.0618, which is **below** 0.0625. This triggers liquidation.
5. **Liquidation Price** for a short position:

```
LiquidationPrice = (| EscrowedAmount + PositionValueAtOpen |)
                   / ((1 + MMF) * PosSize)
= (|100 + 1000|) / ((1 + 0.0625) * 100)
= 1100 / (1.0625 * 100)
= 1100 / 106.25
≈ 10.35
```

The position gets liquidated around **$10.35**. The penalty is split: 80% to protocol, 20% to liquidator.

#### **Liquidation Bot**

Anyone can run an **open-source liquidation bot**. It monitors the protocol’s subgraph for under-collateralized accounts and executes liquidation transactions via the **order processor** API routes. This **decentralized approach** ensures the market self-regulates and maintains solvency.

### **3) Margin Specs**

#### **Margin Ratio**

**Margin Ratio (MR)** gauges your position’s risk level:

```
MR = (Value of Collateral) / (Value of Position)
```

* If a trader deposits **$200** in collateral and opens a **$1,000** position, MR = 0.2.
* As the market moves, **MR** fluctuates based on unrealized gains or losses.

Keeping **MR** above the **Maintenance Margin Fraction (MMF)** is critical to avoid liquidation.

#### **Buying Power**

**Buying Power** defines how much you can trade relative to your deposited collateral. With up to **10× leverage** on XTrading:

* **Example**: Deposit **$200** → Buying Power of **$2,000** (10×).
* Opening a **$400** position uses **$400** of your buying power, leaving **$1,600** of remaining buying power.

#### **Margin Usage**

Reflects the portion of your margin currently in use. If you deposit **$500** and open a position worth **$100** in initial margin:

```
Margin Usage = 100 / 500 = 0.2 (or 20%)
```

#### **Mark Price**

**Mark Price** is derived from the **current highest bid** and **lowest ask** in the order book:

```
MarkPrice = (LowestAsk + HighestBid) / 2
```

This price is used for **PnL calculations** and **liquidation thresholds**, ensuring trades settle at a fair, transparent rate.

#### **Account Value**

Your **Account Value** (AccValue) is the sum of your **Collateral**, **Unrealized PnL**, and **Realized PnL**:

```
AccValue = Collateral + UnrealizedPnL + RealizedPnL
```

**Example**

1. You deposit **$300** in collateral.
2. Open a long position of 30 tokens at **$5** each (position value = $150).
3. Suppose the token’s price rises to **$8**. Your unrealized profit is **$3** per token, so **$3 × 30 = $90**.
4. You pay **$0.50** in funding fees.
5. New AccValue = $300 + $90 - $0.50 = $389.50.

#### **Health Factor**

The **Health Factor** forecasts your **liquidation risk**. The closer your **Margin Ratio** is to the **Maintenance Margin (MMF)**, the lower your Health Factor.

```
HealthFactor = 100 - RiskFactor
```

If MMF = 0.0625, then any Margin Ratio near 0.0625 signals heightened risk.

## **Roadmap**

### **Short-Term (3-6 Months)**

* **Cross-Margin Launch**: Simplified collateral management across multiple positions.
* **Refined AI Terminal**: Enhanced voice recognition and chat-based user assistance.

### **Mid-Term (6-12 Months)**

* **Uniswap v4 Hooks Integration**: Liquidity innovations for improved capital efficiency.
* **AVS Adoption**: Potential for advanced verification solutions or identity integration.
* **Insurance Module**: Initial rollout to safeguard traders against extreme market events.

### **Long-Term (12-18+ Months)**

* **XTrading App-Chain**: A dedicated chain for higher throughput and advanced DeFi functionalities.
* **Expanded RWA & Ordinals Coverage**: More asset classes integrated, broadening user choice.
* **DAO Governance**: Progressive decentralization, with token holders guiding platform upgrades and policy decisions.

## **Token Utility**

* **Staking & Governance**: Locking $XTRA tokens grants voting rights on platform changes and treasury allocations.
* **AI-Feature Access**: Certain advanced analytics, risk bots, or voice modules may require tokens for access.
* **Reward Mechanisms**: Referral bonuses, trading discounts, or premium support tiers for active token holders.
* **Treasury & Buybacks**: Revenue from protocol fees can be recycled into a treasury to fund further development, incentives, and ecosystem growth.

## **Conclusion**

As the **DeFi perpetual market** rapidly expands, **XTrading** stands ready to lead in **AI-driven**, user-friendly solutions. By melding intuitive design, robust security, multi-asset support, and advanced risk management, XTrading lowers barriers for newcomers while offering cutting-edge tools to professionals.

Join us on this journey to **reimagine decentralized trading**, where **voice commands**, **24/7 intelligent support**, and a **rich token ecosystem** converge to empower the next generation of traders.

**Welcome to XTrading: The AI-Powered Perpetual DEX for Everyone.**

**Use this revised text** to update the Whitepaper, ensuring it emphasizes **perpetual markets**, **AI integration**, and the broad scope of **digital asset coverage** while highlighting how XTrading delivers a **unique advantage** in user experience, security, and community-driven innovation.
