> For the complete documentation index, see [llms.txt](https://docs.aftermath.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aftermath.finance/trade/smart-order-router.md).

# Smart-Order Router

Find the best swap prices on Sui across any DEX, all in one place

Our Smart Order-Router (SOR) is a DEX aggregator. It connects to all of the pools on Aftermath and to any other DEX on Sui that provides an API we can connect to and has sufficient liquidity. When you choose an asset to trade for, the Router searches every DEX on Sui for the best price, even if it doesn't come from one of our own pools.

The trade settings list every aggregated DEX, and you can toggle each one on or off. As new sources of liquidity come online on Sui, we integrate them into the router, so you can get the best price for your swaps in one place.

<figure><img src="https://3284144787-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmeKfXaQnIP3bbI1AdlVX%2Fuploads%2Fgit-blob-3d2806db52ac78b728e22d2b9aba59dc632f5cac%2Fincluded-dexes.png?alt=media" alt="" width="375"><figcaption><p>Liquidity sources integrated by the Aftermath Smart-Order Router</p></figcaption></figure>

The Smart-Order Router can also split a single swap into multiple sub-paths. Part of the swap can route through one or more pools on one DEX, while other sub-paths complete the rest of the trade. This helps most with large trades, because splitting the trade across pools on multiple DEXes reduces slippage. The aggregator uses Sui's native features, so any route needs only one signed transaction, however many swaps it contains.

Programmable Transaction Blocks (PTB) make the sub-paths possible. A PTB batches multiple related swaps into one atomically executed transaction. A Hot Potato pattern enforces route-wide validity checks so slippage tolerances are not exceeded. It also prevents misuse of coins touched along the route, since some sub-paths involve coins other than the input and output coins the user specified. Because these checks are enforced at the contract level, others can build on top of the SOR without permission.

Other Sui builders can integrate the SOR into their dApps. Current SOR integrations include Aftermath's [Dynamic Gas](/getting-started/dynamic-gas.md) feature, in-wallet swaps on [Nightly wallet](https://twitter.com/Nightly_app), swaps within the [Scallop](https://twitter.com/Scallop_io) Tools UI, and trading through the [Suiba ](https://twitter.com/SuibaOnSUI)Telegram bot.
