Query editor
-- 元クエリ: 2248391 "glp Liquidity distribution2" / https://dune.com/queries/2248391-- glpETH mar15 プールの Mint を tick 帯ごとに展開した流動性分布(2112250 の第 2 弾プール版)。-- 変更点:-- - Spark の `explode(sequence(lowerTick, upperTick, 60))` は Trino に無いので-- `CROSS JOIN UNNEST(sequence(...)) AS t(tick)` に置換。sequence の引数は bigint が要るので cast-- - `(upperTick - lowerTick) / 60` は Trino だと integer 同士で切り捨て除算になるため cast(... as double)-- - amount (uint256) は元クエリどおり CAST(... AS DOUBLE) / 1e6-- - prices.usd に `minute >= now() - interval '7' day` を追加(order by minute desc limit 1 の結果は不変、スキャン量削減)-- - ethprice CTE は元クエリでも最終 SELECT に列として現れない(クロス結合するだけ)ので挙動は同じwithmint_burn as (SELECTCAST(amount AS DOUBLE) / 1e6 as amount,'glpEth' as Token,tickLower AS lowerTick,tickUpper as upperTickFROMvoltz_arbitrum.glpEth_mar15_16days_vamm_evt_Mint),calc as (selectToken,upperTick,lowerTick,amount * (sqrt(power(1.0001, upperTick)) - sqrt(power(1.0001, lowerTick))) as amountfrommint_burn),aggregated as (SELECTlowerTick,upperTick,Token,SUM(amount / abs(cast(upperTick - lowerTick as double) / 60)) over (partition byToken,lowerTick,upperTick) as summFROMcalc),liq_ticks as (SELECTt.tick as tick,casewhen a.Token = 'glpEth' then a.summelse 0end as amount_glpEth_tickFROMaggregated aCROSS JOIN UNNEST(sequence(cast(a.lowerTick as bigint), cast(a.upperTick as bigint), 60)) AS t(tick)),ethprice as (selectprice