Polytraders Dev Guide
internal
v3 spine Phase 1 · Shared contracts 9 demo-wired · 0 shadow-ready · 0 production-live · 100 pending · 109 total 15/33 infra tasks the plan status board

← Principles & schemas

Dependency graph

Which bot needs which other bot to function. The graph is read-only documentation generated from each bot's declared dependencies.

How to read this

An arrow A → B means "A depends on B": A cannot make a correct decision unless B is responding. The graph is generated by walking each bot's dependencies.depends_on list.

Layer-level dependencies (always-true)

Strategy        →  Discovery (markets must be qualified before Strategy sees them)
Risk            →  Strategy (Risk only votes on existing OrderIntents)
Execution       →  Risk (Execution only acts on approved ExecutionPlans)
Security        →  every layer that signs (cross-cutting)
Governance      →  every layer (read-only: it logs and reconciles)
Intelligence    →  no internal deps; produces signals consumed by Strategy

Critical path bots

If any of these is unavailable, the entire pipeline degrades to a documented safe-fallback behaviour. Each is a P0 service.

External dependencies

ServiceEndpointSLA we assumeIf it fails
Gamma APIgamma-api.polymarket.com99.9% / 200ms p99Discovery degrades to cached snapshot ≤ 60s old.
Data APIdata-api.polymarket.com99.9% / 500ms p99Median-spread inputs fall back to 24h snapshot.
CLOB API (read)clob.polymarket.com99.95% / 200ms p99Risk bots HARD_REJECT until book data is fresh.
CLOB API (auth/trade)clob.polymarket.com99.95% / 500ms p99Execution layer pauses; in-flight orders complete via WebSocket user channel.
WS marketws-subscriptions-clob.polymarket.com/ws/market99.9% / no message-loss on resumeAuto-reconnect with exponential backoff; staleness alerts after 60s.
WS userws-subscriptions-clob.polymarket.com/ws/user99.9% / authenticated, last-message-id resumeOrder-state reconciliation falls back to REST polling on a 2s loop.
WS sportssports-api.polymarket.com/ws99% / best-effortSports-specific Discovery bots degrade to 30s polling.
WS RTDSws-live-data.polymarket.com99% / best-effortIntelligence signals using crypto/equity prices mark themselves stale.
UMA Optimistic Oracleon-chain (Polygon)2h challenge, 4–6 days if disputedOracleRiskMonitor pauses affected markets for the duration.
NegRiskAdapteron-chain (Polygon)per Polygon blockConvert-arb strategies pause; existing positions unaffected.

Cross-bot graph

Generated below at build time. (Auto-rendered from each bot's dependencies.depends_on; bots without a declared dependency block are omitted.)

BotDepends onWhy
0.1risk.kill_switchKillSwitch gate determines whether candidates are emitted.
0.2disc.marketscannerProvides the candidate market list that MarketQualityRanker scores.
0.2risk.kill_switchKillSwitch gate suppresses all emissions when active.
0.3risk.kill_switchKillSwitch gate suppresses emissions.
0.4disc.marketqualityrankerPrimary source of quality scores for queue entries.
0.4risk.kill_switchKillSwitch gate freezes queue and suppresses emissions.
0.5disc.marketscannerProvides baseline known condition_id set for new-market diffing.
0.5risk.kill_switchKillSwitch suppresses emissions but known set updates continue.
0.6disc.marketscannerScopes detection to tradable markets only.
0.6risk.kill_switchKillSwitch suppresses all emissions.
1.1risk.kill_switchGlobal brake — checked first before any data fetch.
1.10risk.kill_switchGlobal brake checked first.
1.11risk.kill_switchGlobal brake checked first.
1.12risk.kill_switchGlobal brake checked first.
1.13risk.kill_switchGlobal brake checked first.
1.14risk.kill_switchGlobal brake checked first.
1.15risk.kill_switchGlobal brake checked first.
1.16risk.kill_switchAll overrides blocked when kill switch is active.
1.17intel.orderflowanalyzer
1.18intel.orderflowanalyzer
1.19exec.order_lifecycle_manager
1.2risk.portfolio_guardProvides drawdown data that drives the automatic circuit-breaker trigger.
1.3risk.kill_switchGlobal brake — checked first before any oracle fetch.
1.3risk.portfolio_guardPer-market position limit is needed to compute the proposal-window size cap.
1.4risk.kill_switchGlobal brake — checked first before any book data is read.
1.4risk.portfolio_guardBudget remaining for this market caps the reshape ceiling.
1.5risk.kill_switchGlobal brake — checked first; KillSwitch causes rejection of all open-order intents but does not block cancel/flatten.
1.6risk.kill_switchGlobal brake — checked first; KillSwitch triggers emergency unwind of all inventory.
1.6risk.portfolio_guardPortfolioGuard per-market budget is consulted to confirm unwind intents don't inadvertently breach other limits (unwinds are closing, so they typically pass).
1.7risk.kill_switchGlobal brake — checked first before any registry is consulted.
1.8risk.kill_switchGlobal brake — checked first before any compliance data is read.
1.9risk.kill_switchGlobal brake checked first.
2.1risk.kill_switchChecked first before any order construction.
2.1risk.portfolio_guardProvides the approved OrderIntent with constraints.max_size_usd.
2.1sec.contract_address_guardAddress validation must pass before signing.
2.10internal.schedulerProvides probe triggers every probe_interval_s.
2.11exec.orderlifecyclemanagerProvides reject-rate metrics as a secondary degradation signal.
2.12exec.smart_routerSource of ExecutionPlan to validate.
2.13exec.partialfillhandlerSource of sub-minimum remainders forwarded for dust handling.
2.13exec.smart_routerSource of ExecutionPlan sizes to validate and round.
2.14intel.orderflowanalyzer
2.15exec.order_lifecycle_manager
2.2exec.smart_routerProvides the ExecutionPlan that AntiToxicFill evaluates and potentially reshapes.
2.2risk.kill_switchKillSwitch active flag is checked before any evaluation; active flag aborts all processing.
2.2risk.portfolio_guardAdverse RiskVotes from PortfolioGuard with toxicity tags trigger downsize_factor application.
2.3exec.smart_routerSmartRouter provides replacement ExecutionPlan parameters when a cancel-replace is triggered.
2.3exec.nonce_shepherdNonceShepherd assigns the nonce and injects builderCode for every replacement order.
2.3risk.kill_switchKillSwitch active triggers immediate cancellation of all resting orders.
2.4exec.smart_routerReceives ExecutionPlan containing order parameters and builderCode for nonce assignment.
2.4exec.gas_oracleGasOracle DEFER signals pause nonce reservation for queued ops to prevent nonce starvation.
2.4risk.kill_switchKillSwitch active blocks all new nonce assignments.
2.5risk.kill_switchKillSwitch active flag overrides all GasOracle approvals for non-risk-critical ops.
2.6exec.smart_routerProvides signed order with builder_code to initialise state.
2.6risk.kill_switchKillSwitch triggers mass cancel of all open orders.
2.7exec.orderlifecyclemanagerProvides FILLED ExecutionReport with fill_price, size, submit_ms.
2.8exec.orderlifecyclemanagerSource of PARTIAL ExecutionReport with remaining_usd and original_price.
2.8risk.kill_switchKillSwitch forces immediate remainder cancel.
2.9exec.partialfillhandlerPrimary source of requote instructions for partial remainder chasing.
3.1risk.kill_switchChecked first; cancels all open quotes and blocks new intent emission when active.
3.10risk.kill_switchChecked first; blocks all intent emission when active.
3.11risk.kill_switchChecked first; blocks all intent emission when active.
3.11risk.oracle_risk_monitorOracleRiskMonitor must confirm oracle is clear before any OrderIntent is emitted. Active challenge or DVM escalation blocks entry.
3.12risk.kill_switchChecked first; closes open positions and blocks new intent emission when active.
3.13risk.kill_switchChecked first; blocks all intent emission when active.
3.14risk.kill_switchChecked first; blocks all intent emission when active.
3.15risk.kill_switchChecked first; blocks all intent emission when active.
3.16risk.kill_switchChecked first; blocks all intent emission when active.
3.17risk.kill_switchChecked first; blocks all intent emission when active.
3.18risk.kill_switchChecked first; blocks all intent emission when active.
3.19risk.kill_switchChecked first; blocks all intent emission when active.
3.2risk.kill_switchChecked first; cancels all open quotes and blocks new intent emission when active.
3.20risk.kill_switchChecked first; blocks all intent emission when active.
3.21risk.kill_switchChecked first; blocks all intent emission when active.
3.22risk.kill_switchChecked first; blocks all intent emission when active.
3.23risk.kill_switchChecked first; blocks all intent emission when active.
3.24risk.kill_switchChecked first; blocks all intent emission when active.
3.3risk.kill_switchChecked first; blocks all intent emission when active.
3.4risk.kill_switchChecked first; blocks all intent emission when active.
3.5risk.kill_switchChecked first; blocks all intent emission when active.
3.6risk.kill_switchChecked first; blocks all intent emission when active.
3.7risk.kill_switchChecked first; blocks all intent emission when active.
3.8risk.kill_switchChecked first; blocks all intent emission when active.
3.9risk.kill_switchChecked first; blocks all intent emission when active.
4.1risk.kill_switchKillSwitch gate determines whether ObservationReports are emitted.
4.10risk.kill_switchSuppress emissions when KillSwitch is active.
4.11risk.kill_switchSuppress emissions when KillSwitch is active.
4.12risk.kill_switchSuppress emissions when KillSwitch is active.
4.13risk.kill_switchSuppress emissions when KillSwitch is active.
4.13risk.liquidity_guardProvide forward liquidity signals for LiquidityGuard risk decisions.
4.14risk.kill_switchSuppress emissions when KillSwitch is active.
4.14intel.onchainwatcherUses OnChainWatcher as upstream for initial wallet detection.
4.15risk.kill_switchSuppress emissions when KillSwitch is active.
4.16intel.orderflowanalyzer
4.16exec.order_lifecycle_manager
4.2risk.kill_switchKillSwitch gate suppresses ObservationReport emissions when active.
4.3risk.kill_switchKillSwitch gate suppresses ObservationReport emissions.
4.4risk.kill_switchKillSwitch gate suppresses ObservationReport emissions.
4.5risk.kill_switchKillSwitch gate suppresses ObservationReport emissions.
4.6risk.kill_switchSuppress emissions when KillSwitch is active.
4.7risk.kill_switchKillSwitch gate suppresses ObservationReport emissions.
4.8risk.kill_switchSuppress emissions when KillSwitch is active.
4.9risk.kill_switchSuppress emissions when KillSwitch is active.
4.9intel.resolutionruleparserConsume parsed resolution rules for cross-validation.
5.1risk.kill_switchKillSwitch gate runs first.
5.1sec.session_key_managerProvides session expiry and scope.
5.2risk.kill_switchKillSwitch gate before any on-chain read.
5.2sec.rpc_failover_managerRPC endpoint health for allowance reads.
5.3risk.kill_switchKillSwitch gate.
5.3sec.contract_address_guardDomain separator pre-validated.
5.4risk.kill_switchKillSwitch triggers mass session revocation.
5.5risk.kill_switchKillSwitch gate.
5.5sec.session_key_managerSession key provides fingerprint for rotation check.
5.6risk.kill_switchKillSwitch halts all probes.
5.7risk.kill_switchKillSwitch gate.
5.7sec.rpc_failover_managerProvides healthy primary RPC provider.
5.8risk.kill_switchKillSwitch gate is checked before any address validation.
5.9exec.order_lifecycle_manager
6.1exec.smart_routerSmartRouter populates the builderCode bytes32 field on each order before BuilderAttribution sees it.
6.10internal.config_storeConfig store fires pre-write events to the audit hook.
6.11gov.killswitchIncidentCommander checks KillSwitch state before dispatching halt_all.
6.12internal.report_archiveDecisionReport and RiskVote fetched for each fill.
6.13internal.event_streamAll user action events are sourced from the platform event stream.
6.14gov.builderattributionBuilderAttribution provides reconciliation status and quarantine counts.
6.15internal.metrics_storeAll SLO compliance data is sourced from Prometheus metrics.
6.16exec.order_lifecycle_manager
6.2internal.config_storeBot registry is loaded from config store on startup.
6.3gov.portfolio_syncPosition store snapshot is required to compute unrealised P&L on open positions.
6.3gov.builder_attributionFill log joined for per-builder P&L breakdown and builder_fee_pusd.
6.4internal.report_archiveAll historical ObservationReport, DecisionReport, RiskVote, ExecutionReport, and SettlementReport envelopes are fetched from the report archive for replay reconstruction.
6.4internal.clob_archiveTick-level CLOB snapshots (order book + trades) are the primary replay data source for simulated fill computation.
6.5internal.signal_busPaper-Trade Runner subscribes to the live signal bus to receive the same signals as live strategies, ensuring paper results are directly comparable.
6.5internal.risk_stackRisk guardrail votes are simulated through the full stack in paper mode to ensure the paper path is identical to live.
6.6internal.config_storeCron manifest is loaded from the config store on startup and on change events.
6.6internal.killswitchKillSwitch status is checked before dispatching trading-class tasks.
6.7internal.clob_authOpen orders and market metadata are fetched from clob_auth on each sync cycle.
6.7internal.onchain_rpcpUSD on-chain balance cross-check requires Polygon RPC access.
6.8gov.backtesterBacktest artefact references required for promotion gates.
6.9internal.report_busMatched-pair samples are derived from OperationsReport records on the report bus.