A bot that copies Polymarket whale trades in real time with your own risk limits and position sizing.
Why this bot over Python or TypeScript bots: Built in Rust for speed and reliability—no interpreter or GC pauses, so you get lower latency and more consistent execution. One compiled binary, minimal CPU/memory use, and strong typing so it keeps running without the runtime surprises common in scripted bots.
Follow this guide from zero to live copy trading. Each step is designed so you can verify everything before risking real funds.
| What you need | Where to get it |
|---|---|
| Polymarket account | polymarket.com |
| Web3 wallet (MetaMask or similar) | Export private key for a wallet you will use only for this bot |
| RPC API key | Free: Alchemy or Chainstack (Polygon network) |
| Whale address | The trader you want to copy (40-character hex; find via Research commands) |
| Funds | USDC on Polygon (e.g. 50–100 USDC to start) + a little MATIC for gas |
-
Install Rust (one-time):
- Windows: rustup.rs → run installer → restart terminal.
- macOS/Linux:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shthensource ~/.cargo/env
-
Clone and enter the project:
git clone <repository-url> cd rust
-
Check versions:
rustc --version cargo --version
-
Run the setup wizard (creates and fills
.env):cargo run --release setup setup
-
When prompted, enter:
- Target whale address — The trader you’re copying
- Private key — Your bot wallet’s key (64 hex chars, no
0x) - Funder address — Same as wallet address for normal wallets; for Gnosis Safe, use the Safe address
- RPC API key — From Alchemy or Chainstack (Polygon)
- Strategy —
PERCENTAGE(e.g. copy 10% of each trade),FIXED(e.g. $50 per trade), orADAPTIVE - Risk limits — Max/min order size (USD), and optionally max position and daily volume
-
Validate setup:
cargo run --release setup system-status
Fix any errors (balance, connectivity, config) before continuing.
The bot needs permission to spend your USDC and conditional tokens:
cargo run --release wallet check-allowance- EOA (MetaMask-style): The bot can set allowances for you.
- Gnosis Safe: Follow the on-screen instructions to approve in the Safe UI.
Run the bot without placing real orders:
-
In
.envset:MOCK_TRADING=trueENABLE_TRADING=true
-
Start the bot:
cargo run --release main run
-
Watch the logs: you’ll see which trades would have been placed. Let it run for a while to confirm behavior.
-
Stop with
Ctrl+Cwhen done testing.
-
In
.envset:MOCK_TRADING=falseENABLE_TRADING=true
-
Start the bot:
cargo run --release main run
-
The bot will:
- Monitor the whale’s trades in real time
- Size your orders (by your chosen strategy and limits)
- Place copy trades on Polymarket
- Log activity to CSV
-
Stop anytime with
Ctrl+C(it will finish current work then exit).
| Goal | Command |
|---|---|
| Check balance & status | cargo run --release setup system-status |
| Recent activity | cargo run --release wallet check-recent-activity |
| Positions | cargo run --release wallet check-positions-detailed |
| P&L / stats | cargo run --release wallet check-my-stats |
To change risk or strategy: edit .env (e.g. COPY_SIZE, MAX_ORDER_SIZE_USD, COPY_STRATEGY), then restart the bot.
- Wallet has USDC (and a little MATIC for gas) on Polygon
-
.envhas correctPRIVATE_KEY,FUNDER_ADDRESS,TARGET_WHALE_ADDRESS, and RPC key -
cargo run --release setup system-statuspasses - Token allowances set via
cargo run --release wallet check-allowance - Tested with
MOCK_TRADING=true - Using a dedicated wallet (not your main one)
Minimal path (after Rust is installed and repo cloned):
# 1. Configure (interactive wizard)
cargo run --release setup setup
# 2. Validate
cargo run --release setup system-status
# 3. Approve tokens
cargo run --release wallet check-allowance
# 4. Run bot (use MOCK_TRADING=true in .env first to test)
cargo run --release main run💡 Windows: Install Rust from rustup.rs, then use PowerShell or CMD for the commands above.
- Rust 1.70 or later
- Polygon network access (for Polygon mainnet trading)
- RPC provider API key (Alchemy or Chainstack recommended)
Windows:
- Download and run the installer from https://rustup.rs/
- Follow the installation wizard
- Restart your terminal/PowerShell
macOS/Linux:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/envrustc --version
cargo --versiongit clone <repository-url>
cd rustThe easiest way to configure the bot is using the interactive setup wizard:
cargo run --release setup setupThe wizard will guide you through:
- Target whale address - The trader you want to copy
- Wallet configuration - Your private key and funder address
- RPC provider - Alchemy API key
- Trading strategy - PERCENTAGE, FIXED, or ADAPTIVE
- Risk limits - Max/min order sizes, position caps, daily volume limits
- Multipliers - Single and tiered multipliers
The wizard automatically:
- ✅ Creates your
.envfile - ✅ Backs up existing
.envif present - ✅ Preserves important configuration sections
If you prefer manual setup, create a .env file from the example:
# Windows (PowerShell)
Copy-Item .env.example .env
# macOS/Linux
cp .env.example .envEdit .env and set the following required variables:
# Wallet Configuration
PRIVATE_KEY=your_private_key_here # 64 hex chars, no 0x prefix
FUNDER_ADDRESS=your_funder_address_here # 40 hex chars (Gnosis Safe or EOA)
# Trading Configuration
TARGET_WHALE_ADDRESS=target_whale_address # 40 hex chars, no 0x prefix
# RPC Provider (choose ONE)
ALCHEMY_API_KEY=your_alchemy_api_key # Recommended
# OR
CHAINSTACK_API_KEY=your_chainstack_api_key # Alternative
# Trading Strategy
COPY_STRATEGY=PERCENTAGE # PERCENTAGE, FIXED, or ADAPTIVE
COPY_SIZE=10.0 # % for PERCENTAGE, $ for FIXED, base % for ADAPTIVE
TRADE_MULTIPLIER=1.0 # Single multiplier (1.0 = normal)
# Risk Limits
MAX_ORDER_SIZE_USD=100.0 # Maximum order size
MIN_ORDER_SIZE_USD=1.0 # Minimum order size
# MAX_POSITION_SIZE_USD=500.0 # Optional: Max position per market
# MAX_DAILY_VOLUME_USD=1000.0 # Optional: Max daily volume
# Trading Flags
ENABLE_TRADING=true # Enable trading (false = no trades)
MOCK_TRADING=false # Mock mode (true = test mode, no real trades)
⚠️ Important for Gnosis Safe:
PRIVATE_KEY= Private key that can sign on behalf of your Gnosis SafeFUNDER_ADDRESS= Your Gnosis Safe address (proxy wallet)- These addresses will be different!
For regular EOA wallets:
PRIVATE_KEY= Your wallet's private keyFUNDER_ADDRESS= Same address as the private key
The bot supports three trading strategies:
- Copies a fixed percentage of the trader's order size
- Example:
COPY_SIZE=10.0= 10% of trader's order - Best for: Consistent risk exposure relative to trader
- Always uses a fixed dollar amount per trade
- Example:
COPY_SIZE=50.0= $50 per trade - Best for: Fixed risk per trade, budget-conscious trading
- Dynamically adjusts percentage based on trade size
- Higher % for small trades, lower % for large trades
- Requires:
ADAPTIVE_MIN_PERCENT,ADAPTIVE_MAX_PERCENT,ADAPTIVE_THRESHOLD_USD - Best for: Balancing risk across different trade sizes
- Tiered multipliers
- Adaptive strategy parameters
- Risk management (circuit breakers)
- Advanced features
Before running, validate your configuration:
cargo run --release setup system-statusThis checks:
- ✅ Configuration format
- ✅ Wallet balance
- ✅ Network connectivity
- ✅ Token approvals
- ✅ Trading strategy settings
- ✅ Risk limits
1. Approve Tokens for Trading:
cargo run --release wallet check-allowance- For Gnosis Safe wallets, this will show manual approval instructions. Follow them to approve tokens through the Safe interface.
- For EOA wallets, this will auto-approve tokens.
2. Test in Mock Mode (Recommended):
Set MOCK_TRADING=true in .env, then:
cargo run --release main runThe bot will show what trades it would make without executing them.
3. Start Live Trading:
Set ENABLE_TRADING=true and MOCK_TRADING=false in .env, then:
cargo run --release main runUsing the unified CLI (recommended):
cargo run --release <group> <command>Using individual binaries:
cargo run --release --bin pm_bot # Start bot
cargo run --release --bin validate_setup
cargo run --release --bin approve_tokensHelper scripts:
# Linux/macOS
./run.sh
# Windows
run.batPress Ctrl+C for graceful shutdown. The bot will finish current operations before exiting.
The bot uses a unified CLI structure. Get help at any level:
cargo run --release -- --help # Main help (all commands)
cargo run --release -- setup --help # Setup commands help
cargo run --release -- wallet --help # Wallet commands helpNote: Use
--to separate Cargo arguments from binary arguments. The--helpflag should come after the command group.
cargo run --release setup setup # Interactive setup wizard (creates .env file)
cargo run --release setup system-status # Validate config, check balances, connectivity, show strategy
cargo run --release setup help # Print all available commandsSetup Wizard Features:
- ✅ Guides you through all configuration steps
- ✅ Validates inputs (addresses, keys, etc.)
- ✅ Backs up existing
.envfile automatically - ✅ Shows current strategy and risk limits in system-status
cargo run --release main run # Start the copy trading botcargo run --release wallet check-proxy-wallet # Check Gnosis Safe balance/positions
cargo run --release wallet check-both-wallets <a1> <a2> # Compare two wallets
cargo run --release wallet check-my-stats # View wallet statistics
cargo run --release wallet check-recent-activity # View recent trades
cargo run --release wallet check-positions-detailed # View detailed positions
cargo run --release wallet check-pnl-discrepancy # Analyze P&L discrepancies
cargo run --release wallet verify-allowance # Verify token allowance
cargo run --release wallet check-allowance # Check and set allowance
cargo run --release wallet set-token-allowance # Set ERC1155 allowance
cargo run --release wallet find-my-eoa # Find EOA wallet
cargo run --release wallet find-gnosis-safe-proxy # Find Gnosis Safe proxycargo run --release position manual-sell <market> <outcome> <amount> # Manual sell
cargo run --release position sell-large # Sell large positions
cargo run --release position close-stale # Close old positions
cargo run --release position close-resolved # Close resolved positions
cargo run --release position redeem-resolved # Redeem resolved positionscargo run --release research find-best-traders # Find top performers
cargo run --release research find-low-risk-traders # Find low-risk traders
cargo run --release research scan-best-traders # Scan top traders
cargo run --release research scan-from-markets # Scan from marketscargo run --release simulation simulate-profitability [trader] # Simulate profitability
cargo run --release simulation simulate-profitability-old [trader] # Legacy simulation
cargo run --release simulation run [preset] # Run batch simulations
cargo run --release simulation compare [mode] # Compare results
cargo run --release simulation aggregate # Aggregate results
cargo run --release simulation audit # Audit algorithm
cargo run --release simulation fetch-historical [--force] [--days N] # Fetch historical dataGetting help:
cargo run --release -- --help # Show all commands
cargo run --release -- setup --help # Show setup commands
cargo run --release -- wallet --help # Show wallet commandsNote: Use
--to separate Cargo arguments from binary arguments. The--helpflag should come after the command group.
The bot monitors successful traders (whales) and automatically copies their trades with intelligent scaling and risk management.
Trading Flow:
- Monitors blockchain events for trades from target whale (real-time via WebSocket)
- Analyzes each trade (size, price, market conditions) using multi-layer risk checks
- Calculates position size (2% default) and price (whale price + buffer)
- Executes scaled copy trade with optimized order types (FAK/GTD)
- Retries failed orders with intelligent resubmission (up to 4-5 attempts)
- Protects with risk guards (circuit breakers) and safety features
- Logs everything to CSV files for analysis
- Three Trading Strategies: PERCENTAGE (default), FIXED, and ADAPTIVE
- Flexible Position Sizing: Configurable percentage or fixed dollar amounts
- Multipliers: Single multiplier for all trades, plus optional tiered multipliers
- Risk Limits: Max/min order size, max position size, max daily volume caps
- Tiered Execution: Different strategies for large (4000+), medium (2000-3999), and small (<2000) trades
- Multi-Layer Risk Management: 4 layers of safety checks prevent dangerous trades
- Intelligent Pricing: Price buffers optimize fill rates (higher for large trades, none for small)
- Sport-Specific Adjustments: Additional buffers for tennis and soccer markets
- Price Precision: Automatic rounding to 3 decimal places (0.001 tick size) for Polymarket compliance
- ✅ Real-time trade copying - WebSocket-based monitoring
- ✅ Three trading strategies - PERCENTAGE, FIXED, and ADAPTIVE
- ✅ Intelligent position sizing - Configurable percentage or fixed amounts
- ✅ Multipliers - Single and tiered multipliers for flexible scaling
- ✅ Risk limits - Max/min order size, position caps, daily volume limits
- ✅ Interactive setup wizard - Guided configuration with validation
- ✅ Circuit breakers - Multi-layer risk management
- ✅ Automatic order resubmission - Handles failures with intelligent retry logic
- ✅ Market cache system - Fast market data lookups
- ✅ CSV logging - Complete trade history
- ✅ Live market detection - Adjusts order types based on market status
- ✅ Gnosis Safe support - Full support for multi-sig wallets
- ✅ Price precision - Automatic rounding to Polymarket's 0.001 tick size
- ✅ Smart error handling - Stops retrying on insufficient balance/allowance errors
- ✅ Tiered execution - Different strategies based on trade size
- ✅ Order type optimization - FAK for immediate fills, GTD for limit orders
- ✅ Price buffers - Dynamic buffers based on trade size and market type
- ✅ Sport-specific buffers - Additional buffers for ATP and Ligue 1 markets
- ✅ Rate limit handling - Automatic retries with exponential backoff
- ✅ Cache refresh - Automatic background cache updates
- A Polymarket Account - Sign up at https://polymarket.com
- A Web3 Wallet - Supports both:
- Regular EOA wallets (MetaMask, etc.) - PRIVATE_KEY and FUNDER_ADDRESS should match
- Gnosis Safe wallets - PRIVATE_KEY (signer) and FUNDER_ADDRESS (Safe) will be different
- RPC Provider API Key - Free tier from:
- Alchemy (recommended)
- Chainstack (alternative)
- The Whale Address - The trader you want to copy (40-character hex address)
- Token Approvals - Must approve USDC and Conditional Tokens (see wallet commands)
- Some Coding Knowledge - Not required, but helpful for troubleshooting
- Sufficient Funds - The bot uses 2% of whale trade size by default (configurable)
- Minimum: 50-100 USDC recommended
- Gas fees: 0.01-0.1 MATIC recommended
- Gnosis Safe Setup - For enhanced security with multi-sig wallets
IMPORTANT:
- Never share your
PRIVATE_KEYwith anyone- Never commit your
.envfile to git (it's already in.gitignore)- Start with small amounts to test
- Use
MOCK_TRADING=truefirst to verify everything works- Use a separate wallet for bot trading (not your main wallet)
- Use Gnosis Safe for enhanced security (multi-sig wallets)
For EOA wallets:
- Store private key securely (password manager recommended)
- Use a dedicated wallet for bot trading
- Monitor wallet activity regularly
For Gnosis Safe:
- Private key should belong to an authorized signer
- Set appropriate threshold (2-of-3, 3-of-5, etc.)
- Monitor Safe activity through Safe interface
| Issue | What to do |
|---|---|
| "Insufficient balance" | Add USDC (and MATIC for gas) to your bot wallet on Polygon. |
| "Allowance" / approval errors | Run cargo run --release wallet check-allowance and complete approvals (Safe: use Safe UI). |
| No trades copying | Confirm TARGET_WHALE_ADDRESS is correct and the whale is active. Check ENABLE_TRADING=true and MOCK_TRADING=false for live trading. |
| Bot exits or connection errors | Check RPC key (Alchemy/Chainstack), network, and setup system-status. |
| Orders too big/small | Adjust COPY_SIZE, MAX_ORDER_SIZE_USD, MIN_ORDER_SIZE_USD in .env. |
| Wrong strategy | Set COPY_STRATEGY to PERCENTAGE, FIXED, or ADAPTIVE and set COPY_SIZE accordingly. |
For more: run cargo run --release -- --help and cargo run --release setup system-status to validate config and connectivity.