☢️ I built an autonomous AI Agent to find +EV bets on Polymarket

Hey everyone,

I wanted to share a project I’ve been building called **Nuke.Farm**. It’s an AI-powered trading terminal for Polymarket that automates the research and execution process for prediction markets.

I built this to solve a specific headache: prediction markets have complex “Resolution Criteria” (the fine print) that is tedious to cross-reference with real-world news. I wanted an agent that could read the rules, check the news, do the math, and execute the trade for me.

:hammer_and_wrench: The Stack

  • Web Framework: Next.js

  • AI Model: Google Gemini 3 Flash

  • Web3: Wagmi/Viem

  • State: Postgres

  • Infrastructure: Polymarket API

:brain: How it works (The Technicals)

1. The “Analyst” (Server-Side AI)
When you select a market, the agent ingests the specific `resolution_criteria`, `end_date`, and current `liquidity`. It then performs a web search to find live data (e.g., poll numbers or injury reports). It calculates an Expected Value (EV) and a Kelly Stake size, returning a structured trade recommendation.

2. 100% Gasless Transactions (The Relayer)
This is the part I’m most proud of. The app uses the Gnosis Safe proxy pattern (native to Polymarket).
Instead of the user paying MATIC for every trade:

  1. We derive a Gnosis Safe address from the user’s EOA.
  2. The user signs a “Session Key” (EIP-712).
  3. The app constructs a transaction object.
  4. We send this to the Polymarket Relayer, which broadcasts the tx and pays the gas.
    Result: A completely Web2-like experience where the user never worries about gas or bridging native tokens.

3. The Order Book (CLOB)
Mapping prediction market “outcomes” to ERC-20 Token IDs is surprisingly complex. I built a recursive resolver that maps human-readable outcomes (e.g., “Yes”, “Trump”, “Kansas City”) to their specific Hex Token IDs on the CLOB (Central Limit Order Book) to ensure the AI trades the exact right asset.

:locked: Security

The app is non-custodial. It uses the standard Gnosis Safe architecture. The session keys allow the app to trade on the user’s behalf for a limited time, but funds always remain in the user’s on-chain Proxy Safe.

Links:

Thanks for checking it out!