How It Works β€” ArbitRay Polymarket Arbitrage Bot | ArbitRay
Gabagool logoArbitRay
> The Bot> How It Works> Doc> Careers> Contact
StatusGet the bot

$ cat ./how-it-works

Here is the technical breakdown of how these apex arbitrageurs systematically extract yield from Polymarket’s bucket contracts. Three highly automated, latency-optimized strategies running 24/7 across BTC, ETH, SOL, DOGE, BNB, and XRP.

$ cat ./bucket-markets
Polymarket's crypto UP/DOWN markets are binary contracts that resolve based on whether an asset's price is above or below a strike price at expiry. Each market has two tokens:
UP Token
Pays $1.00 if the asset closes above the strike. Otherwise $0.
DOWN Token
Pays $1.00 if the asset closes below the strike. Otherwise $0.
New markets open every 5 minutes, 15 minutes, and 1 hour across four assets. Because UP + DOWN must resolve to exactly $1.00, any pricing that sums to less creates a risk-free arbitrage opportunity. Any pricing that deviates from fair value creates a directional opportunity.
BTCETHSOLXRPDOGEBNB5m / 15m / 1h windows
$ cat ./strategies
β–ΆMomentum Trading
The momentum strategy exploits the latency between Binance spot prices and Polymarket contract pricing. When BTC moves sharply on Binance, Polymarket's UP/DOWN tokens take seconds to reprice. The bot detects the move via a real-time Binance aggTrade WebSocket feed and enters a Polymarket position before the market adjusts.
Signal detection uses a configurable lookback window and minimum delta threshold. When the price move exceeds the threshold, the bot fires an order on the corresponding UP or DOWN token.
4 execution modes: single_taker (FOK at ask β€” default), gtc_at_ask (GTC limit at ask, rests if no fill), single_maker (GTC at bid for maker fees), dual_hybrid (taker on signal side + maker on contra side simultaneously). Each mode trades off fill probability against execution cost. See the parameter tuning guide for details.
β–ΆMarket Making
Two-sided quoting on both UP and DOWN tokens. The bot posts resting limit orders on both sides of the spread and profits from the bid-ask gap. The key edge is Binance preemptive cancel: the bot monitors the real-time Binance price feed and cancels resting orders before an adverse price move results in a toxic fill.
When the Binance feed signals a sharp BTC move, the bot cancels its exposed side (e.g., cancels resting UP bids if BTC is about to dump) in sub-second, then re-quotes once the move settles. This dramatically reduces adverse selection β€” the #1 killer of market-making strategies.
Automatic position rebalancing and on-chain merging via ProxyWallet Factory. When the bot accumulates both UP and DOWN tokens, it merges them on-chain to recover USDC and free up capital.
β–ΆSpread Capture (Arbitrage)
The spread capture strategy exploits a fundamental constraint: UP + DOWN tokens must resolve to exactly $1.00. When the combined bid prices sum to less than $1.00 (e.g., UP bid at $0.48 + DOWN bid at $0.49 = $0.97), the bot buys both sides at the bid for a guaranteed $0.03 profit at resolution, regardless of which direction the asset moves.
This is a risk-neutral strategy β€” the bot profits at resolution no matter the outcome. Each instance monitors one asset/window combination, checking every tick whether the combined price falls below the spread threshold. Run multiple instances to cover all markets.
$ cat ./architecture
The bot is a single Rust binary that runs as a systemd service on a Linux VPS. Event-driven architecture β€” the evaluation loop wakes on each Binance aggTrade, not on a fixed timer.
Binance WebSocket (aggTrade)
  β”‚
  β”œβ”€β†’ Signal Engine (lookback, delta threshold)
  β”‚     β”‚
  β”‚     β”œβ”€β†’ Momentum Strategy ───→ Polymarket CLOB
  β”‚     β”œβ”€β†’ Market Making ───────→ Polymarket CLOB
  β”‚     └─→ Spread Capture ──────→ Polymarket CLOB
  β”‚
  └─→ Preemptive Cancel (adverse move detection)
        └─→ Cancel resting orders before toxic fill
βœ“Each asset (BTC, ETH, SOL, XRP, DOGE, BNB) gets its own Binance feed and strategy instances
βœ“Vendored Polymarket SDK β€” full CLOB API integration, no external dependencies
βœ“GTC and FOK order types with configurable execution modes per strategy
βœ“On-chain merge via ProxyWallet Factory β€” recovers capital from matched UP/DOWN positions
$ cat ./differentiators
βœ“Arbitrage trading algo β€” ~44K lines of Rust. Not a hosted service, not an API wrapper. You own it, deploy it...
βœ“6.8 GB Historical Data β€” 11,201 market files across BTC, ETH, SOL, XRP, DOGE, BNB at 100ms resolution with embedded Binance klines.
βœ“Parallel Backtester β€” 3 fill models (deterministic, probabilistic, latency). Tests thousands of markets in minutes.
βœ“Pre-Tuned Configs β€” 42 ready-to-trade configurations spanning 5 assets, from 5-minute to daily markets, with nominal and low-budget profiles.
βœ“Real-Time Dashboard β€” dashboard showing live positions, P&L, order flow, and momentum signals.
βœ“Production Battle-Tested β€” the same codebase running on the developer's own VPS with $500K+ in verified profit.

$ cat ./deep-dives

Technical details behind each component. Click to expand.

Full strategy docs, deployment guides, and parameter tuningRead the docs β†’