> For the complete documentation index, see [llms.txt](https://docs.nexus.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nexus.xyz/exchange/trading/perpetuals/margining.md).

# Margining

Margin is enforced **natively inside the exchange engine** and verified atomically before any order is accepted. Margining is **whole-account (cross)**: your entire USDX balance is the collateral pool backing every open position. Per-market isolated margin is planned for a later release.

### Definitions

| Term                   | Meaning                                                                             |
| ---------------------- | ----------------------------------------------------------------------------------- |
| **Notional**           | `position_size × mark_price` — the value of the position at the current mark price. |
| **Equity**             | Account balance + unrealized PnL across all positions.                              |
| **Initial margin**     | Collateral required to *open or increase* a position.                               |
| **Maintenance margin** | Minimum collateral required to *keep* a position open.                              |

### Initial margin

Initial margin is the notional scaled by the market's initial margin rate:

```
initial_margin = position_size × mark_price × initial_margin_rate
```

Equivalently, `initial_margin_rate = 1 / max_leverage`. The engine sums the initial margin required across all positions and rejects an order if your equity cannot cover it.

### Maintenance margin

Each market defines its own **maintenance margin rate** — a configured fraction of notional, not a value derived from leverage at request time:

```
maintenance_margin = position_size × mark_price × maintenance_margin_rate
```

The maintenance margin rate is always **less than or equal to** the initial margin rate (the engine rejects any configuration where maintenance exceeds initial). A position becomes eligible for liquidation when account equity falls below the total maintenance margin across all positions:

```
liquidatable when:  equity < Σ maintenance_margin
```

> **Current testnet values.** Every market currently runs a deliberate **flat 2% margin profile** — `initial_margin_rate = maintenance_margin_rate = 0.02`, which corresponds to **up to 50x** maximum leverage. These are per-market configurable and will be tuned per market in later gates. See Market Specifications for the live per-market values.

### Why mark price, not last price

All margin calculations use the mark price — an external index price — rather than the last trade on the book. This prevents a single thin-book trade from pushing an account into liquidation.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.nexus.xyz/exchange/trading/perpetuals/margining.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
