Automated trading bot for Polymarket with mempool monitoring and priority execution
Features β’ Quick Start β’ Architecture β’ Documentation β’ Contributing
| Platform | Link |
|---|---|
| π± Telegram | t.me/novustch |
| π² WhatsApp | wa.me/14105015750 |
| π¬ Discord | discordapp.com/users/985432160498491473 |
Feel free to reach out for implementation assistance or integration support.
- Overview
- Features
- Architecture
- Quick Start
- Configuration
- Requirements
- Scripts
- Documentation
- Contributing
- License
- Disclaimer
Polymarket Sniper Bot is a sophisticated automated trading system designed for the Polymarket prediction market platform. It monitors the Polygon mempool and Polymarket API for pending trades from target addresses, then executes orders with higher priority gas pricing to frontrun target transactions.
- Real-time Mempool Monitoring: Subscribes to pending transactions on Polygon network
- Hybrid Detection: Combines mempool monitoring with API polling for comprehensive trade detection
- Priority Execution: Configurable gas price multipliers for competitive frontrunning
- Intelligent Sizing: Proportional frontrun sizing based on target trade size
- Error Handling: Robust retry mechanisms and error recovery
- Balance Management: Automatic balance validation before trade execution
- π Mempool Monitoring: Real-time detection of pending transactions to Polymarket contracts
- π API Integration: Hybrid approach combining mempool and API monitoring for faster detection
- β‘ Priority Execution: Configurable gas price multipliers for frontrunning
- π° Smart Sizing: Proportional frontrun sizing (configurable multiplier)
- π‘οΈ Error Handling: Comprehensive error handling with retry logic
- π Trade Filtering: Minimum trade size thresholds to focus on profitable opportunities
- π Balance Validation: Automatic checks for sufficient USDC and POL balances
- π Structured Logging: Color-coded console logging with debug support
- π³ Docker Support: Containerized deployment with Docker and Docker Compose
- π§ CLI Tools: Utility commands for allowance management and manual operations
polymarket-sniper-bot/
βββ src/
β βββ app/ # Application entry point
β βββ cli/ # CLI commands and utilities
β βββ config/ # Configuration management
β βββ constants/ # Application constants
β βββ domain/ # Domain models and types
β βββ errors/ # Custom error classes
β βββ infrastructure/ # External service integrations
β βββ services/ # Core business logic
β βββ utils/ # Utility functions
βββ docs/ # Documentation
βββ docker-compose.yml # Docker Compose configuration
βββ Dockerfile # Docker image definition
βββ package.json # Project dependencies
βββββββββββββββββββ
β Mempool Monitorβ
β Service β
ββββββββββ¬βββββββββ
β
βββββββββββββββββββ
β β
βΌ βΌ
βββββββββββββββββββ ββββββββββββββββ
β Pending TX β β API Polling β
β Detection β β (Activity) β
ββββββββββ¬βββββββββ ββββββββ¬ββββββββ
β β
ββββββββββββ¬ββββββββ
β
βΌ
ββββββββββββββββββββ
β Trade Signal β
β Generation β
ββββββββββ¬ββββββββββ
β
βΌ
ββββββββββββββββββββ
β Trade Executor β
β Service β
ββββββββββ¬ββββββββββ
β
ββββββββββββββββ
β β
βΌ βΌ
ββββββββββββββββ ββββββββββββββββ
β Balance β β Order β
β Validation β β Execution β
ββββββββββββββββ ββββββββββββββββ
- MempoolMonitorService: Monitors Polygon mempool for pending transactions
- TradeExecutorService: Executes frontrun trades with priority gas pricing
- ClobClientFactory: Creates and configures Polymarket CLOB client instances
- Configuration: Centralized environment variable management
- Error Handling: Custom error classes for better error management
- Node.js 18+ and npm
- Polygon wallet with USDC balance
- POL/MATIC for gas fees
- RPC endpoint supporting pending transaction monitoring
# Clone the repository
git clone https://github.com/your-org/polymarket-sniper-bot.git
cd polymarket-sniper-bot
# Install dependencies
npm install
# Build the project
npm run buildCreate a .env file in the project root:
# Required
TARGET_ADDRESSES=0xabc...,0xdef... # Target addresses to frontrun (comma-separated)
PUBLIC_KEY=your_bot_wallet # Public address of your bot wallet
PRIVATE_KEY=your_bot_wallet_privatekey # Private key of above address
RPC_URL=https://polygon-mainnet... # Polygon RPC endpoint
# Optional
FETCH_INTERVAL=1 # Polling interval (seconds)
MIN_TRADE_SIZE_USD=100 # Minimum trade size to frontrun (USD)
FRONTRUN_SIZE_MULTIPLIER=0.5 # Frontrun size as % of target (0.0-1.0)
GAS_PRICE_MULTIPLIER=1.2 # Gas price multiplier for priority
USDC_CONTRACT_ADDRESS=0x2791... # USDC contract (default: Polygon mainnet)# Development mode
npm run dev
# Production mode
npm run build && npm start# Using Docker Compose
docker-compose up -d
# Or using Docker directly
docker build -t polymarket-sniper-bot .
docker run --env-file .env polymarket-sniper-bot| Variable | Description | Example |
|---|---|---|
TARGET_ADDRESSES |
Comma-separated target addresses to frontrun | 0xabc...,0xdef... |
PUBLIC_KEY |
Your Polygon wallet address | your_wallet_address |
PRIVATE_KEY |
Your wallet private key | your_private_key |
RPC_URL |
Polygon RPC endpoint (must support pending tx monitoring) | https://polygon-mainnet.infura.io/v3/YOUR_PROJECT_ID |
| Variable | Default | Description |
|---|---|---|
FETCH_INTERVAL |
1 |
Polling frequency in seconds |
MIN_TRADE_SIZE_USD |
100 |
Minimum trade size to frontrun (USD) |
FRONTRUN_SIZE_MULTIPLIER |
0.5 |
Frontrun size as % of target (0.0-1.0) |
GAS_PRICE_MULTIPLIER |
1.2 |
Gas price multiplier for priority (e.g., 1.2 = 20% higher) |
RETRY_LIMIT |
3 |
Maximum retry attempts for failed orders |
USDC_CONTRACT_ADDRESS |
0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 |
USDC contract on Polygon |
To identify successful traders to track:
- Polymarket Leaderboard: https://polymarket.com/leaderboard
- Predictfolio: https://predictfolio.com/ - Analytics platform for prediction market traders
- Node.js: 18 or higher
- Polygon Wallet: With USDC balance for trading
- POL/MATIC: For gas fees (recommended: 0.2-1.0 POL)
- RPC Endpoint: Must support pending transaction monitoring (Infura, Alchemy, QuickNode)
| Command | Description |
|---|---|
npm run dev |
Development mode with TypeScript |
npm run build |
Compile TypeScript to JavaScript |
npm start |
Run compiled production build |
npm run lint |
Run ESLint |
npm run lint:fix |
Fix ESLint errors automatically |
npm run format |
Format code with Prettier |
npm run check-allowance |
Check token allowance |
npm run verify-allowance |
Verify token allowance |
npm run set-token-allowance |
Set token allowance |
npm run manual-sell |
Manual sell command |
npm run simulate |
Run trading simulations |
- Complete Guide: Detailed setup, configuration, and troubleshooting
- Architecture Overview: System design and component overview
- API Reference: (Coming soon) Detailed API documentation
Contributions are welcome! Please see our Contributing Guidelines for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow TypeScript best practices
- Use ESLint and Prettier for code formatting
- Write meaningful commit messages
- Add tests for new features
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
This software is provided as-is for educational and research purposes only.
- Trading involves substantial risk of loss
- Past performance does not guarantee future results
- Use at your own risk
- The authors and contributors are not responsible for any financial losses
- Always test thoroughly in a safe environment before using real funds
- Ensure compliance with local regulations and terms of service
Built with β€οΈ for the Polymarket community
β Star this repo if you find it helpful!