Files
mev-beta/scripts/check-wallet-balance.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

154 lines
5.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Check wallet balance on Arbitrum One
# Verifies wallet is ready for MEV bot execution
set -euo pipefail
PRIVATE_KEY_FILE="/tmp/wallet_key.txt"
ALCHEMY_RPC="https://arb-mainnet.g.alchemy.com/v2/d6VAHgzkOI3NgLGem6uBMiADT1E9rROB"
MIN_BALANCE_ETH="0.001"
echo "═══════════════════════════════════════════════════════════"
echo "💰 MEV Bot Wallet Balance Check"
echo "═══════════════════════════════════════════════════════════"
echo ""
# Check if private key file exists
if [ ! -f "$PRIVATE_KEY_FILE" ]; then
echo "❌ Error: Private key file not found at $PRIVATE_KEY_FILE"
exit 1
fi
PRIVATE_KEY=$(cat "$PRIVATE_KEY_FILE")
# Derive wallet address
echo "🔍 Deriving wallet address..."
if command -v cast &> /dev/null; then
WALLET_ADDRESS=$(cast wallet address "$PRIVATE_KEY")
elif command -v python3 &> /dev/null; then
WALLET_ADDRESS=$(python3 << 'EOF'
try:
from eth_account import Account
import sys
with open('/tmp/wallet_key.txt', 'r') as f:
private_key = f.read().strip()
if private_key.startswith('0x'):
private_key = private_key[2:]
account = Account.from_key(bytes.fromhex(private_key))
print(account.address)
except Exception as e:
print(f"Error: {e}", file=sys.stderr)
sys.exit(1)
EOF
)
else
echo "❌ Error: Neither cast nor python3 available"
echo " Please install Foundry or Python with eth_account"
exit 1
fi
echo "✅ Wallet Address: $WALLET_ADDRESS"
echo ""
# Query balance from Arbitrum
echo "🌐 Querying Arbitrum One network..."
BALANCE_HEX=$(curl -s -X POST "$ALCHEMY_RPC" \
-H "Content-Type: application/json" \
-d "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBalance\",\"params\":[\"$WALLET_ADDRESS\",\"latest\"],\"id\":1}" | \
grep -o '"result":"[^"]*"' | \
cut -d'"' -f4)
if [ -z "$BALANCE_HEX" ]; then
echo "❌ Error: Failed to query balance from Arbitrum"
echo " RPC endpoint may be unavailable"
exit 1
fi
# Convert hex to decimal (wei)
# Handle both with and without 0x prefix
if [[ "$BALANCE_HEX" == 0x* ]]; then
BALANCE_WEI=$((BALANCE_HEX))
else
BALANCE_WEI=$((0x$BALANCE_HEX))
fi
# Convert wei to ETH (1 ETH = 10^18 wei)
BALANCE_ETH=$(echo "scale=6; $BALANCE_WEI / 1000000000000000000" | bc)
echo "✅ Balance Retrieved"
echo ""
# Display balance
echo "═══════════════════════════════════════════════════════════"
echo "💰 Current Balance"
echo "═══════════════════════════════════════════════════════════"
echo ""
echo " Address: $WALLET_ADDRESS"
echo " Network: Arbitrum One (Chain ID: 42161)"
echo " Balance: $BALANCE_ETH ETH"
echo " Value: ~\$$(echo "scale=2; $BALANCE_ETH * 2000" | bc) USD (at \$2000/ETH)"
echo ""
# Check if balance meets minimum
BALANCE_CHECK=$(echo "$BALANCE_ETH >= $MIN_BALANCE_ETH" | bc)
if [ "$BALANCE_CHECK" -eq 1 ]; then
echo "✅ Wallet is funded and ready for execution!"
echo ""
# Calculate estimated trades
TRADES=$(echo "scale=0; $BALANCE_ETH / 0.0005" | bc)
echo "📊 Estimated Capacity:"
echo " • Max gas per trade: ~\$1.00 (~0.0005 ETH)"
echo " • Estimated trades: ~$TRADES transactions"
echo " • Recommended refill: When balance < 0.0005 ETH"
echo ""
echo "⏭️ Next Steps:"
echo " 1. Run: ./scripts/setup-keystore.sh"
echo " 2. Enable execution mode in config"
echo " 3. Restart bot to begin trading"
echo ""
# Arbiscan link
echo "🔗 View on Arbiscan:"
echo " https://arbiscan.io/address/$WALLET_ADDRESS"
echo ""
exit 0
else
echo "⚠️ Wallet balance is below minimum threshold"
echo ""
echo "❌ Current: $BALANCE_ETH ETH"
echo "✅ Required: $MIN_BALANCE_ETH ETH"
echo "📉 Deficit: $(echo "scale=6; $MIN_BALANCE_ETH - $BALANCE_ETH" | bc) ETH"
echo ""
echo "💡 Funding Instructions:"
echo ""
echo " **Option 1: Bridge from Ethereum**"
echo " • Visit: https://bridge.arbitrum.io/"
echo " • Bridge 0.001-0.005 ETH from Ethereum to Arbitrum"
echo " • Wait 7-15 minutes for confirmation"
echo ""
echo " **Option 2: Exchange Withdrawal**"
echo " • Go to Coinbase/Binance/Kraken"
echo " • Withdraw → ETH → Select 'Arbitrum One' network"
echo " • Send to: $WALLET_ADDRESS"
echo " • Amount: 0.001-0.005 ETH"
echo ""
echo " **Option 3: From Existing Arbitrum Wallet**"
echo " • Open MetaMask on Arbitrum One network"
echo " • Send 0.001-0.005 ETH to: $WALLET_ADDRESS"
echo ""
echo "🔗 Track transaction:"
echo " https://arbiscan.io/address/$WALLET_ADDRESS"
echo ""
exit 1
fi