# Liquidation

Mosaiq liquidates at the account level. An account is liquidatable when it
holds a position 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

Health is re-evaluated on every risk tick after funding, confirmed fills, and
fees for that tick have settled. For each liquidatable account Mosaiq:

1. selects the leg with the largest maintenance-margin contribution;
2. sizes a reduce that brings the account back above maintenance with a
   buffer, capped at 50% of that leg's notional;
3. cancels the account's open orders;
4. sends one reduce-only market order on the leg's own venue through the normal
   execution path: a marketable IOC on Hyperliquid, a native market order on
   Lighter;
5. settles the confirmed fill and re-evaluates on a later tick.

Most liquidations are therefore partial and may take several ticks. While a
reduce is in flight, no second reduce is sent for the same 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

If three consecutive liquidation reduces on the same leg end without a fill
for reasons other than a venue outage, Mosaiq halts trading platform-wide,
cancels all live user orders, and waits for an operator. During the halt,
`withdraw` fails with `operations_halted`, modifies are rejected, and only
immediate reduce-only placements are admitted; cancels are not gated. Reduces
on a leg are retried at most once per second.

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).
