Smart Routing

Smart routing is a crucial mechanism being used by DerpDEX to optimise the process of swapping tokens for users. It involves dynamically determining the most efficient path for executing a trade across multiple liquidity sources while minimising slippage and maximising trading outcomes. When a user initiate a token swap, DerpDEX checks if the token pool is available and there is sufficient liquidity to the pool. If the liquidity for the token pool is available, the swap analysis like price impact, fee and slippage to the user.

If no liquidity is found for the tokens, the combined multiple pools will be used to execute swap. Swap through multiple route won't affect the trade and routing is done by DerpDEX in the background. Instead by using router contract, DerpDEX will find the most efficient path using all the existing pools.

The smart routing optimises trading routes, splits orders if necessary, and considers gas costs. If no liquidity found, we will use 1inch DEX aggregator to find the routes from other protocols (DEX) on ZkSync Era at the end. This ensures that DerpDEX will work as expected even if it runs lows on liquidity.

Below is the flow stating how tokens are swapped from more than one pool to provide the required token to the user.

Last updated