Paper Trading Backend
The paper backend is the no-real-value proving ground for Arenaton Exchange. It lives in the Go pulse server and mirrors the production exchange shape while staying isolated on Polygon Amoy with PaperUSDC.
Paper mode must be useful enough to test the whole flow, but it must never blur into production funds, production order books, or production registries.
Flutter paper app -> PaperUSDC faucet -> EIP-712 order signing -> Go paper exchange order intake -> price/time matching -> settlement run -> CTF-style position deltas -> lifecycle and resolution -> direct redemption -> WebSocket and portfolio projectionCore Modules
Section titled “Core Modules”| Module | Responsibility |
|---|---|
| Order intake | Validate JSON, account, signature, registry, collateral, fee, expiry, and Live State Version. |
| Matching | Apply price/time priority, maker/taker semantics, self-trade prevention, and partial fills. |
| Settlement | Confirm primary split or resale transfer semantics and emit position deltas. |
| Lifecycle | Close, resolve, finalize, invalidate, and expose redeemable Markets. |
| Faucet | Mint no-value PaperUSDC with rate limits and maximum balance rules. |
| Indexer projection | Aggregate confirmed position deltas and subtract redemptions. |
| Incident controls | Pause intake, hide Markets, set close-only mode, retry settlement, and publish audit notes. |
| WebSocket hub | Broadcast book, fill, lifecycle, live-state, portfolio, redemption, and status events. |
Order States
Section titled “Order States”OPEN -> MATCHED_PENDING_SETTLEMENT -> SETTLED -> CANCELED -> EXPIRED -> STALEAn order becomes stale when its liveStateVersion no longer matches the Market. Material game, score, period, feed, or final-state changes must invalidate old live orders.
Matching Rules
Section titled “Matching Rules”- Better price wins.
- Earlier submission wins at the same price.
- Resting orders are makers; incoming orders are takers.
- Buy YES plus buy NO can settle as a primary binary split.
- Buy YES plus sell YES can settle as secondary resale.
- Buy NO plus sell NO can settle as secondary resale.
- The same beneficial account must not self-trade.
- Partial fills reduce remaining quantity without changing the original digest.
Settlement Modes
Section titled “Settlement Modes”Primary Binary Split
Section titled “Primary Binary Split”YES buyer signs buy YES at price PNO buyer signs buy NO at price 1 - P or bettersettlement confirms both signaturessettlement splits Collateral into YES and NO Outcome Sharesposition deltas credit both buyersSecondary Resale
Section titled “Secondary Resale”seller owns YESseller signs sell YESbuyer signs buy YESsettlement transfers Collateral to sellersettlement transfers YES Outcome Shares to buyerposition deltas debit seller and credit buyerFailed resale must not create user debt. If approval, balance, signature, expiry, cancellation, Live State Version, or registry validation fails, the fill stays failed/retryable according to the worker path.
Lifecycle And Redemption
Section titled “Lifecycle And Redemption”DRAFT -> SCHEDULED -> OPEN_PRE_EVENT -> OPEN_LIVE -> CLOSING -> CLOSED_PENDING_RESOLUTION -> RESOLVED or INVALID -> REDEEMABLERedeemable Markets appear only after final resolution. Redemption subtracts confirmed positions from the projection and emits a redemption event.
API Surface
Section titled “API Surface”GET /api/paper/marketsGET /api/paper/markets/{marketId}GET /api/paper/markets/{marketId}/bookGET /api/paper/markets/{marketId}/tradesGET /api/paper/markets/{marketId}/rules
POST /api/paper/faucet/claimPOST /api/paper/ordersPOST /api/paper/orders/{orderId}/cancelPOST /api/paper/settlement/run
GET /api/paper/accounts/{account}/portfolioGET /api/paper/accounts/{account}/positionsGET /api/paper/accounts/{account}/fillsGET /api/paper/accounts/{account}/orders
POST /api/paper/markets/{marketId}/live-events/simulatePOST /api/paper/markets/{marketId}/closePOST /api/paper/markets/{marketId}/resolvePOST /api/paper/markets/{marketId}/resolution/finalizePOST /api/paper/markets/{marketId}/redeem
GET /api/paper/statusWS /api/paper/wsAdmin endpoints exist for incident controls and audit logs. They must stop new risk without mutating settled user positions or blocking allowed cancellation/redemption paths.
WebSocket Events
Section titled “WebSocket Events”paper_market_bookpaper_matched_pending_fillpaper_settlement_confirmedpaper_account_positionspaper_market_lifecyclepaper_redemption_confirmedpaper_market_live_statepaper_statusSafety Guarantees
Section titled “Safety Guarantees”- PaperUSDC has no real value.
- Paper and production order books are separate.
- Paper and production contract registries are separate.
- Paper builds refuse Polygon mainnet signing.
- Production builds refuse Amoy signing.
- Pending fills are not confirmed Outcome Shares.
- Portfolio positions derive from confirmed settlement/indexer state.
- No admin path may transfer user Collateral or Outcome Shares.
Release Evidence
Section titled “Release Evidence”Paper backend changes require evidence that order intake, matching, settlement, lifecycle, redemption, WebSocket projection, and admin incident controls still preserve user asset boundaries.