Skip to content

Latest commit

 

History

History
60 lines (49 loc) · 2.1 KB

File metadata and controls

60 lines (49 loc) · 2.1 KB

Polygate Implementation Plan

Based on PRD v1.0 (Polymarket Execution Gateway)

🟢 Phase 1: Foundation & Signing (The Launcher)

Goal: Can sign and broadcast a simple order to the network.

  • 1.1 Config & Secrets (C-01)
    • Load .env / config.yaml
    • Support PROXY_ADDRESS (EOA) & PRIVATE_KEY
    • Setup Multi-environment (Mainnet/Amoy)
  • 1.2 Optimized Signer (E-01)
    • Port polymarket-go-sdk signing logic
    • Pre-calculate Domain Separator & TypeHash (Performance)
    • Unit Test: Benchmark Signing (<1ms)
  • 1.3 Basic REST API (Interface)
    • POST /v1/orders (Basic Passthrough)
    • GET /health

🟡 Phase 2: Execution Engine (The Engine)

Goal: High-performance, non-blocking order placement.

  • 2.1 Optimistic Nonce Manager (E-02)
    • Fetch initial nonce on startup
    • Atomic local increment
    • Auto-resync on "Nonce too low"
  • 2.2 Connection Management (D-02)
    • Global HTTP Client (Keep-Alive, Connection Pooling)
  • 2.3 Basic Rate Limiter (E-03)
    • Token Bucket implementation for API limits

🔵 Phase 3: Real-time Data (The Mirror)

Goal: Zero-latency data access via Shadow Orderbook.

  • 3.1 WebSocket Client (D-02)
    • Connect to Polymarket CLOB WS
    • Handle Ping/Pong
    • Reconnect Logic (Exponential Backoff)
  • 3.2 Shadow Orderbook (D-01)
    • In-Memory Orderbook Structure (map[string]*Orderbook)
    • Handle Snapshots & Deltas
    • GET /v1/markets/:id/book (Read from memory)

🔴 Phase 4: Risk & Robustness (The Shield)

Goal: Safety mechanisms for 24/7 operation.

  • 4.1 Fat Finger Check (R-01)
    • Max Order Value check
    • Price Deviation check
  • 4.2 Kill Switch (R-02)
    • DELETE /panic endpoint
  • 4.3 Graceful Shutdown
    • Cancel open orders on SIGTERM

🟣 Phase 5: AI Readiness & Advanced

Goal: Preparing for AI Agent integration.

  • 5.1 Semantic Error Codes
  • 5.2 Read-Only Mode
  • 5.3 Structured Logging (Audit)