#!/bin/bash # MEV Bot Profit Monitoring Script # Tracks bot performance and profitability CONTRACT_ADDRESS=$(cat .contract-address 2>/dev/null || echo "") RPC_URL="${ARBITRUM_RPC_URL:-https://arb1.arbitrum.io/rpc}" if [ -z "$CONTRACT_ADDRESS" ]; then echo "❌ Contract not deployed yet. Run ./scripts/deploy-contract.sh first" exit 1 fi echo "📊 MEV Flash Loan Bot - Profit Monitor" echo "======================================" echo "" echo "Contract: $CONTRACT_ADDRESS" echo "Network: Arbitrum (Chain ID 42161)" echo "" # Get contract owner OWNER=$(cast call "$CONTRACT_ADDRESS" "owner()(address)" --rpc-url "$RPC_URL") echo "👤 Owner: $OWNER" # Get ETH balance BALANCE=$(cast balance "$OWNER" --rpc-url "$RPC_URL" --ether) echo "💰 ETH Balance: $BALANCE ETH" echo "" # Check recent transactions echo "📈 Recent Activity:" echo " View on Arbiscan: https://arbiscan.io/address/$CONTRACT_ADDRESS" echo "" # Monitor in real-time echo "🔄 Monitoring for new profits (press Ctrl+C to stop)..." echo "" # Watch for ArbitrageExecuted events cast logs \ --address "$CONTRACT_ADDRESS" \ --from-block latest \ --follow \ --rpc-url "$RPC_URL" \ "ArbitrageExecuted(address indexed asset, uint256 amount, uint256 profit, uint256 gasUsed)" \ 2>/dev/null | while read -r line; do echo "✅ PROFIT! $line" echo " $(date)" done # If cast logs not available, fall back to polling echo "Polling for events every 5 seconds..." LAST_BLOCK=$(cast block-number --rpc-url "$RPC_URL") while true; do sleep 5 CURRENT_BLOCK=$(cast block-number --rpc-url "$RPC_URL") if [ "$CURRENT_BLOCK" -gt "$LAST_BLOCK" ]; then # Check for new profits BALANCE_NEW=$(cast balance "$OWNER" --rpc-url "$RPC_URL" --ether) if [ "$BALANCE_NEW" != "$BALANCE" ]; then DIFF=$(echo "$BALANCE_NEW - $BALANCE" | bc) echo "💰 Balance changed: $BALANCE ETH -> $BALANCE_NEW ETH (Δ $DIFF ETH)" BALANCE=$BALANCE_NEW fi LAST_BLOCK=$CURRENT_BLOCK fi done