Query editor
with deposits as(with stats as (selectdate_trunc('hour',dp.evt_block_time) as hourr,sum(dp.assets/1e18) as ron_deposited,sum(dp.assets * pr.price /1e18) as usd_deposited,count(distinct owner) as usersfrom liquidron_ronin.liquidron_evt_deposit dpinner join prices.usd pron date_trunc('minute',dp.evt_block_time)=pr.minutewhere 1=1and pr.contract_address=0xe514d9deb7966c8be0ca922de8a064264ea6bcd4group by 1)select *,sum(ron_deposited) over(order by hourr asc) as cum_ron_deposited,sum(usd_deposited) over(order by hourr asc) as cum_usd_depositedfrom stats),withdrawals as(with stats as (selectdate_trunc('hour',wt.evt_block_time) as hourr,sum(wt.assets/1e18) as ron_withdrawn,sum(wt.assets * pr.price /1e18) as usd_withdrawn,count(distinct owner) as users_withdrawingfrom liquidron_ronin.liquidron_evt_withdraw wtinner join prices.usd pron date_trunc('minute',wt.evt_block_time)=pr.minutewhere 1=1and pr.contract_address=0xe514d9deb7966c8be0ca922de8a064264ea6bcd4group by 1)select *,sum(ron_withdrawn) over(order by hourr asc) as cum_ron_withdrawn,sum(usd_withdrawn) over(order by hourr asc) as cum_usd_withdrawnfrom stats)selectdp.*,coalesce(wt.ron_withdrawn, 0) as ron_withdrawn,coalesce(wt.usd_withdrawn, 0 ) as usd_withdrawn,sum(wt.ron_withdrawn) over(order by dp.hourr asc) as cum_ron_withdrawn,coalesce(wt.cum_usd_withdrawn, 0) as cum_usd_withdrawn,coalesce(wt.users_withdrawing, 0) as users_withdrawing,coalesce(dp.ron_deposited,0)-coalesce(wt.ron_withdrawn,0) as net_deposited,coalesce(dp.cum_ron_deposited,0)-coalesce(wt.cum_ron_withdrawn,0) as cum_net_deposited-- (dp.ron_deposited-wt.ron_withdrawn)*pr.price as net_deposited_current_usd,-- (dp.cum_ron_deposited-wt.cum_ron_withdrawn)*pr.price as cum_net_deposited_current_usdfrom deposits dpleft join withdrawals wton dp.hourr=wt.hourr-- left join prices.usd_latest pr-- on dp.hourr=date_trunc('hour',pr.minute)-- where pr.contract_address=0xe514d9deb7966c8be0ca922de8a064264ea6bcd4order by dp.hourr desc