fix(multicall): resolve critical multicall parsing corruption issues
- 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>
This commit is contained in:
@@ -3,6 +3,7 @@ package types
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
)
|
||||
@@ -10,22 +11,49 @@ import (
|
||||
// ArbitrageOpportunity represents a potential arbitrage opportunity
|
||||
// This is the canonical definition used across all packages
|
||||
type ArbitrageOpportunity struct {
|
||||
Path []string // Token path for the arbitrage
|
||||
Pools []string // Pools involved in the arbitrage
|
||||
AmountIn *big.Int // Input amount for the arbitrage
|
||||
Profit *big.Int // Estimated profit in wei
|
||||
NetProfit *big.Int // Net profit after gas costs
|
||||
GasEstimate *big.Int // Estimated gas cost
|
||||
ROI float64 // Return on investment percentage
|
||||
Protocol string // DEX protocol
|
||||
ExecutionTime int64 // Estimated execution time in milliseconds
|
||||
Confidence float64 // 0-1 confidence score
|
||||
PriceImpact float64 // Price impact percentage
|
||||
MaxSlippage float64 // Maximum acceptable slippage
|
||||
TokenIn common.Address // Input token address
|
||||
TokenOut common.Address // Output token address
|
||||
Timestamp int64 // Detection timestamp
|
||||
Risk float64 // Risk assessment score (0-1)
|
||||
ID string // Unique identifier for the opportunity
|
||||
Path []string // Token path for the arbitrage
|
||||
Pools []string // Pools involved in the arbitrage
|
||||
AmountIn *big.Int // Input amount for the arbitrage (wei)
|
||||
Profit *big.Int // Estimated gross profit in wei
|
||||
NetProfit *big.Int // Net profit after gas costs in wei
|
||||
GasEstimate *big.Int // Estimated gas usage cost in wei
|
||||
GasCost *big.Int // Calculated gas cost in wei (optional)
|
||||
EstimatedProfit *big.Int // Cached estimated profit in wei
|
||||
RequiredAmount *big.Int // Capital required to execute in wei
|
||||
ROI float64 // Return on investment percentage
|
||||
Protocol string // DEX protocol
|
||||
ExecutionTime int64 // Estimated execution time in milliseconds
|
||||
Confidence float64 // 0-1 confidence score
|
||||
PriceImpact float64 // Price impact percentage
|
||||
MaxSlippage float64 // Maximum acceptable slippage percentage
|
||||
TokenIn common.Address // Input token address
|
||||
TokenOut common.Address // Output token address
|
||||
Timestamp int64 // Detection timestamp (unix seconds)
|
||||
DetectedAt time.Time // Detection timestamp with higher precision
|
||||
ExpiresAt time.Time // Expiration timestamp
|
||||
Urgency int // Relative urgency (1-10)
|
||||
Risk float64 // Risk assessment score (0-1)
|
||||
Profitable bool // Indicates if opportunity is currently profitable
|
||||
Quantities *OpportunityQuantities // Optional UniversalDecimal snapshots
|
||||
}
|
||||
|
||||
// DecimalAmount serialises a decimal quantity without importing math helpers.
|
||||
type DecimalAmount struct {
|
||||
Value string `json:"value"`
|
||||
Decimals uint8 `json:"decimals"`
|
||||
Symbol string `json:"symbol"`
|
||||
}
|
||||
|
||||
// OpportunityQuantities bundles the primary decimal metrics for an opportunity.
|
||||
type OpportunityQuantities struct {
|
||||
AmountIn DecimalAmount `json:"amount_in"`
|
||||
AmountOut DecimalAmount `json:"amount_out"`
|
||||
GrossProfit DecimalAmount `json:"gross_profit"`
|
||||
NetProfit DecimalAmount `json:"net_profit"`
|
||||
GasCost DecimalAmount `json:"gas_cost"`
|
||||
ProfitPercent DecimalAmount `json:"profit_percentage"`
|
||||
PriceImpact DecimalAmount `json:"price_impact"`
|
||||
}
|
||||
|
||||
// PriceMovement represents a potential price movement
|
||||
|
||||
Reference in New Issue
Block a user