fix(critical): complete execution pipeline - all blockers fixed and operational
This commit is contained in:
@@ -14,14 +14,16 @@ import (
|
||||
|
||||
// Config represents the application configuration
|
||||
type Config struct {
|
||||
Arbitrum ArbitrumConfig `yaml:"arbitrum"`
|
||||
Bot BotConfig `yaml:"bot"`
|
||||
Uniswap UniswapConfig `yaml:"uniswap"`
|
||||
Log LogConfig `yaml:"log"`
|
||||
Database DatabaseConfig `yaml:"database"`
|
||||
Ethereum EthereumConfig `yaml:"ethereum"`
|
||||
Contracts ContractsConfig `yaml:"contracts"`
|
||||
Arbitrage ArbitrageConfig `yaml:"arbitrage"`
|
||||
Arbitrum ArbitrumConfig `yaml:"arbitrum"`
|
||||
Bot BotConfig `yaml:"bot"`
|
||||
Uniswap UniswapConfig `yaml:"uniswap"`
|
||||
Log LogConfig `yaml:"log"`
|
||||
Database DatabaseConfig `yaml:"database"`
|
||||
Ethereum EthereumConfig `yaml:"ethereum"`
|
||||
Contracts ContractsConfig `yaml:"contracts"`
|
||||
Arbitrage ArbitrageConfig `yaml:"arbitrage"`
|
||||
Features Features `yaml:"features"`
|
||||
ArbitrageOptimized ArbitrageOptimizedConfig `yaml:"arbitrage_optimized"`
|
||||
}
|
||||
|
||||
// ArbitrumConfig represents the Arbitrum node configuration
|
||||
@@ -156,6 +158,8 @@ type ContractsConfig struct {
|
||||
FlashLoanReceiver string `yaml:"flash_loan_receiver"`
|
||||
// Balancer Vault address for flash loans
|
||||
BalancerVault string `yaml:"balancer_vault"`
|
||||
// Data fetcher contract address for batch pool data fetching
|
||||
DataFetcher string `yaml:"data_fetcher"`
|
||||
// Authorized caller addresses
|
||||
AuthorizedCallers []string `yaml:"authorized_callers"`
|
||||
// Authorized DEX addresses
|
||||
@@ -799,3 +803,77 @@ type PoolDiscoveryConfig struct {
|
||||
CacheSize int `yaml:"cache_size"`
|
||||
CacheTTL time.Duration `yaml:"cache_ttl"`
|
||||
}
|
||||
|
||||
// Features represents Layer 2 optimization feature flags
|
||||
type Features struct {
|
||||
// Phase 1: Configuration tuning
|
||||
UseArbitrumOptimizedTimeouts bool `yaml:"use_arbitrum_optimized_timeouts"`
|
||||
UseDynamicTTL bool `yaml:"use_dynamic_ttl"`
|
||||
|
||||
// Phase 2: Transaction filtering
|
||||
EnableDEXPrefilter bool `yaml:"enable_dex_prefilter"`
|
||||
|
||||
// Phase 3: Sequencer optimization
|
||||
UseDirectSequencerFeed bool `yaml:"use_direct_sequencer_feed"`
|
||||
|
||||
// Phase 4-5: Timeboost
|
||||
EnableTimeboost bool `yaml:"enable_timeboost"`
|
||||
}
|
||||
|
||||
// ArbitrageOptimizedConfig represents Arbitrum-optimized arbitrage timing
|
||||
type ArbitrageOptimizedConfig struct {
|
||||
// Opportunity lifecycle (tuned for 250ms blocks)
|
||||
OpportunityTTL time.Duration `yaml:"opportunity_ttl"`
|
||||
MaxPathAge time.Duration `yaml:"max_path_age"`
|
||||
ExecutionDeadline time.Duration `yaml:"execution_deadline"`
|
||||
|
||||
// Legacy values for rollback
|
||||
LegacyOpportunityTTL time.Duration `yaml:"legacy_opportunity_ttl"`
|
||||
LegacyMaxPathAge time.Duration `yaml:"legacy_max_path_age"`
|
||||
|
||||
// Dynamic TTL settings
|
||||
DynamicTTL DynamicTTLConfig `yaml:"dynamic_ttl"`
|
||||
}
|
||||
|
||||
// DynamicTTLConfig represents dynamic TTL calculation settings
|
||||
type DynamicTTLConfig struct {
|
||||
MinTTLBlocks int `yaml:"min_ttl_blocks"`
|
||||
MaxTTLBlocks int `yaml:"max_ttl_blocks"`
|
||||
ProfitMultiplier bool `yaml:"profit_multiplier"`
|
||||
VolatilityAdjustment bool `yaml:"volatility_adjustment"`
|
||||
}
|
||||
|
||||
// GetOpportunityTTL returns the active opportunity TTL based on feature flags
|
||||
func (c *Config) GetOpportunityTTL() time.Duration {
|
||||
if c.Features.UseArbitrumOptimizedTimeouts {
|
||||
return c.ArbitrageOptimized.OpportunityTTL
|
||||
}
|
||||
// Fallback to legacy config
|
||||
if c.Arbitrage.OpportunityTTL > 0 {
|
||||
return c.Arbitrage.OpportunityTTL
|
||||
}
|
||||
// Default fallback
|
||||
return 30 * time.Second
|
||||
}
|
||||
|
||||
// GetMaxPathAge returns the active max path age based on feature flags
|
||||
func (c *Config) GetMaxPathAge() time.Duration {
|
||||
if c.Features.UseArbitrumOptimizedTimeouts {
|
||||
return c.ArbitrageOptimized.MaxPathAge
|
||||
}
|
||||
// Fallback to legacy config
|
||||
if c.Arbitrage.MaxPathAge > 0 {
|
||||
return c.Arbitrage.MaxPathAge
|
||||
}
|
||||
// Default fallback
|
||||
return 60 * time.Second
|
||||
}
|
||||
|
||||
// GetExecutionDeadline returns the execution deadline
|
||||
func (c *Config) GetExecutionDeadline() time.Duration {
|
||||
if c.Features.UseArbitrumOptimizedTimeouts && c.ArbitrageOptimized.ExecutionDeadline > 0 {
|
||||
return c.ArbitrageOptimized.ExecutionDeadline
|
||||
}
|
||||
// Default fallback for Arbitrum (12 blocks @ 250ms)
|
||||
return 3 * time.Second
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
pkgerrors "github.com/fraktal/mev-beta/pkg/errors"
|
||||
)
|
||||
|
||||
// LogLevel represents different log levels
|
||||
@@ -225,6 +227,50 @@ func (l *Logger) Error(v ...interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
// ErrorStructured logs a structured error with full context
|
||||
func (l *Logger) ErrorStructured(err *pkgerrors.StructuredError) {
|
||||
if !l.shouldLog(ERROR) {
|
||||
return
|
||||
}
|
||||
|
||||
// Log compact format to main log
|
||||
compactMsg := fmt.Sprintf("%s [%s] %s",
|
||||
time.Now().Format("2006/01/02 15:04:05"),
|
||||
"ERROR",
|
||||
err.FormatCompact())
|
||||
l.logger.Println(compactMsg)
|
||||
|
||||
// Log full detailed format to error log
|
||||
fullMsg := fmt.Sprintf("%s [%s] %s",
|
||||
time.Now().Format("2006/01/02 15:04:05"),
|
||||
"ERROR",
|
||||
err.FormatForLogging())
|
||||
l.errorLogger.Println(fullMsg)
|
||||
}
|
||||
|
||||
// WarnStructured logs a structured warning with full context
|
||||
func (l *Logger) WarnStructured(err *pkgerrors.StructuredError) {
|
||||
if !l.shouldLog(WARN) {
|
||||
return
|
||||
}
|
||||
|
||||
// Log compact format to main log
|
||||
compactMsg := fmt.Sprintf("%s [%s] %s",
|
||||
time.Now().Format("2006/01/02 15:04:05"),
|
||||
"WARN",
|
||||
err.FormatCompact())
|
||||
|
||||
// Check if warning should be suppressed
|
||||
for _, substr := range suppressedWarningSubstrings {
|
||||
if strings.Contains(compactMsg, substr) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
l.logger.Println(compactMsg)
|
||||
l.errorLogger.Println(compactMsg)
|
||||
}
|
||||
|
||||
// Opportunity logs a found opportunity with detailed information
|
||||
// This always logs regardless of level since opportunities are critical
|
||||
func (l *Logger) Opportunity(txHash, from, to, method, protocol string, amountIn, amountOut, minOut, profitUSD float64, additionalData map[string]interface{}) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
// ArbitrumTokens contains the addresses of popular tokens on Arbitrum
|
||||
type ArbitrumTokens struct {
|
||||
// Tier 1 - Major Assets
|
||||
WETH common.Address
|
||||
USDC common.Address
|
||||
USDT common.Address
|
||||
@@ -16,13 +17,28 @@ type ArbitrumTokens struct {
|
||||
UNI common.Address
|
||||
GMX common.Address
|
||||
GRT common.Address
|
||||
|
||||
// Tier 2 - DeFi Blue Chips
|
||||
USDCe common.Address // Bridged USDC
|
||||
PENDLE common.Address
|
||||
RDNT common.Address
|
||||
MAGIC common.Address
|
||||
GRAIL common.Address
|
||||
|
||||
// Tier 3 - Additional High Volume
|
||||
AAVE common.Address
|
||||
CRV common.Address
|
||||
BAL common.Address
|
||||
COMP common.Address
|
||||
MKR common.Address
|
||||
}
|
||||
|
||||
// GetArbitrumTokens returns the addresses of popular tokens on Arbitrum
|
||||
func GetArbitrumTokens() *ArbitrumTokens {
|
||||
return &ArbitrumTokens{
|
||||
// Tier 1 - Major Assets
|
||||
WETH: common.HexToAddress("0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"), // Wrapped Ether
|
||||
USDC: common.HexToAddress("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"), // USD Coin (bridged)
|
||||
USDC: common.HexToAddress("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"), // USD Coin (Native)
|
||||
USDT: common.HexToAddress("0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"), // Tether USD
|
||||
ARB: common.HexToAddress("0x912CE59144191C1204E64559FE8253a0e49E6548"), // Arbitrum Token
|
||||
WBTC: common.HexToAddress("0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f"), // Wrapped Bitcoin
|
||||
@@ -31,6 +47,20 @@ func GetArbitrumTokens() *ArbitrumTokens {
|
||||
UNI: common.HexToAddress("0xFa7F8980b0f1E64A2062791cc3b0871572f1F7f0"), // Uniswap
|
||||
GMX: common.HexToAddress("0xfc5A1A6EB076a2C7aD06eD22C90d7E710E35ad0a"), // GMX
|
||||
GRT: common.HexToAddress("0x9623063377AD1B27544C965cCd7342f7EA7e88C7"), // The Graph
|
||||
|
||||
// Tier 2 - DeFi Blue Chips
|
||||
USDCe: common.HexToAddress("0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8"), // USD Coin (Bridged)
|
||||
PENDLE: common.HexToAddress("0x0c880f6761F1af8d9Aa9C466984b80DAb9a8c9e8"), // Pendle
|
||||
RDNT: common.HexToAddress("0x3082CC23568eA640225c2467653dB90e9250AaA0"), // Radiant Capital
|
||||
MAGIC: common.HexToAddress("0x539bdE0d7Dbd336b79148AA742883198BBF60342"), // Magic
|
||||
GRAIL: common.HexToAddress("0x3d9907F9a368ad0a51Be60f7Da3b97cf940982D8"), // Camelot (GRAIL)
|
||||
|
||||
// Tier 3 - Additional High Volume
|
||||
AAVE: common.HexToAddress("0xba5DdD1f9d7F570dc94a51479a000E3BCE967196"), // Aave
|
||||
CRV: common.HexToAddress("0x11cDb42B0EB46D95f990BeDD4695A6e3fA034978"), // Curve
|
||||
BAL: common.HexToAddress("0x040d1EdC9569d4Bab2D15287Dc5A4F10F56a56B8"), // Balancer
|
||||
COMP: common.HexToAddress("0x354A6dA3fcde098F8389cad84b0182725c6C91dE"), // Compound
|
||||
MKR: common.HexToAddress("0x2e9a6Df78E42a30712c10a9Dc4b1C8656f8F2879"), // Maker
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user