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

# Exchange abstraction

> One engine, many venues — the exchange abstraction layer.

The exchange-abstraction layer is what lets Perps Agent ship **one grid engine, one AI loop, one proof layer** — against many venues.

## The adapter interface

Every venue implements the same small surface:

* `placeOrder(...)`, `cancelOrder(...)`, `cancelAll(...)`
* `streamFills()`, `streamPositions()`, `streamFunding()`
* `getMarket(marketId)` — tick size, lot size, fee schedule, max leverage
* `enforceCaps(caps)` — reject any order that would breach committed risk caps

If a venue can answer that interface, the rest of Perps Agent works against it unchanged.

## What lives above the adapter

* The grid engine (ladder generation, refill logic, PnL tracking).
* The AI loop (param proposal, risk-adjusted scoring).
* The Mantle proof layer (commit / attest / recall).
* The Telegram UX.

## What lives below the adapter

* Venue-specific REST / WebSocket / RPC code.
* Venue-specific signing, rate limits, and error handling.
* Venue-specific normalization (symbols, decimals, funding conventions).

## Why this matters

* **Velocity.** Adding a venue is one adapter, not a fork of the agent.
* **Comparability.** The same risk-adjusted score is computed the same way across venues, so attested track records are apples-to-apples.
* **Resilience.** A venue going down doesn't break the engine — it just disables that adapter.
