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>
91 lines
2.8 KiB
Go
91 lines
2.8 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
"time"
|
|
|
|
"github.com/fraktal/mev-beta/tools/profitability-audit/internal"
|
|
)
|
|
|
|
func main() {
|
|
var (
|
|
exchange = flag.String("exchange", "", "Exchange to audit (uniswap_v2, uniswap_v3, curve, balancer, all)")
|
|
minProfitBP = flag.Float64("min-profit", 10.0, "Minimum profit threshold in basis points")
|
|
maxSlippage = flag.Float64("max-slippage", 50.0, "Maximum acceptable slippage in basis points")
|
|
scenarios = flag.String("scenarios", "default", "Test scenarios file (default, stress, production)")
|
|
outputDir = flag.String("output", "reports/profitability", "Output directory for reports")
|
|
verbose = flag.Bool("verbose", false, "Enable verbose output")
|
|
realtime = flag.Bool("realtime", false, "Enable real-time profit monitoring")
|
|
duration = flag.Duration("duration", 5*time.Minute, "Duration for real-time monitoring")
|
|
)
|
|
flag.Parse()
|
|
|
|
if *exchange == "" {
|
|
fmt.Println("Usage: profitability-audit -exchange <exchange> [options]")
|
|
flag.PrintDefaults()
|
|
os.Exit(1)
|
|
}
|
|
|
|
// Create output directory
|
|
if err := os.MkdirAll(*outputDir, 0755); err != nil {
|
|
log.Fatalf("Failed to create output directory: %v", err)
|
|
}
|
|
|
|
// Initialize profitability auditor
|
|
auditor, err := internal.NewProfitabilityAuditor(&internal.Config{
|
|
MinProfitBP: *minProfitBP,
|
|
MaxSlippageBP: *maxSlippage,
|
|
OutputDir: *outputDir,
|
|
Verbose: *verbose,
|
|
ScenariosFile: *scenarios,
|
|
})
|
|
if err != nil {
|
|
log.Fatalf("Failed to initialize auditor: %v", err)
|
|
}
|
|
|
|
ctx := context.Background()
|
|
|
|
// Run profitability audit
|
|
if *realtime {
|
|
fmt.Printf("Starting real-time profitability monitoring for %v...\n", *duration)
|
|
if err := runRealtimeAudit(ctx, auditor, *exchange, *duration); err != nil {
|
|
log.Fatalf("Real-time audit failed: %v", err)
|
|
}
|
|
} else {
|
|
fmt.Printf("Running profitability audit for exchange: %s\n", *exchange)
|
|
if err := runStaticAudit(ctx, auditor, *exchange); err != nil {
|
|
log.Fatalf("Static audit failed: %v", err)
|
|
}
|
|
}
|
|
|
|
fmt.Printf("Audit complete. Reports saved to: %s\n", *outputDir)
|
|
}
|
|
|
|
func runStaticAudit(ctx context.Context, auditor *internal.ProfitabilityAuditor, exchange string) error {
|
|
if exchange == "all" {
|
|
exchanges := []string{"uniswap_v2", "uniswap_v3", "curve", "balancer"}
|
|
for _, ex := range exchanges {
|
|
if err := auditor.AuditExchange(ctx, ex); err != nil {
|
|
return fmt.Errorf("failed to audit %s: %w", ex, err)
|
|
}
|
|
}
|
|
} else {
|
|
if err := auditor.AuditExchange(ctx, exchange); err != nil {
|
|
return fmt.Errorf("failed to audit %s: %w", exchange, err)
|
|
}
|
|
}
|
|
|
|
return auditor.GenerateReport()
|
|
}
|
|
|
|
func runRealtimeAudit(ctx context.Context, auditor *internal.ProfitabilityAuditor, exchange string, duration time.Duration) error {
|
|
ctx, cancel := context.WithTimeout(ctx, duration)
|
|
defer cancel()
|
|
|
|
return auditor.MonitorRealTimeProfit(ctx, exchange)
|
|
}
|