Portfolio Sync
PortfolioSync keeps the in-memory portfolio state — open positions and open orders — continuously synchronised with on-chain pUSD balances and CLOB op
What it does
PortfolioSync keeps the in-memory portfolio state — open positions and open orders — continuously synchronised with on-chain pUSD balances and CLOB open-order state. It reconciles the internal position store against clob_auth open orders and the Polygon on-chain balance every sync_interval_s. For negative-risk markets (NegRiskAdapter), it correctly aggregates multi-outcome positions using the negRisk flag. On discrepancy beyond discrepancy_alert_usd, it emits an alert and, if configured, pauses the affected strategy to prevent trading against a stale view of risk. Emits both a SettlementReport (position deltas) and an OperationsReport (sync health) on every cycle.
Pipeline placement
Applies to: All open positions and open orders across all active markets, including negative-risk multi-outcome positions
Why it matters
| If this fails | Consequence |
|---|---|
| In-memory position state drifts from on-chain reality | Strategies trade against a stale position view. Risk guards (PortfolioGuard, KillSwitch) see incorrect exposure, potentially allowing positions that exceed risk limits. |
| Negative-risk positions aggregated incorrectly | Multi-outcome positions in negRisk markets have correlated payoffs. Treating them as independent binary positions overstates available margin and may cause liquidation. |
| Open-order count diverges from CLOB | Strategies submit orders assuming capacity that no longer exists. This inflates fill expectations and distorts P&L projections. |
| Strategy not paused on drift beyond threshold | Trading continues against a stale portfolio state. Risk exposure is uncontrolled until the next successful sync cycle. |
Inputs
Polymarket inputs
| Input | Source | Required | Use |
|---|---|---|---|
| Open orders from CLOB (per wallet, per market) | clob_auth | required | Compare against internal open-order store to detect divergence. |
| On-chain pUSD balance (Polygon wallet) | onchain | required | Cross-check internal pUSD accounting against actual on-chain balance. |
| Market metadata (negRisk flag, condition_id, outcome tokens) | clob_auth | required | Correctly aggregate multi-outcome positions in negRisk markets using NegRiskAdapter. |
Internal inputs
| Input | Source | Required | Use |
|---|---|---|---|
| Internal position store snapshot | in-memory state | required | The current internal view of open positions that must be reconciled against external state. |
| KillSwitch active flag | KillSwitch | optional | When KillSwitch is active, continue syncing but suppress auto-pause-strategy logic. |
Authority
What this bot is permitted to do
State
Readiness
General live
Status
live
Class
Governance Service
Default mode
general_live
Developer owner
Polytraders core — Governance pod
Capital impact
Indirect
Reason codes emitted
| Code | Severity | Meaning | Action |
|---|---|---|---|
| PORTFOLIO_SYNC_CYCLE_COMPLETE | INFO | Full sync cycle completed; OperationsReport emitted. | No action — routine. |
| PORTFOLIO_SYNC_DISCREPANCY | WARN | Position drift between internal store and CLOB exceeds discrepancy_alert_usd threshold. | Emit alert; apply delta to internal store; log drift_pusd. |
| PORTFOLIO_SYNC_CRITICAL_DISCREPANCY | WARN | Position drift exceeds the hard threshold (500 pUSD). This indicates a significant state divergence. | Emit page alert; optionally pause affected strategy (auto_pause_strategy_on_drift). |
| PORTFOLIO_SYNC_STRATEGY_PAUSED | WARN | A strategy was automatically paused because position drift exceeded the hard threshold. | Notify on-call; do not resume until drift is investigated and resolved. |
| PORTFOLIO_SYNC_CLOB_UNAVAILABLE | WARN | CLOB auth API was unavailable during a sync cycle; no delta applied. | Skip cycle; emit alert; retry on next interval. |
| PORTFOLIO_SYNC_NEGRISK_AGGREGATE | INFO | A negative-risk multi-outcome market was encountered; NegRiskAdapter aggregation applied. | No action — informational. |
| STALE_DATA | WARN | CLOB or RPC data is older than sync_interval_s; internal store may be stale. | Emit WARN; skip delta application; retry sync on next cycle. |
| PARAMETER_CHANGE_REQUIRES_APPROVAL | HARD_REJECT | sync_interval_s exceeds the 300s hard maximum. | Reject the config change; emit alert. |
Related bots in Governance & Ops
Used by
Reverse index — strategies that currently reference gov.portfolio-sync. If you change this bot's authority or reason codes, these strategies must re-pass shadow.
| Strategy | State | Activity |
|---|---|---|
| NBA H2H — moneyline market-make | demo-wired | last triggered 24m ago |
| US Elections — sentiment fade | demo-wired | last triggered 31m ago |
Showing 2 of 2 · demo-wired ≠ production-live
Why this matters
Governance & Ops bots does NOT propose, approve, or block trades; only observes and reports. Understanding the authority boundary prevents misuse and makes promotion-gate reviews faster and more reliable. View raw spec JSON →