DEV Community

Harrier
Harrier

Posted on

I built an open-source market maker for prediction markets (Polymarket/CLOB) — here's how it works

Hey everyone,

I've been deep in prediction market infrastructure for a while and just open-sourced a market maker bot designed for CLOB-based prediction markets like Polymarket.

What it does:

  • Quotes both sides of a binary market automatically
  • Adjusts spreads based on order book depth and volatility
  • Manages inventory risk to avoid getting stuck on the wrong side of a resolved market
  • Built on top of Polymarket's CLOB API with Gnosis Safe / EOA wallet support on Polygon

The core challenge with prediction markets vs. regular markets:

Normal market making is about capturing spread. Prediction markets add a brutal edge case — resolution risk. If you're holding YES at 0.6 and the market resolves NO, you're not just down on the spread, you're down the full position. So the bot has to:

  • Track time-to-resolution and widen spreads as resolution approaches
  • Reduce inventory exposure on markets with high directional momentum
  • Use FAK orders to avoid resting limit orders too long near resolution

Stack:

  • Rust
  • Polymarket CLOB API
  • Polygon (USDC settlement)
  • SQLite for order state tracking

What's next:

  • Dynamic spread model based on implied volatility
  • Multi-market portfolio rebalancing
  • Better signal integration (news feeds, oracle data)

GitHub: https://github.com/HarrierOnChain/Prediction-Markets-Trading-Bot-Toolkits

Happy to answer questions on the architecture, risk model, or anything CLOB-related. Always looking for feedback from others building in this space.

Top comments (0)