> For the complete documentation index, see [llms.txt](https://sol-perps-bot.gitbook.io/sol-perps-bot-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sol-perps-bot.gitbook.io/sol-perps-bot-docs/trading-basics/orderbook-and-matching.md).

# Orderbook & Matching Engine

Fluvion operates a high-performance, off-chain **Central Limit Order Book (CLOB)** paired with verifiable on-chain settlement across Solana and major EVM networks. This hybrid architecture delivers the sub-millisecond execution speeds of institutional centralized exchanges while maintaining decentralized custody of collateral.

***

## What is a Central Limit Order Book (CLOB)?

Unlike Automated Market Makers (AMMs) that rely on passive liquidity pools with high price impact and deterministic bonding curves (`x · y = k`), a **CLOB** aggregates all individual bids (buyers) and asks (sellers) into an organized, transparent depth ladder.

```
       SELLERS / ASKS (Red)
       $150.15 | 240.5 SOL
       $150.10 | 120.0 SOL
       $150.05 |  55.2 SOL
 ---------------------------------- <-- SPREAD ($0.05)
       $150.00 |  80.0 SOL
       $149.95 | 165.4 SOL
       $149.90 | 310.0 SOL
       BUYERS / BIDS (Green)
```

* **Bid**: The highest price a buyer is willing to pay.
* **Ask (Offer)**: The lowest price a seller is willing to accept.
* **Spread**: The difference between the best ask and the best bid. Tighter spreads mean lower trading friction for users.
* **Depth**: The volume of orders waiting at each price level. Deeper books allow larger trades with minimal price impact.

***

## Price-Time Priority Matching

The Fluvion matching engine matches trades according to strict **Price-Time Priority**:

1. **Price Priority**: The best priced order is matched first.
   * For Buy orders, higher prices take precedence.
   * For Sell orders, lower prices take precedence.
2. **Time Priority**: If two orders are placed at the exact same price level, the one that arrived earlier in the orderbook is executed first.

***

## Makers vs. Takers

Every trade executed on the platform involves two sides:

### Maker (Liquidity Provider)

* An order that sits in the orderbook waiting to be matched (e.g., a passive limit order placed away from the current spread).
* Makers provide depth and stability to the market.
* **Incentive**: Makers enjoy the lowest trading fees, and high-tier accounts can earn maker fee rebates.

### Taker (Liquidity Consumer)

* An order that matches immediately against an existing resting order in the book (e.g., a market order or a limit order crossing the spread).
* Takers remove liquidity from the orderbook.
* Takers pay the standard taker fee rate.

***

## Price Bands & Protection Mechanisms

To safeguard traders from extreme volatility, flash crashes, and fat-finger entry errors, the Fluvion matching engine enforces several continuous protection mechanisms:

### 1. Price Bands (Anti-Manipulation Limits)

Incoming aggressive market or limit orders cannot trade beyond a maximum deviation band from the **Mark Price** (typically ±3% to ±5% depending on market volatility).

* If an oversized order would blow through the entire orderbook beyond the safe band, the unfilled portion is automatically cancelled to prevent severe slippage.

### 2. Maximum Position Size Limits

Each market enforces a maximum open interest and maximum position size per user. As position sizes approach large notional amounts, the system scales up margin requirements (via the **IMR Factor**) to preserve system solvency.

### 3. Sub-Second Cancellation Processing

During high network volatility, order cancellations are processed with top priority in the matching engine to ensure market makers and algorithmic traders can adjust quotes safely without latency risk.
