Query editor
with flux_finanl_sets as(select * from query_7323590),timeline as (select timestamp as dayfrom utils.dayswhere timestamp >= timestamp '2025-12-15'),pre_flux as (selectblock_date as evt_block_date,symbol,SUM(CASE WHEN operation_type in ('Supply','Supply_Collateral','Add_LP','Swap_Sell' )THEN amount_usd ELSE 0 END) AS deposit_amount_usd,-- withdrawSUM(CASE WHEN operation_type in ( 'Withdraw','Withdraw_Collateral','Remove_LP','Swap_Buy' )THEN amount_usd ELSE 0 END) AS withdraw_amount_usd,-- Net columns (deposit - withdraw)SUM(CASE WHEN operation_type in ('Supply','Supply_Collateral','Add_LP','Swap_Sell' ) THEN amount_usd ELSE 0 END) -SUM(CASE WHEN operation_type in ( 'Withdraw','Withdraw_Collateral','Remove_LP','Swap_Buy' ) THEN amount_usd ELSE 0 END) AS net_supply_amount_usd,SUM(amount_usd) FILTER (WHERE operation_type = 'Borrow') AS borrow_usd,SUM(amount_usd) FILTER (WHERE operation_type = 'Repay') AS repay_usd,SUM(amount_usd) FILTER (WHERE operation_type = 'Borrow') - SUM(amount_usd) FILTER (WHERE operation_type = 'Repay') AS net_borrow_usdfromflux_finanl_setsgroup by 1,2),spine AS (SELECT a.day, d.symbolFROM timeline aCROSS JOIN (select token_address,symbol from query_6672715where blockchain = 'bnb'group by 1,2) d),filled AS (SELECTs.day,s.symbol,r.deposit_amount_usd,-- withdrawr.withdraw_amount_usd,-- Net columns (deposit - withdraw)r.net_supply_amount_usd,r.borrow_usd,r.repay_usd,r.net_borrow_usdFROM spine sLEFT JOIN pre_flux rON s.day = r.evt_block_date AND s.symbol = r.symbol)selectdate_trunc('day', (date_trunc('week', (evt_block_date) + interval '3' day)) - interval '3' day) AS week,symbol,sum(deposit_amount_usd)deposit_amount_usd,sum(withdraw_amount_usd)withdraw_amount_usd,sum(net_supply_amount_usd)net_supply_amount_usd,sum(borrow_usd)borrow_usd,