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

# Perpetuals

> How positions, margin, funding, and liquidation work.

> [!NOTE]
>
> **Testnet-Only.** Perpetuals is available on Ault Testnet. Mainnet currently supports Spot DEX only.

Perpetuals let you go long or short without holding the underlying asset. Profit, loss, trading fees, and funding all change your account equity.

Prices are quoted in the market's quote currency, but collateral is always the configured collateral token. For example, `GOLD/USD` is priced in USD, while Testnet collateral is USDC. Ault DEX does not convert between USD and USDC, so 1 USD of PnL or margin counts as 1 USDC, even if USDC trades away from 1 USD.

## Accounts and margin

Each owner has one cross account and a separate isolated account for each market. Cross positions share equity. An isolated position has its own collateral, and its risk is kept separate from other positions.

Resting orders use margin from your cross account, even for isolated positions. They do not hold Spot tokens. Opening or increasing an isolated position can move collateral from cross to isolated when the order fills.

Initial margin is required to open or increase a position. Maintenance margin is the level below which a position can be liquidated. Your maximum leverage depends on the position's notional size. To change a market's margin mode, first close its positions, resting orders, and pending conditional orders.

### Sizing reference

`q` is your signed position size, `Q` is its carried quote balance, `M` is the mark price, `C` is account collateral, and `F` is funding owed. `B` and `A` are the total size of resting bids and asks in each market, excluding reduce-only orders.

```text theme={null}
Position PnL = q * M + Q
Equity = C + sum(position PnL - F)
Position notional N = abs(q) * M
Initial margin IM = sum(N / min(selected leverage, tier max leverage at N))
Worst-case base W = max(abs(q + B), abs(q - A))
Market order margin = (W - abs(q)) * M
                      / min(selected leverage, tier max leverage at W * M)
Cross order margin OM = sum(market order margins)
Available margin = equity - IM - OM
```

Order margin always comes from cross, even when the position is isolated. Initial and order margin round up.

Maintenance margin uses the tier's maximum leverage, not your selected leverage. For a position in tier `t`, `MM = N * r_t - D_t`, where `r_t = 1 / (2 * tier maximum leverage)` and `D_t` sums the lower tier caps times each increase in maintenance ratio. This deduction prevents a sudden jump in maintenance margin when a position moves into the next tier. An account's maintenance margin is the sum across its positions.

### Withdrawal constraint and example

```text theme={null}
Required equity after cross withdrawal = max(IM, total notional * transfer floor) + OM
Maximum withdrawal = floor(max(equity - required equity, 0))
```

Withdrawals need a recent mark price. Available margin is not the amount you can withdraw. Removing margin from an isolated position has its own limit and returns the funds to cross.

For example, assume 20x leverage and a 10% transfer floor. A position is long 10 at 97, the mark is 100, collateral is 180, and it owes 10 in funding. It has 6 units of bids and 8 of asks.

| Measure | Calculation | Result |
| - | - | - |
| Equity | `180 + 10 * (100 - 97) - 10` | 200 |
| Notional / initial margin | `10 * 100`; `1,000 / 20` | 1,000 / 50 |
| Worst-case base / order margin | `max(16, 2)`; `(16 - 10) * 100 / 20` | 16 / 30 |
| Maintenance, within the first tier | `1,000 / (2 * 20)` | 25 |
| Available margin | `200 - 50 - 30` | 120 |
| Maximum withdrawal | `200 - (max(50, 1,000 * 10%) + 30)` | 70 |

## Metal market units

| Market | One unit of the base asset |
| - | - |
| `GOLD/USD` | 1 troy ounce of gold |
| `SILVER/USD` | 1 troy ounce of silver |
| `SILVER/USDC` | 1 troy ounce of silver |
| `PLATINUM/USD` | 1 troy ounce of platinum |

Prices are in the market's quote currency per troy ounce. For example, a position of 2 `GOLD/USD` represents 2 troy ounces of gold.

## Order rules that differ from Spot

* Perpetual markets accept limit orders only. For immediate execution, use an IOC limit order with a worst price.
* Use reduce-only when an exit must not open, increase, or flip a position.
* Order margin assumes the side of your resting orders that would create the larger position. Requirements across markets add up.
* Conditional and TWAP orders do not hold margin in advance. Margin is checked when each order activates or each slice runs.
* Position caps and open-interest caps are separate limits. Resting orders do not reserve open-interest capacity.
* A protocol halt does not close positions or cancel orders.

## Prices, PnL, and funding

The execution price determines your fill. The mark price values your positions and margin. The index is a separate reference used for pricing and funding. See [Oracle](https://docs.aultblockchain.com/ault-dex/oracle.md) for how these prices are built.

Closing a position moves its PnL into collateral. Unrealized PnL and pending funding already count toward equity.

Funding accrues over UTC-hour windows: `pending funding = q * (current cumulative index - last settled index)`. A positive result is owed and reduces equity. A protocol halt or invalid index data can discard a funding window.

A mark price can be old. Not every trading or liquidation path rejects an old mark, but cross withdrawals and isolated-margin removals do.

## Liquidation and ADL

| Condition | What can happen |
| - | - |
| Equity is zero or higher, but below maintenance margin | Ordinary liquidation cancels orders and tries to close the position with a reduce-only IOC order. It may not fully fill. |
| An eligible account is below the backstop threshold, but its equity is not negative | A protocol vault can take over the positions and collateral. This is not guaranteed. |
| Equity is negative | Auto-deleveraging (ADL) can reduce profitable positions on the opposite side. One pass may not resolve everything. |

Cross liquidation looks at the whole account, so a single liquidation price cannot capture every position, funding change, and margin tier.

Ordinary liquidation cancels orders only in the affected Perpetual account, not in your Spot or other isolated accounts. A TWAP can survive liquidation and try later slices, so cancel it if you no longer want it.


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