Status Flow
Step-by-Step Flow
User Creates RFQ
The user submits a parlay bet request with 2-5 legs, each referencing a Kalshi market ticker and a side (yes/no).The system validates that each market exists in our cache and is still active on Kalshi, then broadcasts the RFQ to all connected market makers via WebSocket.Status:
openMarket Makers Submit Quotes
Market makers see the RFQ on the The payout is calculated as:
rfqs:open WebSocket channel and submit quotes with their payout odds.- total_cost = bet_amount (e.g., $100)
- total_payout = bet_amount x payout_odds (e.g., $400)
- mm_payout (MM’s risk) = total_payout - total_cost (e.g., $300)
quotedUser Accepts Best Quote
The user reviews quotes (sorted by best payout odds) and accepts one.This rejects all other pending quotes and gives the market maker a 5-second confirmation deadline.Status:
acceptedMarket Maker Confirms
The market maker must confirm within 5 seconds, triggering the on-chain vault position creation.Status:
confirmedOn-Chain Vault Position Creation
The system executes a single atomic Solana transaction via the Status:
parlay_vaults program. The fee payer covers gas so users and MMs only need USDC in their vaults. User/MM signatures are obtained via Privy TEE wallets.create_position — Both the user’s stake and the MM’s collateral are locked atomically in their persistent vaults. The MM’s collateral is calculated via ILP (Integer Linear Programming) to reflect incremental worst-case exposure across their portfolio, not the full risk amount.The transaction signature and position PDA address are stored in the database and displayed in the UI with links to Solana Explorer.Vault Architecture
Learn more about the vault architecture, Privy TEE wallet integration, and gas-sponsored transactions.
executedSettlement
A background service polls Kalshi every 30 seconds to check if all leg markets have settled. Settlement transfers funds between vaults and deducts a protocol fee on profit:
- All legs win — MM’s risk amount (minus fee) is transferred from the MM vault to the user vault (
settled_win) - Any leg loses — User’s stake (minus fee) is transferred from the user vault to the MM vault (
settled_loss)
settledBackground Services
Two background services manage the vault position lifecycle:- vault-job-service (every 5s) — Processes pending positions: resolves Privy wallets, calculates ILP exposure, executes
create_position - vault-settlement-service (every 30s) — Polls market results, settles or cancels active positions based on outcomes
Validation Rules
| Parameter | Constraint |
|---|---|
| Legs per parlay | 2-5 |
| Bet amount | 100 USDC |
| Payout odds | 1.01x - 1000x |
| RFQ expiration | 60 - 3600 seconds |
| Quote validity | Configurable (default 60s) |
| MM confirmation window | 5 seconds |
