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.

Example

Local

1
WITH current_word AS (
2
SELECT clmm_bitmap_next_initialized_tick(
3
200311::INTEGER,
4
4::INTEGER,
5
365375409332725729550921208179070754913983135744::UINT256,
6
true
7
) AS scan
8
)
9
SELECT
10
(scan).next_tick AS next_tick,
11
(scan).initialized::VARCHAR AS initialized,
12
(scan).compressed_next AS compressed_next,
13
(scan).word_pos AS word_pos,
14
(scan).bit_pos AS bit_pos
15
FROM current_word;
16
-- => [{"next_tick":199680,"initialized":"false","compressed_next":49920,"word_pos":195,"bit_pos":157}]
Notebook ready in readonly mode.

API reference

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

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.

Inputs

Name Type Use
tick INTEGER

INTEGER compressed by floor(tick / tick_spacing). Determica currently accepts values outside Uniswap v4's [-887272, 887272] protocol domain.

required positional
tick_spacing INTEGER

INTEGER greater than zero. Determica currently also accepts spacing above Uniswap v4's maximum 32767.

required positional
bitmap UINT256

UINT256 word for the word_pos reported by this call. The caller must supply the correct StateView word; this helper never fetches it.

required positional
lte BOOLEAN

BOOLEAN true scans less-than-or-equal from the compressed tick; false scans strictly greater beginning at compressed tick + 1.

required positional

Returns

Name Type
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.

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