Fill Status Lifecycle
| Status | Meaning |
|---|---|
matched | Orders matched off-chain. Fill created, awaiting settlement |
settling | Settlement transaction submitted to Solana, waiting for confirmation |
settled | Transaction confirmed. USDC transferred between personal smart wallets |
retrying | Settlement failed temporarily; engine will retry automatically |
failed | Settlement failed permanently (e.g., insufficient on-chain balance) |
failed_insufficient_balance | User’s smart wallet balance was insufficient at settlement time |
How Settlement Works
Match
The matching engine pairs a maker order with a taker order. A fill record is created with
status: matched.Batch
The settlement worker groups pending fills into batches for efficient on-chain submission. Multiple fills can settle in a single Solana transaction.
Submit
The engine builds a Solana transaction containing the fill details and both users’ Ed25519 signatures (from the original order messages). The fill status moves to
settling.Verify On-Chain
The on-chain program verifies:
- Both order signatures are valid
- Prices and quantities match
- Both users have sufficient balances in their personal smart wallets
- The market is still active
Fill Types
The engine supports three matching mechanisms, each with a different settlement flow:Direct Fill
A buyer and seller of the same outcome are matched. Settlement transfers USDC from the buyer’s smart wallet to the seller’s smart wallet, while outcome tokens transfer from seller to buyer.| Side | Smart Wallet Debit | Receives |
|---|---|---|
| Buyer (YES) | USDC (from smart wallet) | YES tokens |
| Seller (YES) | YES tokens | USDC (to smart wallet) |
Complementary Fill
A buyer of YES and a buyer of NO are matched whenyesPriceBps + noPriceBps >= 10000. USDC is transferred from both buyers’ smart wallets into the market vault, and the vault mints one YES token and one NO token (always backed 1:1).
| Side | Smart Wallet Debit | Receives |
|---|---|---|
| YES buyer | USDC (yesPrice, from smart wallet) | YES tokens |
| NO buyer | USDC (noPrice, from smart wallet) | NO tokens |
Sell Complementary Fill
A seller of YES and a seller of NO are matched. Both outcome tokens are burned, and the vault returns the backing USDC directly to both sellers’ personal smart wallets.| Side | Sends | Receives (Smart Wallet Credit) |
|---|---|---|
| YES seller | YES tokens | USDC (split, to smart wallet) |
| NO seller | NO tokens | USDC (split, to smart wallet) |
WebSocket Events
During the settlement lifecycle, relevant events are emitted on both the market channel and user channel:| Event | Channel | When |
|---|---|---|
trade (status: matched) | Market | Fill is created |
trade (status: settled) | Market | Fill is settled on-chain (includes settleTx) |
fill:matched | User | Your fill is created |
fill:settling | User | Your fill is being settled |
fill:settled | User | Your fill is settled (includes settleTx) |
fill:failed | User | Your fill failed settlement |
balance:update | User | Your balances changed |
Viewing Settlement Transactions
After a fill is settled, thesettleTx field contains the Solana transaction signature. You can view it on:
- Solscan:
https://solscan.io/tx/{settleTx} - Solana Explorer:
https://explorer.solana.com/tx/{settleTx}
Timing
Settlement typically occurs within a few seconds of matching. The engine processes fills in batches and submits transactions as quickly as Solana block times allow. If settlement fails due to a transient issue (RPC errors, congestion), the engine automatically retries. The fill status will showretrying during this period.
While a fill is in
settling or retrying status, the associated orders show settling status and cannot be cancelled. This lock is released once settlement succeeds or permanently fails.