[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-82327":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":15,"stars30d":16,"stars90d":15,"forks30d":15,"starsTrendScore":15,"compositeScore":17,"rankGlobal":10,"rankLanguage":10,"license":10,"archived":18,"fork":18,"defaultBranch":19,"hasWiki":20,"hasPages":18,"topics":21,"createdAt":10,"pushedAt":10,"updatedAt":41,"readmeContent":42,"aiSummary":43,"trendingCount":15,"starSnapshotCount":15,"syncStatus":44,"lastSyncTime":45,"discoverSource":46},82327,"polymarket-trading-bot","BlackCandleLab\u002Fpolymarket-trading-bot","BlackCandleLab","polymarket trading bot, polymarket trading bot, polymarket trading bot, polymarket trading bot, polymarket trading bot, polymarket trading bot, polymarket trading bot, polymarket arbitrage bot, polymarket trading bot, polymarket arbitrage bot, polymarket trading bot, polymarket arbitrage bot, polymarket trading bot, polymarket arbitrage bot, ","https:\u002F\u002Fgithub.com\u002FBlackCandleLab\u002Fpolymarket-trading-bot",null,"JavaScript",241,1821,1,0,116,56.78,false,"main",true,[22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,5,37,38,39,40],"algorithmic-trading","arbitrage","automated-trading","btc-trading-bot","clob","copy-trading","crypto-trading-bot","defi","ethereum","market-making","nodejs","polygon","polymarket","polymarket-arbitrage-bot","polymarket-copy-trading-bot","prediction-markets","trading-bot","usdc","web3","2026-06-12 04:01:37","\u003Cdiv align=\"center\">\n\n# Polymarket BTC Up\u002FDown Trading Bot\n\n### BTC 5m Up\u002FDown · CLOB arbitrage · copy-trading · Polygon\n\nA production-oriented **Node.js** trading bot for **Polymarket** short-duration **Up\u002FDown** markets on **Polygon**, with both **arbitrage** and **copy-trading** workflows.\n\n\u003Cp>\n  \u003Ca href=\"https:\u002F\u002Fgithub.com\u002FBlackCandleLab\u002Fpolymarket-trading-bot\">\u003Cb>GitHub · BlackCandleLab\u002Fpolymarket-trading-bot\u003C\u002Fb>\u003C\u002Fa>\n  &nbsp;·&nbsp;\n  \u003Ca href=\"https:\u002F\u002Fpolymarket.com\">\u003Cb>Polymarket.com\u003C\u002Fb>\u003C\u002Fa>\n\u003C\u002Fp>\n\n[![Node.js](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FNode.js-18+-green.svg)](https:\u002F\u002Fnodejs.org\u002F)\n[![Polymarket](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPolymarket-polymarket.com-5D3FD3)](https:\u002F\u002Fpolymarket.com)\n[![GitHub](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FGitHub-BlackCandleLab%2Fpolymarket--trading--bot-181717?logo=github)](https:\u002F\u002Fgithub.com\u002FBlackCandleLab\u002Fpolymarket-trading-bot)\n\n\u003C\u002Fdiv>\n\n\u003Csub>\n\n**Keywords:** polymarket copy trading bot polymarket arbitrage bot, polymarket copy trading bot polymarket arbitrage bot, polymarket copy trading bot polymarket arbitrage bot, polymarket copy trading bot polymarket arbitrage bot, polymarket copy trading bot polymarket arbitrage bot, polymarket copy trading bot polymarket  bot,\n\n\u003C\u002Fsub>\n\n---\n\n### Contents\n\n- [Beyond simple arbitrage (2026)](#beyond-simple-arbitrage-2026)\n- [Four strategies bots profit from](#four-strategies-bots-profit-from)\n- [How this bot maps to those strategies](#how-this-bot-maps-to-those-strategies)\n- [Execution and risk management](#execution-and-risk-management)\n- [Why this repository](#why-this-repository)\n- [Overview](#overview)\n- [Screenshots](#screenshots)\n- [Detailed Runbook](#detailed-runbook)\n- [Key Features](#key-features)\n- [Repository Modes](#repository-modes)\n- [Strategy Summary](#strategy-summary)\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Configuration](#configuration)\n- [Quick Start](#quick-start)\n- [Logging and Output](#logging-and-output)\n- [Project Structure](#project-structure)\n- [File Guide](#file-guide)\n- [Practical Safety Notes](#practical-safety-notes)\n- [Troubleshooting](#troubleshooting)\n- [Recommended First Run](#recommended-first-run)\n- [Disclaimer](#disclaimer)\n\n---\n\n## Beyond simple arbitrage (2026)\n\nThe classic Polymarket playbook — *buy YES and NO when their combined price is below $1.00 and collect the spread* — was real in 2024. By 2026, that edge is largely captured by sub-100ms bots on dedicated Polygon RPC nodes. Orderbook analysis from Q3 2025 through Q1 2026 suggests:\n\n| Metric | Trend |\n| --- | --- |\n| Average arb opportunity duration | ~2.7s (down from ~12.3s in 2024) |\n| Arb profits captured by sub-100ms bots | ~73% |\n| Median arb spread | ~0.3% (often thin after gas) |\n| Bot profits from **non-arb** strategies | ~27% |\n\nProfitable automation in 2026 is less about chasing microsecond YES+NO spreads and more about **multi-strategy portfolios**: market making, information-speed edges, logical correlation plays, and short-window momentum — with disciplined execution and risk caps.\n\nThis README incorporates that framework from [Beyond Simple Arbitrage: 4 Polymarket Strategies Bots Actually Profit From in 2026](https:\u002F\u002Fmedium.com\u002Fillumination\u002Fbeyond-simple-arbitrage-4-polymarket-strategies-bots-actually-profit-from-in-2026-ddacc92c5b4f) (Jemy Rose, ILLUMINATION, Feb 2026) and maps it to what **this repository** actually runs.\n\n> **Disclaimer:** Past market statistics and backtests in the article do not guarantee future results. This software is educational\u002Foperational tooling, not financial advice.\n\n---\n\n## Four strategies bots profit from\n\n### 1. Automated market making\n\n**Profile:** ~78–85% win rate · low volatility · ~1–3% monthly (article benchmarks)\n\nInstead of betting on an outcome, the bot posts liquidity on **both** sides and earns the bid–ask spread. That requires continuous orderbook monitoring, inventory limits, spread widening on volatility, and pulling quotes before major news — work that is impractical manually but feasible for a 24\u002F7 bot.\n\n### 2. AI-powered probability arbitrage\n\n**Profile:** ~65–75% win rate · medium volatility · ~3–8% monthly\n\nWhen news or data moves fair probability faster than the CLOB reprices, there is a short window (seconds to minutes) to trade the gap. Ensemble models (LLMs + fine-tuned models) can ingest headlines and update Bayesian-style estimates faster than discretionary traders — **this repo does not ship LLM\u002Fnews APIs**; see [extension points](#how-this-bot-maps-to-those-strategies) if you want to build that layer.\n\n### 3. Correlation and logical arbitrage\n\n**Profile:** ~70–80% win rate · low–medium volatility · ~2–5% monthly\n\nExploit **impossible or inconsistent** prices across related markets (e.g. “Team X wins” vs “Conference Y wins”, or outcome probabilities that sum above 100%). Requires graph-style relationship mapping and multi-leg execution within a tight window — **not implemented** in this codebase today.\n\n### 4. High-frequency momentum \u002F latency (BTC 5-minute markets)\n\n**Profile:** ~60–70% win rate · high volatility · ~8–15% monthly (aggressive profiles)\n\nOn short Up\u002FDown windows, price can lag oracle or orderbook reality for seconds. Bots that monitor Chainlink\u002Foracle feeds and the CLOB WebSocket can act before the UI catches up. **This is the primary focus of the main arbitrage engine** (`btc-updown-5m-*`).\n\n### Multi-strategy portfolios (article takeaway)\n\nProfessional setups rarely rely on one mode. Typical allocations described in the article:\n\n| Profile | Mix (illustrative) | Role of simple arb |\n| --- | --- | --- |\n| Conservative | ~80% arb\u002FMM, ~20% market making | Ballast — market-neutral, steady |\n| Balanced | ~50% arb, ~30% AI\u002Fsignals, ~20% MM | Growth with measured risk |\n| Aggressive | ~30% arb, ~50% AI\u002Fmomentum, ~20% MM | Returns driver; higher drawdown |\n\nEven “aggressive” portfolios keep some market-neutral arb\u002FMM to smooth returns. **This repo** gives you **Strategy 1 (partial)** via dual-sided ladders, **Strategy 4** via the 5m BTC engine, and **copy-trading** as a separate social-signal path — not a full four-strategy stack out of the box.\n\n---\n\n## How this bot maps to those strategies\n\n| Strategy | In this repo? | Where |\n| --- | --- | --- |\n| Market making (dual-sided liquidity) | **Partial** | Symmetric buy ladders on Up and Down; merge when paired (`src\u002Ftrader.js`) |\n| AI probability arbitrage | **No** | Would need news\u002FLLM pipelines (not in `package.json`) |\n| Correlation \u002F logical arb | **No** | Single-market 5m focus; no cross-market graph |\n| Momentum \u002F latency (5m BTC) | **Yes (core)** | WebSocket orderbook, taker arb when `bestAskUp + bestAskDown \u003C 1 - TARGET_EDGE`, oracle-aware resolution flow |\n| Copy-trading (information follow) | **Yes** | `src\u002Fcopy-trader.js`, `src\u002Fcopy\u002F` — mirror target wallet buys |\n| Simple YES+NO arb | **Yes (component)** | Paired taker buys + merge\u002Fredeem; compete with HFT — use private RPC and tight risk caps |\n\n#### Extension points (not included today)\n\n- Cross-platform arb (Polymarket vs Kalshi, etc.)\n- Automated correlation graph across 100+ markets\n- Built-in news\u002FLLM ensemble signals\n- Telegram or managed “platform” orchestration\n\nThose are extension points if you fork and combine this runtime with external signal services.\n\n---\n\n## Execution and risk management\n\nThe article argues **strategy is ~30% of success; execution and risk are ~70%**. This bot aligns with that stack:\n\n| Concern | Implementation here |\n| --- | --- |\n| Fast execution | CLOB WebSocket + REST fallback (`src\u002Fclob.js`); dedicated `POLYGON_RPC` recommended |\n| Partial fills \u002F liquidity | `MAX_TAKER_FILL_USDC`, ladder sizing, merge thresholds |\n| Position limits | `MAX_SPEND_PER_MARKET`, `MAX_INVENTORY_IMBALANCE_USDC` |\n| Circuit breakers | `MAX_LOSS_PER_HOUR_USDC`, `COMBINED_ASK_STOP` |\n| Stop adding risk near close | `STOP_BUYING_BEFORE_CLOSE` |\n| Copy-trade caps | `COPY_MAX_*`, slippage and stale-trade filters |\n| Credential resilience | Auto L1→L2 CLOB credential derive\u002Frefresh in `src\u002Fclob.js` |\n\n**Infrastructure the article recommends (and this repo expects):**\n\n- Node 18+, reliable Polygon RPC (Alchemy\u002FInfura-class, not only public endpoints)\n- USDC + MATIC on Polygon, Polymarket proxy wallet configured correctly\n- 24\u002F7 process if you want continuous 5m windows; graceful shutdown on `SIGINT` \u002F `SIGTERM`\n\nManual browser trading against sub-100ms automation is a structural disadvantage; this project is the **DIY \u002F open-source** path (full control, you own ops and maintenance).\n\n---\n\n## Why this repository\n\nThis project is built for users who need an operational trading runtime instead of a toy script:\n\n- Real CLOB authentication and order execution on Polymarket\n- On-chain approvals, merge, and redeem transaction flows\n- Real-time order-book monitoring via WebSocket with fallback logic\n- Configurable risk limits, circuit breakers, and graceful shutdown behavior\n- Dedicated copy-trading path for mirroring selected wallet activity\n\nThis repository contains:\n\n- A **5-minute BTC Up\u002FDown arbitrage bot** that posts both sides of the market, takes mispriced liquidity, merges matched pairs, and redeems after resolution.\n- An **integrated wallet-following module** that can mirror future buys from a target wallet during the main runtime.\n- A **dedicated buy-only copy trader** under `src\u002Fcopy\u002F` that polls Polymarket's public trade feed and reacts to fresh target-wallet buys.\n\nThe codebase is structured for real trading: on-chain approvals, Polymarket CLOB authentication, WebSocket order-book tracking, risk caps, circuit breakers, structured logging, and graceful shutdown handling are all included.\n\n> Important: This software places live blockchain and market orders. Use it only if you fully understand the strategy, the wallet setup, the gas implications, and the market risks.\n\n## Overview\n\nThis bot is designed around **Polymarket complementary-token markets**, especially the recurring `btc-updown-5m-*` markets.\n\nAt a high level, the main arbitrage engine:\n\n1. Loads your signer and Polymarket proxy wallet configuration.\n2. Ensures the required Polygon approvals are in place.\n3. Derives or refreshes Polymarket CLOB API credentials automatically.\n4. Discovers the next 5-minute BTC Up\u002FDown market before it opens.\n5. Posts a symmetric buy ladder on both `Up` and `Down`.\n6. Aggressively buys both sides when the combined ask becomes favorable.\n7. Merges matched pairs back into USDC when economically sensible.\n8. Cancels open orders at market close.\n9. Waits for resolution and redeems winning positions.\n\nThe repository also supports copy-trading workflows for users who want to follow a target Polymarket wallet with configurable sizing and risk caps.\n\n## Screenshots\n\nThe following screenshots show the workflow this bot targets.\n\n### Performance\n\n![1D performance view](img\u002FScreenshot_3.png)\n\n![Past week performance view](img\u002FScreenshot_1.png)\n\n![All-time performance view](img\u002FScreenshot_2.png)\n\n### Activity Snapshot\n\n![Trading activity snapshot](img\u002FG7o1D49WcAErNMi.png)\n\n## Detailed Runbook\n\n1. Install dependencies:\n\n```bash\nnpm install\n```\n\n2. Create your local environment file:\n\n```powershell\nCopy-Item .env.example .env\n```\n\nor:\n\n```bash\ncp .env.example .env\n```\n\n3. Configure at minimum:\n- `PRIVATE_KEY`\n- `PROXY_WALLET`\n- `POLYGON_RPC` (strongly recommended)\n\n4. Start with conservative limits and run:\n\n```bash\nnpm start\n```\n\n## Key Features\n\n- **Dual-sided ladder execution** for recurring BTC 5-minute markets.\n- **Taker arbitrage logic** when combined best ask drops below the configured edge threshold.\n- **On-chain merge and redeem support** for Polymarket negative-risk markets.\n- **Session and per-market risk controls** including spend caps and circuit breakers.\n- **Automatic CLOB credential derivation** through Polymarket's documented L1-to-L2 auth flow.\n- **Live WebSocket order-book tracking** for low-latency price updates.\n- **Optional wallet mirroring** for follow-trading workflows.\n- **Dedicated copy-trading engine** with filters for stale trades, price bounds, slippage, and cumulative spend.\n- **Structured console and file logging** through `winston`.\n- **Graceful shutdown** on `SIGINT` \u002F `SIGTERM`.\n\n## Repository Modes\n\nThere are two primary ways to use this repository.\n\n### 1. Main Arbitrage Engine\n\nThe main runtime lives in `src\u002Findex.js`.\n\nIt is focused on:\n\n- Discovering the next `btc-updown-5m` market\n- Posting both-sided ladders at the open\n- Executing taker arb when the market offers enough edge\n- Merging matched pairs back into USDC\n- Redeeming after oracle resolution\n\nThis is the core strategy described by the main `package.json` metadata.\n\n### 2. Copy-Trading Workflows\n\nThe repo currently contains **two copy-related paths**:\n\n- **Integrated copy watcher** in `src\u002Fcopy-trader.js`  \n  If `TARGET_WALLET` is set, the main runtime snapshots that wallet's current positions and then mirrors future increases in `totalBought`.\n\n- **Dedicated buy-only copy trader** in `src\u002Fcopy\u002F`  \n  This path uses `src\u002Fcopy\u002FactivityFeed.js` plus `src\u002Fcopy\u002FcopyTrader.js` to detect fresh public trade activity from one or more target wallets and submit capped buy orders quickly.\n\nIf your goal is to use the dedicated copy system, read the copy-trading section below carefully and prefer the explicit `src\u002Fcopy\u002Findex.js` entrypoint.\n\n## Strategy Summary\n\nIn the [2026 multi-strategy framing](#four-strategies-bots-profit-from), the main engine is closest to **high-frequency momentum \u002F latency on BTC 5-minute Up\u002FDown markets**, with **market-making-style** dual-sided ladders and **simple complementary-token arb** when the combined ask offers edge.\n\n### Main Arb Logic\n\nThe core `Trader` class in `src\u002Ftrader.js` implements a market lifecycle roughly like this:\n\n1. **Wait for market open**  \n   The bot discovers the next market before open, then waits until the trading window is live.\n\n2. **Post the ladder**  \n   It places buy orders across many configured price levels on both outcomes.\n\n3. **Monitor live best asks**  \n   A WebSocket feed keeps the current top-of-book available with REST fallback when needed.\n\n4. **Fire taker arb orders**  \n   When `bestAskUp + bestAskDown \u003C 1 - TARGET_EDGE`, the bot submits paired buy orders.\n\n5. **Merge matched pairs**  \n   If both outcomes have been accumulated in sufficient size, the bot merges them back into USDC.\n\n6. **Stop buying near market close**  \n   It stops adding risk before the window ends, then cancels remaining open orders.\n\n7. **Wait for resolution and redeem**  \n   After the market resolves, the bot redeems any winning positions.\n\n### Built-In Risk Controls\n\nThe main strategy includes multiple safety mechanisms:\n\n- `MAX_SPEND_PER_MARKET`\n- `MAX_TAKER_FILL_USDC`\n- `MAX_INVENTORY_IMBALANCE_USDC`\n- `COMBINED_ASK_STOP`\n- `MAX_LOSS_PER_HOUR_USDC`\n- `STOP_BUYING_BEFORE_CLOSE`\n- `MERGE_THRESHOLD_USDC`\n\nThese controls are not optional decoration. They define how aggressively the bot is allowed to trade and when it must stop.\n\n## Requirements\n\nBefore running the bot, make sure you have:\n\n- **Node.js 18+**\n- A **Polymarket account**\n- Your **Polygon EOA private key**\n- Your **Polymarket proxy wallet address**\n- **USDC on Polygon**\n- Enough native MATIC for gas\n- Access to a reliable Polygon RPC endpoint\n\nRecommended:\n\n- Use a dedicated wallet for bot operation\n- Start with small size caps\n- Use a private RPC provider instead of the default public endpoint\n- Test copy workflows with `COPY_DRY_RUN=true` first\n\n## Installation\n\nClone this repository (canonical URL):\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002FBlackCandleLab\u002Fpolymarket-trading-bot.git\ncd polymarket-trading-bot\n```\n\nThen install dependencies:\n\n```bash\nnpm install\n```\n\nThe repo already includes a `package-lock.json`, so a normal `npm install` is the intended setup path.\n\n## Configuration\n\nCopy the example environment file.\n\nPowerShell:\n\n```powershell\nCopy-Item .env.example .env\n```\n\nBash:\n\n```bash\ncp .env.example .env\n```\n\nThen edit `.env` with your real wallet and risk settings.\n\n### Minimum Required Settings\n\nThese values are essential for almost every real run:\n\n| Variable | Required | Purpose |\n| --- | --- | --- |\n| `PRIVATE_KEY` | Yes | Your Polygon signer used for approvals and order signing |\n| `PROXY_WALLET` | Yes | The Polymarket proxy wallet tied to your account |\n| `POLYGON_RPC` | Strongly recommended | Polygon RPC endpoint used by `ethers` |\n| `LOG_LEVEL` | No | Console\u002Ffile logging verbosity |\n\n### Main Arbitrage Settings\n\nThese parameters shape the main strategy:\n\n| Variable | What it controls |\n| --- | --- |\n| `MAX_SPEND_PER_MARKET` | Total buy-side budget for one 5-minute market |\n| `TARGET_EDGE` | Minimum combined-price edge before firing arb buys |\n| `MERGE_THRESHOLD_USDC` | Minimum matched pair size before merge |\n| `MAX_TAKER_FILL_USDC` | Maximum size for a single taker action |\n| `MAX_INVENTORY_IMBALANCE_USDC` | Inventory imbalance guardrail |\n| `COMBINED_ASK_STOP` | Hard stop if the market becomes too expensive |\n| `MAX_LOSS_PER_HOUR_USDC` | Rolling session loss circuit breaker |\n| `LADDER_LEVELS` | Ladder prices posted on both sides |\n| `LADDER_SIZE_PER_LEVEL_USDC` | Size allocated to each ladder level |\n\n### Copy-Trading Settings\n\nThe repo exposes two different copy-trading parameter groups.\n\n#### Integrated Copy Watcher\n\n| Variable | Purpose |\n| --- | --- |\n| `TARGET_WALLET` | Single target Polymarket wallet to mirror during main runtime |\n| `COPY_TRADE_BUY_PERCENT` | Percent of target spend to mirror |\n| `COPY_TRADE_POLL_MS` | Poll interval for the target positions API |\n\n#### Dedicated Buy-Only Copy Trader\n\n| Variable | Purpose |\n| --- | --- |\n| `COPY_TARGETS` | Comma-separated list of target wallets |\n| `COPY_SIZE_MODE` | `FIXED`, `MIRROR`, or `RATIO` |\n| `COPY_FIXED_USDC` | Fixed spend per copied trade |\n| `COPY_RATIO` | Spend multiplier when `COPY_SIZE_MODE=RATIO` |\n| `COPY_MAX_USDC_PER_TRADE` | Hard cap per copied trade |\n| `COPY_MAX_USDC_PER_MARKET` | Hard cap per market |\n| `COPY_MAX_USDC_PER_HOUR` | Rolling hourly cap |\n| `COPY_MAX_USDC_TOTAL` | Session-wide cap |\n| `COPY_MAX_SLIPPAGE` | Maximum price premium above target fill |\n| `COPY_MAX_PRICE` | Upper price filter |\n| `COPY_MIN_PRICE` | Lower price filter |\n| `COPY_STALE_MS` | Reject stale signals |\n| `COPY_POLL_MS` | Poll frequency for target trades |\n| `COPY_ALLOWED_CONDITIONS` | Optional allow-list |\n| `COPY_BLOCKED_CONDITIONS` | Optional block-list |\n| `COPY_DRY_RUN` | Log-only mode without real orders |\n\n### CLOB Credentials\n\nThe example file includes:\n\n- `POLY_API_KEY`\n- `POLY_API_SECRET`\n- `POLY_API_PASSPHRASE`\n\nThese can be left blank on first run. The client in `src\u002Fclob.js` attempts to derive valid credentials automatically from your signer. If cached credentials become invalid, the client also attempts a refresh flow.\n\n## Quick Start\n\n### Main Arbitrage Bot\n\n1. Install dependencies with `npm install`.\n2. Copy `.env.example` to `.env`.\n3. Fill in `PRIVATE_KEY`, `PROXY_WALLET`, and a reliable `POLYGON_RPC`.\n4. Start with conservative values such as a smaller `MAX_SPEND_PER_MARKET`.\n5. Run the bot.\n\n```bash\nnpm start\n```\n\nYou can also run the explicit arb script:\n\n```bash\nnpm run arb\n```\n\nFor development mode with Node's file watcher:\n\n```bash\nnpm run dev\n```\n\nor\n\n```bash\nnpm run arb:dev\n```\n\n### Integrated Wallet Mirroring\n\nIf you want the main runtime to also mirror future buys from a specific target wallet:\n\n1. Set `TARGET_WALLET` in `.env`.\n2. Optionally tune `COPY_TRADE_BUY_PERCENT` and `COPY_TRADE_POLL_MS`.\n3. Launch the main bot as normal.\n\nThe bot will snapshot existing positions first, then only react to **new buy increases** observed after startup.\n\n### Dedicated Buy-Only Copy Trader\n\nIf you want the dedicated `src\u002Fcopy\u002F` implementation:\n\n1. Configure `COPY_TARGETS`.\n2. Set conservative caps.\n3. Prefer starting with `COPY_DRY_RUN=true`.\n4. Run the dedicated entrypoint directly.\n\n```bash\nnode src\u002Fcopy\u002Findex.js\n```\n\nThis path is useful when your focus is low-latency buy-following rather than the BTC 5-minute arbitrage lifecycle.\n\n## Logging and Output\n\nThe logger writes:\n\n- Colored structured logs to the console\n- JSON logs to `bot.log`\n\nThis is useful for:\n\n- Live monitoring\n- Post-session debugging\n- Reviewing order failures\n- Investigating market timing and slippage\n\n## Project Structure\n\n```text\n.\n|-- .env.example\n|-- package.json\n|-- img\u002F\n|-- src\u002F\n|   |-- index.js\n|   |-- trader.js\n|   |-- copy-trader.js\n|   |-- market.js\n|   |-- clob.js\n|   |-- onchain.js\n|   |-- pnl.js\n|   |-- logger.js\n|   `-- copy\u002F\n|       |-- index.js\n|       |-- activityFeed.js\n|       |-- copyTrader.js\n|       `-- config.js\n`-- README.md\n```\n\n## File Guide\n\n- `src\u002Findex.js`  \n  Main bot lifecycle, startup, market loop, graceful shutdown, and optional integrated copy watcher.\n\n- `src\u002Ftrader.js`  \n  Per-market state machine for ladder posting, taker arb, merge logic, order cancellation, and redeem flow.\n\n- `src\u002Fmarket.js`  \n  Polymarket Gamma\u002FData API helpers for market discovery, wallet positions, and resolution polling.\n\n- `src\u002Fclob.js`  \n  CLOB REST and WebSocket client, auth handling, order signing, and order posting utilities.\n\n- `src\u002Fonchain.js`  \n  Polygon approvals, token balances, merge transactions, and redeem transactions.\n\n- `src\u002Fcopy-trader.js`  \n  Integrated target-wallet mirroring based on changes in target positions.\n\n- `src\u002Fcopy\u002FactivityFeed.js`  \n  High-frequency polling of public trade data for specific wallets.\n\n- `src\u002Fcopy\u002FcopyTrader.js`  \n  Dedicated copy-trading execution engine with filters and spend accounting.\n\n## Practical Safety Notes\n\n- Do **not** start with large sizing.\n- Do **not** run with a wallet you use for unrelated funds.\n- Do **not** assume public RPC endpoints are stable enough for serious production usage.\n- Do **not** skip reading the `.env.example` comments; they explain the intended meaning of most controls.\n- Do start with `COPY_DRY_RUN=true` for copy trading.\n- Do verify your proxy wallet address carefully.\n- Do keep enough MATIC available for approvals, merges, and redeems.\n\n## Troubleshooting\n\n### The bot exits immediately with a missing env var error\n\nCheck `.env` and confirm the required fields are actually populated:\n\n- `PRIVATE_KEY`\n- `PROXY_WALLET`\n\nFor dedicated copy trading, also confirm:\n\n- `COPY_TARGETS`\n\n### Orders fail or the bot cannot authenticate\n\n- Confirm your signer matches the intended Polymarket account.\n- Confirm `PROXY_WALLET` is the correct proxy wallet for that signer.\n- Try a stable private Polygon RPC endpoint.\n- Leave `POLY_API_*` blank if you want the bot to derive fresh credentials automatically.\n\n### Copy trades are not firing\n\n- Make sure your target wallet address is lowercased correctly in the copy settings.\n- Check that the target is placing fresh **BUY** trades, not only sells or old fills.\n- Verify your caps are not too restrictive.\n- For dedicated copy mode, make sure `COPY_DRY_RUN` is set the way you expect.\n\n### Merge or redeem transactions fail\n\n- Confirm approvals were granted successfully.\n- Confirm you hold enough matched positions to merge.\n- Confirm the market is actually resolved before expecting redeem payout.\n- Check `bot.log` for the underlying error payload.\n\n## Recommended First Run\n\nIf you are launching this repo for the first time, the safest path is:\n\n1. Fill `.env` with real wallet values.\n2. Use a private RPC endpoint.\n3. Lower your spend caps materially.\n4. Run the main bot in observation mode with small sizing.\n5. If testing copy logic, enable `COPY_DRY_RUN=true` first.\n6. Review `bot.log` after a short session before scaling up.\n\n## Disclaimer\n\nThis repository is provided for research and operational use by experienced users. It is **not financial advice**, and it does not guarantee profit. Real-money trading on Polymarket and Polygon involves market risk, execution risk, smart contract risk, RPC reliability risk, and operational risk. You are fully responsible for how you configure and use this software.\n\nStrategic context in this README is adapted from [Beyond Simple Arbitrage: 4 Polymarket Strategies Bots Actually Profit From in 2026](https:\u002F\u002Fmedium.com\u002Fillumination\u002Fbeyond-simple-arbitrage-4-polymarket-strategies-bots-actually-profit-from-in-2026-ddacc92c5b4f). That article’s performance figures and product references (e.g. third-party managed bots) are **not** endorsements by this project — verify all claims independently before risking capital.\n","该项目是一个针对Polymarket平台的自动化交易机器人，主要用于Polygon网络上的短期涨跌市场。它基于Node.js开发，支持套利和跟单两种交易策略。该机器人能够实时分析订单簿，并在发现有利可图的机会时自动执行交易，适用于希望提高交易效率并捕捉市场价格波动机会的用户。此外，它还提供了详细的运行手册和配置指南，帮助用户快速上手。",2,"2026-06-01 03:57:56","CREATED_QUERY"]