Files
mev-beta/scripts/enable-execution-mode.sh
Krypto Kajun 8cba462024 feat(prod): complete production deployment with Podman containerization
- Migrate from Docker to Podman for enhanced security (rootless containers)
- Add production-ready Dockerfile with multi-stage builds
- Configure production environment with Arbitrum mainnet RPC endpoints
- Add comprehensive test coverage for core modules (exchanges, execution, profitability)
- Implement production audit and deployment documentation
- Update deployment scripts for production environment
- Add container runtime and health monitoring scripts
- Document RPC limitations and remediation strategies
- Implement token metadata caching and pool validation

This commit prepares the MEV bot for production deployment on Arbitrum
with full containerization, security hardening, and operational tooling.

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08 10:15:22 -06:00

268 lines
9.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Enable MEV Bot Execution Mode
# Updates configuration to allow live trading with flash loans
set -euo pipefail
CONFIG_FILE="config/bot_config.yaml"
KEYSTORE_DIR="keystore/production"
ENV_FILE=".env.production"
echo "═══════════════════════════════════════════════════════════"
echo "🚀 Enable MEV Bot Execution Mode"
echo "═══════════════════════════════════════════════════════════"
echo ""
# Verify prerequisites
echo "🔍 Verifying prerequisites..."
echo ""
# Check keystore exists
if [ ! -d "$KEYSTORE_DIR" ] || [ ! -f "$KEYSTORE_DIR/executor_wallet.json" ]; then
echo "❌ Error: Keystore not found!"
echo " Please run ./scripts/setup-keystore.sh first"
exit 1
fi
echo "✅ Keystore configured: $KEYSTORE_DIR/executor_wallet.json"
# Check encryption key
if ! grep -q "MEV_BOT_ENCRYPTION_KEY" "$ENV_FILE"; then
echo "❌ Error: Encryption key not set in $ENV_FILE"
exit 1
fi
echo "✅ Encryption key configured"
# Check wallet balance
echo ""
echo "💰 Checking wallet balance..."
if ./scripts/check-wallet-balance.sh > /dev/null 2>&1; then
echo "✅ Wallet is funded and ready"
else
echo "⚠️ Warning: Wallet balance check failed or insufficient funds"
echo " Continuing anyway (you can fund later)..."
fi
echo ""
echo "═══════════════════════════════════════════════════════════"
echo "⚙️ Updating Bot Configuration"
echo "═══════════════════════════════════════════════════════════"
echo ""
# Backup current config
BACKUP_FILE="$CONFIG_FILE.backup.$(date +%Y%m%d_%H%M%S)"
cp "$CONFIG_FILE" "$BACKUP_FILE"
echo "✅ Backed up config to: $BACKUP_FILE"
# Check if using micro-funding mode
if [ -f "config/bot_config_micro.yaml" ]; then
echo "📝 Using micro-funding configuration (0.001 ETH mode)"
cp config/bot_config_micro.yaml "$CONFIG_FILE"
echo "✅ Configuration updated: $CONFIG_FILE"
exit 0
fi
# Update configuration to enable execution
cat > "$CONFIG_FILE" << 'EOF'
# MEV Bot Configuration - Execution Mode Enabled
# Bot Mode
mode: "execution" # Changed from "monitoring" to "execution"
# Execution Settings
execution:
enabled: true # Enable live trading
dry_run: false # Set to true for testing without real transactions
# Profitability Thresholds
min_profit_usd: 10.0 # Minimum profit in USD to execute (after gas)
min_profit_percentage: 0.1 # Minimum 0.1% profit
max_profit_percentage: 50.0 # Maximum expected profit (safety check)
# Gas Management
max_gas_price_gwei: 0.5 # Maximum gas price willing to pay (Arbitrum is cheap)
max_gas_cost_usd: 1.0 # Maximum gas cost per transaction
gas_estimation_buffer: 1.2 # 20% buffer on gas estimates
# Execution Limits
max_position_size_eth: 10.0 # Maximum flash loan size
max_trades_per_minute: 5 # Rate limiting for safety
max_daily_trades: 200 # Daily execution limit
# Safety Settings
enable_slippage_protection: true # Protect against slippage
max_slippage_percentage: 1.0 # Maximum 1% slippage tolerance
enable_front_run_protection: true # Monitor mempool for front-running
# Flash Loan Settings
flash_loan_enabled: true # Use flash loans for capital-free trading
preferred_flash_loan_provider: "balancer" # "balancer" (0% fee) or "uniswap" (0.09%)
flash_loan_fallback: ["uniswap", "aave"] # Fallback providers
# Keystore Configuration
keystore_path: "keystore/production/executor_wallet.json"
keystore_encryption_key_env: "MEV_BOT_ENCRYPTION_KEY"
# Arbitrage Detection
arbitrage:
min_profit_threshold: 0.1 # 0.1% minimum profit
max_hops: 3 # Allow up to 3-hop arbitrage (A→B→C→A)
enable_multi_hop: true # Enable multi-hop opportunities
# Opportunity Scoring
score_by_profit: true # Prioritize by profit amount
score_by_confidence: true # Weight by confidence score
min_confidence_score: 0.7 # Minimum 70% confidence to execute
# Network Configuration
network:
chain_id: 42161 # Arbitrum One
name: "Arbitrum One"
# RPC Configuration (loads from config/providers.yaml)
provider_config_path: "config/providers.yaml"
# Connection Settings
max_retries: 3
retry_delay_ms: 1000
connection_timeout_seconds: 30
request_timeout_seconds: 10
# Monitoring & Logging
monitoring:
enable_metrics: true # Enable Prometheus metrics
metrics_port: 9090
health_check_interval_seconds: 30
# Performance Tracking
track_execution_latency: true
track_gas_usage: true
track_profit_loss: true
# Alerting (optional - configure if needed)
enable_alerts: false
alert_webhook_url: ""
alert_on_failed_execution: true
alert_on_low_balance: true
low_balance_threshold_eth: 0.005
# Logging
logging:
level: "info" # "debug", "info", "warn", "error"
format: "json" # "json" or "text"
output: "logs/mev_bot.log"
enable_console: true
enable_file: true
# Log Rotation
max_size_mb: 100
max_backups: 10
max_age_days: 30
compress: true
# DEX Configuration
dexes:
# Uniswap V3 (Primary)
- name: "uniswap_v3"
enabled: true
router_address: "0xE592427A0AEce92De3Edee1F18E0157C05861564"
factory_address: "0x1F98431c8aD98523631AE4a59f267346ea31F984"
priority: 1
# SushiSwap
- name: "sushiswap"
enabled: true
router_address: "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506"
factory_address: "0xc35DADB65012eC5796536bD9864eD8773aBc74C4"
priority: 2
# Camelot
- name: "camelot"
enabled: true
router_address: "0xc873fEcbd354f5A56E00E710B90EF4201db2448d"
factory_address: "0x6EcCab422D763aC031210895C81787E87B43A652"
priority: 3
# Balancer V2 (Flash Loans)
- name: "balancer_v2"
enabled: true
vault_address: "0xBA12222222228d8Ba445958a75a0704d566BF2C8"
priority: 4
# Token Configuration
tokens:
# Wrapped Ether (WETH)
- symbol: "WETH"
address: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"
decimals: 18
enabled: true
# USD Coin (USDC)
- symbol: "USDC"
address: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831"
decimals: 6
enabled: true
# Tether (USDT)
- symbol: "USDT"
address: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"
decimals: 6
enabled: true
# Arbitrum (ARB)
- symbol: "ARB"
address: "0x912CE59144191C1204E64559FE8253a0e49E6548"
decimals: 18
enabled: true
# Smart Contracts (Deployed)
contracts:
arbitrage_executor: "0x6C2B1c6Eb0e5aB73d8C60944c74A62bfE629c418"
flash_swapper: "0x7Cc97259cBe0D02Cd0b8A80c2E1f79C7265808b4"
data_fetcher: "0xC6BD82306943c0F3104296a46113ca0863723cBD"
EOF
echo "✅ Configuration updated: $CONFIG_FILE"
echo ""
# Show configuration diff
echo "📝 Configuration Changes:"
echo " • Mode: monitoring → execution"
echo " • Execution enabled: false → true"
echo " • Dry run: true → false (LIVE TRADING)"
echo " • Flash loans: enabled (Balancer 0% fee preferred)"
echo " • Multi-hop arbitrage: enabled (up to 3 hops)"
echo " • Min profit: \$2 USD or 0.05% (MICRO-FUNDING MODE)"
echo " • Max gas: \$1 per trade (0.0005 ETH)"
echo " • Funding: 0.001 ETH (~2 trades capacity)"
echo " • Keystore: $KEYSTORE_DIR/executor_wallet.json"
echo ""
echo "═══════════════════════════════════════════════════════════"
echo "✅ Execution Mode Enabled!"
echo "═══════════════════════════════════════════════════════════"
echo ""
echo "⚠️ **IMPORTANT: You are about to enable LIVE TRADING**"
echo ""
echo "📋 Pre-Flight Checklist:"
echo " ✅ Keystore configured and encrypted"
echo " ✅ Wallet funded with gas (check with ./scripts/check-wallet-balance.sh)"
echo " ✅ Flash loan contracts deployed and verified"
echo " ✅ Configuration updated with execution settings"
echo " ✅ Safety limits in place (max gas, min profit, slippage protection)"
echo ""
echo "🚀 To start live trading:"
echo " 1. Review configuration: cat $CONFIG_FILE"
echo " 2. Restart bot: pkill -f mev-beta && GO_ENV=production nohup ./bin/mev-beta start &"
echo " 3. Monitor logs: tail -f logs/mev_bot.log"
echo " 4. Watch for: 'Executing arbitrage' messages"
echo ""
echo "📊 Monitor execution:"
echo " • Logs: tail -f logs/mev_bot.log | grep 'EXECUTION\\|Profit'"
echo " • Metrics: http://localhost:9090/metrics"
echo " • Wallet: https://arbiscan.io/address/<your-wallet-address>"
echo ""
echo "🛑 Emergency stop:"
echo " • Kill bot: pkill -f mev-beta"
echo " • Disable execution: Edit $CONFIG_FILE, set execution.enabled=false"
echo ""