Skip to main content
sauce price turns a price into the numbers a swap program takes: a pool’s sqrtPriceX96, sqrtPriceLimitX96, priceLimit, maxAvgPrice and minAvgPrice.

Synopsis

Description

A price is how many <quote> tokens one <base> token is worth. 2700 USDC per WETH and WETH USDC 2700 are the same price. A token is a symbol the chain registers (sauce globals --tokens), or an address with its decimals (0x…:18). With an endpoint, an address alone works: its decimals are read from the token. The first line states the price both ways round (1 WETH = 2700 USDC, 1 USDC = 0.00037… WETH), since a price written backwards is off by a large factor. Then the command prints the pair’s order on the chain (token0 is the lower address), the pool’s sqrtPriceX96 at that price, and for each direction, selling the base token and then buying it: Uniswap V3 and V4 and their forks share this price format.
  • --sqrt-price-x96 <value> reads a pool’s sqrtPriceX96 back into a price.
  • --pool <address> reads the price now from that pool of the pair: a Uniswap V3, PancakeSwap V3 or Aerodrome Slipstream pool. The output names the pool’s venue when the registry’s factory made it.
  • Without --offline, the command also reads the pair’s price now from its deepest Uniswap V3 pool on the chain, and warns on stderr when the price given is 10 times or more away from it. When the price looks written the wrong way round, the warning says so and gives the command that reads it the right way.
The command sends nothing and works on every chain in the registry, preview chains included. With --offline, it reaches no network. The same conversion is in the TypeScript package as sqrtPriceX96FromPrice and priceFromSqrtPriceX96.

Options

Output

Text on stdout; the endpoint note and any warning on stderr. With --json: Exit codes: 0 on success; 2 for a usage error.

Examples

Convert a price on Base

Buying WETH with USDC at 2700, the priceLimit is 2700000000: 2700 × 10^(18 + 6 − 18). The Live: line is the pool’s price at the time of the run.

Catch a price written backwards

The first line is the warning on stderr. The numbers are still printed, for the price as given.

Read a pool’s price now

Read a sqrtPriceX96 back, offline

Next steps