Inspiration
Prediction markets are having a moment. Polymarket processed over $1 billion in trading volume during the 2024 U.S. election cycle alone, proving that crowd-sourced probability is not just a novelty, but a legitimate financial primitive. But there's a glaring gap: every single trade on Polymarket has to be placed manually. Meanwhile, crypto traders on spot and derivatives markets have had algorithmic bots, grid strategies, and automated execution for years. Why should prediction markets be any different? The information edge in event-driven markets is time-sensitive and fleeting. A price that crosses a threshold at 3am shouldn't require a human to be awake to capture it. That was the spark for Polytology.
What I Learned
Building on top of Polymarket's CLOB (Central Limit Order Book) infrastructure taught me a tremendous amount about how decentralized order books actually work. I learned how EIP-712 typed structured data signing is used to authorize trades without broadcasting private keys, how Gnosis Safe proxy contracts enable non-custodial trading accounts, and how Polymarket's Builder Relayer abstracts away gas fees entirely, making the onboarding experience feel like Web2 while remaining fully on-chain on Polygon. On the product side, I learned that the hardest part of building a strategy builder isn't the execution engine. It's the UX of making complex conditional logic feel approachable to non-technical traders.
How I Built It
Polytology is a full-stack application split into two services running concurrently:
Frontend - A Next.js 16 / React 19 app styled with Tailwind CSS v4 and Radix UI primitives. The strategy builder uses @dnd-kit for drag-and-drop block composition. Framer Motion powers the onboarding wizard and micro-interactions. TanStack Query handles server state and cache invalidation. Charts are rendered with Recharts.
Backend - An Express.js server written in TypeScript that maintains a persistent WebSocket connection to Polymarket's CLOB price feed, batches and forwards live price ticks to frontend clients every 250ms, and runs a strategy executor loop every 30 seconds. The executor queries all active strategies from the database, evaluates condition blocks (price crossings with edge detection, cooldown timers, daily trade limits, time schedules, external HTTP data sources), and places orders on Polymarket's CLOB API using stored user credentials, entirely server-side with no browser session required.
Auth & Wallets - Privy handles embedded wallet creation (no seed phrase required). On first login, a Gnosis Safe is automatically deployed via Polymarket's Builder Relayer (gasless), CLOB API credentials are derived from the wallet signature, and everything is stored in Supabase for persistence.
Database - Supabase (PostgreSQL) with 6 incremental migrations tracking strategies, trades, user credentials, cached markets, funding events, and custom data sources.
Challenges
The single hardest challenge was server-side trade execution on behalf of users. Polymarket's CLOB client requires signing orders with a user's private key using EIP-712. Getting this to work in a server environment, reconstructing the signing context from stored credentials without ever exposing raw private keys in logs or responses, required deep dives into the @polymarket/clob-client internals and careful key derivation flows.
Another major challenge was real-time price streaming at scale. Polymarket has over 1,800 active market tokens. Subscribing to all of them over a single WebSocket, parsing price updates, maintaining an in-memory price cache, and fanning that out to connected frontend clients with sub-second latency required careful batching and flush interval tuning to avoid overwhelming the client with re-renders.
Finally, designing a strategy block DSL that was both expressive enough to be useful and simple enough to be built visually was a genuine product design challenge. I went through several iterations before landing on the three-category model (Market -> Conditions -> Actions) that maps cleanly onto a drag-and-drop interface.
Built With
- ethers.js
- express.js
- framer-motion
- gnosis-safe
- next.js
- polygon
- polymarket-builder-relayer
- polymarket-clob-api
- polymarket-gamma-api
- postgresql
- privy
- radix-ui
- react
- recharts
- shadcn/ui
- supabase
- tailwind-css
- tanstack
- typescript
- viem
- wagmi
- websocket
Log in or sign up for Devpost to join the conversation.