How orders execute
Every trade fills at the next oracle print, in ticket order. Why that removes latency arbitrage, and what rejects mean.
In PPM you never trade against the price on your screen. You place an order, and it fills at the first oracle print after it, at that print's price plus or minus the spread. This page explains the rules and why they exist.
The queue
- Place. Opening a position, closing (all or part of) it, and withdrawing margin are requests:
requestOpen,requestReduce,requestRemoveMargin. LP deposits and withdrawals are requests too. Each takes the next ticket from one per-market counter. An open order escrows its margin immediately. A position has at most one pending order. - Print. When the oracle publishes a price, every ticket issued before that moment joins the print's batch. Tickets issued after it wait for the next print.
- Process. Anyone (usually the keeper, in the same transaction as the print) processes the batch strictly in ticket order. Every rule that depends on time (freshness, close-only, funding and borrow accrual) uses the print instant, no matter when the processing transaction lands. The next print is refused until the batch is done, and the oracle can publish at most one print per second.
- Fill or reject. Each order is fill-or-kill at its print. If it can fill, it does, with your limit price respected. If it can't, it is rejected: escrow is refunded, the ticket is consumed, and the reason is stored on your position so the app can show it. A reject never blocks the queue.
Adding margin is not queued: it is immediate, because it can only make a position safer. It is refused (BatchPending) only while a print's batch is still waiting to be processed, which normally happens in the same transaction as the print.
Why latency can't be gamed
In the previous version, trades filled at the last print. Anyone who saw the reference market move before the oracle published could trade at a price that was already wrong: a risk-free profit taken from LPs every print. With next-print fills:
- nobody chooses which print an order fills at: always the first one after it;
- nobody chooses whether it fills: processing is compulsory and its result depends only on the print and the queue;
- nobody chooses the order of fills within a print: it is first in, first out;
- nobody can walk away after seeing news: an order can only be cancelled when the oracle has gone stale (no print for longer than
max_price_age, 120 s in the simulator) or after resolution; - nobody can sneak in an old observation: a print's timestamp may be at most
max_oracle_lag(30 s here, never more than 60 s) behind the time it is published, and an order only fills at an observation taken after it was placed.
What is left is the short delay between an observation and its publication, which the spread and the oracle's confidence cover. Information that arrives after your order's print is genuine forecasting skill and pays exactly as before. Someone who knows the outcome outright still trades at a fresh price, and the profit cap plus price impact bound what they can take (see Fees).
Tested by simulation
The reference core runs trading strategies against 60 random price paths of 400 prints each (a martingale with occasional news jumps, 100-contract trades at about 4× leverage). The same simulation runs in this app's test suite on the TypeScript port and gets identical results:
| Strategy | Result (all paths) |
|---|---|
| Fill at the last print while knowing the next one (old rules) | trader +$2,485.52: the hole is real |
| Know every print one step early, order on it (v3 rules) | trader −$305.78 (6 of 60 paths win) |
| Know the price 30 prints ahead (forecasting) | trader +$1,905.12 |
| Random uninformed flow | LPs +$816.92 |
| See each observation before the oracle publishes it, order on it | 0 of 706 orders filled (all rejected: observation predates the order) |
Reject reasons
The app shows the last reject in plain words. What each one means:
| Reason | What happened |
|---|---|
| SlippageExceeded | The print plus spread was worse than your limit price. |
| InsufficientMargin | At the print, your margin couldn't cover the fee, impact and 10% initial margin (for a margin withdrawal: what would remain, valued at the exit price, is below initial margin). |
| BelowMinMargin | Margin after fees would be under the market minimum ($1). |
| InsufficientLiquidity | The vault couldn't pre-fund your maximum payout on top of everyone else's. |
| OpenInterestCap | Your side's total size would exceed the market's cap. |
| PriceOutOfBand | The print was outside 2¢–98¢, too close to certainty to open. |
| PriceUncertain | The print's confidence was wider than 2¢. Opens and margin withdrawals wait for calmer prints; closes still fill. |
| TradingClosed | The market reached its close-only time before your open filled. |
| MarketPaused | The guardian paused new risk. Closes still fill. |
| RequestNotReady | The print carried an observation taken before your order, so it can't fill at it. Place it again. |
| PositionExists / NoPosition | The position changed before the order's turn, for example it was liquidated before your close. |
| MarketNotActive | The market resolved while the order was queued; escrow refunded. |
| StalePrice | The print was older than the market allows by the time the batch ran. |
Placing an order can also fail immediately (nothing is queued): for example RequestPending if one is already waiting, TradingClosed after the cutoff, or BatchPending for an add-margin sent while a batch is open.
Previews
The trade panel runs the exact fill procedure of the contracts (the TypeScript port is checked bit-for-bit against the reference core) as if your order filled at a print at today's price and confidence. The real fill uses the next print, so set a limit price you are happy with.