> ## Documentation Index
> Fetch the complete documentation index at: https://docs.eco.com/llms.txt
> Use this file to discover all available pages before exploring further.

# sauce pools

> Choose the pools and the price limits a swap program uses, from the chain's state now. For anyone writing a swap.

`sauce pools` lists every pool of a token pair at the venues whose swaps stop at a price limit, deepest first, with each pool's fee, price and depth.

## Synopsis

```bash theme={null}
sauce pools --chain <slug|id> <token> <token> [--v4-key <fee:spacing>]… [--block <number|tag>] [--json]
sauce pools --chain solana <pay token> <buy token> [--pay <token> [--price-limit <n>] [--per-venue] [--slots <n>]] [--json]
```

## Description

**On an EVM chain**, the command reads every pool of the pair at the venues the registry records on the chain:

* Uniswap V3 and PancakeSwap V3, at each fee tier their factory enables;
* Aerodrome Slipstream, at each tick spacing of each of its CLFactories;
* hookless Uniswap V4 pools at the keys `100:1`, `500:10`, `3000:60` and `10000:200`, plus each `--v4-key`.

A token is a symbol the chain registers ([`sauce globals --tokens`](https://docs.eco.com/sauce-sdk/cli/globals)), or an address; then its decimals and symbol are read from the token, or given as `0x…:8`.

Pools with liquidity at their price come first, deepest first by that liquidity, which is in the same units at every venue for one pair. For each pool the command prints:

* the venue, and the contract a program finds the pool through (`UniswapV3.Factory`), the pool's address, or a V4 pool's id and key;
* its fee, read from the pool; a V4 pool's LP fee and protocol fee come from StateView;
* tick spacing, liquidity, tick and `sqrtPriceX96`;
* for each direction: what one token costs in the other before the fee and with it; that price as the distributed swap's `priceLimit` (pay base units per buy base unit, times 1e18); and how much of the paid token, fee included, moves the price 1% against the taker, walked through the pool's ticks.

Pools with no liquidity at their price are listed after the others as skipped. The last section lists the factories, fee tiers, tick spacings and V4 keys that were checked.

The reads go out in five requests, each one `eth_call` covering every read in it, all at one block. The command names that block: `--block`, or the latest when it starts. Pass the same block to [`sauce simulate --block`](https://docs.eco.com/sauce-sdk/cli/simulate) to run a program on the prices the `priceLimit` was taken from.

**On Solana**, it finds every pool of the pair, with `getProgramAccounts` on each venue's program, at the venues whose swap stops at a price limit: Raydium CLMM, PancakeSwap CLMM, Byreal, Stabble CLMM, Orca Whirlpools, Cropper, DefiTuna, Crema and Phoenix's markets. For each pool:

* its fee, liquidity and price both ways, with the fee and as a swap's `priceLimit`;
* how a program finds it by key, such as `Orca.Whirlpool.pool(USDC, WSOL, 4)`, where its venue finds pools by key;
* its slot for each token paid: the nine accounts a swap at the pool takes (program, pool, config, the two vaults, one more account the swap takes, and three tick arrays), with the System program for each unused one.

A pool the distributed swap skips is listed as skipped, with the reason. A token is a symbol the chain registers (`SOL` for WSOL) or a mint.

`--pay <token>` chooses the pools a distributed swap paying that token takes: within `--price-limit`, one per venue with `--per-venue`, up to `--slots` of them. It prints them in slot order for `main`'s `--args`, with the System program for an empty slot, and their slots as accounts for `--accounts`.

The command sends nothing, and works on preview chains too.

## Options

| Option | Description |
| - | - |
| `--chain <slug\|id>` | The chain the pools are on |
| `--rpc-url <url>` | Your own RPC endpoint for the chain. Default: a built-in public one |
| `--config <file>` | A file of your own endpoints: `{ "rpcUrls": { "<chain id>": "<url>" } }` |
| `--offline` | Read no chain: no endpoint, built-in ones included |
| `--json` | Print one JSON object instead of text |
| `-h, --help` | Show the help |
| `--no-update-check` | Print no notice of a newer `sauce`, and read no registry for one |

### EVM chains only

| Option | Description |
| - | - |
| `--v4-key <fee:spacing>` | Also try this hookless Uniswap V4 pool key, such as `3000:60` |
| `--block <number\|tag>` | Read the pools at this block: a number, or `latest`, `safe`, `finalized`. Default: `latest` |

### Solana only

| Option | Description |
| - | - |
| `--pay <token>` | Choose the pools a distributed swap paying this token takes, and print their slots' accounts |
| `--price-limit <n>` | With `--pay`: only pools whose price with the fee is within this `priceLimit` |
| `--per-venue` | With `--pay`: only the deepest pool of each venue |
| `--slots <n>` | With `--pay`: how many slots the program has. Default: 4 |

## Output

Text on stdout; the endpoint note and any note about a pool that answered wrongly on stderr.

With `--json` on an EVM chain:

| Field | Contents |
| - | - |
| `chain`, `block` | The chain and the block every read was made at |
| `tokens` | The pair, in the chain's order |
| `sortedBy` | What the pools are sorted by |
| `units` | What each number means, in words |
| `pools` | Each pool: `venue`, `contract`, `contractAddress`, `pool`, `fee`, `tickSpacing`, `liquidity`, `sqrtPriceX96`, `tick`, and `sides`, one per direction with `pay`, `buy`, `feePpm`, `mid`, `taker`, `priceLimit` and `depth1Pct` |
| `empty` | The pools skipped for having no liquidity at their price |
| `checked` | Each factory or StateView read, with its fee tiers, tick spacings or keys |

On Solana, `pools` carries `byKey` and `slots`, `skipped` the pools passed over, and with `--pay`, `chosen`, `poolArgs` and `accounts`.

Exit codes: `0` on success; `1` on Solana when a venue could not be read, with the listing partial and a note naming the venue; `2` for a usage error.

## Examples

### List WETH/USDC pools on Base

```bash theme={null}
sauce pools --chain base WETH USDC
```

```text theme={null}
WETH/USDC on base at block <block>: 24 pools with liquidity, deepest first (by liquidity at the pool's price)
  token0  WETH  0x4200000000000000000000000000000000000006  18 decimals
  token1  USDC  0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913  6 decimals

1.  Uniswap V3 0x6c561B446416E1A00E8E93E221854d6eA4171372
    UniswapV3.Factory 0x33128a8fC17869897dcE68Ed026d694621f6FDfD
    fee 0.3% (read from the pool), tick spacing 60, liquidity 39603938475025901579, tick -198525
    sqrtPriceX96  3874339611902810733848867
    buy USDC with WETH  0.000419439 WETH each, 0.000418181 before the fee; 3888.57 WETH moves it 1%
                        priceLimit 419438832068076680286427500
    buy WETH with USDC  2398.51 USDC each, 2391.31 before the fee; 9625626 USDC moves it 1%
                        priceLimit 2398507319

2.  Aerodrome Slipstream 0x3FE04A59Ebd38cF06080a6F60a98D124eb59392A
    AerodromeSlipstream.CLFactoryGaugesV3 0xf8f2eB4940CFE7d13603DDDD87f123820Fc061Ef
    fee 0.0975% (read from the pool), tick spacing 50, liquidity 1263589966744596942, tick -198504
    sqrtPriceX96  3878281237601202000000000
    buy USDC with WETH  0.000417738 WETH each, 0.000417331 before the fee; 113.087 WETH moves it 1%
                        priceLimit 417738220867428703299540135
    buy WETH with USDC  2398.52 USDC each, 2396.18 before the fee; 275902 USDC moves it 1%
                        priceLimit 2398518512
…

10. Uniswap V4 key 3000:60 (pool id 0x1d8c55f347727c0fb4f5e1b65cdb93639e0c7102580a7d345e1144cd5a718f54)
    UniswapV4.StateView 0xA3c0c9b65baD0b08107Aa264b0f3dB444b867A71
    fee 0.3% + protocol fee 0.05%, tick spacing 60, liquidity 23767013340462875, tick -198527
    sqrtPriceX96  3873904159144749493289898
    …

No liquidity at their price, skipped (2):
  Uniswap V4 key 100:1 (pool id 0xf97566d3f65c048c9fa568ac3346c7970fd8030e62eeb5c0bdf409fe17c7c511)  fee 0.01%: no liquidity at its price
  Uniswap V4 key 10000:200 (pool id 0x4949ca7a256e6eb04214e80f98c890bba07658bc314e42a676bdafa2704662b7)  fee 1%: no liquidity at its price

Looked at:
  UniswapV3.Factory 0x33128a8fC17869897dcE68Ed026d694621f6FDfD: fee tiers 100, 200, 300, 400, 500, 3000, 10000
  PancakeswapV3.Factory 0x0BFbCF9fa4f9C56B0F40a671Ad40E0805A091865: fee tiers 100, 500, 2500, 10000
  AerodromeSlipstream.CLFactory 0x5e7BB104d84c7CB9B682AaC2F3d509f5F406809A: tick spacings 1, 50, 100, 200, 2000, 10
  …
  UniswapV4.StateView 0xA3c0c9b65baD0b08107Aa264b0f3dB444b867A71: hookless keys 100:1, 500:10, 3000:60, 10000:200
```

A pool trades to a program only while its price with its fee is below the `priceLimit` given. To simulate on these prices, pass the block the first line names to `sauce simulate --block`.

### The same as JSON

```bash theme={null}
sauce pools --chain base WETH USDC --json
```

```json theme={null}
{
  "chain": "base",
  "block": <block>,
  "tokens": [ … ],
  "sortedBy": …,
  "units": { … },
  "pools": [
    {
      "venue": "Uniswap V3",
      "contract": "UniswapV3.Factory",
      "contractAddress": "0x33128a8fC17869897dcE68Ed026d694621f6FDfD",
      "pool": "0x6c561B446416E1A00E8E93E221854d6eA4171372",
      "fee": 3000,
      "tickSpacing": 60,
      "liquidity": "39603938475025901579",
      "sqrtPriceX96": "3874339611902810733848867",
      "tick": -198525,
      "sides": [
        {
          "pay": "WETH",
          "buy": "USDC",
          "feePpm": 3000,
          "mid": "0.00041818051557187245",
          "taker": "0.00041943883206807668",
          "means": "0.00041943883206807668 WETH per USDC, fee included",
          "priceLimit": "419438832068076680286427500",
          "depth1Pct": "3888.574614114015826988"
        },
        {
          "pay": "USDC",
          "buy": "WETH",
          "feePpm": 3000,
          "mid": "2391.31179661126646",
          "taker": "2398.50731856696736",
          "means": "2398.50731856696736 USDC per WETH, fee included",
          "priceLimit": "2398507319",
          "depth1Pct": "9625626.14345"
        }
      ]
    },
    …
  ],
  "empty": [ … ],
  "checked": [ … ]
}
```

### List USDC/WSOL pools on Solana

```bash theme={null}
sauce pools --chain solana USDC WSOL
```

```text theme={null}
USDC/WSOL on solana: 44 pools to trade, 46 skipped. Prices are USDC per WSOL paying USDC, then the reverse; a slot is the nine accounts a swap at the pool takes, paying the token named.

Orca Whirlpools Czfq3xZZDmsdGdUyrNLtRhGc47cXcZtLG4crryfu44zE: fee 0.04%, liquidity 864585671961784
  found by key: Orca.Whirlpool.pool(USDC, WSOL, 4)
  paying USDC: 104.44582 USDC per WSOL, 104.48761 with the fee, priceLimit 104487619083185073
  paying WSOL: 0.0095743416 WSOL per USDC, 0.0095781728 with the fee, priceLimit 9578172888209530833
  slot paying USDC: program=whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc pool=Czfq3xZZDmsdGdUyrNLtRhGc47cXcZtLG4crryfu44zE config=11111111111111111111111111111111 vaultA=EUuUbDcafPrmVTD5M6qoJAoyyNbihBhugADAxRMn5he9 vaultB=2WLWEuKDgkDUccTpbwYp1GToYktiSB1cXvreHUwiSUVP extra=FoKYKtRpD25TKzBMndysKpgPqbj8AdLXjfpYHXn9PGTX ticks=…
  …

Raydium CLMM 3ucNos4NbumPLZNWztqGHNFFgkHeRMBQAVemeeomsUxv: fee 0.04%, liquidity 195248378206691
  found by key: Raydium.CLMM.pool(USDC, WSOL, 400)
  …
```

### Choose the pools for a distributed swap on Solana

```bash theme={null}
sauce pools --chain solana USDC WSOL --pay USDC --per-venue --slots 3 --json
```

```json theme={null}
{
  "chain": "solana",
  …
  "chosen": [
    { "venue": "Orca Whirlpools", "pool": "Czfq3xZZDmsdGdUyrNLtRhGc47cXcZtLG4crryfu44zE", "taker": "104.57573" },
    { "venue": "Raydium CLMM", "pool": "3ucNos4NbumPLZNWztqGHNFFgkHeRMBQAVemeeomsUxv", "taker": "104.50327" },
    { "venue": "PancakeSwap CLMM", "pool": "DJNtGuBGEQiUCWE8F981M2C3ZghZt2XLD8f2sQdZ6rsZ", "taker": "104.49125" }
  ],
  "poolArgs": [
    "Czfq3xZZDmsdGdUyrNLtRhGc47cXcZtLG4crryfu44zE",
    "3ucNos4NbumPLZNWztqGHNFFgkHeRMBQAVemeeomsUxv",
    "DJNtGuBGEQiUCWE8F981M2C3ZghZt2XLD8f2sQdZ6rsZ"
  ],
  "accounts": {
    "program0": "whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc",
    "pool0": "Czfq3xZZDmsdGdUyrNLtRhGc47cXcZtLG4crryfu44zE",
    "config0": "11111111111111111111111111111111",
    "vaultA0": "EUuUbDcafPrmVTD5M6qoJAoyyNbihBhugADAxRMn5he9",
    …
  },
  …
}
```

`poolArgs` goes to the program's `--args`, and `accounts` to `--accounts`.

## Next steps

* [`sauce price`](https://docs.eco.com/sauce-sdk/cli/price): convert a price into the same limits.
* [Distributed swap](https://docs.eco.com/quickstarts/sauce/distributed-swap.md) and [Solana distributed swap](https://docs.eco.com/quickstarts/sauce/solana-distributed-swap.md): programs that take these pools and limits.
* [`sauce simulate`](https://docs.eco.com/sauce-sdk/cli/simulate): run a program at the block the pools were read.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.