Files
mev-beta/orig/scripts/test-live-extraction.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

105 lines
4.2 KiB
Bash
Executable File

#!/bin/bash
# Test extraction logic with real log data
# Color codes
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m'
# Get the last opportunity from logs
line=$(grep "OPPORTUNITY DETECTED" logs/mev_bot.log | tail -1)
echo "════════════════════════════════════════════════════════════"
echo "Testing Extraction Logic with Real Log Data"
echo "════════════════════════════════════════════════════════════"
echo ""
# Extract timestamp
TIMESTAMP=$(echo "$line" | awk '{print $1, $2}')
echo "Timestamp: $TIMESTAMP"
# Check if executable
if echo "$line" | grep -q "isExecutable:true"; then
echo "Status: EXECUTABLE ✅"
else
echo "Status: NOT EXECUTABLE ⚠️"
fi
echo ""
echo "Extracted Fields:"
echo "----------------"
# Token pair (FIXED)
TOKEN_IN=$(echo "$line" | grep -oP 'tokenIn:[^ \]]+' | cut -d: -f2)
TOKEN_OUT=$(echo "$line" | grep -oP 'tokenOut:[^ \]]+' | cut -d: -f2)
echo "Token In: $TOKEN_IN"
echo "Token Out: $TOKEN_OUT"
# Amounts
AMOUNT_IN=$(echo "$line" | grep -oP 'Amount In: [0-9.]+' | grep -oP '[0-9.]+')
AMOUNT_OUT=$(echo "$line" | grep -oP 'Amount Out: [0-9.]+' | grep -oP '[0-9.]+')
echo "Amount In: $AMOUNT_IN"
echo "Amount Out: $AMOUNT_OUT"
# Financial metrics
ESTIMATED_PROFIT=$(echo "$line" | grep -oP 'estimatedProfitETH:[0-9.]+' | cut -d: -f2)
GAS_COST=$(echo "$line" | grep -oP 'gasCostETH:[0-9.eE+-]+' | cut -d: -f2)
NET_PROFIT=$(echo "$line" | grep -oP 'netProfitETH:-?[0-9.eE+-]+' | cut -d: -f2)
echo "Estimated Profit: $ESTIMATED_PROFIT ETH"
echo "Gas Cost: $GAS_COST ETH"
echo "Net Profit: $NET_PROFIT ETH"
# Price impact & margin
PRICE_IMPACT=$(echo "$line" | grep -oP 'priceImpact:[0-9.eE+-]+' | cut -d: -f2)
PROFIT_MARGIN=$(echo "$line" | grep -oP 'profitMargin:-?[0-9.eE+-]+' | cut -d: -f2)
echo "Price Impact: $PRICE_IMPACT"
echo "Profit Margin: $PROFIT_MARGIN"
# Confidence
CONFIDENCE=$(echo "$line" | grep -oP 'confidence:[0-9.]+' | cut -d: -f2)
echo "Confidence: $CONFIDENCE"
# Reject reason (FIXED)
REASON=$(echo "$line" | grep -oP 'rejectReason:[^ ]+ [^ ]+ [^ ]+ [^ ]+ [^ ]+ [^ ]+' | cut -d: -f2)
# Trim to just the meaningful part (remove trailing field names)
REASON=$(echo "$REASON" | sed 's/ token[0-9].*$//' | sed 's/ protocol.*$//' | sed 's/ poolAddress.*$//')
echo "Reject Reason: $REASON"
echo ""
echo "════════════════════════════════════════════════════════════"
echo "Now showing formatted output:"
echo "════════════════════════════════════════════════════════════"
echo ""
# Show formatted output
echo -e "${YELLOW}[$TIMESTAMP] 🎯 Opportunity (not executable)${NC}"
echo -e "${CYAN} 🔄 Pair: ${TOKEN_IN}${TOKEN_OUT}${NC}"
echo -e "${CYAN} 📊 Amounts: ${AMOUNT_IN}${AMOUNT_OUT}${NC}"
echo -e "${YELLOW} 💰 Estimated Profit: ${ESTIMATED_PROFIT} ETH${NC}"
echo -e "${RED} ⛽ Gas Cost: ${GAS_COST} ETH${NC}"
echo -e "${RED} 📉 Net After Gas: ${NET_PROFIT} ETH${NC}"
# Price impact as percentage
if [[ -n "$PRICE_IMPACT" ]]; then
PRICE_IMPACT_PCT=$(echo "$PRICE_IMPACT * 100" | bc -l 2>/dev/null || echo "$PRICE_IMPACT")
echo -e "${YELLOW} 📊 Price Impact: $(printf "%.6f" $PRICE_IMPACT_PCT 2>/dev/null || echo "$PRICE_IMPACT")%${NC}"
fi
# Profit margin as percentage
if [[ -n "$PROFIT_MARGIN" ]]; then
PROFIT_MARGIN_PCT=$(echo "$PROFIT_MARGIN * 100" | bc -l 2>/dev/null || echo "$PROFIT_MARGIN")
echo -e "${RED} 📊 Profit Margin: $(printf "%.6f" $PROFIT_MARGIN_PCT 2>/dev/null || echo "$PROFIT_MARGIN")%${NC}"
fi
# Confidence as percentage
if [[ -n "$CONFIDENCE" ]]; then
CONFIDENCE_PCT=$(echo "$CONFIDENCE * 100" | bc -l 2>/dev/null || echo "$CONFIDENCE")
echo -e "${YELLOW} 🎯 Confidence: $(printf "%.1f" $CONFIDENCE_PCT 2>/dev/null || echo "$CONFIDENCE")%${NC}"
fi
echo -e "${RED} ❌ Reason: $REASON${NC}"
echo ""