Files
mev-beta/scripts/verify-20-token-expansion.sh

200 lines
5.4 KiB
Bash
Executable File

#!/bin/bash
# Verification script for 20-token expansion
# Verifies that all code changes are in place
set -e
echo "=========================================="
echo "20-Token Expansion Verification Script"
echo "=========================================="
echo ""
# Color codes
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Counters
PASSED=0
FAILED=0
# Function to check and report
check() {
local description=$1
local command=$2
local expected=$3
echo -n "Checking: $description... "
if result=$(eval "$command" 2>&1); then
if [[ "$result" == *"$expected"* ]] || [[ "$expected" == "any" ]]; then
echo -e "${GREEN}✓ PASS${NC}"
((PASSED++))
return 0
fi
fi
echo -e "${RED}✗ FAIL${NC}"
echo " Expected: $expected"
echo " Got: $result"
((FAILED++))
return 1
}
echo "=== 1. Token Struct Verification ==="
echo ""
# Check for 20 token fields in ArbitrumTokens struct
check "ArbitrumTokens has WETH field" \
"grep -c 'WETH common.Address' internal/tokens/arbitrum.go" \
"1"
check "ArbitrumTokens has all Tier 2 tokens (USDCe, PENDLE, RDNT, MAGIC, GRAIL)" \
"grep -c 'USDCe\|PENDLE\|RDNT\|MAGIC\|GRAIL' internal/tokens/arbitrum.go" \
"any"
check "ArbitrumTokens has all Tier 3 tokens (AAVE, CRV, BAL, COMP, MKR)" \
"grep -c 'AAVE\|CRV\|BAL\|COMP\|MKR' internal/tokens/arbitrum.go" \
"any"
echo ""
echo "=== 2. Token Address Verification ==="
echo ""
# Verify addresses are present
check "USDC.e address (0xFF970A61...)" \
"grep -c '0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8' internal/tokens/arbitrum.go" \
"1"
check "PENDLE address (0x0c880f67...)" \
"grep -c '0x0c880f6761F1af8d9Aa9C466984b80DAb9a8c9e8' internal/tokens/arbitrum.go" \
"1"
check "AAVE address (0xba5DdD1f...)" \
"grep -c '0xba5DdD1f9d7F570dc94a51479a000E3BCE967196' internal/tokens/arbitrum.go" \
"1"
echo ""
echo "=== 3. Main.go Discovery Loop Verification ==="
echo ""
check "main.go has TOP 20 tokens comment" \
"grep -c 'TOP 20 tokens' cmd/mev-bot/main.go" \
"any"
check "main.go has 190 pairs expected" \
"grep -c '190 pairs expected' cmd/mev-bot/main.go" \
"1"
check "main.go tokenList includes USDC.e" \
"grep -c 'USDC.e.*arbTokens.USDCe' cmd/mev-bot/main.go" \
"1"
check "main.go tokenList includes all Tier 2 tokens" \
"grep -c 'PENDLE\|RDNT\|MAGIC\|GRAIL' cmd/mev-bot/main.go" \
"any"
check "main.go tokenList includes all Tier 3 tokens" \
"grep -c 'AAVE\|CRV\|BAL\|COMP\|MKR' cmd/mev-bot/main.go" \
"any"
echo ""
echo "=== 4. Build Verification ==="
echo ""
check "Binary exists" \
"test -f ./mev-bot && echo 'exists'" \
"exists"
check "Binary size is reasonable (>20MB)" \
"stat -c%s ./mev-bot | awk '{print (\$1 > 20000000) ? \"ok\" : \"fail\"}'" \
"ok"
check "Binary is executable" \
"test -x ./mev-bot && echo 'executable'" \
"executable"
echo ""
echo "=== 5. Documentation Verification ==="
echo ""
check "20-token expansion documentation exists" \
"test -f docs/20_TOKEN_EXPANSION_COMPLETE.md && echo 'exists'" \
"exists"
check "Documentation mentions 190 pairs" \
"grep -c '190 pairs' docs/20_TOKEN_EXPANSION_COMPLETE.md" \
"any"
check "Documentation lists all token addresses" \
"grep -c '0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8' docs/20_TOKEN_EXPANSION_COMPLETE.md" \
"any"
echo ""
echo "=== 6. Mathematical Verification ==="
echo ""
# Calculate expected pairs programmatically
echo -n "Calculating pairs from 20 tokens... "
EXPECTED_PAIRS=$((20 * 19 / 2))
if [ "$EXPECTED_PAIRS" -eq 190 ]; then
echo -e "${GREEN}✓ PASS${NC} (C(20,2) = 190)"
((PASSED++))
else
echo -e "${RED}✗ FAIL${NC} (Expected 190, got $EXPECTED_PAIRS)"
((FAILED++))
fi
echo ""
echo "=== 7. Token Count Verification ==="
echo ""
# Count token definitions in struct
TIER1_COUNT=$(grep -A 20 "// Tier 1" internal/tokens/arbitrum.go | grep -c "common.Address" || true)
TIER2_COUNT=$(grep -A 10 "// Tier 2" internal/tokens/arbitrum.go | grep -c "common.Address" || true)
TIER3_COUNT=$(grep -A 10 "// Tier 3" internal/tokens/arbitrum.go | grep -c "common.Address" || true)
TOTAL_TOKENS=$((TIER1_COUNT + TIER2_COUNT + TIER3_COUNT))
echo " Tier 1 tokens: $TIER1_COUNT (expected: 10)"
echo " Tier 2 tokens: $TIER2_COUNT (expected: 5)"
echo " Tier 3 tokens: $TIER3_COUNT (expected: 5)"
echo -n " Total tokens: $TOTAL_TOKENS (expected: 20)... "
if [ "$TOTAL_TOKENS" -eq 20 ]; then
echo -e "${GREEN}✓ PASS${NC}"
((PASSED++))
else
echo -e "${RED}✗ FAIL${NC}"
((FAILED++))
fi
echo ""
echo "=========================================="
echo "Verification Summary"
echo "=========================================="
echo ""
echo -e "Tests Passed: ${GREEN}$PASSED${NC}"
echo -e "Tests Failed: ${RED}$FAILED${NC}"
echo ""
if [ "$FAILED" -eq 0 ]; then
echo -e "${GREEN}✓ ALL CHECKS PASSED${NC}"
echo ""
echo "The 20-token expansion is fully implemented and verified!"
echo ""
echo "Next steps:"
echo " 1. Configure valid RPC endpoint: export ARBITRUM_RPC_ENDPOINT=\"...\""
echo " 2. Run the bot: ./mev-bot start"
echo " 3. Verify discovery: jq 'length' data/pools.json"
echo " 4. Expected result: 250-400+ pools discovered"
echo ""
exit 0
else
echo -e "${RED}✗ SOME CHECKS FAILED${NC}"
echo ""
echo "Please review the failed checks above and ensure all code changes are in place."
echo ""
exit 1
fi