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

# How Perpetra Works

> A walkthrough of what happens when you place a trade on Perpetra

Perpetra combines an off-chain orderbook with on-chain settlement. This page walks through what that means end to end, from the moment you submit an order to the moment your position is live.

## The hybrid model

<Steps>
  <Step title="You sign an order, not send a transaction">
    Placing an order doesn't cost gas and isn't a blockchain transaction.
    Instead, your wallet signs an
    [EIP-712](https://eips.ethereum.org/EIPS/eip-712) typed message describing
    the order: market, side, size, price, leverage. The signature proves the
    order came from you without broadcasting anything on-chain yet.
  </Step>

  <Step title="The matching engine looks for a counterparty">
    Your signed order is sent to Perpetra's off-chain matching engine, which
    holds the live orderbook in memory. It checks incoming orders against
    resting orders on the opposite side and looks for a price match.
  </Step>

  <Step title="A match triggers on-chain settlement">
    Once two orders match, the matching engine hands the fill off to be settled
    on-chain. A transaction is submitted to Perpetra's contracts, which validate
    the match, move collateral, and update both traders' positions.
  </Step>

  <Step title="Your position is now on-chain">
    From this point, your position (size, entry price, collateral, accrued
    funding) lives in Perpetra's on-chain position registry, the same as it
    would on a fully on-chain orderbook. Nothing about your custody or final
    state depends on the off-chain engine staying up.
  </Step>
</Steps>

<Note>
  Perpetra supports both **limit orders**, which rest on the book at your price
  until they're filled, and **market orders**, which match immediately against
  the best available price on the opposite side.
</Note>

## Why not a pooled-liquidity model?

Pool-based perpetuals (like GMX) let traders take the opposite side of a shared liquidity vault, with price derived from an oracle rather than an orderbook. That model needs less counterparty depth to get going, but it means every trader is effectively trading against the pool, and pricing follows the oracle rather than real bid/ask activity.

Perpetra's orderbook model means:

* Prices reflect actual resting orders, not just an oracle feed
* Liquidity providers aren't on the other side of every trade; other traders are
* Limit orders behave like limit orders: they sit at your price until filled

The tradeoff is that an orderbook needs depth to have tight spreads and reliable fills, which is why Perpetra runs market-making keepers to keep the book populated (more on this in [Protocol Architecture](/architecture/overview)).

## Keeping prices honest

Because matching happens off-chain, Perpetra needs a way to make sure the price you trade at doesn't drift too far from the real market. Two mechanisms handle this:

* **Mark price**: a smoothed reference price (index price plus an EMA-adjusted premium) used for PnL and liquidation calculations, so a single stale or manipulated orderbook print can't trigger unfair liquidations. See [Mark Price & Index Price](/trading/mark-price-and-index-price).
* **Funding rate**: a periodic payment between longs and shorts that pushes the perpetual's price back toward the spot price whenever they drift apart. See [Funding Rate](/trading/funding-rate).

## What's next

* New to placing an order? Start with [Placing Orders](/trading/placing-orders).
* Want the contract-level view of this same flow? See [Order Lifecycle](/architecture/order-lifecycle) in Protocol Architecture.
