CTF Paper Mode
CTF Paper Mode is the no-real-value proving ground for Arenaton Exchange. It must behave like the production exchange shape while staying isolated on Polygon Amoy with PaperUSDC.
Boundaries
Section titled “Boundaries”| Area | Paper mode rule |
|---|---|
| App | https://paper.arenaton.com |
| API | https://server.arenaton.com/api/paper/* |
| Chain | Polygon Amoy 80002 |
| Collateral | PaperUSDC only |
| Registry | /api/paper/contract-registry |
| Portfolio source | confirmed paper settlement, lifecycle, resolution, redemption, and indexer state |
Paper mode cannot sign Polygon mainnet orders, call the production faucet, reuse production order books, or show PaperUSDC in real portfolios.
End-To-End Path
Section titled “End-To-End Path”Flutter paper app claims PaperUSDC through /api/paper/faucet/claim loads paper Market and registry signs EIP-712 ArenatonOrder
Go paper exchange validates chain, collateral, registry, fee, signature, and Live State Version matches compatible orders marks fills matchedPending
ArenatonCTFSettlement verifies both signed orders settles primary or resale path emits settlement and position-delta events
CTF indexer projection stores canonical logs by chain, tx, block, and log index aggregates position deltas subtracts confirmed redemptions rewinds and replays on reorg
Flutter portfolio shows pending fills before settlement shows Outcome Shares only after confirmed settlement/indexer state shows redeemable Markets only after finalized resolutionSettlement Modes
Section titled “Settlement Modes”Primary Binary Match
Section titled “Primary Binary Match”The first fill for a binary Market is commonly complementary buy-side demand:
YES buyer signs buy YES at price PNO buyer signs buy NO at price 1 - P or betterArenatonCTFSettlement settles this by:
- transferring PaperUSDC from both buyers,
- splitting Collateral into CTF YES and NO Outcome Shares,
- transferring YES shares to the YES buyer and NO shares to the NO buyer,
- charging only the taker fee, capped by the Fee Ceiling,
- emitting
FillSettled,FillSettlementAccounts,FillSettlementSignatures, and two positiveFillPositionDeltaevents.
The settlement contract must not retain PaperUSDC or Outcome Shares after the transaction.
Secondary Resale
Section titled “Secondary Resale”After a user owns Outcome Shares, resale uses same-outcome buy/sell matching:
seller signs sell YESbuyer signs buy YESArenatonCTFSettlement settles this by:
- transferring Collateral from buyer to seller and fee recipient,
- transferring existing CTF Outcome Shares from seller to buyer,
- emitting one positive buyer
FillPositionDeltaand one negative sellerFillPositionDelta.
Failed resale cannot create user debt. If approvals, signatures, expiry, cancellation, Live State Version, or balances fail, settlement reverts and the fill is failed by the worker/API path.
Indexer Rules
Section titled “Indexer Rules”Confirmed paper portfolio state follows chain/indexer state, not UI state.
- Store every canonical log with chain ID, contract address, transaction hash, block number, block hash, and log index.
- Treat duplicate logs as idempotent.
- Rewind all affected logs when a block number reappears with a different block hash.
- Aggregate
FillPositionDeltaquantities for the same account, condition, and outcome. - Subtract
PayoutRedemptionquantities from positions. - Never let a later fill overwrite earlier balance for the same account/outcome.
- Expose redeemable Markets only after resolver payout reporting and finalized lifecycle state.
The in-memory Go CTF harness covers canonical identity, duplicate logs, aggregation, redemption subtraction, and reorg replay. DB-backed production indexer wiring remains a production blocker.
Paper API Surface
Section titled “Paper API Surface”Core paper tracer endpoints:
GET /api/paper/marketsGET /api/paper/markets/{marketId}GET /api/paper/markets/{marketId}/bookGET /api/paper/markets/{marketId}/tradesGET /api/paper/markets/{marketId}/rulesGET /api/paper/accounts/{account}/portfolioGET /api/paper/accounts/{account}/positionsGET /api/paper/accounts/{account}/fills
POST /api/paper/faucet/claimPOST /api/paper/ordersPOST /api/paper/orders/{orderId}/cancelPOST /api/paper/settlement/runPOST /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
WS /api/paper/wsImportant WebSocket events:
paper_market_bookpaper_matched_pending_fillpaper_settlement_confirmedpaper_account_positionspaper_market_lifecyclepaper_redemption_confirmedpaper_market_live_statepaper_statusEvidence Expectations
Section titled “Evidence Expectations”CTF Paper Mode must preserve faucet idempotency, signed order intake, indexer projection, settlement, lifecycle transitions, resolution, finalization, and redemption. Paper-mode evidence does not approve production real-money trading by itself.