Star 历史趋势
数据来源: GitHub API · 生成自 Stargazers.cn
README.md

Polymarket Arbitrage Bot

Automated dump-and-hedge trading for Polymarket’s 15-minute crypto Up/Down markets — TypeScript, official CLOB client, hands-free across BTC, ETH, SOL, and XRP.

Active development for this line of work: 2026-01-04 through 2026-04-02.

Node.js TypeScript

Contents


Why this exists

Short-dated prediction markets move fast. When one side dumps in seconds, the other side often lags — and if you can buy both legs cheaply enough, their combined cost can sit below $1 per paired share, locking in a structural edge before resolution.

This bot watches those markets continuously, detects sharp moves that match your thresholds, executes a two-leg cycle (dump capture → hedge), and tracks P&L — with optional simulation so you can validate behavior before risking capital.


What it does

CapabilityDescription
Multi-assetTrade one or many markets: btc, eth, sol, xrp (comma-separated).
Auto-discoveryResolves the active 15m Up/Down market per asset from Polymarket’s Gamma API and rolls forward each new period.
Dump detectionUses recent ask history to flag a leg when price falls by your move threshold within a short time window.
Hedge logicAfter leg 1, waits for leg 2 when leg1 entry + opposite ask ≤ your sum target (e.g. 0.95).
Risk controlsConfigurable stop-loss hedge if the favorable hedge does not appear within N minutes.
SettlementOn market close, reconciles winners/losers and can redeem winning positions on-chain (production).
LoggingStreams activity to stderr and appends a history file for review and auditing.

Strategy flow

New 15m round ┌─────────────────┐ rapid drop on Up or Down ┌──────────────┐ │ Watch window │ ───────────────────────────────► │ Buy dumped │ │ (first N min) │ │ leg (Leg 1) │ └─────────────────┘ └──────┬───────┘ opposite ask cheap enough │ (sum ≤ target) ▼ ┌──────────────┐ │ Buy hedge │ │ (Leg 2) │ └──────┬───────┘ timeout? ─────────────────────────────┤ Stop-loss hedge path

Simplified view of the trader module; tune thresholds with environment variables.


Tech stack

  • Runtime: Node.js 16+
  • Language: TypeScript
  • Polymarket: @polymarket/clob-client (orders, auth), Gamma + CLOB HTTP APIs (markets, prices)
  • Chain: Polygon (USDC, CTF redemption flow)

Quick start

Prerequisites

  • Node.js 16 or newer
  • A Polymarket-compatible wallet and (for live trading) USDC on Polygon, plus a clear choice of EOA vs proxy signing (SIGNATURE_TYPE in .env)

Install

clone the repo cd polymarket-arbitrage-bot npm install cp .env.example .env # Edit .env — see [Configuration](#configuration-env) npm run build

Run modes

CommandPurpose
npm run devRun from source with ts-node (development).
npm run typecheckTypeScript check without emitting dist/.
npm run cleanRemove compiled output in dist/.
npm run simSimulation — logs trades, no real orders (--simulation).
npm run prodProduction — real CLOB orders (--production).
npm startRun dist/main.js; combine with your flags and .env as below.

Live trading: set PRODUCTION=true in .env and run npm run prod (or node dist/main.js --production) so the process is not left in simulation mode.


Configuration (.env)

Copy .env.example to .env and adjust.

VariableRole
PRIVATE_KEYRequired for real orders and redemption.
PROXY_WALLET_ADDRESSPolymarket proxy/profile address if applicable.
SIGNATURE_TYPE0 EOA, 1 Proxy, 2 Gnosis Safe (default in example: 2).
GAMMA_API_URLOptional; default https://gamma-api.polymarket.com.
CLOB_API_URLOptional; default https://clob.polymarket.com.
API_KEY / API_SECRET / API_PASSPHRASEOptional; use if your setup requires CLOB API credentials.
MARKETSe.g. btc or btc,eth,sol,xrp (comma-separated, lowercase).
CHECK_INTERVAL_MSPrice polling interval in ms (default 1000).
MARKET_CLOSURE_CHECK_INTERVAL_SECONDSHow often to check for round closure (default 20).
DUMP_HEDGE_SHARESSize per leg (shares).
DUMP_HEDGE_SUM_TARGETMax combined price for hedge (e.g. 0.95).
DUMP_HEDGE_MOVE_THRESHOLDMin fractional drop to count as a dump (e.g. 0.15 = 15%).
DUMP_HEDGE_WINDOW_MINUTESOnly look for dumps in the first N minutes of the round.
DUMP_HEDGE_STOP_LOSS_MAX_WAIT_MINUTESForce the stop-loss path if no favorable hedge within N minutes.
DUMP_HEDGE_STOP_LOSS_PERCENTAGECap on the forced hedge sum: max(leg1 + opposite) = 1 + this fraction (default 0.2).
PRODUCTIONfalse = simulation; use true with --production for live execution.

Project layout

src/ main.ts # Entry: discovery, monitors, period rollover monitor.ts # Price polling and snapshots dumpHedgeTrader.ts # Dump → hedge → stop-loss → settlement tracking api.ts # Gamma, CLOB, orders, redemption, activity config.ts # Environment loading models.ts # Shared types logger.ts # History file + stderr

Disclaimer

This software is provided for educational and research purposes only. Prediction markets and automated trading involve substantial financial risk, including possible total loss. Past or simulated behavior does not guarantee future results. You are solely responsible for compliance with applicable laws, exchange terms, and tax obligations. Nothing here is investment, legal, or tax advice.


Operational safety checklist

  • Run in simulation first and inspect history.toml over multiple rounds.
  • Start with low DUMP_HEDGE_SHARES and conservative thresholds in production.
  • Keep private keys out of version control; rotate any exposed credentials.

Contributors

Core development (Q1 2026): buffalu, bunghi, calvinzhou-rockx, Carlosted, cavemanloverboy, ch9xy, ChewingGlass, codemonkey6969, cryptogosu, cryptopapi997, danpaul000.


Contributing

Issues and pull requests are welcome: strategy ideas, safer defaults, tests, and clearer documentation help everyone.
See CONTRIBUTING.md for the local workflow and commit guidelines.


Troubleshooting

  • Failed to fetch market/orderbook: Often transient API or network issues; confirm endpoints and retry behavior.
  • Order failures in production: Verify PRIVATE_KEY, SIGNATURE_TYPE, and proxy wallet settings match your Polymarket account.
  • No market found: Ensure MARKETS only lists supported assets (btc, eth, sol, xrp) and wait for the next 15-minute round.

License

See LICENSE in this repository for terms.

关于 About

polymarket arbitrage bot polymarket arbitrage bot polymarket arbitrage bot polymarket arbitrage bot polymarket arbitrage bot polymarket arbitrage bot polymarket arbitrage bot polymarket arbitrage bot polymarket arbitrage bot polymarket arbitrage bot polymarket arbitrage bot polymarket arbitrage bot polymarket arbitrage bot polymarket arbitrage bot
arbitragebotpolymarket-arbitrage-bottrading

语言 Languages

TypeScript100.0%

提交活跃度 Commit Activity

代码提交热力图
过去 52 周的开发活跃度
10
Total Commits
峰值: 2次/周
Less
More

核心贡献者 Contributors