Query editor
withbnb_rewards_cte AS (SELECTDATE_TRUNC('day', call_block_time) as date,_amount / POWER(10, 18) total_rewards,CASEWHEN DATE(call_block_time) > DATE('2023-02-01') THEN 0.11111111else 0end stader_cutFROMstader_labs_bnb.StakeManager_call_addRestakingRewards--WHERE-- DATE(call_block_time) >= DATE('2024-01-01')),prices as (SELECTDATE(minute) pdate,symbol,AVG(price) priceFROMprices.usdWHEREsymbol in ('BNB')and contract_address is null-- and minute >= DATE('2024-01-01')GROUP BY1,2),base_data as (SELECTdate,DATE_TRUNC('month',date) month,'BSC' chain,SUM((stader_cut * total_rewards) * price) as stader_revenue,SUM(((1 - stader_cut) * total_rewards) * price) as supply_side_feeFROMbnb_rewards_cte brcLEFT JOIN prices as p on brc.date = p.pdateGROUP BY1,2,3ORDER BY1)SELECT*,SUM(stader_revenue) OVER (ORDER BYdate) cumulative_stader_revenue,SUM(supply_side_fee) OVER (ORDER BYdate) cumulative_supply_side_fee,SUM(supply_side_fee) OVER (PARTITION BY month) monthly_supply_side_fee,SUM(stader_revenue) OVER (