Polytraders Dev Guide
internal
Phase 1 · 9/109 wired

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