Add enhanced concurrency patterns, rate limiting, market management, and pipeline processing

This commit is contained in:
Krypto Kajun
2025-09-12 01:35:50 -05:00
parent 300976219a
commit fbb85e529a
17 changed files with 1440 additions and 190 deletions

View File

@@ -3,16 +3,17 @@ package main
import (
"context"
"fmt"
"log"
"os"
"os/signal"
"syscall"
"time"
"github.com/urfave/cli/v2"
"github.com/your-username/mev-beta/internal/config"
"github.com/your-username/mev-beta/internal/logger"
"github.com/your-username/mev-beta/internal/ratelimit"
"github.com/your-username/mev-beta/pkg/market"
"github.com/your-username/mev-beta/pkg/monitor"
"github.com/your-username/mev-beta/pkg/scanner"
)
func main() {
@@ -40,7 +41,8 @@ func main() {
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
}
@@ -56,8 +58,24 @@ func startBot() error {
log.Info("Starting MEV bot...")
// Create Arbitrum monitor
monitor, err := monitor.NewArbitrumMonitor(cfg.Arbitrum.RPCEndpoint, time.Duration(cfg.Bot.PollingInterval)*time.Second)
// Create rate limiter manager
rateLimiter := ratelimit.NewLimiterManager(&cfg.Arbitrum)
// Create market manager
marketMgr := market.NewMarketManager(&cfg.Uniswap, log)
// Create market scanner
scanner := scanner.NewMarketScanner(&cfg.Bot, log)
// Create Arbitrum monitor with concurrency support
monitor, err := monitor.NewArbitrumMonitor(
&cfg.Arbitrum,
&cfg.Bot,
log,
rateLimiter,
marketMgr,
scanner,
)
if err != nil {
return fmt.Errorf("failed to create Arbitrum monitor: %w", err)
}
@@ -89,6 +107,9 @@ func startBot() error {
// Stop the monitor
monitor.Stop()
// Stop the scanner
scanner.Stop()
log.Info("MEV bot stopped.")
return nil
}