- Added comprehensive bounds checking to prevent buffer overruns in multicall parsing - Implemented graduated validation system (Strict/Moderate/Permissive) to reduce false positives - Added LRU caching system for address validation with 10-minute TTL - Enhanced ABI decoder with missing Universal Router and Arbitrum-specific DEX signatures - Fixed duplicate function declarations and import conflicts across multiple files - Added error recovery mechanisms with multiple fallback strategies - Updated tests to handle new validation behavior for suspicious addresses - Fixed parser test expectations for improved validation system - Applied gofmt formatting fixes to ensure code style compliance - Fixed mutex copying issues in monitoring package by introducing MetricsSnapshot - Resolved critical security vulnerabilities in heuristic address extraction - Progress: Updated TODO audit from 10% to 35% complete 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
70 lines
2.2 KiB
Go
70 lines
2.2 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
"time"
|
|
|
|
"github.com/fraktal/mev-beta/tools/opportunity-validator/internal"
|
|
)
|
|
|
|
func main() {
|
|
var (
|
|
exchanges = flag.String("exchanges", "uniswap_v2,uniswap_v3,curve,balancer", "Comma-separated list of exchanges")
|
|
minProfitBP = flag.Float64("min-profit", 10.0, "Minimum profit threshold in basis points")
|
|
maxSlippage = flag.Float64("max-slippage", 100.0, "Maximum slippage in basis points")
|
|
outputDir = flag.String("output", "reports/opportunities", "Output directory")
|
|
verbose = flag.Bool("verbose", false, "Enable verbose output")
|
|
realtime = flag.Bool("realtime", false, "Enable real-time opportunity monitoring")
|
|
duration = flag.Duration("duration", 10*time.Minute, "Duration for real-time monitoring")
|
|
dryRun = flag.Bool("dry-run", true, "Perform dry run without actual execution")
|
|
testMode = flag.Bool("test", false, "Run in test mode with simulated data")
|
|
)
|
|
flag.Parse()
|
|
|
|
// Create output directory
|
|
if err := os.MkdirAll(*outputDir, 0755); err != nil {
|
|
log.Fatalf("Failed to create output directory: %v", err)
|
|
}
|
|
|
|
// Initialize opportunity validator
|
|
validator, err := internal.NewOpportunityValidator(&internal.ValidatorConfig{
|
|
Exchanges: *exchanges,
|
|
MinProfitBP: *minProfitBP,
|
|
MaxSlippage: *maxSlippage,
|
|
OutputDir: *outputDir,
|
|
Verbose: *verbose,
|
|
DryRun: *dryRun,
|
|
TestMode: *testMode,
|
|
})
|
|
if err != nil {
|
|
log.Fatalf("Failed to initialize validator: %v", err)
|
|
}
|
|
|
|
ctx := context.Background()
|
|
|
|
if *realtime {
|
|
fmt.Printf("Starting real-time opportunity validation for %v...\n", *duration)
|
|
ctx, cancel := context.WithTimeout(ctx, *duration)
|
|
defer cancel()
|
|
|
|
if err := validator.MonitorOpportunities(ctx); err != nil {
|
|
log.Fatalf("Real-time monitoring failed: %v", err)
|
|
}
|
|
} else {
|
|
fmt.Printf("Running opportunity validation audit...\n")
|
|
if err := validator.ValidateOpportunities(ctx); err != nil {
|
|
log.Fatalf("Opportunity validation failed: %v", err)
|
|
}
|
|
|
|
if err := validator.GenerateReport(); err != nil {
|
|
log.Fatalf("Report generation failed: %v", err)
|
|
}
|
|
}
|
|
|
|
fmt.Printf("Opportunity validation complete. Reports saved to: %s\n", *outputDir)
|
|
}
|