# clmm_liquidity_for_amounts_x96

Liquidity two token amounts buy in a price range, as Uniswap v3-periphery LiquidityAmounts.getLiquidityForAmounts. Integer math only; NULL propagates.

Canonical HTML: <https://determica.com/docs/functions/clmm_liquidity_for_amounts_x96>

- Kind: scalar function
- Category: [Fixed-point and AMM math](/docs/category/fixed-point-and-amm-math.md)
- Tags: Clmm Math, Deterministic, Offline, Types

Liquidity two token amounts buy in a price range, as Uniswap v3-periphery LiquidityAmounts.getLiquidityForAmounts. Integer math only; NULL propagates.

## Overload 1: clmm_liquidity_for_amounts_x96(UINT256, UINT256, UINT256, UINT256, UINT256)

```sql
clmm_liquidity_for_amounts_x96(UINT256, UINT256, UINT256, UINT256, UINT256)
```

Liquidity two token amounts buy in a price range, as Uniswap v3-periphery LiquidityAmounts.getLiquidityForAmounts. Integer math only; NULL propagates.

- Kind: scalar
- Execution context: Offline
- Behavior: Transform
- Execution modes: Offline
- Input shape: Scalar Arguments
- Planning contract: Runtime
- Cardinality: One Per Input
- Determinism: Deterministic
- Return shape: Scalar
- Schema stability: Fixed
- Stability: Stable
- Side effects: None documented

### Inputs

- `sqrt_price_x96` (UINT256; required; positional) — UINT256 inside inclusive TickMath bounds.
- `sqrt_price_a_x96` (UINT256; required; positional) — UINT256 Q64.96 price; boundary order free.
- `sqrt_price_b_x96` (UINT256; required; positional) — UINT256 Q64.96 price, not equal to first.
- `amount0` (UINT256; required; positional) — UINT256 raw currency0 available.
- `amount1` (UINT256; required; positional) — UINT256 raw currency1 available.

### Returns

Position liquidity

UINT256 liquidity, rounded down: amount0 below range, amount1 above, smaller of both inside. Each side exact before the min, so an unbounded side lets the other bind. NULL input returns NULL; result above 2^128 - 1 or empty range errors.

- `liquidity` (UINT256)

Position liquidity. UINT256 liquidity, rounded down: amount0 below range, amount1 above, smaller of both inside. Each side exact before the min, so an unbounded side lets the other bind. NULL input returns NULL; result above 2^128 - 1 or empty range errors.

### Examples

_Local SQL · Local_

```sql
-- Liquidity of 1860.606774 USDC and 0.844506684178188026 WETH in ticks 197940..198960
SELECT clmm_liquidity_for_amounts_x96('1615992376167869037152219662794366'::UINT256,
  clmm_tick_to_sqrt_price_x96(197940), clmm_tick_to_sqrt_price_x96(198960),
  1860606774::UINT256, 844506684178188026::UINT256)::VARCHAR AS liquidity;
-- => [{"liquidity":"1576006372865616"}]
```

## 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 or bitmap words, resolve dynamic fees or hooks, apply slippage policy, select routes, produce calldata, or return an executable quote. clmm_swap_x96 crosses only the initialized ticks the caller lists.
- Pin onchain reads before use. The six-argument swap-step fee denominator and the bitmap result diagnostics are Determica extensions, not Uniswap v4 interfaces.

```sql
WITH bounds AS (
  SELECT
    clmm_tick_to_sqrt_price_x96(-60) AS sqrt_price_a_x96,
    clmm_tick_to_sqrt_price_x96(60) AS sqrt_price_b_x96
)
SELECT clmm_amount0_delta_x96(
  sqrt_price_a_x96,
  sqrt_price_b_x96,
  1000000::UINT256,
  false
) AS amount0
FROM bounds;
```

## Related functions

- [clmm_amounts_for_liquidity_x96](/docs/functions/clmm_amounts_for_liquidity_x96.md) — Alternative
- [clmm_tick_to_sqrt_price_x96](/docs/functions/clmm_tick_to_sqrt_price_x96.md) — Usually Before
