Query editor
withmaticx_reward_hash AS (SELECTcall_tx_hashFROMmaticx_ethereum.MaticX_call_stakeRewardsAndDistributeFeesWHEREcall_success = true--AND DATE(call_block_time) < DATE_TRUNC('month', current_date)),prices as (SELECTDATE(minute) pdate,symbol,AVG(price) priceFROMprices.usdWHEREsymbol in ('MATIC')and contract_address is nullGROUP BY1,2),final_cte as (SELECTDATE_TRUNC('day', evt_block_time) date,DATE_TRUNC('month', evt_block_time) month,'Polygon' chain,SUM(value * price / POWER(10, 18)) stader_revenue,SUM(value * price * 9 / POWER(10, 18)) supply_side_feeFROMerc20_ethereum.evt_Transfer tk_txnINNER JOIN maticx_reward_hash tx_h ON tk_txn.evt_tx_hash = tx_h.call_tx_hashLEFT JOIN prices p on DATE(evt_block_time) = p.pdatewhereto in (0x80A43dd35382C4919991C5Bca7f46Dd24Fde4C67, 0x01422247a1d15BB4FcF91F5A077Cf25BA6460130)and contract_address = 0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0and "from" = 0xf03A7Eb46d01d9EcAA104558C732Cf82f6B6B645group 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(stader_revenue) OVER (PARTITION BYmonth) monthly_stader_revenue,