// Package parsers defines the parser interface and factory for protocol-specific parsers package parsers import ( "context" "github.com/ethereum/go-ethereum/core/types" mevtypes "github.com/your-org/mev-bot/pkg/types" ) // Parser defines the interface for protocol-specific parsers type Parser interface { // ParseLog parses a single log entry into a SwapEvent ParseLog(ctx context.Context, log types.Log, tx *types.Transaction) (*mevtypes.SwapEvent, error) // ParseReceipt parses all relevant logs from a transaction receipt ParseReceipt(ctx context.Context, receipt *types.Receipt, tx *types.Transaction) ([]*mevtypes.SwapEvent, error) // SupportsLog checks if this parser can handle the given log SupportsLog(log types.Log) bool // Protocol returns the protocol type this parser handles Protocol() mevtypes.ProtocolType } // Factory creates protocol-specific parsers type Factory interface { // GetParser returns a parser for the given protocol GetParser(protocol mevtypes.ProtocolType) (Parser, error) // ParseLog routes a log to the appropriate parser ParseLog(ctx context.Context, log types.Log, tx *types.Transaction) (*mevtypes.SwapEvent, error) // ParseTransaction parses all swap events from a transaction ParseTransaction(ctx context.Context, tx *types.Transaction, receipt *types.Receipt) ([]*mevtypes.SwapEvent, error) // RegisterParser registers a new parser for a protocol RegisterParser(protocol mevtypes.ProtocolType, parser Parser) error }