# clmm_amount1_delta_x96

Computes the Uniswap v4 SqrtPriceMath currency1 delta between two Q64.96 boundaries. Determica requires non-zero uint128 liquidity; arithmetic is deterministic and NULL propagates.

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

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

Computes the Uniswap v4 SqrtPriceMath currency1 delta between two Q64.96 boundaries. Determica requires non-zero uint128 liquidity; arithmetic is deterministic and NULL propagates.

## Overload 1: clmm_amount1_delta_x96(UINT256, UINT256, UINT256, BOOLEAN)

```sql
clmm_amount1_delta_x96(UINT256, UINT256, UINT256, BOOLEAN)
```

Computes the Uniswap v4 SqrtPriceMath currency1 delta between two Q64.96 boundaries. Determica requires non-zero uint128 liquidity; arithmetic is deterministic and 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_a_x96` (UINT256; required; positional) — UINT256 sqrt(currency1/currency0) * 2^96 within the inclusive TickMath bounds.
- `sqrt_price_b_x96` (UINT256; required; positional) — UINT256 boundary in the same orientation; argument order does not matter.
- `liquidity` (UINT256; required; positional) — UINT256 SQL value restricted by Determica to [1, 2^128 - 1].
- `round_up` (BOOLEAN; required; positional) — BOOLEAN true rounds the required amount1 up; false rounds the received amount down.

### Returns

Currency1 delta

UINT256 raw currency1 units computed as liquidity * abs(sqrt_b - sqrt_a) / 2^96. NULL input returns NULL. Invalid sqrt bounds, zero liquidity, liquidity above uint128, or output overflow errors.

- `amount1` (UINT256)

Currency1 delta. UINT256 raw currency1 units computed as liquidity * abs(sqrt_b - sqrt_a) / 2^96. NULL input returns NULL. Invalid sqrt bounds, zero liquidity, liquidity above uint128, or output overflow errors.

### Examples

_Local SQL · Local_

```sql
SELECT format_units(
  clmm_amount1_delta_x96(
    1771666303844022531703651649114164::UINT256 - 79228162514264337593543950336::UINT256,
    1771666303844022531703651649114164::UINT256,
    346116498647157539896::UINT256,
    false
  ),
  18
) AS weth_amount1;
-- => [{"weth_amount1":"346.116498647157539896"}]
```

## 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.

```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_tick_to_sqrt_price_x96](/docs/functions/clmm_tick_to_sqrt_price_x96.md) — Usually After
- [clmm_swap_step_x96](/docs/functions/clmm_swap_step_x96.md) — See Also
- [muldiv](/docs/functions/muldiv.md) — See Also
