[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-82146":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":8,"htmlUrl":8,"language":9,"languages":8,"totalLinesOfCode":8,"stars":10,"forks":11,"watchers":12,"openIssues":13,"contributorsCount":13,"subscribersCount":13,"size":13,"stars1d":13,"stars7d":13,"stars30d":14,"stars90d":13,"forks30d":13,"starsTrendScore":13,"compositeScore":15,"rankGlobal":8,"rankLanguage":8,"license":8,"archived":16,"fork":16,"defaultBranch":17,"hasWiki":18,"hasPages":16,"topics":19,"createdAt":8,"pushedAt":8,"updatedAt":20,"readmeContent":21,"aiSummary":22,"trendingCount":13,"starSnapshotCount":13,"syncStatus":23,"lastSyncTime":24,"discoverSource":25},82146,"arbitrage-copy-trading-bot-sports-crypto-all-markets","0xLumiere\u002Farbitrage-copy-trading-bot-sports-crypto-all-markets","0xLumiere",null,"TypeScript",249,7335,1,0,76,51.6,false,"main",true,[],"2026-06-12 04:01:37","# Polymarket Copy Trading Bot\n\nA full-stack tool for **Polymarket wallet copy trading** across **any market**: a target wallet’s trades (via the Data API), optional copy-trading (dry-run or live), and real-time copy activity over WebSocket.\n\n---\n\n## Features\n\n| Area | Description |\n|------|-------------|\n| **Markets** | Target-trade and copy logic is market-agnostic: it follows the configured wallet across all Polymarket markets. |\n| **Target trades** | Single backend poll loop per `target::global`; updates pushed over **WebSocket** when new trades are detected after copy zero-point seeding. Same loop drives **copy** when enabled. |\n| **Copy trading** | **Dry run** (log + activity) or **live** orders. Supports **limit GTC** (default) and **market FOK** (optional) to reduce drift when the book moves. Zero-point: first tick seeds baseline keys and does **not** copy; only later new trades are candidates to copy. |\n| **Activity** | In-memory ring buffer + **`\u002Fapi\u002Fcopy\u002Fws`** for baseline, simulated, posted, skipped, and error events. |\n| **My trades** | Polls Data API for **`CLOB_FUNDER_ADDRESS`** across all markets while copy is running (same REST shape as target trades; not CLOB user WS). |\n\n**Trade source:** Polymarket **Data API** `GET \u002Factivity` with `type=TRADE` (not `\u002Ftrades`), deduped and normalized.\n\n## Polymarket updates (CLOB V2 + pUSD + deposit wallets)\n\nPolymarket migrated production trading to **CLOB V2** on **Apr 28, 2026**. This project now targets the V2 SDK (`@polymarket\u002Fclob-client-v2`) and the production host `https:\u002F\u002Fclob.polymarket.com`.\n\n- **Collateral**: trading collateral is **pUSD** (Polymarket USD), not USDC.e. Your funder\u002Fdeposit wallet must hold pUSD to place BUY orders.\n- **Deposit wallet \u002F funder address**: for most Polymarket.com users, funds live in a **proxy wallet (Gnosis Safe)**. Use `CLOB_SIGNATURE_TYPE=2` and set `CLOB_FUNDER_ADDRESS` to that proxy\u002Fdeposit wallet address (see the wallet shown in your profile dropdown \u002F settings).\n\nReferences: [Migrating to CLOB V2](https:\u002F\u002Fdocs.polymarket.com\u002Fv2-migration), [Quickstart](https:\u002F\u002Fdocs.polymarket.com\u002Fdevelopers\u002FCLOB\u002Fquickstart), [Authentication](https:\u002F\u002Fdocs.polymarket.com\u002Fdevelopers\u002FCLOB\u002Fauthentication).\n\n## Architecture\n\n```text\n┌─────────────┐     REST\u002FWS      ┌─────────────────┐     HTTPS      ┌──────────────────────────┐\n│   React UI  │ ◄──────────────► │ Express + `ws`  │ ◄────────────► │ Data API + CLOB REST +  │\n│  (Vite 5173)│                  │ (Node, :3001)   │                │ Gamma metadata endpoints │\n└─────────────┘                  └─────────────────┘                └──────────────────────────┘\n```\n\n- **Frontend:** `VITE_API_BASE_URL` empty in dev → Vite proxies `\u002Fapi` (and WebSocket upgrades) to the backend.\n- **Backend:** One **`targetFeedLoops`** map entry per `lowercase(target)::global`; **`copyEnabled`** toggles order placement on top of the same tick that can broadcast **`target_trades`** and copy activity.\n\n---\n\n## Requirements\n\n- **Node.js** 18+ (or 20+ recommended)\n- **npm** or **yarn** at the repo root (workspaces)\n\n---\n\n## Quick start\n\n```bash\n# Install (from repository root)\nyarn install\n\n# Development: backend :3001 + frontend :5173\nyarn dev\n```\n\nOpen the UI URL printed by Vite (default **http:\u002F\u002Flocalhost:5173**). The API is expected at **http:\u002F\u002Flocalhost:3001** unless you set `VITE_API_BASE_URL`.\n\n**Production build**\n\n```bash\nyarn build\nyarn start   # runs both workspaces; for static hosting, host frontend\u002Fdist and set VITE_API_BASE_URL at build time\n```\n\n---\n\n## Environment variables (backend)\n\nCreate **`backend\u002F.env`** (see `.gitignore`). Current template (`backend\u002F.env copy.example`) includes:\n\n| Variable | Required for | Default |\n|----------|----------------|---------|\n| `PORT` | HTTP server | `3001` |\n| `CLOB_HOST` | CLOB REST | `https:\u002F\u002Fclob.polymarket.com` |\n| `CLOB_CHAIN_ID` | CLOB chain | `137` |\n| `GAMMA_API_BASE_URL` | Market \u002F event metadata | `https:\u002F\u002Fgamma-api.polymarket.com` |\n| `DATA_API_BASE_URL` | Trades feed | `https:\u002F\u002Fdata-api.polymarket.com` |\n| `CLOB_FUNDER_ADDRESS` | “My trades” + signing context | — |\n| `CLOB_PRIVATE_KEY` | **Live** copy orders | — |\n| `CLOB_SIGNATURE_TYPE` | CLOB client | often `2` |\n| `POLYGON_RPC_URL` | RPC for signing + L1 auth (viem) | `https:\u002F\u002Fpolygon-rpc.com` |\n| `CLOB_WS_URL` | Upstream market WS (chart relay) | `wss:\u002F\u002Fws-subscriptions-clob.polymarket.com\u002Fws\u002Fmarket` |\n\nOptional (not in the example file, but supported):\n\n- `CLOB_API_KEY`\n- `CLOB_SECRET`\n- `CLOB_PASSPHRASE`\n\nIf these optional L2 creds are not set, backend auto-derives API creds from `CLOB_PRIVATE_KEY`.\n\n**Live trading** needs a funded wallet and valid CLOB setup; **misconfiguration can lose funds**. Prefer **dry run** until you understand behavior.\n\n---\n\n## Notable HTTP routes\n\n| Method | Path | Role |\n|--------|------|------|\n| GET | `\u002Fapi\u002Fhealth` | Health check |\n| GET | `\u002Fapi\u002Ftarget-trades` | Merged recent trades across all markets (query: `userAddress`, optional `limit`) |\n| POST | `\u002Fapi\u002Ffeed\u002Fstart` | Start watch-only poll + WS `target_trades` |\n| POST | `\u002Fapi\u002Ffeed\u002Fstop` | Stop that loop entirely |\n| POST | `\u002Fapi\u002Fcopy\u002Fstart` | Enable copy on the same loop key |\n| POST | `\u002Fapi\u002Fcopy\u002Fstop` | `fullStop: false` → watch-only; `fullStop: true` → remove loop |\n| GET | `\u002Fapi\u002Fcopy\u002Factivity` | Activity history (`global=true` in current UI flow) |\n| GET | `\u002Fapi\u002Fwallet` | Exposes `CLOB_FUNDER_ADDRESS` to the UI |\n\n## WebSocket paths\n\n| Path | Query | Payloads |\n|------|--------|----------|\n| `\u002Fapi\u002Fcopy\u002Fws` | `targetAddress`, `global=true` | `subscribed`, `target_trades`, `copy_activity` |\n\n## Copy loop behavior (current)\n\n- Poll interval defaults to **250ms** (`\u002Fapi\u002Fcopy\u002Fstart` supports `pollMs`, min 200ms).\n- Each tick fetches **latest 50** target trades from Data API `\u002Factivity` (`type=TRADE`, `sortDirection=DESC`), then sorts oldest→newest for deterministic processing.\n- **Zero-point on start:** first tick only seeds dedupe keys (`processedCopyKeys`) and does not copy or send baseline trades to UI.\n- After zero-point, only newly discovered trades (not in `processedCopyKeys`) are:\n  - broadcast as `target_trades` over `\u002Fapi\u002Fcopy\u002Fws`\n  - considered for copy (dry-run\u002Flive)\n\n---\n\n## Live order posting notes\n\n- **Minimum order size**: Polymarket enforces a minimum (commonly **5 shares**). If a scaled\u002Fcapped copy order falls below the minimum, it is **skipped** and logged as a `skipped` copy activity event.\n- **Balance-aware caps**: live copy orders are capped by your actual balances:\n  - BUY orders are capped by **pUSD** balance.\n  - SELL orders are capped by **outcome token (share)** balance for that token.\n- **Order mode**:\n  - **Limit GTC** (default): mirrors the target’s price\u002Fsize as a limit order.\n  - **Market FOK** (optional): uses Fill-or-Kill market orders (with a `priceHint`) to reduce drift when the book moves.\n\n- `order_posted` means the backend believes posting succeeded.\n- If CLOB returns a structured error (for example `Unauthorized\u002FInvalid api key`), backend now treats it as an **error** event, not success.\n- If you see 401 in logs:\n  - verify `CLOB_PRIVATE_KEY` and `CLOB_FUNDER_ADDRESS` match,\n  - remove stale `CLOB_API_KEY` \u002F `CLOB_SECRET` \u002F `CLOB_PASSPHRASE` so backend can derive fresh API creds,\n  - restart backend after changing `.env`.\n\n---\n\n## Project layout\n\n```text\nPolyMarket-Crypto-Copy-Trading-Bot\u002F\n├── backend\u002Fsrc\u002Findex.ts   # Single server: REST + WS + loops + Gamma\u002FData\u002FCLOB\n├── frontend\u002Fsrc\u002F          # React UI (target trades + copy activity + my trades)\n├── package.json           # Workspaces + dev script\n└── README.md\n```\n\n---\n\n## Disclaimer\n\nThis software interacts with **real markets** and, in live mode, can **place real orders**. It is provided as-is for educational and operational use at your own risk. You are responsible for keys, compliance, and capital. **Never commit private keys or `.env` files.**\n\n---\n\n## License\n\nISC (see `package.json` files in workspaces).\n","该项目是一个全栈工具，用于在Polymarket平台上进行钱包跟单交易，支持任何市场。其核心功能包括跨市场的目标交易追踪与复制逻辑、通过WebSocket实时推送交易更新以及支持干运行和实际订单的跟单交易。技术上，该工具使用TypeScript开发，并采用了React作为前端框架，Express和WebSocket作为后端服务来处理数据API交互及实时通信。适用于希望自动跟随特定钱包进行交易策略复制的用户或开发者，尤其适合那些需要在多个市场间灵活操作且追求低延迟响应的应用场景。",2,"2026-06-01 03:57:23","CREATED_QUERY"]