close

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 (3)

Collapse
 
hiren-kava profile image
Hiren Kava

Excellent work—this clearly shows that prediction-market making is not just standard spread capture with a different API. The combination of time-to-resolution controls, inventory-aware exposure reduction, and FAK execution addresses the real tail risk of holding the losing outcome at settlement. I especially like the decision to widen spreads as resolution approaches, although it would be interesting to see the model also account for liquidity imbalance and sudden information-driven probability jumps. Rust is also a strong choice for maintaining predictable execution and order-state management under fast CLOB updates. The planned portfolio rebalancing and oracle/news integration could make this a very valuable open-source foundation for prediction-market infrastructure.

Collapse
 
harrieronchain profile image
Harrier

For sure, are you by any chance developing a Polymarket trading bot as well?

Collapse
 
hiren-kava profile image
Hiren Kava

🌟