Swap Router Overview
Last updated
Last updated
A swap router is an application that allows swaps to take place that span multiple pools.
The price of a token isn't decided by the balance of a single liquidity pool (LP). Most tokens have multiple LPs that connect different ecosystems and projects to each other in the broader defi landscape. For example, even though a large portion of xUSD liquidity is held in the pact stable pool, the protocol also has a significant pool on Tinyman and many other smaller pools with connections to various communities like and . This network of connections is actively maintained by arbitrage bots, so when price changes happen in one pool, they are automatically propagated to other pools in the ecosystem. Arbitrage bots do this because they can make a profit buying in an unbalanced environment and selling to balance the environment. These profits for the bots are paid by the user. Lets talk about how this works.
The diagram above illustrates a comparison of a simple (single pool) swap, compared to a router swap. You can see in the simple swap on the left, the user is trying to buy xUSD using USDC. Since all of this swap is going through the single xUSD/USDC pool, it's only going to affect the price of that single pool. After the swap, the price of xUSD in that pool will be artificially high compared to how other pools are pricing it. Arbitrage bots will notice this, and use other pools in the ecosystem to absorb this price change buying relatively cheaper xUSD from other pools and selling it back into the expensive pool, re-stabilizing the new price across all pools. You can see the arbitrage bots transactions using red arrows. The important point is that this re-stabilization occurs AFTER the user makes the swap, meaning the user is paying more than they should have to, due to the price change occurring only in a single pool.
Compare the simple swap to a routed swap. When using a router a relatively more complicated path is created, using the price values of multiple pools at the same time. The router will look at the state of all xUSD pools and propose a rout that is optimized to give the user the maximum possible profit. To do this, it balances the price change over multiple pools BEFORE the actual swap takes place. This means that when the swap takes place, the user ends up with more of their desired token, and the ecosystem is more balanced. This reduces profit opportunities for the arbitrage bots, keeping the profits in the users wallet.
Beyond spreading user swaps over multiple pools to reduce price variation, there may be momentary imbalances that already exist in the ecosystem. Accurate pricing of each pool allows a router to take advantage of this, effectively performing the service of an arbitrage bot. Returning to the graphic above, imagine that each pool on the right isn't priced identically. The router would then push more of a swap through pools that have a higher value for xUSD to get an increased output returning to the users wallet.
While the benefits of a swap router become more pronounced for larger swaps, that create larger price changes, a router is useful for swaps of any size. Anyone not using a swap router is leaving money on the table for the bots.