# clmm_bitmap_next_initialized_tick

Scans exactly one Uniswap v4-style compressed tick bitmap word. Compression rounds negative non-multiples toward negative infinity. It is deterministic, propagates NULL, and does not fetch adjacent words.

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

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

Scans exactly one Uniswap v4-style compressed tick bitmap word. Compression rounds negative non-multiples toward negative infinity. It is deterministic, propagates NULL, and does not fetch adjacent words.

## Overload 1: clmm_bitmap_next_initialized_tick(INTEGER, INTEGER, UINT256, BOOLEAN)

```sql
clmm_bitmap_next_initialized_tick(INTEGER, INTEGER, UINT256, BOOLEAN)
```

Scans exactly one Uniswap v4-style compressed tick bitmap word. Compression rounds negative non-multiples toward negative infinity. It is deterministic, propagates NULL, and does not fetch adjacent words.

- 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

- `tick` (INTEGER; required; positional) — INTEGER compressed by floor(tick / tick_spacing). Determica currently accepts values outside Uniswap v4's [-887272, 887272] protocol domain.
- `tick_spacing` (INTEGER; required; positional) — INTEGER greater than zero. Determica currently also accepts spacing above Uniswap v4's maximum 32767.
- `bitmap` (UINT256; required; positional) — UINT256 word for the word_pos reported by this call. The caller must supply the correct StateView word; this helper never fetches it.
- `lte` (BOOLEAN; required; positional) — BOOLEAN true scans less-than-or-equal from the compressed tick; false scans strictly greater beginning at compressed tick + 1.

### Returns

One-word tick scan

STRUCT fields: next_tick is compressed_next * tick_spacing; initialized says whether a set bit was found; compressed_next is the selected compressed tick or word boundary; word_pos identifies the searched 256-bit word; bit_pos is the mask origin (the current compressed bit for lte, or compressed + 1 for strict-greater). With no set bit, lte returns the word's lower boundary and strict-greater its upper boundary. NULL input returns NULL; non-positive spacing errors. INTEGER multiplication can exceed the v4 domain because permissive validation is retained.

- `tick_step` (STRUCT(next_tick INTEGER, initialized BOOLEAN, compressed_next INTEGER, word_pos INTEGER, bit_pos UTINYINT))

One-word tick scan. STRUCT fields: next_tick is compressed_next * tick_spacing; initialized says whether a set bit was found; compressed_next is the selected compressed tick or word boundary; word_pos identifies the searched 256-bit word; bit_pos is the mask origin (the current compressed bit for lte, or compressed + 1 for strict-greater). With no set bit, lte returns the word's lower boundary and strict-greater its upper boundary. NULL input returns NULL; non-positive spacing errors. INTEGER multiplication can exceed the v4 domain because permissive validation is retained.

### Examples

_Local SQL · Local_

```sql
WITH current_word AS (
  SELECT clmm_bitmap_next_initialized_tick(
    200311::INTEGER,
    4::INTEGER,
    365375409332725729550921208179070754913983135744::UINT256,
    true
  ) AS scan
)
SELECT
  (scan).next_tick AS next_tick,
  (scan).initialized::VARCHAR AS initialized,
  (scan).compressed_next AS compressed_next,
  (scan).word_pos AS word_pos,
  (scan).bit_pos AS bit_pos
FROM current_word;
-- => [{"next_tick":199680,"initialized":"false","compressed_next":49920,"word_pos":195,"bit_pos":157}]
```

## 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) — See Also
- [clmm_sqrt_price_x96_to_tick](/docs/functions/clmm_sqrt_price_x96_to_tick.md) — See Also
- [clmm_swap_step_x96](/docs/functions/clmm_swap_step_x96.md) — See Also
