# Rebalancing

Mosaiq trades through omnibus venue accounts. Rebalancing is how Mosaiq keeps
enough USDC on each venue so orders and liquidation reduces can keep executing
when margin usage moves across venues.

The goal is to prevent venue-level undercollateralization when another venue or
the operator wallet has idle collateral. It is a safety mechanism, not a
guarantee against every venue, withdrawal, or oracle failure.

## What It Moves

Rebalancing is **collateral-only**. It moves Mosaiq operator collateral between
the operator wallet and venue accounts.

It does not directly:

* debit a user balance;
* withdraw user funds;
* close a user position.

User position reduction is handled by [Liquidation](/concepts/liquidation) when
an account is unhealthy.

## How It Decides

For each venue, Mosaiq tracks:

```text
venue margin used / venue account value
```

When a venue is above the rebalance trigger, Mosaiq estimates how much USDC is
needed to bring it back under the target. It funds that need in this order:

1. idle USDC in the operator wallet;
2. safe free margin from another venue, capped by the donor venue's threshold;
3. no transfer if the amount is below the venue minimum deposit.

Mosaiq does not withdraw from a donor venue if doing so would push that donor
above its own safety threshold.

## How It Moves Funds

A wallet-to-venue rebalance is a deposit. A venue-to-venue rebalance withdraws
to the operator wallet, then deposits to the target venue.

Each operation is journaled before transactions are sent. Only one rebalance
plan runs at a time. If funds enter an unknown state, new rebalances halt until
an operator reconciles the transfer.

## User Impact

Most rebalances are invisible to users: balances, positions, and fills do not
change just because Mosaiq moved collateral between venues.

Possible impact during stress:

* new orders can be rejected or delayed if the selected venue does not have
  enough safe margin yet;
* venue choice can matter because beta orders are routed to the requested venue;
* if rebalancing cannot restore venue margin and the user account itself is
  unhealthy, the risk engine may liquidate according to
  [Liquidation](/concepts/liquidation);
* deposits and withdrawals remain manual during the beta and are separate from
  internal rebalancing.

:::note\[Transfer costs]
Rebalancing transfer costs are Mosaiq operating costs. Normal user fill fees
are documented in [Fees](/concepts/fees).
:::
