Concepts
Clearing and d*
All orders in a batch trade at one discount, d*, chosen to match the most volume.
Finding d*
For every tick k on the grid:
- D(k) is the size of all buys whose minimum discount is at or under k;
- S(k) is the size of all sells whose maximum discount is at or over k;
- the volume that could trade at k is min(D(k), S(k)).
The clear picks the k with the largest volume. Ties go to the smallest imbalance |D(k) − S(k)|; any tie left over is an interval, and d* is its middle, rounded toward the lower discount. A lone crossing pair therefore clears halfway between the two limits.
Because both sides are sized in SPACEX, d* depends only on the book, not on the oracle price. The Pyth price sets the level: price = P_SPCXx × (1 − d*).
Who fills
Fills follow price priority:
- buyers fill from the lowest minimum discount up, since they bid the most;
- sellers fill from the highest maximum discount down, since they ask the least;
- the last tick touched on each side is shared pro rata by size.
Every order at a better tick than the marginal one fills in full. Orders past it get nothing.
Rounding
Whoever receives rounds down and whoever pays rounds up, so the vault stays solvent in both assets after every settlement.
Checking a clear yourself
Every batch page shows the revealed book as a histogram, the D(k) and S(k) curves, and d*. The page also recomputes the clear in your browser from the published histogram, with the same function the program mirrors, and shows whether it matches.