CRITICAL BUG FIX: - MultiHopScanner.updateTokenGraph() was EMPTY - adding no pools! - Result: Token graph had 0 pools, found 0 arbitrage paths - All opportunities showed estimatedProfitETH: 0.000000 FIX APPLIED: - Populated token graph with 8 high-liquidity Arbitrum pools: * WETH/USDC (0.05% and 0.3% fees) * USDC/USDC.e (0.01% - common arbitrage) * ARB/USDC, WETH/ARB, WETH/USDT * WBTC/WETH, LINK/WETH - These are REAL verified pool addresses with high volume AGGRESSIVE THRESHOLD CHANGES: - Min profit: 0.0001 ETH → 0.00001 ETH (10x lower, ~$0.02) - Min ROI: 0.05% → 0.01% (5x lower) - Gas multiplier: 5x → 1.5x (3.3x lower safety margin) - Max slippage: 3% → 5% (67% higher tolerance) - Max paths: 100 → 200 (more thorough scanning) - Cache expiry: 2min → 30sec (fresher opportunities) EXPECTED RESULTS (24h): - 20-50 opportunities with profit > $0.02 (was 0) - 5-15 execution attempts (was 0) - 1-2 successful executions (was 0) - $0.02-$0.20 net profit (was $0) WARNING: Aggressive settings may result in some losses Monitor closely for first 6 hours and adjust if needed Target: First profitable execution within 24 hours 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
235 lines
8.3 KiB
Bash
Executable File
235 lines
8.3 KiB
Bash
Executable File
#!/bin/bash
|
|
###############################################################################
|
|
# RPC Configuration Fix Script
|
|
#
|
|
# This script fixes the critical RPC rate limiting issue by ensuring
|
|
# the bot uses the paid Chainstack endpoint instead of the public endpoint.
|
|
#
|
|
# Usage: ./scripts/fix-rpc-config.sh
|
|
###############################################################################
|
|
|
|
set -euo pipefail
|
|
|
|
# Colors
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m' # No Color
|
|
|
|
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
|
|
echo -e "${BLUE} MEV Bot RPC Configuration Fix${NC}"
|
|
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
|
|
echo ""
|
|
|
|
###############################################################################
|
|
# Step 1: Check Current Configuration
|
|
###############################################################################
|
|
|
|
echo -e "${YELLOW}[1/5] Checking current RPC configuration...${NC}"
|
|
echo ""
|
|
|
|
# Check if environment variables are set
|
|
if [ -z "${ARBITRUM_RPC_ENDPOINT:-}" ]; then
|
|
echo -e "${RED}✗ ARBITRUM_RPC_ENDPOINT not set${NC}"
|
|
ENV_SET=false
|
|
else
|
|
echo -e "${GREEN}✓ ARBITRUM_RPC_ENDPOINT is set${NC}"
|
|
echo " Current value: ${ARBITRUM_RPC_ENDPOINT}"
|
|
ENV_SET=true
|
|
fi
|
|
|
|
if [ -z "${ARBITRUM_WS_ENDPOINT:-}" ]; then
|
|
echo -e "${RED}✗ ARBITRUM_WS_ENDPOINT not set${NC}"
|
|
WS_SET=false
|
|
else
|
|
echo -e "${GREEN}✓ ARBITRUM_WS_ENDPOINT is set${NC}"
|
|
echo " Current value: ${ARBITRUM_WS_ENDPOINT}"
|
|
WS_SET=true
|
|
fi
|
|
|
|
echo ""
|
|
|
|
###############################################################################
|
|
# Step 2: Detect Issue
|
|
###############################################################################
|
|
|
|
echo -e "${YELLOW}[2/5] Detecting RPC issues...${NC}"
|
|
echo ""
|
|
|
|
# Check if using public endpoint
|
|
if [[ "${ARBITRUM_RPC_ENDPOINT:-}" == *"arb1.arbitrum.io"* ]]; then
|
|
echo -e "${RED}✗ CRITICAL: Using public RPC endpoint!${NC}"
|
|
echo " This will cause rate limiting (429 errors)"
|
|
USING_PUBLIC=true
|
|
elif [[ "${ARBITRUM_RPC_ENDPOINT:-}" == *"chainstack.com"* ]]; then
|
|
echo -e "${GREEN}✓ Using paid Chainstack endpoint${NC}"
|
|
USING_PUBLIC=false
|
|
else
|
|
echo -e "${YELLOW}⚠ Unknown RPC endpoint${NC}"
|
|
USING_PUBLIC=unknown
|
|
fi
|
|
|
|
# Check recent logs for 429 errors
|
|
if [ -f "logs/mev_bot.log" ]; then
|
|
RATE_LIMIT_COUNT=$(tail -1000 logs/mev_bot.log | grep -c "429 Too Many Requests" || echo "0")
|
|
|
|
if [ "$RATE_LIMIT_COUNT" -gt 10 ]; then
|
|
echo -e "${RED}✗ High rate limiting detected: $RATE_LIMIT_COUNT errors in last 1000 lines${NC}"
|
|
HAS_RATE_LIMIT=true
|
|
elif [ "$RATE_LIMIT_COUNT" -gt 0 ]; then
|
|
echo -e "${YELLOW}⚠ Some rate limiting detected: $RATE_LIMIT_COUNT errors${NC}"
|
|
HAS_RATE_LIMIT=true
|
|
else
|
|
echo -e "${GREEN}✓ No rate limiting detected${NC}"
|
|
HAS_RATE_LIMIT=false
|
|
fi
|
|
else
|
|
echo -e "${YELLOW}⚠ No log file found, cannot check for rate limiting${NC}"
|
|
HAS_RATE_LIMIT=unknown
|
|
fi
|
|
|
|
echo ""
|
|
|
|
###############################################################################
|
|
# Step 3: Load Correct Configuration
|
|
###############################################################################
|
|
|
|
echo -e "${YELLOW}[3/5] Loading correct configuration...${NC}"
|
|
echo ""
|
|
|
|
# Check if .env.production exists
|
|
if [ -f ".env.production" ]; then
|
|
echo -e "${GREEN}✓ Found .env.production${NC}"
|
|
|
|
# Source it
|
|
set -a
|
|
source .env.production
|
|
set +a
|
|
|
|
echo -e "${GREEN}✓ Loaded .env.production${NC}"
|
|
|
|
# Verify it has the right endpoint
|
|
if [[ "${ARBITRUM_RPC_ENDPOINT:-}" == *"chainstack.com"* ]]; then
|
|
echo -e "${GREEN}✓ Chainstack endpoint configured in .env.production${NC}"
|
|
else
|
|
echo -e "${RED}✗ .env.production does not have Chainstack endpoint!${NC}"
|
|
echo " Please edit .env.production and set:"
|
|
echo " ARBITRUM_RPC_ENDPOINT=wss://arbitrum-mainnet.core.chainstack.com/YOUR_KEY"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo -e "${RED}✗ .env.production not found!${NC}"
|
|
echo ""
|
|
echo "Creating .env.production from template..."
|
|
|
|
# Create from .env.example
|
|
if [ -f ".env.example" ]; then
|
|
cp .env.example .env.production
|
|
echo -e "${YELLOW}⚠ Created .env.production from .env.example${NC}"
|
|
echo -e "${RED}✗ You must edit .env.production and set your Chainstack API key!${NC}"
|
|
echo ""
|
|
echo "Steps:"
|
|
echo " 1. Edit .env.production"
|
|
echo " 2. Replace YOUR_KEY_HERE with your actual Chainstack API key"
|
|
echo " 3. Run this script again"
|
|
exit 1
|
|
else
|
|
echo -e "${RED}✗ .env.example not found either!${NC}"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
echo ""
|
|
|
|
###############################################################################
|
|
# Step 4: Stop Bot if Running
|
|
###############################################################################
|
|
|
|
echo -e "${YELLOW}[4/5] Stopping MEV bot if running...${NC}"
|
|
echo ""
|
|
|
|
# Check if bot is running
|
|
BOT_PID=$(pgrep -f "mev-bot start" || echo "")
|
|
|
|
if [ -n "$BOT_PID" ]; then
|
|
echo -e "${YELLOW}⚠ Found running bot process (PID: $BOT_PID)${NC}"
|
|
echo "Stopping bot..."
|
|
|
|
kill -TERM "$BOT_PID" 2>/dev/null || true
|
|
|
|
# Wait up to 10 seconds for graceful shutdown
|
|
for i in {1..10}; do
|
|
if ! kill -0 "$BOT_PID" 2>/dev/null; then
|
|
echo -e "${GREEN}✓ Bot stopped gracefully${NC}"
|
|
break
|
|
fi
|
|
sleep 1
|
|
done
|
|
|
|
# Force kill if still running
|
|
if kill -0 "$BOT_PID" 2>/dev/null; then
|
|
echo -e "${YELLOW}⚠ Force killing bot...${NC}"
|
|
kill -9 "$BOT_PID" 2>/dev/null || true
|
|
fi
|
|
else
|
|
echo -e "${GREEN}✓ Bot is not running${NC}"
|
|
fi
|
|
|
|
echo ""
|
|
|
|
###############################################################################
|
|
# Step 5: Verify Configuration
|
|
###############################################################################
|
|
|
|
echo -e "${YELLOW}[5/5] Verifying configuration...${NC}"
|
|
echo ""
|
|
|
|
# Display final configuration
|
|
echo "Configuration:"
|
|
echo " ARBITRUM_RPC_ENDPOINT: ${ARBITRUM_RPC_ENDPOINT}"
|
|
echo " ARBITRUM_WS_ENDPOINT: ${ARBITRUM_WS_ENDPOINT:-NOT_SET}"
|
|
echo " PROVIDER_CONFIG_PATH: ${PROVIDER_CONFIG_PATH:-$PWD/config/providers_runtime.yaml}"
|
|
echo ""
|
|
|
|
# Verify it's not the public endpoint
|
|
if [[ "${ARBITRUM_RPC_ENDPOINT}" == *"arb1.arbitrum.io"* ]]; then
|
|
echo -e "${RED}✗ STILL using public endpoint!${NC}"
|
|
echo " Configuration fix failed"
|
|
exit 1
|
|
else
|
|
echo -e "${GREEN}✓ Using paid endpoint${NC}"
|
|
fi
|
|
|
|
echo ""
|
|
|
|
###############################################################################
|
|
# Summary and Next Steps
|
|
###############################################################################
|
|
|
|
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
|
|
echo -e "${GREEN}✓ RPC Configuration Fix Complete${NC}"
|
|
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
|
|
echo ""
|
|
|
|
echo -e "${YELLOW}Next Steps:${NC}"
|
|
echo ""
|
|
echo "1. Start the bot with correct configuration:"
|
|
echo " ${GREEN}PROVIDER_CONFIG_PATH=\$PWD/config/providers_runtime.yaml ./bin/mev-bot start${NC}"
|
|
echo ""
|
|
echo "2. Monitor for rate limiting errors:"
|
|
echo " ${GREEN}tail -f logs/mev_bot.log | grep \"429 Too Many Requests\"${NC}"
|
|
echo " ${YELLOW}(Should show NO results if fix is working)${NC}"
|
|
echo ""
|
|
echo "3. Verify block processing:"
|
|
echo " ${GREEN}tail -f logs/mev_bot.log | grep \"Processing block\"${NC}"
|
|
echo " ${YELLOW}(Should show continuous block processing)${NC}"
|
|
echo ""
|
|
echo "4. Check connection status:"
|
|
echo " ${GREEN}tail -f logs/mev_bot.log | grep -i \"connected\"${NC}"
|
|
echo " ${YELLOW}(Should show successful connection to Chainstack)${NC}"
|
|
echo ""
|
|
|
|
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
|
|
echo ""
|