Skip to main content
Margin is computed per sub-account. Deposits land in the main spot account; to trade with leverage, users move collateral into a margin sub-account and place orders against that account.

Sub-accounts

Sub-accounts isolate balances, positions, and margin checks from each other.

Account types

Cross-margin is not global across all of a user’s accounts. Two cross-margin sub-accounts have separate collateral pools and separate liquidation risk.

Creating Accounts And Transfers

There is no separate “create sub-account” endpoint. Create an account by transferring spot balance into a new target_index with target_account_type set. POST /account/transfer/sub-account moves spot balance between sub-accounts owned by the same user. The request is signed and submitted to the OMS, which forwards it to the clearing engine. Transfers and withdrawals move spot balances only, so a leveraged position cannot leave a sub-account intact. A margin position has two legs:
  • Asset (base) balance — the directional exposure. It cannot be transferred or withdrawn while non-zero; close it by trading it to zero through orders.
  • Quote (USD) balance — the cash leg. Once the asset balance is zero, POST /account/transfer/close-position folds the remaining quote into the sub-account’s spot balance, from where it can be transferred (for example, back to the main account) or withdrawn.
A position therefore exits a sub-account only by being closed, never by being moved out with an open asset balance. The examples below show request shape. Real requests must include a valid signature over inner and any required additional signers. To transfer into an existing account:
To create a new account, choose an unused target_index and include the type:
For isolated margin, use {"Isolated": {"asset": "2"}} as the target type. Spot sub-accounts use "Spot". Validation rules:
  • source_index and target_index must differ.
  • transfer_amount must be non-zero and available in the source account, in 18-decimal internal units.
  • If the target exists, omit target_account_type; if it does not exist, include it.
  • A transfer out of a margin account must leave the source passing margin checks. If a configured minimum sub-account balance applies, the remaining balance must be either zero or above that minimum.
  • A transfer into a margin account must satisfy account-type rules and any configured minimum balance.
  • Assets with zero collateral factor cannot be transferred out of a spot account.
  • Isolated-only assets cannot be moved into cross-margin. An isolated account accepts only its isolated asset and USD.
Rename user-created accounts with PATCH /account/{user_id}/sub-account/{account_index}/name. Accounts 0 and 1 keep the reserved names Spot and Margin. Custom names must be 1-32 characters, cannot contain control characters, and cannot be Spot or Margin.

Margin requirements

Margin is computed in USD per sub-account from per-asset risk parameters published onchain in the registry and served by GET /registry/risk-parameters. Values in examples are illustrative.

Requirements and surplus

A sub-account is measured against two thresholds.
  • Maintenance margin (MM) — the threshold for avoiding liquidation, calculated as MM surplus: the distance from liquidation (distance_from_liquidation internally, maintenance_margin_surplus in the API). An account becomes liquidatable only when it has borrows, has no circuit-broken collateral, and its MM surplus falls below zero.
  • Initial margin (IM) — the threshold for opening or increasing a position, calculated as IM surplus. A risk-increasing order is admitted only if it leaves IM surplus >= zero.

Risk parameters

MM and IM replace raw market value with conservative, risk-adjusted value. Three per-asset registry parameters set the haircuts:
  • Collateral factor (CF) — only CF of an asset’s value counts as collateral, rounded down. Applies to the asset side of MM.
  • Liability factor (LF) — borrows count at (2 - LF) of value, rounded up; e.g. LF = 50% counts a borrow at 1.5x. Applies to the borrow side of MM.
  • IM factor — for IM, assets are valued at im_factor * CF * price and borrows at (2 - im_factor) * (2 - LF) * price. im_factor is 1.0 at low exposure and steps down toward a floor as net spot-margin exposure in an asset approaches its open-interest cap, tightening IM as the market crowds.
im_factor steps down from 1.0 toward a floor as spot-margin exposure approaches the open-interest cap Illustrative. im_factor is 1.0 at low exposure and steps down to a floor as exposure nears the cap; the breakpoints and floor are per-asset registry parameters.

Equations

Margin checks

This is when each requirement is evaluated: IM checks apply only to accounts with open borrows. Risk-reducing trades skip IM requirements. ie. an account with negative IM surplus can submit a trade that still results in a negative IM surplus as long as IM surplus improved.

Trading capacity and order pressure

Every resting order reserves margin in case it fills. Trading capacity is the IM surplus left after that reservation:
GET /margin/user/{user_id} reports it as available_margin. Both pressure terms are defined below.

Order pressure

An order’s pressure is the margin it would consume if it filled, including taker fees. Only the quantity that would increase risk counts:
  • A buy nets against an existing margin short in the same asset; only buy quantity beyond that short adds pressure.
  • A sell nets against an existing margin long in the same asset; only sell quantity beyond that long adds pressure.
  • A reduce-only order’s reducing quantity has zero pressure; quantity that would flip or grow exposure is not valid as reduce-only.
Offsets are per asset: a short in ETH nets only against ETH buys, never against buys on another book. For one order’s risk-increasing notional:
Example — a 5,000 USD order on an asset with CF = 80%, LF = 80%, im_factor = 90%, taker fee 2.5 bps (1.25 USD):

Aggregating across books

Pressure pools by direction across every book in the sub-account: all buys into buy_side_pressure, all sells into sell_side_pressure, regardless of asset. Capacity subtracts only the larger total:
The max is taken once over the whole sub-account, not per book. Buys and sells move exposure in opposite directions, so only the heavier side is reserved. Offsets stay per-asset — a BTC short never nets against ETH buys — but residual pressures pool across assets within each side. Example — one cross-margin sub-account, IM surplus 3,000 USD, same risk params as above (buy factor 0.28, sell factor 0.32, fee 2.5 bps of notional), resting orders on three books:
The SOL sell adds no margin cost while the buy side is heavier. Rest a second 4,000 USD SOL sell and sell-side pressure becomes 2,562.00 USD, overtakes the buy side, and capacity drops to 3,000 - 2,562.00 = 438.00 USD.

Admission

A new order only adds to its own side, so it can only lower that side’s capacity. It is admitted if the resulting capacity stays above a small minimum, else rejected with InsufficientMargin.
  • Negative capacity triggers auto-reduce, which cancels or shrinks resting orders farthest-from-market first, per side.
  • Market-maker accounts: post-only orders skip this pre-flight check. MM accounts are exempt from auto-reduce.

Account leverage

Leverage reported by the margin API is total notional divided by equity:
Example: 60,000 USD total notional and 15,000 USD equity reports 4x leverage.

Protocol caps

Caps are checked on the proposed post-trade protocol state for every modified non-USD asset. They reject only cap-increasing changes; decreases or unchanged exposure pass. The checks are:
Total OI example: if post-trade ETH total OI would be 2,010 ETH, mark is 100 USD, oracle is 99 USD, and the cap is 200,000 USD, the mark-side notional is 201,000 USD, so the trade is rejected. A trade that reduces total OI passes even if the market is already above the cap. Spot-margin OI example: if aggregate ETH credits are 700 ETH and aggregate ETH borrows are 950 ETH, spot-margin OI is abs(700 - 950) = 250 ETH. With a 200 ETH cap, a trade that increases the imbalance is rejected; a trade that brings it toward zero passes. Collateral cap example: if margin sub-accounts already hold 9,500 ETH and the ETH collateral cap is 10,000 ETH, adding 600 ETH as margin collateral is rejected because post-trade usage would be 10,100 ETH. Removing collateral passes.

Margin endpoints

See the Trading API for authentication, signing, and request schemas. External venue accounts can also count as collateral via cross-margining.