On-chain matching
The NeutronX order book lives in network state, and the validators match it in every block. Matching rules are the same for every participant, and every validator checks them.
Where matching happens
The proposer takes new orders from the mempool and matches them against the book. It places the resulting trades in the first transaction of the block. The other validators repeat the matching and reject the block on any mismatch. Trades are settled at the start of block execution.
Details are in Architecture.
Priority
- Price. The best price executes first.
- Block. Within one price level, an order from an earlier block goes first.
- Place in the block. Within one block, the order that comes earlier in the block goes first. No order field, including
client_id, can move it in the queue.
Trade price
| Case | Price |
|---|---|
| Limit orders crossed while matching in the block | The price of the order that rested in the book first, if it is inside the execution band, otherwise the other order's price |
| Market order | The price of the resting order it matches |
| System orders: liquidations, SL/TP, TWAP, POV, position close | The price of the resting order it matches |
The oracle price and the mark price never set a trade price. They are used only for margin, liquidations and conditional order triggers.
A consequence of the first row: the order that crossed the book later gets the price of the order resting in it, as on any continuous book.
Price bands
| Band | Value | What it limits |
|---|---|---|
| Placement | 50% of the oracle price | How far from the oracle an order can be placed |
| Execution | 1% of the oracle price, 0.5% for BTC and ETH | At what price a trade can execute |
An order beyond the execution band rests in the book and fills once the oracle price comes closer. Governance sets the bands for each market.
Self-trading and post-only
- Self-trading. An order never matches an opposite order of the same owner. That order is skipped, and matching continues down the book.
- Post-only. A post-only order never takes liquidity. If it would fill at once, at placement or later as the oracle price moves, it is cancelled.
If a trade fails to settle
Each trade settles separately. If settlement fails, for example one side lacks margin, the whole trade is cancelled. The order of the side that caused the failure is removed from the book. The other side stays in the book.
Limits
| Limit | Value |
|---|---|
| Minimum order size | 10 USDC |
| Open orders per subaccount | 500 |
| Placements and replacements per address per block | 30, each order of a batch counts separately |
| Active orders across the network | 500,000 |