InfiRouter
(InfiRouter.sol)
This smart contract serves as the primary entry point and central coordinator for the entire protocol. Its responsibilities include:
State Management: Maintaining the canonical, up-to-date registry of crucial addresses: – ADAPTERS: An array (address[]) containing the deployed contract addresses of all vetted and active DEX Adapter contracts integrated with the protocol. The index of an adapter within this array serves as its unique identifier for routing and execution instructions – TRUSTED_TOKENS: An array (address[]) storing the addresses of liquid and recognized tokens. These tokens act as potential intermediate pivot points for constructing multi-hop swap routes, enabling efficient trades between less liquid token pairs. – WNATIVE: The immutable address of the Wrapped Native Asset contract for the chain. Used for seamless wrapping/unwrapping of the chain’s native currency when interacting with DEXs that primarily operate with the wrapped version. – FEE_CLAIMER & MIN_FEE: Parameters governing the optional protocol fee mechanism
Interface Exposure: Providing the public and external functions defined in the IInfiRouter interface, which include: – Pathfinding Functions: findBestPath(...) and findBestPathWithGas(...) allow users and applications to query the router to discover the optimal swap route based on different optimization criteria (gross output vs. net output). – Swap Execution Functions: swapNoSplit(...) and swapNoSplitWithPermit(...) are used to execute the actual swap along a pre-determined path.
Internal Logic: Containing the implementation of the pathfinding algorithms, the swap execution orchestration, fee calculations, and interactions with WNATIVE
Administration (Maintainable): Incorporating access control mechanisms (e.g., an onlyMaintainer modifier) that allow authorized addresses to perform essential administrative tasks like adding/removing adapters, updating the trusted tokens list, and adjusting fee parameters.
Last updated