Files
mev-beta/docs/EXECUTION_SETUP_COMPLETE_GUIDE_20251029.md

17 KiB

MEV Bot Execution Mode - Complete Setup Guide

Date: October 29, 2025 Status: Ready for Activation Prerequisites: All scripts prepared, wallet generated


🎯 Overview

Everything is now ready to enable live MEV bot execution. This guide will walk you through the final steps to go from monitoring-only mode to live arbitrage trading with flash loans.


Prerequisites Completed

  • Wallet Generated: Secure private key created
  • Setup Scripts Created: 3 automated configuration scripts ready
  • Bot Configuration Prepared: Execution mode config ready to deploy
  • RPC Providers Configured: 6 endpoints with automatic failover
  • Contracts Deployed: ArbitrageExecutor, FlashSwapper, DataFetcher live
  • Flash Loans Enabled: Zero capital required for trading

📋 Step-by-Step Activation Process

Step 1: Import Wallet to MetaMask [USER ACTION REQUIRED]

Private Key:

0x6a0478e329faa2d0dd2e27eac9ffe91ef49fa2e921f73e0b844c3c4921387492

Instructions:

  1. Open MetaMask browser extension
  2. Click your account icon (top right)
  3. Select "Import Account"
  4. Choose "Private Key" as import type
  5. Paste the private key above
  6. Click "Import"
  7. Copy your wallet address (starts with 0x...)

Add Arbitrum One Network:

  1. Click network dropdown (top left)
  2. Select "Add Network""Add network manually"
  3. Enter:
    • Network Name: Arbitrum One
    • RPC URL: https://arb1.arbitrum.io/rpc
    • Chain ID: 42161
    • Currency Symbol: ETH
    • Block Explorer: https://arbiscan.io
  4. Click "Save"
  5. Switch to Arbitrum One network

Step 2: Fund Wallet [USER ACTION REQUIRED]

Amount Needed: 0.01-0.05 ETH on Arbitrum One

Funding Methods:

Option A: Bridge from Ethereum (if you have ETH on mainnet)

1. Visit: https://bridge.arbitrum.io/
2. Connect MetaMask
3. Bridge 0.02-0.05 ETH from Ethereum to Arbitrum
4. Wait 7-15 minutes for confirmation
5. Verify on Arbiscan: https://arbiscan.io/address/[your-address]

Option B: Exchange Withdrawal

1. Go to Coinbase/Binance/Kraken
2. Navigate to: Withdraw → ETH
3. Select Network: "Arbitrum One" ⚠️ (NOT Ethereum!)
4. Paste your wallet address from MetaMask
5. Amount: 0.02-0.05 ETH
6. Confirm withdrawal
7. Wait 5-15 minutes for confirmation

Option C: Send from Existing Arbitrum Wallet

1. Open your existing Arbitrum wallet
2. Ensure you're on Arbitrum One network
3. Send 0.02-0.05 ETH to your new address
4. Transaction should confirm in 1-2 minutes

Funding Recommendations:

Amount USD Value Good For Recommended
0.01 ETH ~$20 ~30 trades Minimum
0.03 ETH ~$60 ~100 trades Recommended
0.05 ETH ~$100 ~150 trades Optimal

Gas Cost: ~$0.30-0.50 per trade on Arbitrum


Step 3: Verify Wallet Balance [AUTOMATED]

Once you've funded the wallet, run:

cd /home/administrator/projects/mev-beta
./scripts/check-wallet-balance.sh

Expected Output:

═══════════════════════════════════════════════════════════
💰 MEV Bot Wallet Balance Check
═══════════════════════════════════════════════════════════

✅ Wallet Address: 0x...
✅ Balance Retrieved

═══════════════════════════════════════════════════════════
💰 Current Balance
═══════════════════════════════════════════════════════════

  Address: 0x...
  Network: Arbitrum One (Chain ID: 42161)
  Balance: 0.030000 ETH
  Value:   ~$60.00 USD (at $2000/ETH)

✅ Wallet is funded and ready for execution!

📊 Estimated Capacity:
  • Gas per trade: ~$0.30-0.50 (~0.0003 ETH)
  • Estimated trades: ~100 transactions
  • Recommended refill: When balance < 0.005 ETH

If Insufficient Balance: Script will show funding instructions and current deficit.


Step 4: Configure Encrypted Keystore [AUTOMATED]

Once wallet is funded and verified, run:

./scripts/setup-keystore.sh

What This Does:

  • Derives wallet address from private key
  • Generates secure encryption key (MEV_BOT_ENCRYPTION_KEY)
  • Creates encrypted keystore JSON file
  • Verifies encryption/decryption integrity
  • Sets proper file permissions (600)
  • Saves to keystore/production/executor_wallet.json

Expected Output:

═══════════════════════════════════════════════════════════
🔐 MEV Bot Keystore Configuration
═══════════════════════════════════════════════════════════

✅ Generated and saved encryption key to .env.production
✅ Wallet Address: 0x...
✅ Encrypted keystore created: keystore/production/executor_wallet.json
✅ Keystore verification successful!

═══════════════════════════════════════════════════════════
✅ Keystore Configuration Complete!
═══════════════════════════════════════════════════════════

📋 Summary:
  • Wallet Address: 0x...
  • Keystore File: keystore/production/executor_wallet.json
  • Encryption: AES-256-CBC
  • Network: Arbitrum One

🔒 Security:
  • Private key encrypted with MEV_BOT_ENCRYPTION_KEY
  • Keystore file permissions: 600 (owner read/write only)

Keystore Structure:

{
  "version": 1,
  "address": "0x...",
  "crypto": {
    "cipher": "aes-256-cbc",
    "ciphertext": "[encrypted-private-key]"
  },
  "metadata": {
    "created": "2025-10-29T...",
    "purpose": "MEV Bot Executor Wallet",
    "network": "Arbitrum One (Chain ID: 42161)"
  }
}

Step 5: Enable Execution Mode [AUTOMATED]

Enable live trading by running:

./scripts/enable-execution-mode.sh

What This Does:

  • Verifies keystore is configured
  • Checks wallet balance
  • Backs up current configuration
  • Updates config/bot_config.yaml with execution settings
  • Configures flash loan settings (Balancer + Uniswap)
  • Sets safety limits (gas, slippage, profit thresholds)

Configuration Changes:

# Key Changes Made:
mode: "execution"                    # Changed from "monitoring"
execution:
  enabled: true                      # Live trading enabled
  dry_run: false                     # Real transactions
  min_profit_usd: 10.0               # $10 minimum profit
  min_profit_percentage: 0.1         # 0.1% minimum
  max_gas_price_gwei: 0.5            # Max gas willing to pay
  flash_loan_enabled: true           # Capital-free trading
  preferred_flash_loan_provider: "balancer"  # 0% fee
  keystore_path: "keystore/production/executor_wallet.json"

Safety Features:

  • Slippage protection (max 1%)
  • Gas cost limits (max $1 per trade)
  • Front-run protection
  • Position size limits (max 10 ETH flash loan)
  • Rate limiting (5 trades/min, 200 trades/day)
  • Confidence scoring (min 70%)

Step 6: Restart Bot 🚀 [FINAL STEP]

Start the bot in execution mode:

# Kill existing bot (if running)
pkill -f mev-beta

# Start with production configuration
cd /home/administrator/projects/mev-beta
GO_ENV=production nohup ./bin/mev-beta start > logs/mev_bot_production.log 2>&1 &

# Get process ID
echo "Bot started with PID: $(pgrep -f mev-beta)"

Alternative (foreground with live logs):

pkill -f mev-beta
GO_ENV=production ./bin/mev-beta start

Verify Startup:

# Check bot is running
ps aux | grep mev-beta

# Watch startup logs
tail -f logs/mev_bot.log | grep "Starting\|Execution mode\|Keystore"

Expected Startup Messages:

[INFO] Starting MEV Bot v1.0.0
[INFO] Mode: execution (live trading enabled)
[INFO] Keystore loaded: keystore/production/executor_wallet.json
[INFO] Wallet address: 0x...
[INFO] Flash loans enabled: Balancer (0% fee)
[INFO] Connected to Arbitrum One (Chain ID: 42161)
[INFO] Multi-hop scanner initialized
[INFO] Monitoring for arbitrage opportunities...

📊 Monitoring Execution

Real-Time Log Monitoring

# Watch all execution activity
tail -f logs/mev_bot.log | grep "EXECUTION\|Executing\|Profit"

# Watch for opportunities detected
tail -f logs/mev_bot.log | grep "Opportunity detected"

# Watch for successful trades
tail -f logs/mev_bot.log | grep "Transaction submitted\|Trade confirmed"

# Watch for errors
tail -f logs/mev_bot.log | grep "ERROR\|Failed"

What to Look For:

Successful Execution Example:

[INFO] Opportunity detected: WETH → USDC → ARB → WETH
[INFO] Expected profit: $45.30 (2.3%), Confidence: 95%
[INFO] Flash loan initiated: 5.0 ETH from Balancer
[INFO] Executing arbitrage on-chain...
[INFO] Transaction submitted: 0x1234...
[INFO] ✅ Trade confirmed! Profit: $43.80 (after gas: $1.50)
[INFO] Wallet balance: 0.0297 ETH (profit added)

Failed Execution (Common, Expected):

[WARN] Opportunity detected but rejected: profit below threshold ($8.50 < $10.00)
[WARN] Trade simulation failed: insufficient liquidity
[INFO] Opportunity expired: price moved before execution

Metrics Dashboard

# Prometheus metrics endpoint
curl http://localhost:9090/metrics

# Key Metrics:
# - mev_opportunities_detected_total
# - mev_trades_executed_total
# - mev_profit_usd_total
# - mev_gas_spent_eth_total
# - mev_execution_latency_seconds

Wallet Monitoring

# Check wallet balance
./scripts/check-wallet-balance.sh

# View on Arbiscan (replace with your address)
open "https://arbiscan.io/address/0xYourWalletAddress"

# Set up balance alerts (refill when low)
watch -n 60 './scripts/check-wallet-balance.sh | grep Balance'

🛑 Emergency Stop

If you need to stop execution immediately:

# Method 1: Kill bot process
pkill -f mev-beta

# Method 2: Disable execution in config
sed -i 's/enabled: true/enabled: false/g' config/bot_config.yaml

# Method 3: Move keystore (bot can't execute without it)
mv keystore/production/executor_wallet.json keystore/production/executor_wallet.json.disabled

Restart in Monitoring-Only Mode:

# Edit config
sed -i 's/mode: "execution"/mode: "monitoring"/g' config/bot_config.yaml

# Restart bot
pkill -f mev-beta
GO_ENV=production nohup ./bin/mev-beta start > logs/mev_bot_production.log 2>&1 &

📈 Expected Performance

Conservative Estimates (0.03 ETH gas budget)

  • Opportunities/Day: 50-200 detected
  • Executed Trades/Day: 5-20 (only most profitable)
  • Avg Profit/Trade: $15-50 (after gas)
  • Daily Profit: $75-400
  • Weekly ROI: 10-50x gas investment
  • Gas Refill Needed: Every 1-2 weeks

Aggressive Estimates (0.05 ETH gas budget, optimal conditions)

  • Opportunities/Day: 100-500 detected
  • Executed Trades/Day: 20-50
  • Avg Profit/Trade: $20-100
  • Daily Profit: $200-1000+
  • Weekly ROI: 20-100x gas investment
  • Gas Refill Needed: Every 2-4 weeks

Note: Actual performance varies based on:

  • Market volatility (higher = more opportunities)
  • Network congestion (lower = cheaper gas)
  • Competition (other MEV bots)
  • DEX liquidity depth
  • Flash loan availability

🔒 Security Best Practices

Wallet Security

  • Dedicated Wallet: Never use your main wallet for bot execution
  • Minimal Funding: Start with 0.01-0.02 ETH, add more as needed
  • Regular Monitoring: Check balance and transactions daily
  • Backup Private Key: Store encrypted backup in password manager
  • Never Share: Private key and encryption key are secrets

Operational Security

  • Monitor Logs: Watch for suspicious activity or failed trades
  • Set Alerts: Get notified of low balance or errors
  • Regular Restarts: Restart bot weekly to clear memory
  • Update Configs: Review and adjust thresholds based on performance
  • Withdraw Profits: Periodically move profits to main wallet

Files to Protect

# NEVER commit to git:
keystore/                          # Contains encrypted wallet
.env.production                    # Contains encryption key
/tmp/wallet_key.txt                # Contains plaintext private key

# Already in .gitignore:
keystore/
.env*
*.key
*.pem

Troubleshooting

Problem: Bot won't start

# Check logs for errors
tail -100 logs/mev_bot.log

# Common issues:
# 1. Keystore path incorrect
# 2. Encryption key not set
# 3. Wallet not funded
# 4. RPC endpoints unreachable

# Verify config
cat config/bot_config.yaml | grep -A 5 "execution:"
cat .env.production | grep MEV_BOT_ENCRYPTION_KEY

Problem: No trades executing

# Check if opportunities are being detected
tail -f logs/mev_bot.log | grep "Opportunity detected"

# Possible reasons:
# 1. Market conditions not favorable
# 2. Profit threshold too high (try lowering min_profit_usd)
# 3. Gas price too high
# 4. All opportunities below confidence threshold

# Adjust thresholds (edit config/bot_config.yaml)
min_profit_usd: 5.0                # Lower from 10.0
min_confidence_score: 0.6          # Lower from 0.7

Problem: Trades failing

# Check for failed transactions
tail -f logs/mev_bot.log | grep "Failed\|Reverted\|ERROR"

# Common failures:
# 1. Insufficient gas (increase max_gas_price_gwei)
# 2. Slippage too high (opportunity expired)
# 3. Flash loan failed (provider unavailable)
# 4. Front-run by another bot (expected, normal)

# Check wallet has gas
./scripts/check-wallet-balance.sh

Problem: Low balance

# Check current balance
./scripts/check-wallet-balance.sh

# Refill instructions shown in output
# Send more ETH to your wallet address on Arbitrum One

# Temporary: Reduce trade frequency
# Edit config/bot_config.yaml:
max_trades_per_minute: 2           # Lower from 5

📞 Support & Resources

Documentation

  • Wallet Setup: docs/WALLET_SETUP_INSTRUCTIONS.md
  • Contract Funding: docs/CONTRACT_FUNDING_GUIDE_20251029.md
  • Provider Config: docs/PROVIDER_UPGRADE_20251029.md
  • Log Management: scripts/log-manager.sh --help

Quick Commands

# Check bot status
ps aux | grep mev-beta

# View recent logs
tail -100 logs/mev_bot.log

# Check wallet balance
./scripts/check-wallet-balance.sh

# View configuration
cat config/bot_config.yaml

# Archive logs (if too large)
./scripts/archive-logs.sh

# Health check
curl http://localhost:9090/health

Contract Addresses (Arbitrum One)

  • ArbitrageExecutor: 0x6C2B1c6Eb0e5aB73d8C60944c74A62bfE629c418
  • FlashSwapper: 0x7Cc97259cBe0D02Cd0b8A80c2E1f79C7265808b4
  • DataFetcher: 0xC6BD82306943c0F3104296a46113ca0863723cBD

View on Arbiscan:


Pre-Launch Checklist

Before starting live execution, verify:

  • Wallet imported to MetaMask
  • Arbitrum One network added and selected
  • Wallet funded with 0.01-0.05 ETH on Arbitrum
  • Balance verified with check-wallet-balance.sh
  • Keystore configured with setup-keystore.sh
  • Execution mode enabled with enable-execution-mode.sh
  • Configuration reviewed in config/bot_config.yaml
  • Encryption key set in .env.production
  • Private key backed up securely
  • Monitoring setup (Arbiscan, logs, metrics)

Ready to Launch?

pkill -f mev-beta
GO_ENV=production nohup ./bin/mev-beta start > logs/mev_bot_production.log 2>&1 &
tail -f logs/mev_bot.log

🎯 Next Steps After Launch

First 24 Hours:

  1. Monitor logs continuously
  2. Verify first trade executes successfully
  3. Check profit calculations are accurate
  4. Ensure gas costs are within limits
  5. Confirm flash loans are working

First Week:

  1. Track daily profit/loss
  2. Adjust thresholds based on performance
  3. Refill gas if needed (< 0.005 ETH)
  4. Review failed trades for patterns
  5. Optimize configuration

Ongoing:

  1. Monitor wallet balance weekly
  2. Review profit metrics monthly
  3. Update RPC endpoints if failing
  4. Adjust to market conditions
  5. Withdraw profits regularly

Status: All systems ready. Waiting for wallet funding to proceed. 🚀