feat(testing): add Anvil fork local testing infrastructure
Complete local testing setup with Anvil fork of Arbitrum mainnet: Infrastructure: - Docker Compose orchestration (Anvil, MEV Bot, Prometheus, Grafana) - Anvil fork configuration with 1-second blocks - Multi-stage Dockerfile for optimized builds - Health checks and auto-restart policies Configuration: - Comprehensive .env.example with all parameters - Prometheus metrics collection setup - Grafana datasource provisioning - .gitignore to prevent committing secrets Testing Scripts: - setup-local-fork.sh: Initialize fork and fund test wallet - create-test-swap.sh: Generate test swaps for bot detection - Both scripts include validation and helpful output Integration Components: - pkg/sequencer/reader.go: WebSocket reader for pending transactions - Worker pool pattern (10 workers) - <50ms processing target - Front-running capability - Auto-reconnection with exponential backoff - pkg/pools/discovery.go: Pool discovery service - UniswapV2-style pools (SushiSwap, Camelot) - UniswapV3 pools (multiple fee tiers) - Factory contract queries - Liquidity filtering Documentation: - TESTING.md: Complete testing guide - Quick start instructions - Testing scenarios - Monitoring and debugging - Performance benchmarks - Troubleshooting guide This enables safe local testing without deploying to public testnet, using real Arbitrum mainnet state forked locally with Anvil. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
147
.env.example
Normal file
147
.env.example
Normal file
@@ -0,0 +1,147 @@
|
||||
# MEV Bot V2 Configuration
|
||||
# Copy this file to .env and fill in your values
|
||||
|
||||
# ============================================================================
|
||||
# NETWORK CONFIGURATION
|
||||
# ============================================================================
|
||||
|
||||
# Arbitrum RPC URL (for forking with Anvil)
|
||||
ARBITRUM_RPC_URL=https://arb1.arbitrum.io/rpc
|
||||
|
||||
# Block number to fork from (optional, defaults to latest)
|
||||
# FORK_BLOCK_NUMBER=latest
|
||||
|
||||
# Local Anvil URLs (used by bot when running in docker-compose)
|
||||
# RPC_URL=http://anvil:8545
|
||||
# WS_URL=ws://anvil:8546
|
||||
# SEQUENCER_WS_URL=ws://anvil:8546
|
||||
|
||||
# Production Arbitrum URLs (when not using Anvil)
|
||||
# RPC_URL=https://arb1.arbitrum.io/rpc
|
||||
# WS_URL=wss://arb1.arbitrum.io/ws
|
||||
# SEQUENCER_WS_URL=wss://arb1.arbitrum.io/ws
|
||||
|
||||
# Private RPC endpoint (optional, for faster execution)
|
||||
# PRIVATE_RPC_URL=
|
||||
# USE_PRIVATE_RPC=false
|
||||
|
||||
# ============================================================================
|
||||
# WALLET CONFIGURATION
|
||||
# ============================================================================
|
||||
|
||||
# Private key for the wallet that will execute trades
|
||||
# IMPORTANT: Never commit this file with real keys!
|
||||
# Use a dedicated wallet for testing with test funds only
|
||||
PRIVATE_KEY=0000000000000000000000000000000000000000000000000000000000000000
|
||||
|
||||
# ============================================================================
|
||||
# SMART CONTRACT ADDRESSES
|
||||
# ============================================================================
|
||||
|
||||
# Flashloan executor contract (deployed on Arbitrum)
|
||||
# Leave as zero address if not deployed yet
|
||||
EXECUTOR_CONTRACT=0x0000000000000000000000000000000000000000
|
||||
|
||||
# ============================================================================
|
||||
# TRADING PARAMETERS
|
||||
# ============================================================================
|
||||
|
||||
# Minimum profit threshold (in wei, 0.01 ETH = 10000000000000000)
|
||||
MIN_PROFIT=10000000000000000
|
||||
|
||||
# Minimum ROI percentage (1% = 0.01)
|
||||
MIN_ROI=0.01
|
||||
|
||||
# Maximum slippage in basis points (200 = 2%)
|
||||
MAX_SLIPPAGE_BPS=200
|
||||
|
||||
# Minimum swap amount (in wei, 0.001 ETH = 1000000000000000)
|
||||
MIN_SWAP_AMOUNT=1000000000000000
|
||||
|
||||
# Minimum pool liquidity (in wei, 1 ETH = 1000000000000000000)
|
||||
MIN_POOL_LIQUIDITY=1000000000000000000
|
||||
|
||||
# ============================================================================
|
||||
# RISK MANAGEMENT
|
||||
# ============================================================================
|
||||
|
||||
# Maximum position size per trade (in wei, 10 ETH = 10000000000000000000)
|
||||
MAX_POSITION_SIZE=10000000000000000000
|
||||
|
||||
# Maximum daily volume (in wei, 100 ETH = 100000000000000000000)
|
||||
MAX_DAILY_VOLUME=100000000000000000000
|
||||
|
||||
# Maximum gas limit per transaction
|
||||
MAX_GAS_LIMIT=3000000
|
||||
|
||||
# Gas price strategy (fast, normal, slow)
|
||||
GAS_PRICE_STRATEGY=fast
|
||||
|
||||
# ============================================================================
|
||||
# ARBITRAGE DETECTION
|
||||
# ============================================================================
|
||||
|
||||
# Maximum hops in arbitrage path
|
||||
MAX_HOPS=3
|
||||
|
||||
# Maximum paths to explore per token
|
||||
MAX_PATHS=100
|
||||
|
||||
# Maximum concurrent detection operations
|
||||
MAX_CONCURRENT_DETECTION=10
|
||||
|
||||
# ============================================================================
|
||||
# EXECUTION SETTINGS
|
||||
# ============================================================================
|
||||
|
||||
# Enable transaction simulation before execution
|
||||
ENABLE_SIMULATION=true
|
||||
|
||||
# Enable front-running of detected opportunities
|
||||
ENABLE_FRONT_RUNNING=true
|
||||
|
||||
# Number of confirmations to wait
|
||||
CONFIRMATION_BLOCKS=1
|
||||
|
||||
# Transaction timeout (in seconds)
|
||||
TX_TIMEOUT=300
|
||||
|
||||
# Maximum retries for failed transactions
|
||||
MAX_RETRIES=3
|
||||
|
||||
# ============================================================================
|
||||
# POOL DISCOVERY
|
||||
# ============================================================================
|
||||
|
||||
# Maximum number of pools to discover
|
||||
MAX_POOLS_TO_DISCOVER=1000
|
||||
|
||||
# ============================================================================
|
||||
# PERFORMANCE TUNING
|
||||
# ============================================================================
|
||||
|
||||
# Number of worker threads for transaction processing
|
||||
WORKER_COUNT=10
|
||||
|
||||
# Transaction buffer size
|
||||
BUFFER_SIZE=1000
|
||||
|
||||
# ============================================================================
|
||||
# MONITORING
|
||||
# ============================================================================
|
||||
|
||||
# Metrics server port
|
||||
METRICS_PORT=9090
|
||||
|
||||
# Log level (debug, info, warn, error)
|
||||
LOG_LEVEL=info
|
||||
|
||||
# ============================================================================
|
||||
# TESTING CONFIGURATION
|
||||
# ============================================================================
|
||||
|
||||
# Enable dry-run mode (log opportunities but don't execute)
|
||||
# DRY_RUN=false
|
||||
|
||||
# Enable test mode with reduced thresholds
|
||||
# TEST_MODE=false
|
||||
Reference in New Issue
Block a user