This is an automated copy trading bot for Polymarket that monitors target traders and automatically replicates their positions in real-time. The bot continuously tracks the target trader's positions and executes buy/sell orders to match their portfolio, enabling you to follow successful traders automatically.
- Real-time Position Monitoring - Continuously monitors target trader positions every 4 seconds (configurable)
- Automatic Trade Execution - Automatically places buy/sell orders to match target portfolio
- Position Difference Detection - Compares target positions with your current positions
- Risk Management - Applies position limits and minimum trade size constraints
- Auto Redeem - Optionally redeems resolved positions automatically
- Blacklist Support - Exclude specific markets from trading
- Comprehensive Logging - Detailed logging for monitoring and debugging
Polymarket-Copytrading-Bot/
├── src/
│ ├── polymarket/ # Polymarket bot core modules
│ │ ├── api-client.ts # Polymarket API client for fetching data and placing orders
│ │ ├── position-monitor.ts # Monitors target trader positions
│ │ ├── trade-executor.ts # Executes trades based on position differences
│ │ ├── bot.ts # Main bot orchestrator
│ │ └── index.ts # Module exports
│ ├── constants/ # Configuration constants
│ │ ├── constants.ts # Environment variables and connection setup
│ │ └── index.ts # Constants exports
│ ├── utils/ # Utility functions
│ │ ├── logger.ts # Logging configuration
│ │ ├── utils.ts # Helper functions
│ │ └── index.ts # Utils exports
│ ├── main.ts # Application entry point
│ ├── buy.ts # Buy example (legacy)
│ ├── sell.ts # Sell example (legacy)
│ ├── pumpswap.ts # PumpSwap SDK (legacy)
│ ├── pool.ts # Pool utilities (legacy)
│ ├── IDL/ # Anchor IDL definitions (legacy)
│ ├── jito/ # Jito bundle utilities (legacy)
│ └── nozomi/ # Nozomi transaction submission (legacy)
├── .env.example # Environment variables template
├── package.json # Node.js dependencies and scripts
├── tsconfig.json # TypeScript configuration
├── tsconfig.base.json # Base TypeScript configuration
├── README.md # This file
└── README-example.md # Example README reference
- Node.js v16 or higher
- npm or yarn package manager
- Polygon wallet with USDC balance
- Private key of your trading wallet
- Target trader's wallet address to copy
# Clone the repository
git clone <repository-url>
cd Polymarket-Copytrading-Bot
# Install dependencies
npm install
# Configure environment variables
# Copy .env.example to .env and fill in your settings
cp .env.example .env
# Edit .env file with your configuration:
# - TARGET_USER_ADDRESS: Address of the trader you want to copy
# - MY_USER_ADDRESS: Your wallet address
# - PRIVATE_KEY: Your wallet's private key
# - API endpoints (already configured by default)
# Start the application
npm run startCreate a .env file in the root directory with the following variables (see .env.example for template):
TARGET_USER_ADDRESS- Ethereum/Polygon address of the trader you want to copyMY_USER_ADDRESS- Your wallet address (the bot will trade from this address)PRIVATE_KEY- Private key of your trading wallet (without 0x prefix)CLOB_HTTP_URL- Polymarket CLOB HTTP API endpoint (default: https://clob.polymarket.com/)CLOB_WS_URL- Polymarket CLOB WebSocket endpoint (default: wss://ws-subscriptions-clob.polymarket.com/ws)GAMMA_API_URL- Polymarket Gamma API endpoint (default: https://gamma-api.polymarket.com)
POLLING_INTERVAL- Polling interval in milliseconds (default: 4000 = 4 seconds)MAX_POSITION_LIMIT- Maximum position limit in USD (default: 0.2 = $0.20)MIN_TRADE_SIZE- Minimum trade size in shares (default: 1)AUTO_REDEEM- Enable auto-redeem for resolved positions (default: false)REDEEM_INTERVAL- Redeem interval in milliseconds (default: 7200000 = 2 hours)LOG_LEVEL- Logging level (default: info)
The bot continuously monitors the target trader's positions by polling the Polymarket API at configurable intervals. It compares the target positions with your current positions and identifies differences.
When position differences are detected, the bot automatically:
- Calculates the required trade size
- Checks position limits and minimum trade size
- Gets current market prices
- Places buy or sell orders to match the target portfolio
- Logs all trade executions
- Position Limits: Maximum position value per trade (configurable)
- Minimum Trade Size: Minimum number of shares to trade (configurable)
- Blacklist: Exclude specific markets from trading
- Error Handling: Comprehensive error handling and retry logic
The bot uses structured logging with the following levels:
info: General information and status updateswarn: Warnings and non-critical issueserror: Errors and failuresdebug: Detailed debugging information
- Telegram: https://t.me/DevCutup
- Whatsapp: https://wa.me/13137423660
- Twitter: https://x.com/devcutup