Query editor
WITH timeline as (select timestamp as dayfrom utils.dayswhere timestamp >= timestamp '2025-12-15'),-- Step 1: 解包 exchangePricesAndConfig 和 totalAmountsevents AS (SELECTevt_block_time,DATE_TRUNC('day', evt_block_time) AS day,token,-- supplyExchangePrice: bits 91-154,精度 1e12CAST(bitwise_and(bitwise_right_shift(exchangePricesAndConfig, 91),UINT256 '18446744073709551615' -- 0xFFFFFFFFFFFFFFFF) AS double) AS supply_ep,-- borrowExchangePrice: bits 155-218,精度 1e12CAST(bitwise_and(bitwise_right_shift(exchangePricesAndConfig, 155),UINT256 '18446744073709551615') AS double) AS borrow_ep,-- Step 1 中改为不 cast,保持 uint256-- rawSupplyWithInterest BigMath: bits 0-63bitwise_and(totalAmounts, UINT256 '18446744073709551615') AS supply_bm,-- rawBorrowWithInterest BigMath: bits 128-191bitwise_and(bitwise_right_shift(totalAmounts, 128),UINT256 '18446744073709551615') AS borrow_bmFROM fluid_bnb.fluidliquidity_evt_logoperate),-- Step 2: BigMath 解码 → 实际原始数量(token 最小单位)-- Step 2 中 BigMath 解码改为:decoded AS (SELECTevt_block_time,day,token,supply_ep,borrow_ep,-- mantissa = value >> 8,最大 2^56,cast double 安全-- exponent = value & 0xFF,最大 255,cast integer 安全CAST(bitwise_right_shift(supply_bm, 8) AS double)* power(2.0, CAST(bitwise_and(supply_bm, UINT256 '255') AS integer))AS raw_supply,CAST(bitwise_right_shift(borrow_bm, 8) AS double)* power(2.0, CAST(bitwise_and(borrow_bm, UINT256 '255') AS integer))AS raw_borrowFROM events