Under the hood.
Llatria is a self-contained prediction-market exchange. The bonding curve, the order book, the ledger, and settlement all run here — no third-party venue, custody, or market-data feed. It’s play money today, but it’s engineered to the standards a regulated exchange has to meet. Here’s how the pieces fit.
Two phases: curve, then book
Every market lives a two-phase life that mirrors how liquidity actually forms.
Phase 1 — the bonding curve
A new market opens on a constant-product automated market maker (CPMM). It quotes YES and NO continuously, so the market is tradeable the instant it’s created — no waiting for a counterparty, no empty book. Prices move with every buy and sell, the math is integer-exact (no floating-point drift), and every position is fully collateralized: $1 backs one YES + one NO contract, and a contract pays exactly $1.00 if it wins, $0 if it doesn’t.
Graduation
When a market crosses $10,000 in cumulative volume, it has proven demand. The curve freezes, and its liquidity and every open position migrate 1:1 onto the order book — collateral carried over so nothing is ever left unbacked.
Phase 2 — the order book
A native central limit order book (CLOB) takes over: binary contracts priced in whole cents (1–99¢), limit and market orders, price-then-time priority, partial fills and cancels. Matching either opens a new YES/NO pair from collateral, transfers an existing pair between traders, or redeems a pair back to cash — always fully collateralized, never leveraged. Self-trades are prevented and flagged.
Money: the internal ledger
Llatria runs its own money layer — there is no external custodian. A double-entry ledgertracks each account’s available and reserved balances and every market’s collateral pool. Each operation posts balanced legs (debits equal credits) and is idempotency-safe, so a retried trade or order never double-charges.
Balances are play money today. The ledger is deliberately shaped so a real bank/FBO + KYC adapter can slot in later — gated entirely on regulatory designation. Nothing in the architecture assumes a third party holds the money.
Resolution & settlement
At a market’s close, a resolution source decides the outcome. Sources are pluggable: a manual review, a data feed, or an AI classifier with a human backstop. The AI auto-resolves only on a confident, decisive verdict; anything ambiguous is routed to a human, and disputed markets wait for a human decision.
Settlementpays $1.00 per winning contract from the market’s collateral pool; the remainder returns to the creator’s seed. The pool drains exactly to zero — money is only ever redistributed, never created or destroyed.
Built like a regulated exchange
Even in play-money demo, the seams a designated contract market needs are in place from day one:
- Self-trade prevention and wash-trade / manipulation flags in the matching engine.
- Position-limit and surveillance hooks.
- A prohibited-category screen at market creation (see Acceptable Use), plus moderation.
- An append-only audit log capturing every trade, graduation, surveillance flag, and resolution — with forensic before/after snapshots of pool state.
The stack
Backend: Go over Postgres, as a handful of focused packages:
- ledgerdouble-entry play-money custody + collateral pools
- cpmmthe constant-product bonding curve
- clobthe deterministic matching engine (open / transfer / redeem)
- marketorchestration under a per-market lock
- resolutionresolution sources + the human-backstopped AI adapter
- liveLiveKit tokens for per-market video + voice
- storage · pubsubPostgres repos, the audit log, and SSE fan-out
Frontend: Next.js + React, with Server-Sent Events driving real-time prices, the order book, and activity.
Core tables:
accounts · ledger_entries · markets · curve_pools · curve_trades · positions · orders · fills · resolutions · resolution_sources · event_log · users
+ social & live: follows · notifications · market_comments · live_sessions
Guarantees
- Full collateralization. $1 backs each YES + NO pair — no leverage, no margin.
- Money conservation. Settlement only redistributes; pools drain to zero.
- Idempotency. Retried trades and orders never double-charge.
- Determinism. The matching engine is deterministic — same inputs, same fills.
- Auditability. An append-only log records every state change.
Play money while we’re in demo — built, from day one, to earn its place the honest way.