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

# @kumbaya\_xyz/smart-order-router

Finds the optimal route across Kumbaya's V3 pools for a given swap. Handles multi-hop, splits, and gas-cost-aware route selection.

```bash
npm install @kumbaya_xyz/smart-order-router @kumbaya_xyz/sdk-core ethers@^5
```

> **ethers v5 only.** SOR uses `BaseProvider` from `@ethersproject/providers` v5. Use ethers v5 (`providers.JsonRpcProvider`); v6 and viem providers are not directly compatible.

## Main exports

```ts
import {
  AlphaRouter,           // primary router class
  AlphaRouterParams,
  AlphaRouterConfig,
  // …plus the legacy router and lower-level providers/utilities
} from '@kumbaya_xyz/smart-order-router'
```

`AlphaRouter` is the entry point. It takes `{ chainId: ChainId.MEGAETH | ChainId.MEGAETH_TESTNET, provider: BaseProvider }`, and optionally a long list of provider overrides if you want to plug in your own data sources (subgraph, multicall, gas oracle, etc.).

## Use it when

* You're building a swap UI and need quotes that consider all pools, not just one
* You want the optimal route, not just *a* route
* You're OK with the SOR being heavier than `QuoterV2` - it does substantially more work

For one-shot quotes you don't want to compute client-side, use the hosted [**Exchange API `/api/v1/quote`**](/developers/apis/exchange-api/quote.md) endpoint instead.

## Quick example

See [**Quoting prices → Option 2**](/developers/dex-integration/quoting.md#option-2-smart-order-router-client-side) for a runnable example.

The upstream [`@uniswap/smart-order-router` docs](https://github.com/Uniswap/smart-order-router) cover the API surface in more detail - Kumbaya's fork is configured for MegaETH and uses Kumbaya's pool init code hash internally.
