diff --git a/pkg/sequencer/decoder.go b/pkg/sequencer/decoder.go index d7ac881..fb29f8b 100644 --- a/pkg/sequencer/decoder.go +++ b/pkg/sequencer/decoder.go @@ -11,9 +11,23 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/rlp" + "github.com/your-org/mev-bot/pkg/config" "github.com/your-org/mev-bot/pkg/validation" ) +// Package-level DEX configuration +var dexConfig *config.DEXConfig + +// InitDEXConfig loads the DEX configuration from file +func InitDEXConfig(configPath string) error { + cfg, err := config.LoadDEXConfig(configPath) + if err != nil { + return fmt.Errorf("failed to load DEX config: %w", err) + } + dexConfig = cfg + return nil +} + // L2MessageKind represents the type of L2 message type L2MessageKind uint8 @@ -233,36 +247,17 @@ func GetSwapProtocol(to *common.Address, data []byte) *DEXProtocol { selector := hex.EncodeToString(data[0:4]) toAddr := to.Hex() - // Map known router addresses (Arbitrum mainnet) - knownRouters := map[string]*DEXProtocol{ - // UniswapV2/V3 - "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506": {Name: "SushiSwap", Version: "V2", Type: "router"}, - "0xE592427A0AEce92De3Edee1F18E0157C05861564": {Name: "UniswapV3", Version: "V1", Type: "router"}, - "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45": {Name: "UniswapV3", Version: "V2", Type: "router"}, - "0xEf1c6E67703c7BD7107eed8303Fbe6EC2554BF6B": {Name: "UniswapUniversal", Version: "V1", Type: "router"}, - - // Camelot - "0xc873fEcbd354f5A56E00E710B90EF4201db2448d": {Name: "Camelot", Version: "V2", Type: "router"}, - "0x1F721E2E82F6676FCE4eA07A5958cF098D339e18": {Name: "Camelot", Version: "V3", Type: "router"}, - - // Balancer - "0xBA12222222228d8Ba445958a75a0704d566BF2C8": {Name: "Balancer", Version: "V2", Type: "vault"}, - - // Curve - "0x7544Fe3d184b6B55D6B36c3FCA1157eE0Ba30287": {Name: "Curve", Version: "V1", Type: "router"}, - - // Kyber - "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5": {Name: "KyberSwap", Version: "V1", Type: "router"}, - "0xC1e7dFE73E1598E3910EF4C7845B68A19f0e8c6F": {Name: "KyberSwap", Version: "V2", Type: "router"}, - - // Aggregators - "0x1111111254EEB25477B68fb85Ed929f73A960582": {Name: "1inch", Version: "V5", Type: "router"}, - "0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57": {Name: "Paraswap", Version: "V5", Type: "router"}, - } - - // Check if it's a known router - if protocol, ok := knownRouters[toAddr]; ok { - return protocol + // Check if it's a known router (from config if loaded, else use fallback) + if dexConfig != nil { + for addr, routerCfg := range dexConfig.Routers { + if addr == toAddr { + return &DEXProtocol{ + Name: routerCfg.Name, + Version: routerCfg.Version, + Type: routerCfg.Type, + } + } + } } // Try to identify by function selector