[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-93385":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":16,"stars30d":16,"stars90d":15,"forks30d":15,"starsTrendScore":15,"compositeScore":17,"rankGlobal":10,"rankLanguage":10,"license":10,"archived":18,"fork":18,"defaultBranch":19,"hasWiki":18,"hasPages":18,"topics":20,"createdAt":10,"pushedAt":10,"updatedAt":24,"readmeContent":25,"aiSummary":26,"trendingCount":15,"starSnapshotCount":15,"syncStatus":27,"lastSyncTime":28,"discoverSource":29},93385,"polymarket-resolution-sniper","basileus-labs\u002Fpolymarket-resolution-sniper","basileus-labs","Polymarket resolution sniping bot on bitcoin 5min Up or Down market","",null,"TypeScript",189,145,124,0,33,63.29,false,"master",[21,22,23],"polymarket-bot","polymarket-btc-5min-bot","polymarket-sniper","2026-07-22 04:02:09","# Polymarket Resolution Sniper\n\nTypeScript bot that implements **resolution sniping** on Polymarket\n\n## Strategy overview\n\nResolution sniping exploits the gap between when an outcome becomes knowable and when Polymarket officially settles:\n\n1. The underlying interval ends (e.g. a 5-minute BTC window closes).\n2. Chainlink BTC\u002FUSD fixes the final price vs. the window open (\"price to beat\").\n3. Trading may still be open briefly; resting asks at **98–99¢** on the winning side can remain.\n4. The bot buys that liquidity and redeems at **$1** after resolution (~1% per successful snipe).\n\nThe referenced account shows this pattern clearly: **12,935 predictions**, almost all **Bitcoin Up or Down 5m** markets, entries at **99¢**, ~**1.01%** return per win, and large share counts (thousands per window).\n\n### Key risks\n\n| Risk | Mitigation in this bot |\n|------|------------------------|\n| Last-second BTC reversal | `MIN_PRICE_BUFFER_USD` \u002F `MIN_PRICE_BUFFER_BPS` — skip near-tie windows, **plus a stop-loss sell** when the book drops below `SELL_TRIGGER_PRICE` |\n| Wrong price source | On-chain Chainlink feed (same source as market rules) with REST fallback |\n| Misread settlement rules | Hard-coded Up\u002FDown rule: end ≥ open → Up |\n| One bad trade wipes many wins | Dry-run default, **max 1 buy + 1 sell per market**, spread\u002Fmid sanity gates |\n| Position held into a $0 resolution | Order-book stop-loss exits the position early instead of holding a loser to expiry |\n\n### Risk management (buy + protective sell)\n\nEach 5-minute market allows **at most 2 orders**: one **buy** and one **stop-loss sell**.\n\n1. **Buy** — a winning-side token at **98–99¢** in the final ~15s (`SNIPE_MAX_SECONDS_BEFORE_END`).\n2. **Sell (stop-loss)** — every cycle the bot re-reads the held token's order book. As soon as the **best bid drops below `SELL_TRIGGER_PRICE`** (default **90¢**), it exits the whole position at the best bid, capping the downside of a reversal instead of letting the token settle to $0.\n\nPositions are tracked in-memory per window; monitoring stops `POSITION_MONITOR_GRACE_SEC` after the window ends so the bot never dumps into a post-resolution $0 book.\n\n## Architecture\n\n```\nsrc\u002F\n  gamma\u002Fclient.ts       # Discover btc-updown-5m-{timestamp} markets\n  price\u002Fchainlink.ts    # Chainlink BTC\u002FUSD (authoritative) + REST fallback\n  book\u002ForderBook.ts     # CLOB snapshot helpers\n  strategy\u002F\n    outcomeResolver.ts  # Determine Up\u002FDown from open vs current price\n    snipeSelector.ts    # Final-second window + 99¢ ask gate\n    engine.ts           # Parallel scan → execute loop\n  exec\u002FclobClient.ts    # Dry-run + live CLOB execution\n  index.ts              # CLI entry point\n```\n\n## Setup\n\n```bash\ncd polymarket-resolution-sniper\nnpm install\ncp .env.example .env\n# Fill PRIVATE_KEY, BROWSER_ADDRESS, CLOB API creds for live mode\n# Set ETH_RPC_URL for on-chain Chainlink (recommended)\n```\n\n## Run\n\n```bash\n# Interactive dashboard (dry-run, default in TTY)\nnpm run start:dry\n\n# Single cycle — compact table output\nnpx tsx src\u002Findex.ts --dry-run --once\n\n# Force plain text (no blessed UI)\nnpx tsx src\u002Findex.ts --dry-run --plain\n\n# Live trading (requires credentials, DRY_RUN=0)\nnpm run start:live\n```\n\n### Terminal UI\n\nWhen running in a TTY, the bot renders a **blessed dashboard** with:\n\n| Panel | Contents |\n|-------|----------|\n| **Pipeline** | Color-coded steps: Discover → Price → Evaluate → Execute → History → Cycle |\n| **Markets** | Scanned windows with ETA, side, ask, gate status |\n| **Trades** | Recent orders with SIM\u002FLIVE\u002FERR status |\n| **Activity** | Step-by-step colored log |\n\nKeys: `[q]` quit · `[r]` refresh\n\n## Configuration\n\n| Variable | Default | Purpose |\n|----------|---------|---------|\n| `SNIPE_MAX_SECONDS_BEFORE_END` | 45 | Only enter in the last N seconds |\n| `SNIPE_MIN_SECONDS_BEFORE_END` | 2 | Skip if too close to hard close |\n| `BUY_LIMIT_PRICE_MAX` | 0.99 | Max bid price |\n| `MIN_PRICE_BUFFER_USD` | 25 | Min $ distance from open price |\n| `BUY_USDC` | 50 | Notional per snipe |\n| `MAX_PARALLEL_MARKETS` | 12 | Concurrent market evaluations |\n| `SELL_ENABLED` | 1 | Enable the protective stop-loss sell |\n| `SELL_TRIGGER_PRICE` | 0.90 | Sell the held token when best bid drops below this |\n| `MAX_ORDERS_PER_MARKET` | 2 | Cap orders per window (1 buy + 1 sell) |\n| `POSITION_MONITOR_GRACE_SEC` | 60 | Stop monitoring a position this long after window end |\n| `HISTORY_DIR` | history | Directory for `live.json` \u002F `simulation.json` trade logs |\n\n## Trade history\n\nAfter each order (live, simulation, or failed), the bot appends a record to:\n\n- `history\u002Fsimulation.json` — dry-run \u002F paper trades\n- `history\u002Flive.json` — real CLOB orders\n\nRecords are grouped **per market window** (by slug):\n\n```json\n{\n  \"mode\": \"simulation\",\n  \"updatedAt\": \"2026-07-08T21:54:40.000Z\",\n  \"windows\": {\n    \"btc-updown-5m-1783547400\": {\n      \"slug\": \"btc-updown-5m-1783547400\",\n      \"windowStartUtc\": \"2026-07-08T21:50:00.000Z\",\n      \"windowEndUtc\": \"2026-07-08T21:55:00.000Z\",\n      \"trades\": [\n        {\n          \"status\": \"dry_run\",\n          \"side\": \"Up\",\n          \"limitPrice\": 0.99,\n          \"notionalUsdc\": 50,\n          \"openPrice\": 62000,\n          \"currentPrice\": 62150\n        }\n      ]\n    }\n  }\n}\n```\n\n## Tests\n\n```bash\nnpm test\n```\n\nCovers outcome resolution, snipe timing, order-book gates, gamma parsing, RTDS Chainlink parsing, selector logic, and dry-run engine cycles.\n\n## Limitations\n\n- Automated on-chain redemption is **not** implemented — claim via Polymarket UI after resolution.\n- Gamma `endDate` is informational; oracle timing can diverge slightly.\n- Geography \u002F compliance is your responsibility.\n\n## License\n\nMIT\n","这是一个针对Polymarket平台比特币5分钟涨跌预测市场的分辨率狙击（resolution sniping）自动化交易机器人。它利用市场结算前短暂的时间窗口，基于Chainlink链上BTC\u002FUSD价格，在确认结果已知但尚未正式结算时，以98–99美分买入胜出侧代币，并通过内置止损机制（如跌破90美分即卖出）控制反转风险。项目采用TypeScript开发，支持干运行验证、单市场限单（1买+1卖）、链上价格源校验及内存态持仓管理。适用于高频、低延迟、小盈亏比（~1%）的链上预测市场套利场景，尤其适合专注Polymarket BTC 5分钟Up\u002FDown合约的量化策略实践者。",2,"2026-07-17 02:30:09","CREATED_QUERY"]