Query editor
withtimeline as (select timestamp as dayfrom utils.dayswhere timestamp >= timestamp '2025-12-15'), manual_pricing as (select *from "query_5169345"), venusflux_protocol_tokens as (select *from "query_6672715"where blockchain = 'bnb'), venusflux_liquidity_tokens as (select *from "query_6734077"where blockchain = 'bnb'), venusflux_liquidity_operate as (select *from "query_6728443(blockchain='bnb')")-- add previous amounts per token (for fees calculation), venusflux_liquidity_operate_ext as (select*, supply_amount / (supply_exchange_price / 1e12) as supply_amount_raw -- ignore interest free mode for a while, borrow_amount / (borrow_exchange_price / 1e12) as borrow_amount_raw -- ignore interest free mode for a while, sum(coalesce(supply_amount / (supply_exchange_price / 1e12), 0)) over (partition by token_address, blockchain order by block_number asc, event_index asc) as cum_net_deposits_raw, sum(coalesce(borrow_amount / (borrow_exchange_price / 1e12), 0)) over (partition by token_address, blockchain order by block_number asc, event_index asc) as cum_net_borrowed_raw, coalesce(lag(supply_exchange_price, 1) ignore nulls over (partition by token_address, blockchain order by block_number asc, event_index asc), bigint '1000000000000') as supply_exchange_price_prev, coalesce(lag(borrow_exchange_price, 1) ignore nulls over (partition by token_address, blockchain order by block_number asc, event_index asc), bigint '1000000000000') as borrow_exchange_price_prev-- lags for new daily APY/utilization aggregation, coalesce(lag(block_time, 1) over (partition by token_address, blockchain order by block_number asc, event_index asc), block_time) as block_time_prev, coalesce(lag(supply_rate, 1) over (partition by token_address, blockchain order by block_number asc, event_index asc), 0) as supply_rate_prev, coalesce(lag(borrow_rate, 1) over (partition by token_address, blockchain order by block_number asc, event_index asc), 0) as borrow_rate_prev, coalesce(lag(utilization, 1) over (partition by token_address, blockchain order by block_number asc, event_index asc), 0) as utilization_prevfrom venusflux_liquidity_operate), venusflux_daily_liquidity_balances as (selectt.day, tt.token_address, tt.blockchain, tt.symbol, tt.decimals, b.balancefrom timeline as tinner join venusflux_liquidity_tokens as tton t.day >= tt.block_dateasof join (