⚠ INTERNAL — Operator UX mock · Design preview of V2 development path · demo-wired ≠ production-live · back to dev guide
Polygon · pUSD 10
📓 Developer Guide 📋 Reason Codes 📈 Shadow Mode
JD John Doe · Admin

NonceShepherd

exec.nonceshepherd
Execution live General live frozen

NonceShepherd manages the on-chain nonce sequence for the Polytraders signing wallet on Polygon, ensuring that every V2 EIP-712 signed order carries a

What it does

NonceShepherd manages the on-chain nonce sequence for the Polytraders signing wallet on Polygon, ensuring that every V2 EIP-712 signed order carries a valid, non-colliding nonce. It detects nonce gaps (caused by dropped or reverted transactions), resequences pending orders when a gap is found, and enforces a ceiling on the number of pending signed-but-unposted orders. NonceShepherd also tracks CLOB ClobAuth credential TTLs and triggers re-authentication before they expire.

Pipeline placement

runs after: ExecutionPlan assembly (SmartRouter) and GasDecision (GasOracle) NonceShepherd runs before: Order signing (EIP-712 buildOrderTypedData) and CLOB POST /order submission

Applies to: Every order that will be signed with the Polytraders wallet and submitted via CLOB V2

Why it matters

If this failsConsequence
Duplicate nonce on two simultaneous ordersCTFExchangeV2 rejects one of the two orders; fill rate drops and the strategy misses partial execution on fast-moving markets.
Nonce gap after a reverted transactionAll orders with nonces above the gap are stuck pending on-chain; they cannot fill until the gap is resolved, potentially leaving open risk positions unhedged.
Pending order count exceeds thresholdSigning queue backs up; later orders are assigned nonces that depend on earlier unfilled orders, creating a chain of blocked submissions.
Expired ClobAuth credentialCLOB POST /order returns 401; orders cannot be submitted until re-authentication completes, causing submission blackout.

Inputs

Polymarket inputs

InputSourceRequiredUse
ClobAuth credential (L2 API key + secret + passphrase)CLOB V2 auth endpointrequiredAuthenticate order submissions to the Polymarket CLOB V2. ClobAuth domain version is '1' (unchanged in V2).

Internal inputs

InputSourceRequiredUse
On-chain nonce for signing wallet from Polygon stateonchain RPC (eth_getTransactionCount)requiredDetermine the next valid nonce for the pending order; detect gaps by comparing on-chain nonce to internal sequence.
Internal pending-order sequence tableinternal Redis storerequiredTrack which nonces have been assigned to signed-but-unposted orders to detect gaps and collisions.
ExecutionPlan from SmartRouterexec.smart_routerrequiredReceive the order to be signed; assign nonce and inject builderCode (bytes32) before handing off to wallet adapter.

Authority

What this bot is permitted to do

Reshape

State

Readiness

General live

Status

live

Class

Execution Utility

Default mode

general_live

Developer owner

Polytraders core

Capital impact

Direct

Reason codes emitted

CodeSeverityMeaningAction
NONCE_SHEPHERD_OKINFONonce assigned successfully; no gap detected; queue healthy.Emit NonceAssignment; proceed to wallet adapter.
NONCE_SHEPHERD_QUEUE_FULLHARD_REJECTPending signed-but-unposted order count has reached the hard ceiling.Block new signing requests until pending count drops below threshold.
NONCE_SHEPHERD_GAP_DETECTEDWARNA gap in the nonce sequence was detected, indicating a reverted or dropped transaction.Hold new signing for refuse_during_gap_s; trigger resequencing if resequence_on_gap=true.
NONCE_SHEPHERD_GAP_UNRESOLVEDHARD_REJECTNonce gap has not resolved within refuse_during_gap_s hard limit.Pause all new signing; emit alert to on-call; await operator action.
NONCE_SHEPHERD_CREDENTIAL_RENEWINGWARNClobAuth credential TTL is within l2_credential_ttl_h hours of expiry; background re-auth triggered.Schedule background re-auth. Continue processing with current credential.
NONCE_SHEPHERD_CREDENTIAL_EXPIREDHARD_REJECTClobAuth credential has expired; CLOB submissions will fail with 401.Block all order submissions until re-auth completes.
NONCE_SHEPHERD_RPC_FAILUREHARD_REJECTCannot fetch on-chain nonce from Polygon RPC.Block new signing. Emit alert. Resume once RPC recovers.
KILL_SWITCH_ACTIVEHARD_REJECTGlobal kill switch active; no new nonces assigned.Block all signing requests.

Used by

Reverse index — strategies that currently reference exec.nonceshepherd. If you change this bot's authority or reason codes, these strategies must re-pass shadow.

StrategyStateActivity
Crypto Q2 — basket rebalancefrozenlast triggered 20m ago
US Elect — book-builderdemo-wiredlast triggered 27m ago
NBA H2H — moneyline market-makedemo-wiredlast triggered 34m ago

Showing 3 of 3 · demo-wired ≠ production-live

Why this matters

Execution bots does NOT propose new positions; only routes and shapes approved intents. Understanding the authority boundary prevents misuse and makes promotion-gate reviews faster and more reliable. View raw spec JSON →
Polytraders Operator UX Mock · INTERNAL · demo-wired ≠ production-live · the plan · reason codes · shadow-mode pipeline
⚙ Page Configuration
Current page settings
Loading configuration…