Skip to main content
Matching is the process by which orders are filled and corresponding positions are created, closed, and updated. All matches execute at the current . The matching process on a market is triggered automatically by two separate scenarios:
  • A is placed (excludes )
  • A matching transaction is sent to the protocol

How matching works

Each time matching is triggered for a market, the algorithm runs through these steps:
1

Collect executable orders

Every unfilled standard order whose permits execution at the current oracle price is collected. Orders whose threshold is outside that range are skipped this round.
2

Build two queues

The collected orders are split into two opposing queues by the direction they trade:
  • The long queue holds every order that buys. Orders opening a long position and orders closing a short position.
  • The short queue holds every order that sells. Orders opening a short position and orders closing a long position.
Within each queue, orders are arranged by priority (see Order priority below).
3

Match standard orders

The two queues are filled against each other by total notional value, working down from the top of each queue. This first stage fills liquidations, reduce orders, and increase orders. The smaller side of that flow is filled completely; the larger side is filled up to the same notional.For example, if first-stage long flow totals 1,000 of notional and first-stage short flow totals 500, the short side is fully filled and the first 500 of notional on the long side is filled.
4

Fill remaining flow against no-rush orders

Any leftover size from the first stage can fill against no-rush orders on the opposite side. No-rush orders never fill against other no-rush orders. If both sides still have leftover no-rush size, that size stays unfilled this round.
If an order is only partially filled in a cycle, the unfilled portion remains in its queue for the next matching cycle.

Order priority

Within each queue, orders are filled in a strict priority order. There is no price priority. An order’s execution price threshold only determines whether it is executable, not its place in the queue. No-rush orders are unrestricted and skip that threshold check. Orders are filled in the following order of priority:
  1. Liquidations: Close orders generated by the liquidation engine are filled first.
  2. Reduce orders: orders that close or reduce an existing position are filled next.
  3. Increase orders: orders that open or add to a position are filled next.
  4. No-rush orders: remaining opposing flow can then fill against no-rush orders. Within this stage, no-rush reduce orders fill before no-rush increase orders.
Within each level of priority, orders are filled in time priority (FIFO). The order placed earliest is filled first. No-rush orders never fill against other no-rush orders, even if they sit on opposite sides of the book.

Liquidation

When positions are closed by the protocol.

Troubleshooting

Why an order might not fill.
Last modified on October 23, 2026