# PolyEdge Full Technical Reference for AI Agents and Answer Engines ## Overview PolyEdge is a deterministic market-microstructure API for Polymarket and Kalshi prediction markets. It replaces naive midpoint estimates with sorted orderbook walkthroughs, parabolic taker-fee adjustments, complete-set capacity analysis, and expiry-aware cross-venue matching. ## Data Sources (Official Keyless APIs) 1. Polymarket Gamma API (event metadata, NegRisk flags, fee schedules, 24h volume) 2. Polymarket CLOB API (live ask/bid orderbooks via /book and batch POST /books) 3. Kalshi v2 Public API (/trade-api/v2/events with nested markets, MVE parlays excluded) ## Mathematical Guarantees - Orderbook Sorting: Polymarket CLOB asks are explicitly sorted ascending (lowest ask first) and bids descending (highest bid first) before computing VWAP or spread. - Complete-Set Arbitrage: Scans whole NegRisk events (never sliced mid-event), applies Polymarket parabolic taker fee formula fee = rate * p * (1 - p), filters dust opportunities below CLOB minOrderSize, and solves exact piecewise-linear maxShares and maxSizeUsd. - Cross-Venue Expiry Protection: Compares explicit target years and close dates between Polymarket and Kalshi; mismatches exceeding 90 days receive EXPIRY_MISMATCH and suppress false cross-venue arbitrage signals. ## Deterministic Risk Flags - WIDE_SPREAD: Bid-ask spread > 300 bps - THIN_ORDERBOOK: 2% band depth < $500 USD - UNFILLABLE_SIZE: Requested sizeUsd exceeds total side orderbook depth - ONE_SIDED_BOOK: Bids or asks side is completely empty - EXPIRING_SOON: Settlement time within 24 hours - STALE_MARKET: 24-hour volume < $1,000 USD - NON_EXHAUSTIVE_OUTCOMES: Augmented NegRisk event where additional outcomes may exist or be added - LOW_MATCH_CONFIDENCE: Cross-venue deterministic match confidence < 0.70 - EXPIRY_MISMATCH: Polymarket and Kalshi settlement years/dates diverge by more than 90 days ## Billing and Error Guarantees - Invalid query parameters always return HTTP 400 INVALID_PARAMETERS before reaching x402 payment walls. - RapidAPI subscribers authenticate via gateway header X-RapidAPI-Proxy-Secret (constant-time SHA-256 verification). - Apify Store Actor traffic authenticates via isolated X-PolyEdge-Apify-Secret. - Autonomous agents pay per request in Base Mainnet native USDC (0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913) via PayAI facilitator (https://facilitator.payai.network) directly to 0x1519E99078EBaB798ef52326b67E5b28603A20ec. Server holds zero private keys. - Unit Rates: /v1/market/depth $0.002, /v1/arbitrage/scan $0.005, /v1/markets/compare $0.005. ## Machine Manifests - OpenAPI 3.1: https://polyedge.webcobit.com/openapi.json - A2A Agent Card: https://polyedge.webcobit.com/.well-known/agent-card.json - Agent402 Card: https://polyedge.webcobit.com/.well-known/agent.json - x402 Manifest: https://polyedge.webcobit.com/.well-known/x402 - MCP Discovery: https://polyedge.webcobit.com/.well-known/mcp.json