clmm_next_sqrt_price_from_input_x96

Computes the Uniswap v4 SqrtPriceMath next Q64.96 price for exact input. It is deterministic and propagates NULL.

Example

Local

1
SELECT clmm_next_sqrt_price_from_input_x96(79228162514264337593543950336::UINT256, 1000000000000000000::UINT256, 100000000000000000::UINT256, true)::VARCHAR AS sqrt_price_next_x96;
2
-- => [{"sqrt_price_next_x96":"72025602285694852357767227579"}]
Notebook ready in readonly mode.

API reference

Exact signatures with descriptions, requirements, inputs, returns, and examples.

clmm_next_sqrt_price_from_input_x96(UINT256, UINT256, UINT256, BOOLEAN) #

Computes the Uniswap v4 SqrtPriceMath next Q64.96 price for exact input. It is deterministic and propagates NULL.

Inputs

Name Type Use
sqrt_price_x96 UINT256

UINT256 sqrt(currency1/currency0) * 2^96 within the inclusive TickMath bounds.

required positional
liquidity UINT256

UINT256 SQL value restricted to [1, 2^128 - 1].

required positional
amount_in UINT256

UINT256 raw units of currency0 when zero_for_one, else currency1.

required positional
zero_for_one BOOLEAN

BOOLEAN true swaps currency0 in for currency1 out and lowers price; false swaps currency1 in for currency0 out and raises price.

required positional

Returns

Name Type
sqrt_price_next_x96 UINT256

Next exact-input price. UINT256 next Q64.96 price, using SqrtPriceMath input rounding so the pool is not overpaid. Zero amount returns the current price. NULL input returns NULL. Invalid price, zero or above-uint128 liquidity, price under/overflow, or an out-of-range result errors.

Guidance

Uniswap v4-compatible local math boundary

These generic helpers follow Uniswap v4 core TickMath, SqrtPriceMath, SwapMath, and TickBitmap conventions. Q64.96 square-root price means sqrt(currency1 / currency0) * 2^96, using raw token units.

  • Use them as deterministic evidence about one hydrated pool state, price range, bitmap word, or swap step.
  • They do not fetch state, resolve dynamic fees or hooks, cross ticks and update liquidity, iterate bitmap words, apply slippage policy, select routes, produce calldata, or return a complete executable quote.
  • Pin onchain reads before use. The six-argument swap-step fee denominator and the bitmap result diagnostics are Determica extensions, not Uniswap v4 interfaces.

Local SQL

1
WITH bounds AS (
2
SELECT
3
clmm_tick_to_sqrt_price_x96(-60) AS sqrt_price_a_x96,
4
clmm_tick_to_sqrt_price_x96(60) AS sqrt_price_b_x96
5
)
6
SELECT clmm_amount0_delta_x96(
7
sqrt_price_a_x96,
8
sqrt_price_b_x96,
9
1000000::UINT256,
10
false
11
) AS amount0
12
FROM bounds;
Notebook ready in readonly mode.

Related functions

Category and tags

Tag
Clmm Math
Tag
Offline
Tag
Types