Some checks failed
V2 CI/CD Pipeline / Pre-Flight Checks (push) Has been cancelled
V2 CI/CD Pipeline / Build & Dependencies (push) Has been cancelled
V2 CI/CD Pipeline / Code Quality & Linting (push) Has been cancelled
V2 CI/CD Pipeline / Unit Tests (100% Coverage Required) (push) Has been cancelled
V2 CI/CD Pipeline / Integration Tests (push) Has been cancelled
V2 CI/CD Pipeline / Performance Benchmarks (push) Has been cancelled
V2 CI/CD Pipeline / Decimal Precision Validation (push) Has been cancelled
V2 CI/CD Pipeline / Modularity Validation (push) Has been cancelled
V2 CI/CD Pipeline / Final Validation Summary (push) Has been cancelled
Created complete V2 foundation infrastructure for modular MEV bot: Core Types (pkg/types/): - swap.go: SwapEvent with protocol support for 13+ DEXs - pool.go: PoolInfo with multi-index cache support - errors.go: Comprehensive error definitions - Full validation methods and helper functions - Proper decimal scaling (18 decimals internal representation) Parser Interface (pkg/parsers/): - Parser interface for protocol-specific implementations - Factory interface for routing and registration - Support for single log and full transaction parsing - SupportsLog() for dynamic protocol identification Cache Interface (pkg/cache/): - PoolCache interface with multi-index support - O(1) lookups by: address, token pair, protocol, liquidity - Add, Update, Remove, Count, Clear operations - Context-aware for cancellation support Validation Interface (pkg/validation/): - Validator interface for swap events and pools - ValidationRules with configurable thresholds - FilterValid() for batch validation - Zero address, zero amount, decimal precision checks Observability (pkg/observability/): - Logger interface with structured logging (slog) - Metrics interface with Prometheus integration - Performance tracking (parse latency, execution) - Business metrics (arbitrage opportunities, profit) Project Files: - go.mod: Module definition with ethereum and prometheus deps - README.md: Complete project overview and documentation Architecture Principles: - Interface-first design for testability - Single responsibility per interface - Dependency injection ready - Observable by default - 18 decimal internal representation Ready for Phase 1 implementation: - All interfaces defined - Error types established - Core types validated - Logging and metrics infrastructure ready Next: Implement protocol-specific parsers (P2-001 through P2-055) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
72 lines
2.2 KiB
Go
72 lines
2.2 KiB
Go
// Package validation defines the validation interface for swap events and pools
|
|
package validation
|
|
|
|
import (
|
|
"context"
|
|
"math/big"
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
|
|
"github.com/your-org/mev-bot/pkg/types"
|
|
)
|
|
|
|
// Validator defines the interface for validating swap events and pools
|
|
type Validator interface {
|
|
// ValidateSwapEvent validates a swap event
|
|
ValidateSwapEvent(ctx context.Context, event *types.SwapEvent) error
|
|
|
|
// ValidatePoolInfo validates pool information
|
|
ValidatePoolInfo(ctx context.Context, pool *types.PoolInfo) error
|
|
|
|
// FilterValid filters a slice of swap events, returning only valid ones
|
|
FilterValid(ctx context.Context, events []*types.SwapEvent) []*types.SwapEvent
|
|
|
|
// GetValidationRules returns the current validation rules
|
|
GetValidationRules() *ValidationRules
|
|
}
|
|
|
|
// ValidationRules defines the rules for validation
|
|
type ValidationRules struct {
|
|
// Reject zero addresses
|
|
RejectZeroAddresses bool
|
|
|
|
// Reject zero amounts
|
|
RejectZeroAmounts bool
|
|
|
|
// Minimum amount threshold (in wei, scaled to 18 decimals)
|
|
MinAmount *big.Int
|
|
|
|
// Maximum amount threshold (in wei, scaled to 18 decimals)
|
|
MaxAmount *big.Int
|
|
|
|
// Allowed protocols (empty = all allowed)
|
|
AllowedProtocols map[types.ProtocolType]bool
|
|
|
|
// Reject events from blacklisted pools
|
|
BlacklistedPools map[common.Address]bool
|
|
|
|
// Reject events from blacklisted tokens
|
|
BlacklistedTokens map[common.Address]bool
|
|
|
|
// Validate decimal precision
|
|
ValidateDecimals bool
|
|
|
|
// Maximum acceptable slippage (in basis points, e.g. 50 = 0.5%)
|
|
MaxSlippageBps uint32
|
|
}
|
|
|
|
// DefaultValidationRules returns the default validation rules
|
|
func DefaultValidationRules() *ValidationRules {
|
|
return &ValidationRules{
|
|
RejectZeroAddresses: true,
|
|
RejectZeroAmounts: true,
|
|
MinAmount: big.NewInt(1000), // 0.000000000000001 ETH minimum
|
|
MaxAmount: new(big.Int).Exp(big.NewInt(10), big.NewInt(30), nil), // 1 trillion tokens max
|
|
AllowedProtocols: make(map[types.ProtocolType]bool),
|
|
BlacklistedPools: make(map[common.Address]bool),
|
|
BlacklistedTokens: make(map[common.Address]bool),
|
|
ValidateDecimals: true,
|
|
MaxSlippageBps: 50, // 0.5% max slippage
|
|
}
|
|
}
|