Files
mev-beta/orig/scripts/fund-bot-wallet.sh
Administrator c54c569f30 refactor: move all remaining files to orig/ directory
Completed clean root directory structure:
- Root now contains only: .git, .env, docs/, orig/
- Moved all remaining files and directories to orig/:
  - Config files (.claude, .dockerignore, .drone.yml, etc.)
  - All .env variants (except active .env)
  - Git config (.gitconfig, .github, .gitignore, etc.)
  - Tool configs (.golangci.yml, .revive.toml, etc.)
  - Documentation (*.md files, @prompts)
  - Build files (Dockerfiles, Makefile, go.mod, go.sum)
  - Docker compose files
  - All source directories (scripts, tests, tools, etc.)
  - Runtime directories (logs, monitoring, reports)
  - Dependency files (node_modules, lib, cache)
  - Special files (--delete)

- Removed empty runtime directories (bin/, data/)

V2 structure is now clean:
- docs/planning/ - V2 planning documents
- orig/ - Complete V1 codebase preserved
- .env - Active environment config (not in git)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-10 10:53:05 +01:00

217 lines
7.2 KiB
Bash
Executable File

#!/bin/bash
# Fund MEV Bot Wallet Using Cast
# Sends minimum required ETH from a funded source wallet
set -e
ARBITRUM_RPC="https://arb-mainnet.g.alchemy.com/v2/d6VAHgzkOI3NgLGem6uBMiADT1E9rROB"
BOT_WALLET_ADDRESS="0x40091653f652a259747D86d7Cbe3e2848082a051"
MIN_AMOUNT="0.001" # Minimum ETH to send
SAFETY_BUFFER="0.001" # Keep this much in source wallet
echo "═══════════════════════════════════════════════════════════"
echo "💸 Fund MEV Bot Wallet Using Cast"
echo "═══════════════════════════════════════════════════════════"
echo ""
echo "Target Bot Wallet: $BOT_WALLET_ADDRESS"
echo "Amount to Send: $MIN_AMOUNT ETH"
echo "Network: Arbitrum One"
echo ""
# Check if cast is installed
if ! command -v cast &> /dev/null; then
echo "❌ Error: cast (Foundry) not found"
echo " Install: curl -L https://foundry.paradigm.xyz | bash"
exit 1
fi
echo "📋 You need a source wallet with funds on Arbitrum One"
echo ""
echo "Options:"
echo " 1. Provide private key directly (not recommended for large amounts)"
echo " 2. Use Foundry keystore (recommended, encrypted)"
echo " 3. Exit and fund manually via MetaMask"
echo ""
read -p "Choose option (1/2/3): " OPTION
case $OPTION in
1)
echo ""
read -sp "Enter source wallet private key (0x...): " SOURCE_PRIVATE_KEY
echo ""
# Derive source address
SOURCE_ADDRESS=$(cast wallet address "$SOURCE_PRIVATE_KEY")
echo "✅ Source Address: $SOURCE_ADDRESS"
;;
2)
echo ""
echo "📂 Available Foundry keystores:"
if [ -d "$HOME/.foundry/keystores" ]; then
ls -1 "$HOME/.foundry/keystores" 2>/dev/null || echo " (none found)"
else
echo " (no keystore directory)"
fi
echo ""
read -p "Enter keystore name (or path): " KEYSTORE_NAME
# Try to use keystore
SOURCE_ADDRESS=$(cast wallet address --keystore "$KEYSTORE_NAME" 2>/dev/null || {
echo "❌ Failed to access keystore"
exit 1
})
echo "✅ Source Address: $SOURCE_ADDRESS"
# For keystore, we'll need to use --keystore flag in send
USE_KEYSTORE=true
;;
3)
echo ""
echo "Exiting. To fund manually:"
echo " 1. Open MetaMask on Arbitrum One"
echo " 2. Send $MIN_AMOUNT ETH to: $BOT_WALLET_ADDRESS"
echo " 3. Run: ./scripts/check-wallet-balance.sh"
exit 0
;;
*)
echo "❌ Invalid option"
exit 1
;;
esac
echo ""
echo "🔍 Checking source wallet balance..."
# Check source wallet balance
SOURCE_BALANCE_WEI=$(cast balance "$SOURCE_ADDRESS" --rpc-url "$ARBITRUM_RPC")
SOURCE_BALANCE_ETH=$(cast --to-unit "$SOURCE_BALANCE_WEI" ether)
echo " Balance: $SOURCE_BALANCE_ETH ETH"
# Check if sufficient balance
REQUIRED=$(echo "$MIN_AMOUNT + $SAFETY_BUFFER + 0.001" | bc) # +0.001 for gas
SUFFICIENT=$(echo "$SOURCE_BALANCE_ETH >= $REQUIRED" | bc)
if [ "$SUFFICIENT" -eq 0 ]; then
echo ""
echo "❌ Insufficient balance!"
echo " Current: $SOURCE_BALANCE_ETH ETH"
echo " Required: $REQUIRED ETH ($MIN_AMOUNT + $SAFETY_BUFFER safety + 0.001 gas)"
echo ""
echo "Please add funds to: $SOURCE_ADDRESS"
exit 1
fi
echo "✅ Sufficient balance to proceed"
echo ""
# Check bot wallet current balance
echo "🔍 Checking bot wallet current balance..."
BOT_BALANCE_WEI=$(cast balance "$BOT_WALLET_ADDRESS" --rpc-url "$ARBITRUM_RPC")
BOT_BALANCE_ETH=$(cast --to-unit "$BOT_BALANCE_WEI" ether)
echo " Current Bot Balance: $BOT_BALANCE_ETH ETH"
if [ "$(echo "$BOT_BALANCE_ETH >= $MIN_AMOUNT" | bc)" -eq 1 ]; then
echo ""
echo "✅ Bot wallet already has sufficient funds!"
echo ""
echo "Current balance ($BOT_BALANCE_ETH ETH) meets minimum ($MIN_AMOUNT ETH)"
echo ""
read -p "Send additional funds anyway? (y/N): " PROCEED
if [[ ! "$PROCEED" =~ ^[Yy]$ ]]; then
echo "Exiting. Run ./scripts/check-wallet-balance.sh to verify."
exit 0
fi
fi
echo ""
echo "═══════════════════════════════════════════════════════════"
echo "💸 Transaction Summary"
echo "═══════════════════════════════════════════════════════════"
echo ""
echo "From: $SOURCE_ADDRESS"
echo "To: $BOT_WALLET_ADDRESS"
echo "Amount: $MIN_AMOUNT ETH"
echo "Network: Arbitrum One (Chain ID: 42161)"
echo ""
echo "After Transaction:"
echo " Source Balance: ~$(echo "$SOURCE_BALANCE_ETH - $MIN_AMOUNT - 0.001" | bc) ETH"
echo " Bot Balance: ~$(echo "$BOT_BALANCE_ETH + $MIN_AMOUNT" | bc) ETH"
echo ""
read -p "⚠️ Confirm transaction? (yes/no): " CONFIRM
if [ "$CONFIRM" != "yes" ]; then
echo "Transaction cancelled"
exit 0
fi
echo ""
echo "📤 Sending transaction..."
# Send transaction
if [ "$USE_KEYSTORE" = true ]; then
# Use keystore
TXHASH=$(cast send "$BOT_WALLET_ADDRESS" \
--value "${MIN_AMOUNT}ether" \
--keystore "$KEYSTORE_NAME" \
--rpc-url "$ARBITRUM_RPC" \
--legacy)
else
# Use private key
TXHASH=$(cast send "$BOT_WALLET_ADDRESS" \
--value "${MIN_AMOUNT}ether" \
--private-key "$SOURCE_PRIVATE_KEY" \
--rpc-url "$ARBITRUM_RPC" \
--legacy)
fi
if [ $? -eq 0 ]; then
echo ""
echo "✅ Transaction sent successfully!"
echo ""
echo "Transaction Hash: $TXHASH"
echo "View on Arbiscan: https://arbiscan.io/tx/$TXHASH"
echo ""
echo "⏳ Waiting for confirmation (typically 1-2 minutes)..."
# Wait for receipt
sleep 3
cast receipt "$TXHASH" --rpc-url "$ARBITRUM_RPC" > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "✅ Transaction confirmed!"
echo ""
# Check new balance
NEW_BALANCE_WEI=$(cast balance "$BOT_WALLET_ADDRESS" --rpc-url "$ARBITRUM_RPC")
NEW_BALANCE_ETH=$(cast --to-unit "$NEW_BALANCE_WEI" ether)
echo "═══════════════════════════════════════════════════════════"
echo "✅ Bot Wallet Funded Successfully!"
echo "═══════════════════════════════════════════════════════════"
echo ""
echo "Bot Wallet: $BOT_WALLET_ADDRESS"
echo "New Balance: $NEW_BALANCE_ETH ETH"
echo ""
echo "⏭️ Next Steps:"
echo " 1. Configure keystore: ./scripts/setup-keystore.sh"
echo " 2. Enable execution: ./scripts/enable-execution-mode.sh"
echo " 3. Start bot: pkill -f mev-beta && GO_ENV=production nohup ./bin/mev-beta start &"
echo ""
else
echo "⏳ Transaction pending, check Arbiscan for status"
fi
else
echo ""
echo "❌ Transaction failed!"
echo "Check error message above for details"
exit 1
fi