The route building procedure is implemented by three components of the Kinetex internal infrastructure:
Quote Fetcher
Route Finder
Calldata Builder
If users intend to make a deal, they generate a request to exchange assets, passing it through the API Gateway to the internal search and routing services.
The Quote Fetcher service is launched first, the main task of which is to collect rates, liquidity volume, and other parameters necessary for further analysis.
All collected quotes are transferred to the Route Finder service, which determines the best way to exchange any given token between blockchains. The service performs a deep analysis of possible routes using data collected by Quote Fetcher and builds the most optimal route in terms of profitability, speed, and security.
Each integrated DEX and bridge has its own layer in the quote engine that returns the best possible trade option. The Kinetex service compiles them into a list of routes with various combinations of different DEX and bridge quotes. As a result, the user can choose the most suitable route according to their specified priority criteria.
Additionally, Kinetex strives to use existing aggregation solutions to achieve the best results.By integrating popular DEX aggregators whose algorithms search for, prioritize, and optimize routes and distribute liquidity among different DEXes, Kinetex allows users to maximize the overall profit from the transaction.
Besides, Kinetex enables analysis of liquidity volumes in all networks in order to make more profitable intra-chain transactions. Thus, the exchanged asset can be bridged to a neighboring network, exchanged with less slippage, and then returned to the original network.
The Kinetex algorithms take into account that the number of tokens supported by each bridge is limited; therefore, an exchange from a user's asset to a bridge-backed token is often required.
Based on this, the algorithms automatically determine which intermediate token should be used for maximum capital efficiency.
After the route has been built, Calldata Builder helps to form a data package necessary for the transaction. This package is a data structure that stores a set of structures such as SwapStep. The generated data package is signed by the user following the EIP-712 standard to enable further on-chain route verification.