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>
42 lines
1.4 KiB
Go
42 lines
1.4 KiB
Go
// Package cache defines the pool cache interface for multi-index lookups
|
|
package cache
|
|
|
|
import (
|
|
"context"
|
|
"math/big"
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
|
|
"github.com/your-org/mev-bot/pkg/types"
|
|
)
|
|
|
|
// PoolCache defines the interface for multi-index pool cache
|
|
type PoolCache interface {
|
|
// GetByAddress retrieves a pool by its contract address
|
|
GetByAddress(ctx context.Context, address common.Address) (*types.PoolInfo, error)
|
|
|
|
// GetByTokenPair retrieves all pools for a given token pair
|
|
GetByTokenPair(ctx context.Context, token0, token1 common.Address) ([]*types.PoolInfo, error)
|
|
|
|
// GetByProtocol retrieves all pools for a given protocol
|
|
GetByProtocol(ctx context.Context, protocol types.ProtocolType) ([]*types.PoolInfo, error)
|
|
|
|
// GetByLiquidity retrieves pools sorted by liquidity (descending)
|
|
GetByLiquidity(ctx context.Context, minLiquidity *big.Int, limit int) ([]*types.PoolInfo, error)
|
|
|
|
// Add adds or updates a pool in the cache
|
|
Add(ctx context.Context, pool *types.PoolInfo) error
|
|
|
|
// Update updates pool information
|
|
Update(ctx context.Context, address common.Address, updateFn func(*types.PoolInfo) error) error
|
|
|
|
// Remove removes a pool from the cache
|
|
Remove(ctx context.Context, address common.Address) error
|
|
|
|
// Count returns the total number of pools in the cache
|
|
Count(ctx context.Context) (int, error)
|
|
|
|
// Clear removes all pools from the cache
|
|
Clear(ctx context.Context) error
|
|
}
|