{"openapi":"3.1.0","info":{"title":"Sybil API","description":"HTTP API for AI agent trading on Sybil prediction markets","license":{"name":""},"version":"0.1.0"},"paths":{"/v1/accounts":{"post":{"tags":["routes::accounts"],"summary":"POST /v1/accounts","operationId":"create_account","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateAccountRequest"}}},"required":true},"responses":{"200":{"description":"Account created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountResponse"}}}},"403":{"description":"Dev mode required"}}}},"/v1/accounts/{id}":{"get":{"tags":["routes::accounts"],"summary":"GET /v1/accounts/{id}","operationId":"get_account","parameters":[{"name":"id","in":"path","description":"Account ID","required":true,"schema":{"type":"integer","format":"int64","minimum":0}}],"responses":{"200":{"description":"Account details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountResponse"}}}},"404":{"description":"Account not found"}}}},"/v1/accounts/{id}/bridge-key":{"get":{"tags":["routes::bridge"],"summary":"GET /v1/accounts/{id}/bridge-key","operationId":"account_key","parameters":[{"name":"id","in":"path","description":"Account ID","required":true,"schema":{"type":"integer","format":"int64","minimum":0}}],"responses":{"200":{"description":"Account bridge key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BridgeAccountKeyResponse"}}}},"404":{"description":"Account not found"}}}},"/v1/accounts/{id}/equity":{"get":{"tags":["routes::accounts"],"summary":"GET /v1/accounts/{id}/equity?range=","operationId":"get_equity","parameters":[{"name":"id","in":"path","description":"Account ID","required":true,"schema":{"type":"integer","format":"int64","minimum":0}},{"name":"range","in":"query","description":"Time range: 24h | 7d | 30d | all (default all)","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Per-account equity series","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EquitySeriesResponse"}}}}}}},"/v1/accounts/{id}/events":{"get":{"tags":["routes::accounts"],"summary":"GET /v1/accounts/{id}/events?limit&before&category","operationId":"get_account_history","parameters":[{"name":"id","in":"path","description":"Account ID","required":true,"schema":{"type":"integer","format":"int64","minimum":0}},{"name":"limit","in":"query","description":"Max events (default 50, cap 500)","required":false,"schema":{"type":"integer","minimum":0}},{"name":"before","in":"query","description":"Cursor \"<block>.<seq>\"; returns events strictly before it","required":false,"schema":{"type":"string"}},{"name":"category","in":"query","description":"trades | funding | settlement","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Account history feed, newest-first","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/HistoryEventResponse"}}}}}}}},"/v1/accounts/{id}/fills":{"get":{"tags":["routes::accounts"],"summary":"GET /v1/accounts/{id}/fills","operationId":"get_account_fills","parameters":[{"name":"id","in":"path","description":"Account ID","required":true,"schema":{"type":"integer","format":"int64","minimum":0}},{"name":"market_id","in":"query","description":"Filter by market ID","required":false,"schema":{"type":"integer","format":"int32","minimum":0}},{"name":"limit","in":"query","description":"Result limit","required":false,"schema":{"type":"integer","minimum":0}},{"name":"offset","in":"query","description":"Result offset","required":false,"schema":{"type":"integer","minimum":0}}],"responses":{"200":{"description":"Account fill history","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/AccountFillResponse"}}}}}}}},"/v1/accounts/{id}/fund":{"post":{"tags":["routes::accounts"],"summary":"POST /v1/accounts/{id}/fund","operationId":"fund_account","parameters":[{"name":"id","in":"path","description":"Account ID","required":true,"schema":{"type":"integer","format":"int64","minimum":0}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FundAccountRequest"}}},"required":true},"responses":{"200":{"description":"Account funded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountResponse"}}}},"403":{"description":"Dev mode required"},"404":{"description":"Account not found"}}}},"/v1/accounts/{id}/keys":{"post":{"tags":["routes::accounts"],"summary":"POST /v1/accounts/{id}/keys","operationId":"register_key","parameters":[{"name":"id","in":"path","description":"Account ID","required":true,"schema":{"type":"integer","format":"int64","minimum":0}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RegisterKeyRequest"}}},"required":true},"responses":{"200":{"description":"Key registered"},"400":{"description":"Invalid key"},"404":{"description":"Account not found"}}}},"/v1/accounts/{id}/orders":{"get":{"tags":["routes::orders"],"summary":"GET /v1/accounts/{id}/orders — pending orders for an account","operationId":"get_account_orders","parameters":[{"name":"id","in":"path","description":"Account ID","required":true,"schema":{"type":"integer","format":"int64","minimum":0}}],"responses":{"200":{"description":"Pending orders","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/PendingOrderResponse"}}}}}}}},"/v1/accounts/{id}/portfolio":{"get":{"tags":["routes::accounts"],"summary":"GET /v1/accounts/{id}/portfolio","operationId":"get_portfolio","parameters":[{"name":"id","in":"path","description":"Account ID","required":true,"schema":{"type":"integer","format":"int64","minimum":0}}],"responses":{"200":{"description":"Portfolio summary","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PortfolioResponse"}}}},"404":{"description":"Account not found"}}}},"/v1/activity/overview":{"get":{"tags":["routes::aggregates"],"summary":"GET /v1/activity/overview","operationId":"get_activity_overview","responses":{"200":{"description":"Platform-wide aggregates","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ActivityOverviewResponse"}}}}}}},"/v1/blocks":{"get":{"tags":["routes::blocks"],"summary":"GET /v1/blocks?limit=N — last N blocks, newest-first, from in-memory history.","operationId":"get_recent_blocks","parameters":[{"name":"limit","in":"query","description":"Recent blocks, newest-first; clamped to history capacity (default 20)","required":false,"schema":{"type":"integer","minimum":0}}],"responses":{"200":{"description":"Recent blocks, newest-first","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/BlockResponse"}}}}}}}},"/v1/blocks/latest":{"get":{"tags":["routes::blocks"],"summary":"GET /v1/blocks/latest","operationId":"get_latest_block","responses":{"200":{"description":"Latest block","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BlockResponse"}}}},"404":{"description":"No blocks produced yet"}}}},"/v1/blocks/stream":{"get":{"tags":["routes::blocks"],"summary":"GET /v1/blocks/stream","operationId":"stream_blocks","responses":{"200":{"description":"SSE stream of block events"}}}},"/v1/blocks/ws":{"get":{"tags":["routes::blocks"],"summary":"GET /v1/blocks/ws","description":"WebSocket stream of committed blocks. See\n`docs/architecture/WebSocket Block Stream.md` for the message schema,\nbackpressure policy, and reconnect semantics.\n\nQuery parameters:\n- `from_block=<height>` — replay every block from `height` up to the\n  current head before switching to live. Used by clients to resume\n  after a `lagged` close without gaps.","operationId":"ws_blocks","parameters":[{"name":"from_block","in":"query","description":"Replay from this block height","required":false,"schema":{"type":"integer","format":"int64","minimum":0}}],"responses":{"101":{"description":"WebSocket upgrade for block streaming"}}}},"/v1/blocks/{height}":{"get":{"tags":["routes::blocks"],"summary":"GET /v1/blocks/{height}","operationId":"get_block_by_height","parameters":[{"name":"height","in":"path","description":"Block height","required":true,"schema":{"type":"integer","format":"int64","minimum":0}}],"responses":{"200":{"description":"Block at height","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BlockResponse"}}}},"404":{"description":"Block not found"}}}},"/v1/bridge/accounts/by-key/{key_hex}":{"get":{"tags":["routes::bridge"],"summary":"GET /v1/bridge/accounts/by-key/{key_hex}","operationId":"account_by_key","parameters":[{"name":"key_hex","in":"path","description":"Hex-encoded Sybil bridge account key","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Account bridge key mapping","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BridgeAccountKeyResponse"}}}},"403":{"description":"Dev mode required"},"404":{"description":"Bridge key not found"}}}},"/v1/bridge/deposits":{"post":{"tags":["routes::bridge"],"summary":"POST /v1/bridge/deposits","operationId":"submit_l1_deposit","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubmitL1DepositRequest"}}},"required":true},"responses":{"200":{"description":"L1 deposit accepted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BridgeDepositResponse"}}}},"403":{"description":"Dev mode required"}}}},"/v1/bridge/status":{"get":{"tags":["routes::bridge"],"summary":"GET /v1/bridge/status","operationId":"status","responses":{"200":{"description":"Bridge sidecar status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BridgeStatusResponse"}}}}}}},"/v1/bridge/withdrawals":{"post":{"tags":["routes::bridge"],"summary":"POST /v1/bridge/withdrawals","operationId":"create_withdrawal","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateBridgeWithdrawalRequest"}}},"required":true},"responses":{"200":{"description":"Withdrawal leaf created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BridgeWithdrawalResponse"}}}},"403":{"description":"Dev mode required"}}}},"/v1/bridge/withdrawals/signed":{"post":{"tags":["routes::bridge"],"summary":"POST /v1/bridge/withdrawals/signed","operationId":"create_signed_withdrawal","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateSignedBridgeWithdrawalRequest"}}},"required":true},"responses":{"200":{"description":"Signed withdrawal leaf created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BridgeWithdrawalResponse"}}}},"400":{"description":"Invalid withdrawal or signature"},"403":{"description":"Signer/account mismatch"},"404":{"description":"Unknown signer"}}}},"/v1/bridge/withdrawals/{id}":{"get":{"tags":["routes::bridge"],"summary":"GET /v1/bridge/withdrawals/{id}","operationId":"get_withdrawal","parameters":[{"name":"id","in":"path","description":"Withdrawal ID","required":true,"schema":{"type":"integer","format":"int64","minimum":0}}],"responses":{"200":{"description":"Withdrawal leaf","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BridgeWithdrawalResponse"}}}},"404":{"description":"Withdrawal not found"}}}},"/v1/events/{event_id}/traders":{"get":{"tags":["routes::aggregates"],"summary":"GET /v1/events/{event_id}/traders","operationId":"get_event_traders","parameters":[{"name":"event_id","in":"path","description":"Polymarket event id","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Unique placers across the event's markets","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EventTradersResponse"}}}}}}},"/v1/feeds":{"get":{"tags":["routes::feeds"],"summary":"GET /v1/feeds — list registered data feeds.","operationId":"list_feeds","responses":{"200":{"description":"Feeds","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/RegisteredFeedResponse"}}}}}}},"post":{"tags":["routes::feeds"],"summary":"POST /v1/feeds — register a data feed (dev mode only).","operationId":"register_feed","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RegisterFeedRequest"}}},"required":true},"responses":{"200":{"description":"Feed registered","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RegisteredFeedResponse"}}}},"403":{"description":"Dev mode required"}}}},"/v1/health":{"get":{"tags":["routes::system"],"summary":"GET /v1/health","description":"Returns 200 when the sequencer is running, 503 when it is unavailable.\nDownstream services and Docker healthchecks should treat any non-200 as\nunhealthy and stop routing traffic.","operationId":"health","responses":{"200":{"description":"Sequencer healthy","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthResponse"}}}},"503":{"description":"Sequencer unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthResponse"}}}}}}},"/v1/markets":{"get":{"tags":["routes::markets"],"summary":"GET /v1/markets","operationId":"list_markets","responses":{"200":{"description":"List of markets","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/MarketResponse"}}}}}}},"post":{"tags":["routes::markets"],"summary":"POST /v1/markets","operationId":"create_market","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateMarketRequest"}}},"required":true},"responses":{"200":{"description":"Market created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateMarketResponse"}}}},"403":{"description":"Dev mode required"}}}},"/v1/markets/groups":{"get":{"tags":["routes::markets"],"summary":"GET /v1/markets/groups","operationId":"list_market_groups","responses":{"200":{"description":"List of market groups","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/MarketGroupResponse"}}}}}}},"post":{"tags":["routes::markets"],"summary":"POST /v1/markets/groups","operationId":"create_market_group","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateMarketGroupRequest"}}},"required":true},"responses":{"200":{"description":"Market group created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MarketGroupResponse"}}}},"403":{"description":"Dev mode required"}}}},"/v1/markets/prices":{"get":{"tags":["routes::markets"],"summary":"GET /v1/markets/prices","operationId":"get_prices","responses":{"200":{"description":"Market prices","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MarketPricesResponse"}}}}}}},"/v1/markets/prices/reference":{"post":{"tags":["routes::markets"],"summary":"POST /v1/markets/prices/reference — set reference prices from external system (dev mode)","operationId":"set_reference_prices","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SetReferencePricesRequest"}}},"required":true},"responses":{"200":{"description":"Prices updated"}}}},"/v1/markets/search":{"get":{"tags":["routes::markets"],"summary":"GET /v1/markets/search","operationId":"search_markets","parameters":[{"name":"q","in":"query","description":"Text search","required":false,"schema":{"type":"string"}},{"name":"tags","in":"query","description":"Comma-separated tags","required":false,"schema":{"type":"string"}},{"name":"category","in":"query","description":"Category filter","required":false,"schema":{"type":"string"}},{"name":"status","in":"query","description":"Status filter","required":false,"schema":{"type":"string"}},{"name":"min_volume","in":"query","description":"Minimum volume","required":false,"schema":{"type":"integer","format":"int64","minimum":0}},{"name":"sort","in":"query","description":"Sort field","required":false,"schema":{"type":"string"}},{"name":"limit","in":"query","description":"Result limit","required":false,"schema":{"type":"integer","minimum":0}},{"name":"offset","in":"query","description":"Result offset","required":false,"schema":{"type":"integer","minimum":0}}],"responses":{"200":{"description":"Search results","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/MarketResponse"}}}}}}}},"/v1/markets/summary":{"get":{"tags":["routes::markets"],"summary":"GET /v1/markets/summary","description":"Minimal market data for dashboard polling — drops metadata strings\n(description, tags, resolution criteria, external URL). ~5-10x smaller\nwire size than /v1/markets.","operationId":"list_markets_summary","responses":{"200":{"description":"Slim list of markets","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/MarketSummaryResponse"}}}}}}}},"/v1/markets/{id}":{"get":{"tags":["routes::markets"],"summary":"GET /v1/markets/{id}","operationId":"get_market","parameters":[{"name":"id","in":"path","description":"Market ID","required":true,"schema":{"type":"integer","format":"int32","minimum":0}}],"responses":{"200":{"description":"Market details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MarketResponse"}}}},"404":{"description":"Market not found"}}}},"/v1/markets/{id}/metadata":{"post":{"tags":["routes::markets"],"summary":"POST /v1/markets/{id}/metadata — set external metadata for a market (dev mode)","operationId":"set_market_metadata","parameters":[{"name":"id","in":"path","description":"Market ID","required":true,"schema":{"type":"integer","format":"int32","minimum":0}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SetMarketMetadataRequest"}}},"required":true},"responses":{"200":{"description":"Metadata updated"}}}},"/v1/markets/{id}/open-batch":{"get":{"tags":["routes::aggregates"],"summary":"GET /v1/markets/{id}/open-batch","operationId":"get_open_batch","parameters":[{"name":"id","in":"path","description":"Market ID","required":true,"schema":{"type":"integer","format":"int32","minimum":0}}],"responses":{"200":{"description":"Open-batch state for this market","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpenBatchResponse"}}}}}}},"/v1/markets/{id}/orderbook":{"get":{"tags":["routes::orders"],"summary":"GET /v1/markets/{id}/orderbook — all pending orders for a market (dev mode)","operationId":"get_market_orderbook","parameters":[{"name":"id","in":"path","description":"Market ID","required":true,"schema":{"type":"integer","format":"int32","minimum":0}}],"responses":{"200":{"description":"Market order book","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/PendingOrderResponse"}}}}}}}},"/v1/markets/{id}/prices/history":{"get":{"tags":["routes::markets"],"summary":"GET /v1/markets/{id}/prices/history","operationId":"get_price_history","parameters":[{"name":"id","in":"path","description":"Market ID","required":true,"schema":{"type":"integer","format":"int32","minimum":0}},{"name":"from_ms","in":"query","description":"Start timestamp filter","required":false,"schema":{"type":"integer","format":"int64","minimum":0}},{"name":"to_ms","in":"query","description":"End timestamp filter","required":false,"schema":{"type":"integer","format":"int64","minimum":0}}],"responses":{"200":{"description":"Price history","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PriceHistoryResponse"}}}}}}},"/v1/markets/{id}/resolution":{"get":{"tags":["routes::markets"],"summary":"GET /v1/markets/{id}/resolution","operationId":"get_resolution","parameters":[{"name":"id","in":"path","description":"Market ID","required":true,"schema":{"type":"integer","format":"int32","minimum":0}}],"responses":{"200":{"description":"Resolution state","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResolutionResponse"}}}},"404":{"description":"Market not found"}}}},"/v1/markets/{id}/resolve":{"post":{"tags":["routes::markets"],"summary":"POST /v1/markets/{id}/resolve","operationId":"resolve_market","parameters":[{"name":"id","in":"path","description":"Market ID","required":true,"schema":{"type":"integer","format":"int32","minimum":0}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResolveMarketRequest"}}},"required":true},"responses":{"200":{"description":"Market resolved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResolveMarketResponse"}}}},"403":{"description":"Dev mode required"},"404":{"description":"Market not found"}}}},"/v1/orders":{"post":{"tags":["routes::orders"],"summary":"POST /v1/orders","operationId":"submit_orders","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubmitOrderRequest"}}},"required":true},"responses":{"200":{"description":"Orders accepted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderAcceptedResponse"}}}},"400":{"description":"Invalid order"},"404":{"description":"Account not found"}}}},"/v1/orders/cancel/signed":{"post":{"tags":["routes::orders"],"summary":"POST /v1/orders/cancel/signed","operationId":"cancel_signed_order","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CancelSignedOrderRequest"}}},"required":true},"responses":{"200":{"description":"Signed cancel accepted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CancelOrderResponse"}}}},"400":{"description":"Invalid signature payload"},"403":{"description":"Signer or owner mismatch"},"404":{"description":"Unknown signer or pending order not found"}}}},"/v1/orders/pending":{"get":{"tags":["routes::orders"],"summary":"GET /v1/orders/pending — all pending orders (dev mode)","operationId":"get_all_pending_orders","responses":{"200":{"description":"All pending orders","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/PendingOrderResponse"}}}}}}}},"/v1/orders/signed":{"post":{"tags":["routes::orders"],"summary":"POST /v1/orders/signed","operationId":"submit_signed_order","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubmitSignedOrderRequest"}}},"required":true},"responses":{"200":{"description":"Signed order accepted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderAcceptedResponse"}}}},"400":{"description":"Invalid order or signature"},"404":{"description":"Unknown signer"}}}},"/v1/proofs/state/{leaf_key_hex}":{"get":{"tags":["routes::proofs"],"summary":"GET /v1/proofs/state/{leaf_key_hex}","operationId":"get_state_proof","parameters":[{"name":"leaf_key_hex","in":"path","description":"Hex-encoded canonical state leaf key","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"State leaf inclusion or exclusion proof","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StateProofResponse"}}}},"400":{"description":"Invalid state leaf key"},"404":{"description":"No committed block yet"},"503":{"description":"Proof store unavailable"}}}},"/v1/state-root":{"get":{"tags":["routes::system"],"summary":"GET /v1/state-root","operationId":"state_root","responses":{"200":{"description":"Current state root","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StateRootResponse"}}}}}}}},"components":{"schemas":{"AccountFillResponse":{"type":"object","required":["order_id","fill_qty","fill_price_nanos","block_height","timestamp_ms","position_deltas"],"properties":{"block_height":{"type":"integer","format":"int64","minimum":0},"fill_price_nanos":{"type":"integer","format":"int64","minimum":0},"fill_qty":{"type":"integer","format":"int64","minimum":0},"order_id":{"type":"integer","format":"int64","minimum":0},"position_deltas":{"type":"array","items":{"$ref":"#/components/schemas/PositionDeltaResponse"}},"timestamp_ms":{"type":"integer","format":"int64","minimum":0}}},"AccountResponse":{"type":"object","required":["account_id","balance_nanos"],"properties":{"account_id":{"type":"integer","format":"int64","minimum":0},"balance_nanos":{"type":"integer","format":"int64"},"positions":{"type":"array","items":{"$ref":"#/components/schemas/PositionResponse"}}}},"ActivityOverviewResponse":{"type":"object","description":"Response shape for `GET /v1/activity/overview`. All-time + 24h slices.","required":["all_time","last_24h"],"properties":{"all_time":{"$ref":"#/components/schemas/OverviewBucketResponse"},"last_24h":{"$ref":"#/components/schemas/OverviewBucketResponse"}}},"BlockMarketStats":{"type":"object","description":"Nested per-market sidecar on `BlockResponse.by_market`. Grows append-only\nacross steps (each new field carries `#[serde(default)]` so partial\nreverts stay clean). Volume/orders/welfare join in B2 / B6 / B7.","properties":{"matched":{"type":"integer","format":"int32","description":"Resting orders touching this market that exited the book this\nblock AFTER at least one fill (B5's `has_been_matched`).","minimum":0},"placed":{"type":"integer","format":"int32","description":"Non-MM admissions counted against this market in this block.\nMulti-market orders credit each active market.","minimum":0},"placers":{"type":"integer","format":"int32","description":"Unique placers (non-MM accounts) admitted touching this market in\nthe block. Multi-market orders credit each active market; the\nplatform `unique_placers` scalar counts the account once.","minimum":0},"unmatched":{"type":"integer","format":"int32","description":"Resting orders touching this market that exited the book this\nblock WITHOUT any fill. Cancels are excluded.","minimum":0},"volume_nanos":{"type":"integer","format":"int64","description":"Per-market volume contribution from this block's fills, in nanos.\nMulti-market fills credit each active market with their full\nnotional; the platform `total_volume_nanos` scalar counts each fill\nonce.","minimum":0},"welfare_nanos":{"type":"integer","format":"int64","description":"Per-market welfare contribution from this block's fills (B7).\nMulti-market fills credit each active market with their full welfare;\nthe platform `total_welfare_nanos` counts each fill once. Signed —\nsolver rounding can yield small negatives."}}},"BlockResponse":{"type":"object","required":["height","parent_hash","state_root","events_root","order_count","fill_count","timestamp_ms","total_welfare_nanos","total_volume_nanos","orders_filled"],"properties":{"bridge":{"$ref":"#/components/schemas/BridgeBlockResponse"},"by_market":{"type":"object","description":"Nested per-market scalars (decision Q1 in BACKEND_DATA_PLAN.md). Each\n`BlockMarketStats` carries the per-market splits for this block. Old\nclients ignore it; new clients consume what they recognise.","additionalProperties":{"$ref":"#/components/schemas/BlockMarketStats"},"propertyNames":{"type":"string"}},"clearing_prices_nanos":{"type":"object","additionalProperties":{"type":"array","items":{"type":"integer","format":"int64","minimum":0}},"propertyNames":{"type":"string"}},"events_root":{"type":"string"},"fill_count":{"type":"integer","format":"int32","minimum":0},"fills":{"type":"array","items":{"$ref":"#/components/schemas/FillResponse"}},"height":{"type":"integer","format":"int64","minimum":0},"order_count":{"type":"integer","format":"int32","minimum":0},"orders_filled":{"type":"integer","minimum":0},"parent_hash":{"type":"string"},"rejections":{"type":"array","items":{"$ref":"#/components/schemas/RejectionResponse"}},"state_root":{"type":"string"},"system_events":{"type":"array","items":{"$ref":"#/components/schemas/SystemEventResponse"}},"timestamp_ms":{"type":"integer","format":"int64","minimum":0},"total_volume_nanos":{"type":"integer","format":"int64","minimum":0},"total_welfare_nanos":{"type":"integer","format":"int64"},"unique_placers":{"type":"integer","format":"int32","description":"Unique placers (non-MM accounts) admitted into this block. Platform\nscalar — `by_market[m].placers` is the per-market split.","minimum":0}}},"BridgeAccountKeyResponse":{"type":"object","required":["account_id","sybil_account_key_hex"],"properties":{"account_id":{"type":"integer","format":"int64","minimum":0},"sybil_account_key_hex":{"type":"string"}}},"BridgeBlockResponse":{"type":"object","required":["deposit_count","deposit_root_hex"],"properties":{"consumed_deposits":{"type":"array","items":{"$ref":"#/components/schemas/BridgeDepositEventResponse"}},"deposit_count":{"type":"integer","format":"int64","minimum":0},"deposit_root_hex":{"type":"string"},"withdrawal_leaves":{"type":"array","items":{"$ref":"#/components/schemas/BridgeWithdrawalResponse"}}}},"BridgeDepositEventResponse":{"type":"object","required":["deposit_id","account_id","amount_token_units","deposit_root_hex"],"properties":{"account_id":{"type":"integer","format":"int64","minimum":0},"amount_token_units":{"type":"integer","format":"int64","minimum":0},"deposit_id":{"type":"integer","format":"int64","minimum":0},"deposit_root_hex":{"type":"string"}}},"BridgeDepositResponse":{"type":"object","required":["account_id","balance_nanos","deposit_id","deposit_root_hex"],"properties":{"account_id":{"type":"integer","format":"int64","minimum":0},"balance_nanos":{"type":"integer","format":"int64"},"deposit_id":{"type":"integer","format":"int64","minimum":0},"deposit_root_hex":{"type":"string"}}},"BridgeStatusResponse":{"type":"object","required":["deposit_cursor","deposit_root_hex","next_withdrawal_id","withdrawal_count"],"properties":{"deposit_cursor":{"type":"integer","format":"int64","minimum":0},"deposit_root_hex":{"type":"string"},"next_withdrawal_id":{"type":"integer","format":"int64","minimum":0},"withdrawal_count":{"type":"integer","minimum":0}}},"BridgeWithdrawalResponse":{"type":"object","required":["withdrawal_id","account_id","recipient_hex","token_hex","amount_token_units","amount_nanos","expiry_height","nullifier_hex","withdrawal_leaf_hex","withdrawal_leaf_digest_hex","created_at_height"],"properties":{"account_id":{"type":"integer","format":"int64","minimum":0},"amount_nanos":{"type":"integer","format":"int64","minimum":0},"amount_token_units":{"type":"integer","format":"int64","minimum":0},"created_at_height":{"type":"integer","format":"int64","minimum":0},"expiry_height":{"type":"integer","format":"int64","minimum":0},"nullifier_hex":{"type":"string"},"recipient_hex":{"type":"string"},"token_hex":{"type":"string"},"withdrawal_id":{"type":"integer","format":"int64","minimum":0},"withdrawal_leaf_digest_hex":{"type":"string"},"withdrawal_leaf_hex":{"type":"string"}}},"CancelOrderResponse":{"type":"object","required":["cancelled"],"properties":{"cancelled":{"type":"boolean"}}},"CancelSignedOrderRequest":{"type":"object","required":["account_id","order_id","signer_pubkey_hex","signature_hex"],"properties":{"account_id":{"type":"integer","format":"int64","description":"Account ID claiming ownership of the order being cancelled.","minimum":0},"order_id":{"type":"integer","format":"int64","description":"The pending order to cancel.","minimum":0},"signature_hex":{"type":"string","description":"Hex-encoded P256 ECDSA signature over the canonical cancel payload."},"signer_pubkey_hex":{"type":"string","description":"Hex-encoded compressed P256 public key of the signer."}}},"CreateAccountRequest":{"type":"object","required":["initial_balance_nanos"],"properties":{"initial_balance_nanos":{"type":"integer","format":"int64","description":"Initial balance in nanos (1 dollar = 1_000_000_000 nanos).","example":100000000000,"minimum":0}}},"CreateBridgeWithdrawalRequest":{"type":"object","required":["account_id","chain_id","vault_address_hex","recipient_hex","token_address_hex","amount_token_units"],"properties":{"account_id":{"type":"integer","format":"int64","description":"Sybil account whose available balance is burned.","minimum":0},"amount_token_units":{"type":"integer","format":"int64","description":"Token base units released by the vault.","minimum":0},"chain_id":{"type":"integer","format":"int64","description":"Destination chain id.","minimum":0},"expiry_height":{"type":["integer","null"],"format":"int64","description":"Last Sybil block height at which this withdrawal leaf is valid.","minimum":0},"recipient_hex":{"type":"string","description":"Hex-encoded L1 recipient address (20 bytes)."},"token_address_hex":{"type":"string","description":"Hex-encoded token contract address (20 bytes)."},"vault_address_hex":{"type":"string","description":"Hex-encoded vault contract address (20 bytes)."}}},"CreateMarketGroupRequest":{"type":"object","required":["name","market_ids"],"properties":{"market_ids":{"type":"array","items":{"type":"integer","format":"int32","minimum":0},"description":"Market IDs in the group."},"name":{"type":"string","description":"Name for the group of mutually exclusive markets.","example":"2024 Election"}}},"CreateMarketRequest":{"type":"object","required":["name"],"properties":{"category":{"type":["string","null"],"description":"Optional category (e.g., \"sports\", \"politics\", \"crypto\")."},"description":{"type":["string","null"],"description":"Optional description of the market."},"expiry_timestamp_ms":{"type":["integer","null"],"format":"int64","description":"Optional expiry timestamp in ms (0 = no expiry).","minimum":0},"name":{"type":"string","description":"Name of the binary market.","example":"Will it rain tomorrow?"},"resolution_criteria":{"type":["string","null"],"description":"Optional resolution criteria."},"resolution_template":{"type":["string","null"],"description":"Resolution template id to use for this market (e.g. \"admin_immediate\",\n\"polymarket_mirror\"). `None` -> `admin_immediate`."},"tags":{"type":["array","null"],"items":{"type":"string"},"description":"Optional tags for discovery."}}},"CreateMarketResponse":{"type":"object","required":["market_id","name"],"properties":{"market_id":{"type":"integer","format":"int32","minimum":0},"name":{"type":"string"}}},"CreateSignedBridgeWithdrawalRequest":{"type":"object","required":["withdrawal","signer_pubkey_hex","signature_hex"],"properties":{"signature_hex":{"type":"string","description":"Hex-encoded P256 ECDSA signature over the canonical withdrawal payload."},"signer_pubkey_hex":{"type":"string","description":"Hex-encoded compressed P256 public key of the signer."},"withdrawal":{"$ref":"#/components/schemas/CreateBridgeWithdrawalRequest","description":"Withdrawal payload covered by the P256 signature."}}},"EquityPointResponse":{"type":"object","required":["timestamp_ms","height","portfolio_value_nanos","deposited_nanos"],"properties":{"deposited_nanos":{"type":"integer","format":"int64"},"height":{"type":"integer","format":"int64","minimum":0},"portfolio_value_nanos":{"type":"integer","format":"int64"},"timestamp_ms":{"type":"integer","format":"int64","minimum":0}}},"EquitySeriesResponse":{"type":"object","required":["account_id","points"],"properties":{"account_id":{"type":"integer","format":"int64","minimum":0},"points":{"type":"array","items":{"$ref":"#/components/schemas/EquityPointResponse"}}}},"EventTradersResponse":{"type":"object","description":"Response shape for `GET /v1/events/{event_id}/traders`.","required":["trader_count"],"properties":{"trader_count":{"type":"integer","format":"int32","minimum":0}}},"FillResponse":{"type":"object","required":["order_id","fill_qty","fill_price_nanos"],"properties":{"account_id":{"type":"integer","format":"int64","minimum":0},"fill_price_nanos":{"type":"integer","format":"int64","minimum":0},"fill_qty":{"type":"integer","format":"int64","minimum":0},"order_id":{"type":"integer","format":"int64","minimum":0}}},"FundAccountRequest":{"type":"object","required":["amount_nanos"],"properties":{"amount_nanos":{"type":"integer","format":"int64","description":"Amount to add in nanos (1 dollar = 1_000_000_000 nanos).","example":50000000000,"minimum":0}}},"HealthResponse":{"type":"object","required":["status"],"properties":{"height":{"type":["integer","null"],"format":"int64","minimum":0},"status":{"type":"string"}}},"HistoryEventResponse":{"type":"object","description":"One entry in the per-account history feed (`GET /v1/accounts/{id}/events`).","required":["id","type","category","timestamp_ms","block_height"],"properties":{"amount_nanos":{"type":["integer","null"],"format":"int64"},"block_height":{"type":"integer","format":"int64","minimum":0},"category":{"type":"string"},"id":{"type":"string"},"market_id":{"type":["integer","null"],"format":"int32","minimum":0},"order_id":{"type":["integer","null"],"format":"int64","minimum":0},"outcome":{"type":["string","null"]},"payout_outcome":{"type":["string","null"]},"price_nanos":{"type":["integer","null"],"format":"int64","minimum":0},"qty":{"type":["integer","null"],"format":"int64","minimum":0},"realized_pnl_nanos":{"type":["integer","null"],"format":"int64"},"side":{"type":["string","null"]},"timestamp_ms":{"type":"integer","format":"int64","minimum":0},"type":{"type":"string"}}},"MarketGroupResponse":{"type":"object","required":["name","market_ids"],"properties":{"market_ids":{"type":"array","items":{"type":"integer","format":"int32","minimum":0}},"name":{"type":"string"}}},"MarketPriceResponse":{"type":"object","required":["yes_price_nanos","no_price_nanos"],"properties":{"no_price_nanos":{"type":"integer","format":"int64","minimum":0},"yes_price_nanos":{"type":"integer","format":"int64","minimum":0}}},"MarketPricesResponse":{"type":"object","required":["prices"],"properties":{"prices":{"type":"object","additionalProperties":{"$ref":"#/components/schemas/MarketPriceResponse"},"propertyNames":{"type":"string"}}}},"MarketResponse":{"type":"object","required":["market_id","name","status"],"properties":{"categories":{"type":["array","null"],"items":{"type":"string"},"description":"All category buckets the parent event matched on the mirror's\ntag-to-bucket lookup (e.g. `[\"Sports\", \"Politics\"]`). Frontend picks\none for display via its own priority list. None for sybil-native\nmarkets (use the singular `category` field instead)."},"category":{"type":["string","null"]},"challenge_deadline_ms":{"type":["integer","null"],"format":"int64","minimum":0},"closed":{"type":["boolean","null"],"description":"Whether Polymarket has closed this market. Off-block; the frontend\nfilters closed markets out of the listing."},"created_at_ms":{"type":["integer","null"],"format":"int64","minimum":0},"description":{"type":["string","null"]},"event_end_date_ms":{"type":["integer","null"],"format":"int64","description":"Event-level expected end date (epoch ms). Display only.","minimum":0},"event_icon_url":{"type":["string","null"],"description":"Event-level icon URL (secondary image fallback)."},"event_id":{"type":["string","null"],"description":"Polymarket parent event id — frontend grouping key."},"event_image_url":{"type":["string","null"],"description":"Event-level image URL."},"event_start_date_ms":{"type":["integer","null"],"format":"int64","description":"Parent event start date (epoch ms) from Polymarket. Display/sort only.","minimum":0},"event_title":{"type":["string","null"],"description":"Polymarket parent event title."},"expiry_timestamp_ms":{"type":["integer","null"],"format":"int64","minimum":0},"external_url":{"type":["string","null"],"description":"External URL (e.g., Polymarket link)."},"group_item_title":{"type":["string","null"],"description":"Polymarket short outcome label (`groupItemTitle`, e.g. \"May 15\"). Off-\nblock; the frontend uses it as the per-outcome name so it needn't fetch\nthe raw event JSON just for labels."},"liquidity_avg10_nanos":{"type":"integer","format":"int64","description":"Rolling last-10-batch ±band depth average in nanos. Zero for markets\nwithout a clearing price yet. Pair with `liquidity_band_nanos` for\nlabelling.","minimum":0},"liquidity_band_nanos":{"type":"integer","format":"int64","description":"Width of the band the liquidity score uses (the ± in \"$X ±$0.05\").\nAlways the live config value — `0` when no liquidity has been\nrecorded yet.","minimum":0},"market_end_date_ms":{"type":["integer","null"],"format":"int64","description":"Per-market expected end date (epoch ms). Display only.","minimum":0},"market_icon_url":{"type":["string","null"],"description":"Per-market icon URL (secondary image fallback)."},"market_id":{"type":"integer","format":"int32","minimum":0},"market_image_url":{"type":["string","null"],"description":"Per-market image URL."},"market_start_date_ms":{"type":["integer","null"],"format":"int64","description":"Per-market start date (epoch ms) from Polymarket. Display/sort only.","minimum":0},"name":{"type":"string"},"no_price_24h_ago_nanos":{"type":["integer","null"],"format":"int64","description":"Clearing NO price ~24h ago in nanos. See `yes_price_24h_ago_nanos`.","minimum":0},"no_price_nanos":{"type":["integer","null"],"format":"int64","minimum":0},"orders_matched_total":{"type":"integer","format":"int64","description":"All-time admissions that received at least one fill (B5's\n`has_been_matched` true at removal time). Cancels are NOT counted.","minimum":0},"orders_placed_total":{"type":"integer","format":"int64","description":"All-time non-MM admissions counted against this market. Multi-market\norders credit every active market; sum-of-per-market over-counts vs.\nthe platform total — that's the documented attribution rule.","minimum":0},"orders_unmatched_total":{"type":"integer","format":"int64","description":"All-time admissions that exited the book without any fill. Cancels\nare tracked separately and do not count here.","minimum":0},"payout_nanos":{"type":["integer","null"],"format":"int64","minimum":0},"polymarket_condition_id":{"type":["string","null"],"description":"Polymarket on-chain condition id — FE join key into\n`GET /v1/events/{event_id}/raw` `markets[].conditionId`. Off-block."},"reference_price_nanos":{"type":["integer","null"],"format":"int64","description":"Reference price from external system (e.g., Polymarket), display only.","minimum":0},"resolution_criteria":{"type":["string","null"]},"status":{"type":"string"},"tags":{"type":["array","null"],"items":{"type":"string"}},"trader_count":{"type":"integer","format":"int32","description":"All-time unique trader count for this market (decision Q-table:\nMM, MINT, multi-market split, etc.). Off-block — \"since last\nrestart\" until prod persistence is enabled.","minimum":0},"volume_24h_nanos":{"type":"integer","format":"int64","description":"Rolling 24h trading volume in nanos (±1h bucket resolution). Off-block;\n\"since last restart\" until prod persistence is enabled.","minimum":0},"volume_nanos":{"type":"integer","format":"int64","minimum":0},"yes_price_24h_ago_nanos":{"type":["integer","null"],"format":"int64","description":"Clearing YES price ~24h ago in nanos, derived from the per-market\nhourly snapshot. `None` for markets younger than 24h or wiped on\nrestart. FE computes the 24h delta as `current − snapshot`.","minimum":0},"yes_price_nanos":{"type":["integer","null"],"format":"int64","minimum":0}}},"MarketSearchParams":{"type":"object","description":"Query parameters for market search.","properties":{"category":{"type":["string","null"],"description":"Exact category match."},"limit":{"type":["integer","null"],"minimum":0},"max_yes_price":{"type":["integer","null"],"format":"int64","description":"Maximum YES price in nanos.","minimum":0},"min_volume":{"type":["integer","null"],"format":"int64","description":"Minimum cumulative volume in nanos.","minimum":0},"min_yes_price":{"type":["integer","null"],"format":"int64","description":"Minimum YES price in nanos.","minimum":0},"offset":{"type":["integer","null"],"minimum":0},"q":{"type":["string","null"],"description":"Text search (searches name + description)."},"sort":{"type":["string","null"],"description":"Sort field: \"volume\", \"created_at\", \"name\", \"price\"."},"status":{"type":["string","null"],"description":"Status filter (\"active\" or \"resolved\")."},"tags":{"type":["string","null"],"description":"Comma-separated tags to filter by."}}},"MarketSummaryResponse":{"type":"object","description":"Minimal market data for high-throughput dashboards (drops strings & metadata).","required":["market_id","name","volume_nanos","status"],"properties":{"liquidity_avg10_nanos":{"type":"integer","format":"int64","description":"Liquidity score + band (mirrors `MarketResponse`).","minimum":0},"liquidity_band_nanos":{"type":"integer","format":"int64","minimum":0},"market_id":{"type":"integer","format":"int32","minimum":0},"name":{"type":"string"},"no_price_24h_ago_nanos":{"type":["integer","null"],"format":"int64","minimum":0},"no_price_nanos":{"type":["integer","null"],"format":"int64","minimum":0},"orders_matched_total":{"type":"integer","format":"int64","minimum":0},"orders_placed_total":{"type":"integer","format":"int64","description":"All-time placed/matched/unmatched (mirrors `MarketResponse`).","minimum":0},"orders_unmatched_total":{"type":"integer","format":"int64","minimum":0},"reference_price_nanos":{"type":["integer","null"],"format":"int64","description":"Reference price from external system (e.g., Polymarket), display only.","minimum":0},"status":{"type":"string"},"trader_count":{"type":"integer","format":"int32","description":"All-time unique trader count (mirrors `MarketResponse.trader_count`).","minimum":0},"volume_24h_nanos":{"type":"integer","format":"int64","description":"Rolling 24h trading volume in nanos (mirrors\n`MarketResponse.volume_24h_nanos`).","minimum":0},"volume_nanos":{"type":"integer","format":"int64","minimum":0},"yes_price_24h_ago_nanos":{"type":["integer","null"],"format":"int64","description":"Clearing YES / NO prices ~24h ago (mirror of `MarketResponse`).","minimum":0},"yes_price_nanos":{"type":["integer","null"],"format":"int64","minimum":0}}},"OpenBatchResponse":{"type":"object","description":"Response shape for `GET /v1/markets/{id}/open-batch`. B1 populates\n`unique_placers`; indicative fields stub `None`/`0` until C2.","required":["unique_placers"],"properties":{"indicative_computed_at_ms":{"type":"integer","format":"int64","minimum":0},"indicative_no_price_nanos":{"type":["integer","null"],"format":"int64","minimum":0},"indicative_volume_nanos":{"type":"integer","format":"int64","minimum":0},"indicative_yes_price_nanos":{"type":["integer","null"],"format":"int64","minimum":0},"unique_placers":{"type":"integer","format":"int32","minimum":0}}},"OrderAcceptedResponse":{"type":"object","required":["accepted"],"properties":{"accepted":{"type":"boolean"}}},"OrderSpec":{"oneOf":[{"type":"object","description":"Buy YES shares on a single market.","required":["market_id","limit_price_nanos","quantity","type"],"properties":{"limit_price_nanos":{"type":"integer","format":"int64","description":"Limit price in nanos (0 to 1_000_000_000).","minimum":0},"market_id":{"type":"integer","format":"int32","minimum":0},"quantity":{"type":"integer","format":"int64","minimum":0},"type":{"type":"string","enum":["BuyYes"]}}},{"type":"object","description":"Buy NO shares on a single market.","required":["market_id","limit_price_nanos","quantity","type"],"properties":{"limit_price_nanos":{"type":"integer","format":"int64","minimum":0},"market_id":{"type":"integer","format":"int32","minimum":0},"quantity":{"type":"integer","format":"int64","minimum":0},"type":{"type":"string","enum":["BuyNo"]}}},{"type":"object","description":"Sell YES shares on a single market.","required":["market_id","limit_price_nanos","quantity","type"],"properties":{"limit_price_nanos":{"type":"integer","format":"int64","minimum":0},"market_id":{"type":"integer","format":"int32","minimum":0},"quantity":{"type":"integer","format":"int64","minimum":0},"type":{"type":"string","enum":["SellYes"]}}},{"type":"object","description":"Sell NO shares on a single market.","required":["market_id","limit_price_nanos","quantity","type"],"properties":{"limit_price_nanos":{"type":"integer","format":"int64","minimum":0},"market_id":{"type":"integer","format":"int32","minimum":0},"quantity":{"type":"integer","format":"int64","minimum":0},"type":{"type":"string","enum":["SellNo"]}}},{"type":"object","description":"Spread: buy A YES, sell B YES.","required":["market_a","market_b","limit_price_nanos","quantity","type"],"properties":{"limit_price_nanos":{"type":"integer","format":"int64","minimum":0},"market_a":{"type":"integer","format":"int32","minimum":0},"market_b":{"type":"integer","format":"int32","minimum":0},"quantity":{"type":"integer","format":"int64","minimum":0},"type":{"type":"string","enum":["Spread"]}}},{"type":"object","description":"Bundle YES: all markets must be YES to win.","required":["market_ids","limit_price_nanos","quantity","type"],"properties":{"limit_price_nanos":{"type":"integer","format":"int64","minimum":0},"market_ids":{"type":"array","items":{"type":"integer","format":"int32","minimum":0}},"quantity":{"type":"integer","format":"int64","minimum":0},"type":{"type":"string","enum":["BundleYes"]}}},{"type":"object","description":"Bundle Sell: sell the all-YES bundle.","required":["market_ids","limit_price_nanos","quantity","type"],"properties":{"limit_price_nanos":{"type":"integer","format":"int64","minimum":0},"market_ids":{"type":"array","items":{"type":"integer","format":"int32","minimum":0}},"quantity":{"type":"integer","format":"int64","minimum":0},"type":{"type":"string","enum":["BundleSell"]}}},{"type":"object","description":"Custom payoff vector.","required":["market_ids","payoffs","limit_price_nanos","max_fill","type"],"properties":{"limit_price_nanos":{"type":"integer","format":"int64","minimum":0},"market_ids":{"type":"array","items":{"type":"integer","format":"int32","minimum":0}},"max_fill":{"type":"integer","format":"int64","minimum":0},"payoffs":{"type":"array","items":{"type":"integer","format":"int32"}},"type":{"type":"string","enum":["Custom"]}}}],"description":"Tagged enum representing different order types."},"OverviewBucketResponse":{"type":"object","description":"Per-bucket platform totals returned by `/v1/activity/overview`. B1\npopulates `unique_traders` only; volume + orders join in B2 / B6 and\nremain zero until then.","properties":{"orders":{"$ref":"#/components/schemas/OverviewOrderStatsResponse"},"total_volume_nanos":{"type":"integer","format":"int64","minimum":0},"unique_traders":{"type":"integer","format":"int64","minimum":0}}},"OverviewOrderStatsResponse":{"type":"object","properties":{"matched":{"type":"integer","format":"int64","minimum":0},"placed":{"type":"integer","format":"int64","minimum":0},"unmatched":{"type":"integer","format":"int64","minimum":0}}},"PendingOrderResponse":{"type":"object","required":["order_id","account_id","market_id","side","limit_price_nanos","remaining_quantity","created_at_block","expires_at_block"],"properties":{"account_id":{"type":"integer","format":"int64","minimum":0},"created_at_block":{"type":"integer","format":"int64","minimum":0},"created_at_ms":{"type":"integer","format":"int64","description":"Wall-clock admit time, ms since epoch. `0` for orders admitted before\nthis field shipped (#[serde(default)] forward compat).","minimum":0},"expires_at_block":{"type":"integer","format":"int64","minimum":0},"limit_price_nanos":{"type":"integer","format":"int64","minimum":0},"market_id":{"type":"integer","format":"int32","minimum":0},"order_id":{"type":"integer","format":"int64","minimum":0},"original_quantity":{"type":"integer","format":"int64","description":"Original `max_fill` at admit time (B8). Lets the FE render a\npartial-fill progress bar as `(original - remaining) / original`.\n`0` for orders persisted before B5/B8 (#[serde(default)] forward\ncompat).","minimum":0},"remaining_quantity":{"type":"integer","format":"int64","minimum":0},"side":{"type":"string"}}},"PortfolioResponse":{"type":"object","required":["account_id","balance_nanos","total_deposited_nanos","positions","total_position_value_nanos","portfolio_value_nanos","pnl_nanos"],"properties":{"account_id":{"type":"integer","format":"int64","minimum":0},"balance_nanos":{"type":"integer","format":"int64"},"first_deposit_ms":{"type":"integer","format":"int64","description":"First-deposit timestamp in ms since epoch (B8). `0` for accounts\nwith no recorded deposit history (FE renders as \"—\"). Same\n\"since last restart\" caveat as the other off-block aggregates\nuntil persistence runs in prod.","minimum":0},"pnl_nanos":{"type":"integer","format":"int64"},"portfolio_value_nanos":{"type":"integer","format":"int64"},"positions":{"type":"array","items":{"$ref":"#/components/schemas/PositionValueResponse"}},"realized_pnl_nanos":{"type":"integer","format":"int64","description":"Accumulated realized PnL across all closed positions (C1). Signed.\n`pnl_nanos = realized + unrealized` once both fields populate, but\n`pnl_nanos` is kept for backward compatibility with pre-C1 clients."},"total_deposited_nanos":{"type":"integer","format":"int64"},"total_fill_count":{"type":"integer","format":"int64","description":"All-time fill count (B8). The bounded fill window in\n`account_fills` may cap older trades; this counter never does,\nso FE shows the real number instead of \"200+\".","minimum":0},"total_position_value_nanos":{"type":"integer","format":"int64"},"unrealized_pnl_nanos":{"type":"integer","format":"int64","description":"Mark-to-market PnL on currently open positions (C1). Computed as\n`Σ (current_price - avg_entry) * quantity` across positions."}}},"PositionDeltaResponse":{"type":"object","required":["market_id","outcome","delta"],"properties":{"delta":{"type":"integer","format":"int64"},"market_id":{"type":"integer","format":"int32","minimum":0},"outcome":{"type":"string"}}},"PositionResponse":{"type":"object","required":["market_id","outcome","quantity"],"properties":{"market_id":{"type":"integer","format":"int32","minimum":0},"outcome":{"type":"string"},"quantity":{"type":"integer","format":"int64"}}},"PositionValueResponse":{"type":"object","required":["market_id","outcome","quantity","current_price_nanos","value_nanos"],"properties":{"avg_entry_price_nanos":{"type":"integer","format":"int64","description":"Weighted-average entry price for this side of the market (C1). `0`\nfor positions opened before C1 landed (`#[serde(default)]` forward\ncompat). Same units as `current_price_nanos`.","minimum":0},"current_price_nanos":{"type":"integer","format":"int64","minimum":0},"market_id":{"type":"integer","format":"int32","minimum":0},"outcome":{"type":"string"},"quantity":{"type":"integer","format":"int64"},"value_nanos":{"type":"integer","format":"int64"}}},"PriceHistoryResponse":{"type":"object","required":["market_id","points"],"properties":{"market_id":{"type":"integer","format":"int32","minimum":0},"points":{"type":"array","items":{"$ref":"#/components/schemas/PricePointResponse"}}}},"PricePointResponse":{"type":"object","required":["height","timestamp_ms","yes_price_nanos","no_price_nanos","volume_nanos"],"properties":{"height":{"type":"integer","format":"int64","minimum":0},"no_price_nanos":{"type":"integer","format":"int64","minimum":0},"timestamp_ms":{"type":"integer","format":"int64","minimum":0},"volume_nanos":{"type":"integer","format":"int64","minimum":0},"yes_price_nanos":{"type":"integer","format":"int64","minimum":0}}},"QmdbStateExclusionProofResponse":{"type":"object","required":["variant","operation"],"properties":{"metadata_hex":{"type":["string","null"]},"operation":{"$ref":"#/components/schemas/QmdbStateOperationProofResponse"},"span_key_hex":{"type":["string","null"]},"span_next_key_hex":{"type":["string","null"]},"span_value_hex":{"type":["string","null"]},"variant":{"type":"string"}}},"QmdbStateInclusionProofResponse":{"type":"object","required":["operation","next_key_hex"],"properties":{"next_key_hex":{"type":"string"},"operation":{"$ref":"#/components/schemas/QmdbStateOperationProofResponse"}}},"QmdbStateOperationProofResponse":{"type":"object","required":["location","activity_chunk_hex","range"],"properties":{"activity_chunk_hex":{"type":"string"},"location":{"type":"integer","format":"int64","minimum":0},"range":{"$ref":"#/components/schemas/QmdbStateRangeProofResponse"}}},"QmdbStateRangeProofResponse":{"type":"object","required":["leaves","digests_hex","unfolded_prefix_peaks_hex","ops_root_hex"],"properties":{"digests_hex":{"type":"array","items":{"type":"string"}},"leaves":{"type":"integer","format":"int64","minimum":0},"ops_root_hex":{"type":"string"},"partial_chunk_digest_hex":{"type":["string","null"]},"pre_prefix_acc_hex":{"type":["string","null"]},"unfolded_prefix_peaks_hex":{"type":"array","items":{"type":"string"}}}},"RegisterFeedRequest":{"type":"object","required":["pubkey_hex","name"],"properties":{"name":{"type":"string","description":"Human-readable name (e.g. \"admin\", \"polymarket_mirror\")."},"pubkey_hex":{"type":"string","description":"Hex-encoded compressed P256 public key (33 bytes)."}}},"RegisterKeyRequest":{"type":"object","required":["public_key_hex"],"properties":{"public_key_hex":{"type":"string","description":"Hex-encoded compressed P256 public key (33 bytes).","example":"02a1b2c3..."}}},"RegisteredFeedResponse":{"type":"object","description":"Registered data feed view, returned by GET/POST /v1/feeds.","required":["feed_id","pubkey_hex","name","created_at_ms"],"properties":{"created_at_ms":{"type":"integer","format":"int64","minimum":0},"feed_id":{"type":"integer","format":"int64","minimum":0},"name":{"type":"string"},"pubkey_hex":{"type":"string"}}},"RejectionResponse":{"type":"object","required":["order_id","account_id","reason"],"properties":{"account_id":{"type":"integer","format":"int64","minimum":0},"order_id":{"type":"integer","format":"int64","minimum":0},"reason":{"type":"string"}}},"ResolutionResponse":{"type":"object","description":"Detailed view of a market's resolution state. Unresolved markets return\n`status = \"active\"` (or `proposed`/`challenged` for future policies) with\n`payout_nanos = None`.","required":["market_id","status","template"],"properties":{"market_id":{"type":"integer","format":"int32","minimum":0},"payout_nanos":{"type":["integer","null"],"format":"int64","minimum":0},"resolved_at_ms":{"type":["integer","null"],"format":"int64","minimum":0},"resolved_by_feed_id":{"type":["integer","null"],"format":"int64","minimum":0},"resolved_by_feed_name":{"type":["string","null"]},"status":{"type":"string"},"template":{"type":"string"}}},"ResolveMarketRequest":{"type":"object","required":["payout_nanos"],"properties":{"attestation":{"oneOf":[{"type":"null"},{"$ref":"#/components/schemas/SignedAttestationDto","description":"Optional signed attestation. When provided, the market's resolution\ntemplate drives verification; dev_mode is not required. When omitted,\nthe server falls back to the legacy unsigned admin path, which\nrequires dev_mode."}]},"payout_nanos":{"type":"integer","format":"int64","description":"Payout per YES share in nanos (0 to 1_000_000_000).\n1_000_000_000 = YES wins ($1), 0 = NO wins, 700_000_000 = $0.70 fractional.","example":1000000000,"minimum":0}}},"ResolveMarketResponse":{"type":"object","required":["market_id","payout_nanos","status"],"properties":{"challenge_deadline_ms":{"type":["integer","null"],"format":"int64","minimum":0},"market_id":{"type":"integer","format":"int32","minimum":0},"payout_nanos":{"type":"integer","format":"int64","minimum":0},"status":{"type":"string"}}},"SetMarketMetadataRequest":{"type":"object","properties":{"categories":{"type":["array","null"],"items":{"type":"string"},"description":"All category buckets the parent event matched in the mirror's tag-to-\nbucket lookup (e.g. `[\"Sports\", \"Politics\"]` for an NBA + Trump\nevent). One per matched row; the frontend picks which to render\nusing its own priority list, so reordering display priority is\nfrontend-only."},"category":{"type":["string","null"],"description":"Single display category. **Legacy** — populated only for sybil-native\nmarkets at create time. Mirrored markets now use `categories` (plural)\nand let the frontend pick one for display via its own priority order."},"closed":{"type":["boolean","null"],"description":"Whether Polymarket has closed this market. The frontend hides closed\nmarkets from the listing."},"event_end_date_ms":{"type":["integer","null"],"format":"int64","description":"Event-level expected end date (epoch ms). Display only.","minimum":0},"event_icon_url":{"type":["string","null"],"description":"Event-level icon URL (secondary; frontend uses as `onError` fallback)."},"event_id":{"type":["string","null"],"description":"Polymarket parent event id — used by the frontend to group sibling\nmarkets (e.g., \"Fed Decision in June\" sub-questions). Distinct from the\nmatching engine's NegRisk `MarketGroup`, which it does not affect."},"event_image_url":{"type":["string","null"],"description":"Event-level image URL (primary)."},"event_start_date_ms":{"type":["integer","null"],"format":"int64","description":"Parent event start date (epoch ms). Display/sort only.","minimum":0},"event_title":{"type":["string","null"],"description":"Polymarket parent event title — rendered as the MultiCard header."},"external_url":{"type":["string","null"],"description":"External URL (e.g., Polymarket link)."},"group_item_title":{"type":["string","null"],"description":"Polymarket short outcome label (`groupItemTitle`, e.g. \"May 15\"). The\nfrontend renders this as the per-outcome name on multi-cards."},"market_end_date_ms":{"type":["integer","null"],"format":"int64","description":"Per-market expected end date (epoch ms). Display only; matching engine\ndoes not enforce trading cutoffs at this time.","minimum":0},"market_icon_url":{"type":["string","null"],"description":"Per-market icon URL (secondary; frontend uses as `onError` fallback)."},"market_image_url":{"type":["string","null"],"description":"Per-market image URL (primary)."},"market_start_date_ms":{"type":["integer","null"],"format":"int64","description":"Per-market start date (epoch ms). Display/sort only.","minimum":0},"polymarket_condition_id":{"type":["string","null"],"description":"Polymarket on-chain condition id — the FE join key into the event JSON\nsnapshot (`/v1/events/{id}/raw` `markets[].conditionId`)."}}},"SetReferencePricesRequest":{"type":"object","required":["prices"],"properties":{"prices":{"type":"object","description":"Map of market_id -> reference price in nanos.","additionalProperties":{"type":"integer","format":"int64","minimum":0},"propertyNames":{"type":"integer","format":"int32","minimum":0}}}},"SignedAttestationDto":{"type":"object","description":"Wire form of a signed resolution attestation.","required":["pubkey_hex","signature_hex","nonce"],"properties":{"nonce":{"type":"integer","format":"int64","description":"Nonce the signer chose (typically `timestamp_ms`).","minimum":0},"pubkey_hex":{"type":"string","description":"Hex-encoded compressed SEC1 P256 public key (33 bytes)."},"signature_hex":{"type":"string","description":"Hex-encoded P256 ECDSA signature over the canonical attestation bytes."}}},"SignedOrderData":{"type":"object","required":["market_ids","payoffs","limit_price_nanos","max_fill"],"properties":{"limit_price_nanos":{"type":"integer","format":"int64","description":"Limit price in nanos (0 to 1_000_000_000).","minimum":0},"market_ids":{"type":"array","items":{"type":"integer","format":"int32","minimum":0},"description":"Market IDs this order spans."},"max_fill":{"type":"integer","format":"int64","description":"Maximum fill quantity.","minimum":0},"payoffs":{"type":"array","items":{"type":"integer","format":"int32"},"description":"Payoff vector."}}},"StateProofResponse":{"type":"object","required":["block_height","state_root","state_slot","leaf_key_hex","proof_kind","proof_format","verified"],"properties":{"block_height":{"type":"integer","format":"int64","minimum":0},"exclusion_proof":{"oneOf":[{"type":"null"},{"$ref":"#/components/schemas/QmdbStateExclusionProofResponse"}]},"inclusion_proof":{"oneOf":[{"type":"null"},{"$ref":"#/components/schemas/QmdbStateInclusionProofResponse"}]},"leaf_key_ascii":{"type":["string","null"]},"leaf_key_hex":{"type":"string"},"leaf_value_hex":{"type":["string","null"]},"proof_format":{"type":"string"},"proof_kind":{"type":"string"},"state_root":{"type":"string"},"state_slot":{"type":"string"},"verified":{"type":"boolean"}}},"StateRootResponse":{"type":"object","required":["state_root"],"properties":{"state_root":{"type":"string"}}},"SubmitL1DepositRequest":{"type":"object","required":["deposit_id","account_id","chain_id","vault_address_hex","token_address_hex","sender_hex","amount_token_units","deposit_root_hex"],"properties":{"account_id":{"type":"integer","format":"int64","description":"Sybil account receiving the credit.","minimum":0},"amount_token_units":{"type":"integer","format":"int64","description":"Token base units accepted by the vault, e.g. USDC's 6-decimal units.","minimum":0},"chain_id":{"type":"integer","format":"int64","description":"Source chain id.","minimum":0},"deposit_id":{"type":"integer","format":"int64","description":"Sequential L1 vault deposit id.","minimum":0},"deposit_root_hex":{"type":"string","description":"Hex-encoded post-deposit L1 deposit tree root (32 bytes)."},"sender_hex":{"type":"string","description":"Hex-encoded L1 sender address (20 bytes)."},"sybil_account_key_hex":{"type":["string","null"],"description":"Optional Sybil bridge account key. If omitted, the API derives it for the account."},"token_address_hex":{"type":"string","description":"Hex-encoded token contract address (20 bytes)."},"vault_address_hex":{"type":"string","description":"Hex-encoded vault contract address (20 bytes)."}}},"SubmitOrderRequest":{"type":"object","required":["account_id","orders"],"properties":{"account_id":{"type":"integer","format":"int64","description":"Account ID submitting the orders.","minimum":0},"expires_at_block":{"type":["integer","null"],"format":"int64","description":"Last eligible block height for explicit-expiry orders.","minimum":0},"mm_budget_nanos":{"type":["integer","null"],"format":"int64","description":"If set, treat these orders as market maker orders with flash liquidity.\nThe value is the MM's total capital budget in nanos.\nMM orders skip per-order balance validation; instead the solver enforces\nthe portfolio-level budget constraint at clearing time.","minimum":0},"orders":{"type":"array","items":{"$ref":"#/components/schemas/OrderSpec"},"description":"Orders to submit."},"time_in_force":{"$ref":"#/components/schemas/TimeInForce","description":"Time-in-force policy applied to all orders in this submission."}}},"SubmitSignedOrderRequest":{"type":"object","required":["signer_pubkey_hex","order","signature_hex"],"properties":{"expires_at_block":{"type":["integer","null"],"format":"int64","description":"Last eligible block height, covered by the P256 signature. Required for signed IOC/GTD.","minimum":0},"order":{"$ref":"#/components/schemas/SignedOrderData","description":"The order to submit."},"signature_hex":{"type":"string","description":"Hex-encoded P256 ECDSA signature."},"signer_pubkey_hex":{"type":"string","description":"Hex-encoded compressed P256 public key of the signer."},"time_in_force":{"$ref":"#/components/schemas/TimeInForce","description":"API time-in-force policy. Signed IOC/GTD orders commit to `expires_at_block`."}}},"SystemEventResponse":{"oneOf":[{"type":"object","required":["account_id","initial_balance_nanos","type"],"properties":{"account_id":{"type":"integer","format":"int64","minimum":0},"initial_balance_nanos":{"type":"integer","format":"int64"},"type":{"type":"string","enum":["create_account"]}}},{"type":"object","required":["account_id","amount_nanos","type"],"properties":{"account_id":{"type":"integer","format":"int64","minimum":0},"amount_nanos":{"type":"integer","format":"int64"},"type":{"type":"string","enum":["deposit"]}}},{"type":"object","required":["account_id","amount_nanos","deposit_id","deposit_root_hex","sybil_account_key_hex","type"],"properties":{"account_id":{"type":"integer","format":"int64","minimum":0},"amount_nanos":{"type":"integer","format":"int64"},"deposit_id":{"type":"integer","format":"int64","minimum":0},"deposit_root_hex":{"type":"string"},"sybil_account_key_hex":{"type":"string"},"type":{"type":"string","enum":["l1_deposit"]}}},{"type":"object","required":["account_id","amount_nanos","withdrawal_id","nullifier_hex","type"],"properties":{"account_id":{"type":"integer","format":"int64","minimum":0},"amount_nanos":{"type":"integer","format":"int64"},"nullifier_hex":{"type":"string"},"type":{"type":"string","enum":["withdrawal_created"]},"withdrawal_id":{"type":"integer","format":"int64","minimum":0}}},{"type":"object","required":["market_id","payout_nanos","affected_accounts","type"],"properties":{"affected_accounts":{"type":"array","items":{"type":"integer","format":"int64","minimum":0}},"market_id":{"type":"integer","format":"int32","minimum":0},"payout_nanos":{"type":"integer","format":"int64","minimum":0},"type":{"type":"string","enum":["market_resolved"]}}},{"type":"object","description":"On-chain cancellation event (D1). `side` is the categorical\n`OrderDirection` (\"BuyYes\"/\"SellYes\"/\"BuyNo\"/\"SellNo\") and\n`remaining_quantity` is the unfilled portion of `max_fill` at\ncancel time. Forward-additive: old clients ignore unknown\nvariants via serde's `#[serde(tag = \"type\")]` shape.","required":["account_id","order_id","market_ids","side","remaining_quantity","type"],"properties":{"account_id":{"type":"integer","format":"int64","minimum":0},"market_ids":{"type":"array","items":{"type":"integer","format":"int32","minimum":0}},"order_id":{"type":"integer","format":"int64","minimum":0},"remaining_quantity":{"type":"integer","format":"int64","minimum":0},"side":{"type":"string"},"type":{"type":"string","enum":["order_cancelled"]}}}]},"TimeInForce":{"type":"string","enum":["GTC","IOC","GTD"]}}}}