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 oracle price. The matching process is triggered by two separate scenarios:
  • A new order is placed (matching runs automatically for that market)
  • A matching transaction is sent to the protocol
In each matching cycle, the matching algorithm runs through three steps on the executable unfilled orders:
1

Reduce vs Reduce

Closing-long orders are matched against closing-short orders. This pairs traders who are both reducing or closing existing positions.
2

Leftover Reduce vs Same-Side Increase

Any remaining unmatched reduce orders are matched against increase orders on the same side. For example, leftover closing-long orders match against opening-long orders. A trader closing a long is paired with a trader opening a new long.
3

Increase vs Increase

Any remaining opening-long orders are matched against opening-short orders. This pairs traders taking new opposing positions.
If an order is only partially filled in a cycle, the unfilled portion remains in the queue for the next matching cycle.

Order priority

Within each step, orders are processed using price-time priority:
  1. Liquidation close orders are always processed first.
  2. Price priority orders with a more favorable execution price threshold are filled before others.
  3. Time priority (FIFO) among orders at the same price level, earlier orders are filled first.