import { Protocol } from "@steerprotocol/sdk"; /** * Protocol configuration interface */ export interface ProtocolConfig { factoryKey: string; quoterKey: string; } /** * Protocol configuration map * Maps Protocol enum to factory and quoter config keys */ export const PROTOCOL_CONFIG_MAP: Partial> = { [Protocol.Sushi]: { factoryKey: "SushiSwapFactory", quoterKey: "QuoterV2Sushi", }, [Protocol.Forge]: { factoryKey: "ForgeFactory", quoterKey: "QuoterV2forge", }, [Protocol.Maia]: { factoryKey: "MaiaFactory", quoterKey: "QuoterV2Maia", }, [Protocol.PancakeSwap]: { factoryKey: "PancakeSwapFactory", quoterKey: "QuoterV2Pancake", }, [Protocol.Retro]: { factoryKey: "RetroFactory", quoterKey: "QuoterV2Retro", }, [Protocol.Kinetix]: { factoryKey: "KinetixFactory", quoterKey: "QuoterV2Kinetix", }, [Protocol.QuickSwap]: { factoryKey: "QuickSwapFactory", quoterKey: "QuoterV2QuickSwap", }, [Protocol.QuickSwapUniv3]: { factoryKey: "QuickSwapUniv3Factory", quoterKey: "QuoterV2QuickSwapUniv3", }, [Protocol.QuickSwapAlgebra]: { factoryKey: "QuickSwapAlgebraFactory", quoterKey: "QuoterV2QuickSwapAlgebra", }, [Protocol.MetaVault]: { factoryKey: "MetaVaultFactory", quoterKey: "QuoterV2MetaVault", }, [Protocol.Lynex]: { factoryKey: "LynexFactory", quoterKey: "QuoterV2Lynex", }, [Protocol.Camelot]: { factoryKey: "CamelotFactory", quoterKey: "QuoterV2Camelot", }, [Protocol.Thena]: { factoryKey: "ThenaFactory", quoterKey: "QuoterV2Thena", }, [Protocol.Horiza]: { factoryKey: "HorizaFactory", quoterKey: "QuoterV2Horiza", }, [Protocol.BaseX]: { factoryKey: "BaseXFactory", quoterKey: "QuoterV2BaseX", }, [Protocol.ArthSwap]: { factoryKey: "ArthSwapFactory", quoterKey: "QuoterV2ArthSwap", }, [Protocol.Crust]: { factoryKey: "CrustFactory", quoterKey: "QuoterV2Crust", }, [Protocol.Hercules]: { factoryKey: "HerculesFactory", quoterKey: "QuoterV2Hercules", }, [Protocol.Thick]: { factoryKey: "ThickFactory", quoterKey: "QuoterV2Thick", }, [Protocol.Thruster]: { factoryKey: "ThrusterFactory", quoterKey: "QuoterV2Thruster", }, [Protocol.FusionX]: { factoryKey: "FusionXFactory", quoterKey: "QuoterV2FusionX", }, [Protocol.SupSwap]: { factoryKey: "SupSwapFactory", quoterKey: "QuoterV2SupSwap", }, [Protocol.SwapMode]: { factoryKey: "SwapModeFactory", quoterKey: "QuoterV2SwapMode", }, [Protocol.BaseSwap]: { factoryKey: "BaseSwapFactory", quoterKey: "QuoterV2BaseSwap", }, [Protocol.PoolShark]: { factoryKey: "PoolSharkFactory", quoterKey: "QuoterV2PoolShark", }, [Protocol.Equilibre]: { factoryKey: "EquilibreFactory", quoterKey: "QuoterV2Equilibre", }, [Protocol.Kim]: { factoryKey: "KimFactory", quoterKey: "QuoterV2Kim", }, [Protocol.Swapsicle]: { factoryKey: "SwapsicleFactory", quoterKey: "QuoterV2Swapsicle", }, [Protocol.Fenix]: { factoryKey: "FenixFactory", quoterKey: "QuoterV2Fenix", }, [Protocol.LineHub]: { factoryKey: "LineHubFactory", quoterKey: "QuoterV2LineHub", }, [Protocol.Henjin]: { factoryKey: "HenjinFactory", quoterKey: "QuoterV2Henjin", }, [Protocol.Spark]: { factoryKey: "SparkFactory", quoterKey: "QuoterV2Spark", }, [Protocol.Spark32]: { factoryKey: "Spark32Factory", quoterKey: "QuoterV2Spark32", }, [Protocol.NovaSwap]: { factoryKey: "NovaSwapFactory", quoterKey: "QuoterV2NovaSwap", }, [Protocol.Ocelex]: { factoryKey: "OcelexFactory", quoterKey: "QuoterV2Ocelex", }, [Protocol.BeamSwap]: { factoryKey: "BeamSwapFactory", quoterKey: "QuoterV2BeamSwap", }, [Protocol.StellaSwap]: { factoryKey: "StellaSwapFactory", quoterKey: "QuoterV2StellaSwap", }, [Protocol.DragonSwap]: { factoryKey: "DragonSwapFactory", quoterKey: "QuoterV2DragonSwap", }, [Protocol.SpookySwap]: { factoryKey: "SpookySwapFactory", quoterKey: "QuoterV2SpookySwap", }, [Protocol.SilverSwap]: { factoryKey: "SilverSwapFactory", quoterKey: "QuoterV2SilverSwap", }, [Protocol.Kodiak]: { factoryKey: "KodiakFactory", quoterKey: "QuoterV2Kodiak", }, [Protocol.ThickV2]: { factoryKey: "ThickV2Factory", quoterKey: "QuoterV2ThickV2", }, [Protocol.Beam]: { factoryKey: "BeamFactory", quoterKey: "QuoterV2Beam", }, [Protocol.QuickSwapIntegral]: { factoryKey: "QuickSwapIntegralFactory", quoterKey: "QuoterV2QuickSwapIntegral", }, [Protocol.Kyo]: { factoryKey: "KyoFactory", quoterKey: "QuoterV2Kyo", }, [Protocol.Sailor]: { factoryKey: "SailorFactory", quoterKey: "QuoterV2Sailor", }, [Protocol.Wasabee]: { factoryKey: "WasabeeFactory", quoterKey: "QuoterV2Wasabee", }, [Protocol.Eddy]: { factoryKey: "EddyFactory", quoterKey: "QuoterV2Eddy", }, [Protocol.Katana]: { factoryKey: "KatanaFactory", quoterKey: "QuoterV2Katana", }, [Protocol.Dodo]: { factoryKey: "UnagiswapFactory", quoterKey: "QuoterV2Unagiswap", }, [Protocol.Glyph]: { factoryKey: "GlyphFactory", quoterKey: "QuoterV2Glyph", }, [Protocol.Shadow]: { factoryKey: "ShadowFactory", quoterKey: "QuoterV2Shadow", }, [Protocol.MachineX]: { factoryKey: "MachineXSwapFactory", quoterKey: "QuoterV2MachineX", }, [Protocol.KatanaIntegral]: { factoryKey: "KatanaIntegralFactory", quoterKey: "QuoterV2KatanaIntegral", }, [Protocol.Blackhole]: { factoryKey: "BlackholeFactory", quoterKey: "QuoterV2Blackhole", }, [Protocol.Aerodrome]: { factoryKey: "AerodromeFactory", quoterKey: "QuoterV2Aerodrome", }, [Protocol.AerodromeV2]: { factoryKey: "AerodromeV2Factory", quoterKey: "QuoterV2AerodromeV2", }, [Protocol.Nest]: { factoryKey: "NestFactory", quoterKey: "QuoterV2Nest", }, // [Protocol.Cypher]: { // factoryKey: "CypherFactory", // quoterKey: "QuoterV2Cypher", // }, }; /** * Default fallback configuration for Uniswap */ export const DEFAULT_PROTOCOL_CONFIG: ProtocolConfig = { factoryKey: "UniswapFactory", quoterKey: "QuoterV2", }; /** * Get protocol configuration keys for a given protocol * Returns factory and quoter config keys (not addresses) * * @param protocol - The protocol enum value * @returns ProtocolConfig with factoryKey and quoterKey */ export function getProtocolConfigKeys(protocol: Protocol | null): ProtocolConfig { if (!protocol) { return DEFAULT_PROTOCOL_CONFIG; } const config = PROTOCOL_CONFIG_MAP[protocol]; if (!config) { return DEFAULT_PROTOCOL_CONFIG; } return config; } /** * Get factory address for a given protocol from network config * * @param protocol - The protocol enum value (null for Uniswap default) * @param networkConfig - Network configuration object with contract addresses * @returns string - Factory contract address * * @example * ```typescript * const factoryAddress = getFactoryAddress(Protocol.QuickSwap, networkConfig); * // Returns networkConfig.QuickSwapFactory.address * ``` */ export function getFactoryAddress(protocol: Protocol | null, networkConfig: any): string { if (!protocol) { return networkConfig[DEFAULT_PROTOCOL_CONFIG.factoryKey].address; } const config = PROTOCOL_CONFIG_MAP[protocol]; if (!config) { return networkConfig[DEFAULT_PROTOCOL_CONFIG.factoryKey].address; } return networkConfig[config.factoryKey].address; } /** * Get quoter V2 address for a given protocol from network config * * @param protocol - The protocol enum value (null for Uniswap default) * @param networkConfig - Network configuration object with contract addresses * @returns string - QuoterV2 contract address * * @example * ```typescript * const quoterAddress = getQuoterV2Address(Protocol.QuickSwap, networkConfig); * // Returns networkConfig.QuoterV2QuickSwap.address * ``` */ export function getQuoterV2Address(protocol: Protocol | null, networkConfig: any): string { if (!protocol) { return networkConfig[DEFAULT_PROTOCOL_CONFIG.quoterKey].address; } const config = PROTOCOL_CONFIG_MAP[protocol]; if (!config) { return networkConfig[DEFAULT_PROTOCOL_CONFIG.quoterKey].address; } return networkConfig[config.quoterKey].address; }