# Liquidation

Mosaiq liquidates at the account level. An account is liquidatable when it
has positive maintenance margin and

```text
accountValue < maintenanceMarginUsed
```

`accountValue` is settled cash plus unrealized PnL. `maintenanceMarginUsed`
sums every position leg's notional times its maintenance rate, marked at the
oracle or index price of the venue that holds the leg. Open orders reserve
initial margin but are not part of maintenance margin.

## Process

For each liquidatable account Mosaiq:

1. selects the leg with the largest maintenance-margin contribution;
2. sizes a reduction intended to restore the account above maintenance with a
   buffer, capped at 50% of that leg's notional;
3. cancels the account's open orders and waits until they are resolved;
4. sends a reduce-only market order on that leg's venue;
5. re-evaluates the account after the fill.

Liquidation can require several partial reductions. Only one reduction at a
time is sent for an account.

## Costs

A liquidation reduce is a taker execution. It pays the venue fee, the Mosaiq
taker fee, and a liquidation penalty proportional to the maintenance margin
of the size reduced. The penalty rate is fixed when the reduce is sized and
booked when its fill settles.

## Failure handling

Repeated liquidation failures can cause Mosaiq to halt trading platform-wide
and cancel all live user orders. During the halt,
`withdraw` fails with `operations_halted`, modifies are rejected, and only
immediate reduce-only placements are admitted. You can still cancel orders.

There is no insurance fund. If an account's value is still negative after its
positions are flat, the deficit stays on that account; it is not charged to
other users.

Venue collateral is managed separately by [Rebalancing](/concepts/rebalancing).
