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

# Margin and Vaults

> How trader collateral and market maker capital are actually held

Traders and makers post capital very differently on perps.ordr. A trader's
funds are theirs alone. A maker's funds sit in one shared pool with every
other maker approved on that asset.

## A trader's margin and vault

Every trader has two accounts: a **margin account**, which is just a ledger
of `free_balance` and `locked_balance`, and a **vault**, the token account
that USDC actually sits in. Depositing and withdrawing moves tokens in and
out of that vault; opening and closing a position just moves the ledger
between free and locked.

**Isolated margin** locks `margin + a reserved fee` out of free balance the
moment an order is submitted, checked against both the worst price the
batch could give it and the oracle price, so a position can never land
already underwater. If free balance alone is short, the difference is
pulled automatically from the trader's cross collateral, if any.

**Cross margin** works differently. Every trader's cross position lives in
one single, shared account, not one per trader: up to 1024 entries, each
holding up to 4 open positions and its own small price table that's kept
current for every market it's exposed to, refreshed every batch. Opening a
cross position needs the account's total equity, collateral plus every open
position's running PnL and funding, to cover its initial margin requirement
plus whatever's already reserved; only one cross order can be in flight at
a time per account. Withdrawing needs collateral, after unrealized losses,
to still clear the account's initial margin requirement. A market only
carries cross positions if it has opted in, and can't opt back out while
any are still open.

The first cross deposit needs at least 1 USDC, specifically so the account
can't be left open on dust that nobody would bother to use, and anyone can
evict a genuinely idle entry, freeing it for someone else.

## A maker's capital

A maker does not fund each market, or even each leverage tier, separately,
and does not hold a private vault at all. Every maker approved on a pool
shares **one token account**, owned by the pool itself. A maker's own share
of it is tracked as a balance in their own slot inside the pool, alongside
one inventory record per leverage tier in that pool, so a single deposit
can back live positions on every tier an asset offers at once.

| Instruction | What it does |
| - | - |
| `maker_deposit` | Adds to a maker's balance inside the pool's shared account |
| `maker_request_withdraw` | Starts a 24 hour unlock on a withdrawal |
| `maker_withdraw` | Pays the withdrawal out, once allowed |

A withdrawal isn't just a balance check. It's only allowed once the maker's
own equity, their balance plus every leverage tier's inventory marked at
the pool's last recorded price, still clears a 20% cover requirement on
what they have open, and the pool as a whole still has enough left to cover
everything it owes and everything already promised out. Pairing a real
solvency check with a 24 hour delay on withdrawal requests is what lets
makers fund many markets from one balance without that balance quietly
becoming unable to back what it's already quoting.

## The insurance fund

Each market keeps its own insurance fund, a single account that collects 1%
of every liquidation and nothing else. It exists purely as a second line of
defense: when a trader is owed a profit the pool's own balance can't fully
cover, insurance pays what it can before anything is left as an IOU.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.