DEV Community

Milo Forge
Milo Forge

Posted on

Find Polymarket Arbitrage Opportunities with AI in 5 Minutes

Prediction markets are one of the best sources of probability data on the planet. But they have inefficiencies that most traders miss.

Here's the thing about Polymarket: every binary market has a YES token and a NO token. In theory, YES + NO should always equal $1.00. If YES is priced at $0.65, NO should be $0.35. That's just basic probability.

But in practice? It's messier. Liquidity is fragmented. Market makers don't always keep spreads tight. Order books on small markets can sit stale for hours. The result is that YES + NO sometimes adds up to $0.94, or $0.97, or occasionally $1.08.

When YES costs $0.52 and NO costs $0.45, someone's leaving $0.03 on the table per share. That's not huge, but at scale, on 10 different markets simultaneously, with automated tooling, it adds up.

The problem is that there are thousands of active markets on Polymarket at any given time. Scanning them manually is not realistic. That's the problem I built something to solve.


The Tool

I've been working on an MCP server for Polymarket — polymarket-trading-mcp — that gives AI agents real-time market intelligence: slippage estimation, liquidity grading, arbitrage scanning, wallet intelligence, price feeds.

The arbitrage scanner is the one I want to walk through here.

Install it:

pip install polymarket-trading-mcp
Enter fullscreen mode Exit fullscreen mode

Source: github.com/whitmorelabs/polymarket-mcp


Finding the Gaps

The tool is built as an MCP server, so you use it through an AI agent (Claude Desktop, Cursor, etc.) that has the server configured. Once it's running, you can just ask:

"Find all Polymarket markets where YES + NO prices don't add up to 100%"

Under the hood, that calls find_arbitrage_gaps. Here's what a real scan looks like:

> find_arbitrage_gaps(min_gap_pct=2.0)

Found 4 markets with arbitrage gaps:

1. "Will the Fed cut rates in May 2025?"
   Market ID: 0x7a3f...e291
   YES price: 0.41 | NO price: 0.54
   Sum: 0.95 | Gap: 5.0%
   Direction: BUY_BOTH
   — Buying both YES and NO at these prices costs $0.95. At resolution, one pays $1.00. Guaranteed 5.3% return.

2. "Will Bitcoin close above $70k on April 15?"
   Market ID: 0x12bc...9a04
   YES price: 0.52 | NO price: 0.45
   Sum: 0.97 | Gap: 3.0%
   Direction: BUY_BOTH
   — $0.03 per share. 3.1% return locked in.

3. "Will Ethereum ETH/BTC ratio exceed 0.055 by EOQ2?"
   Market ID: 0x88f2...3c71
   YES price: 0.61 | NO price: 0.43
   Sum: 1.04 | Gap: -4.0%
   Direction: SELL_BOTH
   — YES + NO overpriced. Selling both and pocketing the difference works if you can source the tokens.

4. "Will SpaceX Starship reach orbit before June 2025?"
   Market ID: 0x4d9e...b12a
   YES price: 0.38 | NO price: 0.58
   Sum: 0.96 | Gap: 4.0%
   Direction: BUY_BOTH
   — 4.2% gap. Smaller market, worth checking liquidity before entering.
Enter fullscreen mode Exit fullscreen mode

Four gaps found in one scan. Gaps 1, 2, and 4 are all BUY_BOTH situations — you buy YES and NO simultaneously, pay less than $1.00 combined, and collect $1.00 when the market resolves. Gap 3 is the reverse.

Before getting excited, you need to check two more things: slippage and liquidity.


Checking Slippage

A 3% gap sounds great until you realize the order book is so thin that buying $500 worth costs you 2.8% in slippage and wipes out your edge. Let's check the Bitcoin market:

> estimate_slippage(
    market_id="0x12bc...9a04",
    side="BUY",
    position_size_usd=500.0
  )

Results for BUY $500 on "Will Bitcoin close above $70k on April 15?"

YES leg:
  Best price:     $0.52
  Avg fill price: $0.5231
  Slippage:       0.60%
  Liquidity used: $268 of $1,240 available

NO leg:
  Best price:     $0.45
  Avg fill price: $0.4518
  Slippage:       0.40%
  Liquidity used: $232 of $890 available

Combined entry cost: $0.9749 (vs $0.97 mid)
Net edge after slippage: 2.51%
Recommendation: GO — edge survives execution
Enter fullscreen mode Exit fullscreen mode

Slippage is 0.4-0.6% per leg. Combined entry comes out to $0.9749 instead of $0.97 exactly, but the 3% gap still leaves 2.51% net after slippage. That's a solid trade on paper.


Verifying Liquidity

One more check before committing capital. The SpaceX market had a 4% gap but I flagged it as a smaller market. Let's see what the liquidity actually looks like:

> scan_market_liquidity(market_id="0x4d9e...b12a")

Liquidity scan: "Will SpaceX Starship reach orbit before June 2025?"

Best bid:  $0.375
Best ask:  $0.385
Spread:    2.67%

Depth from mid:
  1% depth:  $120 YES / $85 NO
  2% depth:  $340 YES / $210 NO
  5% depth:  $780 YES / $490 NO

Liquidity grade: C
Recommendation: Caution — thin book, size carefully. Max recommended position: $200
Enter fullscreen mode Exit fullscreen mode

Grade C. The 4% gap is real but the book is too thin to put real size on. Buying $500 here would move the market against you. The recommended max is $200, which means your dollar return on a 4% gap is about $8. Probably not worth the complexity unless you're running this across dozens of markets simultaneously.

That's exactly the workflow: scan for gaps, filter by slippage, filter by liquidity, size accordingly.


The Bigger Picture

The arbitrage scanner is one piece of a larger set of tools in the server. The others cover:

  • Wallet intelligence — scores and PnL for 195+ curated on-chain wallets, shadow wallet networks
  • Price feeds — real-time prices from Binance and CoinGecko in parallel
  • Portfolio risk — Kelly criterion warnings, diversification scores, max loss calculations
  • Contract timers — exact expiry for BTC 5-min and 15-min contracts
  • Probability estimation — structured base-rate reasoning for any question

The arbitrage and slippage tools are free. Wallet intelligence requires an API key (7-day trial, then pay-per-request in USDC).


Setup for Claude Desktop

If you're using Claude Desktop, add this to your claude_desktop_config.json:

{
  "mcpServers": {
    "polymarket": {
      "command": "polymarket-mcp",
      "args": ["--stdio"]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Then restart Claude and you can ask questions about Polymarket markets in natural language. The agent calls the tools, you see the results.


Closing

The tools are open source. The data is real-time. The edge is there until it isn't.

Prediction markets are still early enough that inefficiencies like these exist and persist for hours. Automated scanning makes it practical to act on them. Whether you're running $200 or $20,000 through this, the analysis workflow is the same — find the gap, check the slippage, verify the liquidity, size accordingly.

The repo is at github.com/whitmorelabs/polymarket-mcp. Issues, PRs, and stars are welcome.

Top comments (0)