InsidePoly is a real-time insider-trading surveillance tool for Polymarket, the world's largest prediction market platform on Polygon. Prediction markets are uniquely vulnerable to information asymmetry: on-chain data is fully public, yet no tooling existed to systematically flag wallets trading with suspiciously prescient timing or concentration. InsidePoly closes that gap by continuously watching every trade and scoring each trader on a 0–100 insider-trading likelihood scale.

The system is a TypeScript monorepo with three packages: common (shared Drizzle ORM schema and types), backend (Express API plus scoring engine), and frontend (Next.js leaderboard). The data pipeline ingests OrderFilled events from the Polymarket Subgraph (The Graph), enriches them via Alchemy RPC to resolve token/condition IDs and wallet histories, then persists everything to PostgreSQL (Supabase). Redis backs the job queues and sync cursors. Live updates push via socket.io, and the frontend polls via React Query every 30 seconds with WebSocket subscriptions for aggregate tier stats.

I designed and built the entire system end-to-end. The most technically demanding piece was score_wallets(), a PL/pgSQL function that computes five behavioral signals in a single pass without round-tripping through the application layer: bet concentration (top-market volume share), market count, position size, entry timing (how late in a market's lifecycle a wallet first traded), and wallet age (gap between first USDC.e receipt and first trade), each contributing up to 25 points. Wallets scoring 80+ get flagged as suspected insiders on the leaderboard.

  • Stack: TypeScript, Next.js, Express, PostgreSQL, Redis, Drizzle ORM, socket.io, The Graph, Alchemy, Supabase
  • Scoring tiers: Flagged Insider (80–100), Suspicious (60–79), Watchlist (30–59), Normal (0–29)
  • Pipeline stages: Subgraph ingestion → enrichment loop → scoring loop → REST + WebSocket broadcast
Built using: