#!/bin/bash # Monitor Bot Wallet and Auto-Setup Once Funded # Continuously checks wallet balance and automatically proceeds with setup set -e BOT_WALLET="0x40091653f652a259747D86d7Cbe3e2848082a051" ARBITRUM_RPC="https://arb-mainnet.g.alchemy.com/v2/d6VAHgzkOI3NgLGem6uBMiADT1E9rROB" MIN_BALANCE="0.001" CHECK_INTERVAL=10 # seconds between checks echo "═══════════════════════════════════════════════════════════" echo "🤖 MEV Bot Auto-Setup Monitor" echo "═══════════════════════════════════════════════════════════" echo "" echo "Monitoring wallet: $BOT_WALLET" echo "Network: Arbitrum One" echo "Minimum required: $MIN_BALANCE ETH" echo "Check interval: ${CHECK_INTERVAL}s" echo "" echo "📋 To fund the wallet, use one of these methods:" echo "" echo " **Method 1: MetaMask**" echo " • Open MetaMask on Arbitrum One network" echo " • Send 0.001 ETH to: $BOT_WALLET" echo "" echo " **Method 2: Cast (Command Line)**" echo " • Run: ./scripts/fund-bot-wallet.sh" echo " • Follow prompts to use your funded wallet" echo "" echo " **Method 3: Bridge**" echo " • Visit: https://bridge.arbitrum.io/" echo " • Bridge ETH from Ethereum to Arbitrum" echo " • Send to: $BOT_WALLET" echo "" echo "═══════════════════════════════════════════════════════════" echo "" echo "⏳ Monitoring for funds... (Press Ctrl+C to stop)" echo "" # Counter for checks CHECK_COUNT=0 while true; do CHECK_COUNT=$((CHECK_COUNT + 1)) # Get balance BALANCE_WEI=$(cast balance "$BOT_WALLET" --rpc-url "$ARBITRUM_RPC" 2>/dev/null || echo "0") BALANCE_ETH=$(cast --to-unit "$BALANCE_WEI" ether 2>/dev/null || echo "0") # Display status TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S') echo "[$TIMESTAMP] Check #$CHECK_COUNT: Balance = $BALANCE_ETH ETH" # Check if funded if (( $(echo "$BALANCE_ETH >= $MIN_BALANCE" | bc -l) )); then echo "" echo "═══════════════════════════════════════════════════════════" echo "🎉 FUNDING DETECTED!" echo "═══════════════════════════════════════════════════════════" echo "" echo "✅ Wallet Balance: $BALANCE_ETH ETH" echo "" echo "🔗 View on Arbiscan:" echo " https://arbiscan.io/address/$BOT_WALLET" echo "" # Calculate capacity TRADES=$(echo "$BALANCE_ETH / 0.0005" | bc) VALUE=$(echo "$BALANCE_ETH * 2000" | bc) echo "📊 Wallet Capacity:" echo " • Balance: $BALANCE_ETH ETH" echo " • Value: ~\$$VALUE USD (at \$2000/ETH)" echo " • Estimated trades: ~$TRADES transactions" echo "" echo "═══════════════════════════════════════════════════════════" echo "🚀 Proceeding with Automated Setup" echo "═══════════════════════════════════════════════════════════" echo "" # Step 1: Setup Keystore echo "📝 Step 1/3: Configuring encrypted keystore..." echo "" if ./scripts/setup-keystore.sh; then echo "" echo "✅ Keystore configured successfully!" else echo "" echo "❌ Keystore setup failed. Please run manually:" echo " ./scripts/setup-keystore.sh" exit 1 fi echo "" echo "─────────────────────────────────────────────────────────" echo "" # Step 2: Enable Execution Mode echo "📝 Step 2/3: Enabling execution mode..." echo "" if ./scripts/enable-execution-mode.sh; then echo "" echo "✅ Execution mode enabled!" else echo "" echo "❌ Execution mode setup failed. Please run manually:" echo " ./scripts/enable-execution-mode.sh" exit 1 fi echo "" echo "─────────────────────────────────────────────────────────" echo "" # Step 3: Restart Bot echo "📝 Step 3/3: Restarting bot in execution mode..." echo "" # Kill existing bot if pgrep -f mev-beta > /dev/null; then echo "🛑 Stopping existing bot..." pkill -f mev-beta sleep 2 fi # Start bot with production config echo "🚀 Starting bot with execution enabled..." cd /home/administrator/projects/mev-beta GO_ENV=production nohup ./bin/mev-beta start > logs/mev_bot_production.log 2>&1 & BOT_PID=$! echo "✅ Bot started with PID: $BOT_PID" # Wait a moment and verify it's running sleep 3 if ps -p $BOT_PID > /dev/null; then echo "✅ Bot is running successfully!" else echo "⚠️ Bot may have crashed on startup. Check logs:" echo " tail -50 logs/mev_bot_production.log" fi echo "" echo "═══════════════════════════════════════════════════════════" echo "🎉 SETUP COMPLETE - BOT IS LIVE!" echo "═══════════════════════════════════════════════════════════" echo "" echo "✅ Wallet: $BOT_WALLET" echo "✅ Balance: $BALANCE_ETH ETH" echo "✅ Keystore: keystore/production/executor_wallet.json" echo "✅ Execution: ENABLED" echo "✅ Bot Status: RUNNING (PID $BOT_PID)" echo "" echo "📊 Monitor Execution:" echo " • Live logs:" echo " tail -f logs/mev_bot.log | grep 'EXECUTION\\|Profit'" echo "" echo " • Watch opportunities:" echo " tail -f logs/mev_bot.log | grep 'Opportunity detected'" echo "" echo " • Check wallet balance:" echo " ./scripts/check-wallet-balance.sh" echo "" echo " • View on Arbiscan:" echo " https://arbiscan.io/address/$BOT_WALLET" echo "" echo " • Metrics dashboard:" echo " http://localhost:9090/metrics" echo "" echo "🛑 Emergency Stop:" echo " pkill -f mev-beta" echo "" echo "═══════════════════════════════════════════════════════════" echo "" # Tail logs to show activity echo "📺 Showing live logs (Press Ctrl+C to stop)..." echo "" tail -f logs/mev_bot.log exit 0 fi # Wait before next check sleep $CHECK_INTERVAL done