Clearing
Opposite orders cross at one price; solvers compete for the rest; the program checks the result before a token moves.
1 Crossing and the net
For each pair, opposite orders fill against each other at a candidate price without touching an AMM. What is left on one side after crossing is the net.
2 Bids
Solvers read the opened orders, cross them, price the net and post a bid backed by their bond. At the end of the bid window the program takes the bid that leaves the pair's orders the most surplus.
A pair with no bid fills only if its orders cross completely; otherwise they are returned unfilled.
A complete cross clears at the batch's own balancing price: the total quote paid divided by the total base paid, over the orders whose limits that price meets. Nothing is routed. After the bid window anyone can call it with the included set, and the program checks that every included order's limit meets the price, that no excluded order's does, and that the vault balances.
3 One transaction
The winner clears in one transaction: clear_begin releases the net to the solver, the solver's route instructions run, and clear_end checks that the vault received the other side at the bid price or better. The program reads the instructions sysvar to require both in the same transaction.
On mainnet the route is Jupiter Swap API V2 (/build, transactionVersion=1); the solver signs the v1 transaction itself (4096 bytes, 64 accounts inline).
A winner that fails to clear inside its window loses its bond to the pair's orders, and the next bid takes the window.
4 What the program checks
- Every revealed order whose limit the batch price meets is filled in full, and no other order is filled.
- Every fill is at the batch price.
- The vault's balance of each token changes by exactly the fills, the net and the fees, to the atom.