Skip to content

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.

AreaPaper mode rule
Apphttps://paper.arenaton.com
APIhttps://server.arenaton.com/api/paper/*
ChainPolygon Amoy 80002
CollateralPaperUSDC only
Registry/api/paper/contract-registry
Portfolio sourceconfirmed 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.

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 resolution

The first fill for a binary Market is commonly complementary buy-side demand:

YES buyer signs buy YES at price P
NO buyer signs buy NO at price 1 - P or better

ArenatonCTFSettlement 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 positive FillPositionDelta events.

The settlement contract must not retain PaperUSDC or Outcome Shares after the transaction.

After a user owns Outcome Shares, resale uses same-outcome buy/sell matching:

seller signs sell YES
buyer signs buy YES

ArenatonCTFSettlement 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 FillPositionDelta and one negative seller FillPositionDelta.

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.

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 FillPositionDelta quantities for the same account, condition, and outcome.
  • Subtract PayoutRedemption quantities 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.

Core paper tracer endpoints:

GET /api/paper/markets
GET /api/paper/markets/{marketId}
GET /api/paper/markets/{marketId}/book
GET /api/paper/markets/{marketId}/trades
GET /api/paper/markets/{marketId}/rules
GET /api/paper/accounts/{account}/portfolio
GET /api/paper/accounts/{account}/positions
GET /api/paper/accounts/{account}/fills
POST /api/paper/faucet/claim
POST /api/paper/orders
POST /api/paper/orders/{orderId}/cancel
POST /api/paper/settlement/run
POST /api/paper/markets/{marketId}/live-events/simulate
POST /api/paper/markets/{marketId}/close
POST /api/paper/markets/{marketId}/resolve
POST /api/paper/markets/{marketId}/resolution/finalize
POST /api/paper/markets/{marketId}/redeem
WS /api/paper/ws

Important WebSocket events:

paper_market_book
paper_matched_pending_fill
paper_settlement_confirmed
paper_account_positions
paper_market_lifecycle
paper_redemption_confirmed
paper_market_live_state
paper_status

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.