0xaimanNett ETH Volume Flow onto Optimism
    Updated 2023-04-13

    with ETHopWithdraw as
    (Select block_timestamp as t, origin_from_address as withdraw_address, tx_hash, event_inputs:value/10e17 as vol_eth_withdraw from optimism.core.fact_event_logs

    where --tx_hash ='0x6d06ffabd89dda9f2151eccc6e9b02e6792eaf5dd254bb419e835f63bab02c20' and
    origin_to_address = '0x4200000000000000000000000000000000000010' and
    contract_address = '0xdeaddeaddeaddeaddeaddeaddeaddeaddead0000'
    and event_name ='Burn'),

    wd_vol as (select date_trunc('month', t) as month, sum(vol_eth_withdraw) as tot_vol_eth_withdraw
    from ETHopWithdraw
    group by 1 order by 1),


    ethopdepo as (
    select block_timestamp as t, origin_from_address as eth_depositor, amount,amount_usd
    from ethereum.core.ez_eth_transfers
    where eth_to_address = '0x99c9fc46f92e8a1c0dec1b1747d010903e884be1' and origin_to_address = '0x99c9fc46f92e8a1c0dec1b1747d010903e884be1'),

    depo_vol as (select date_trunc('month', t) as month, sum(amount) as tot_vol_eth_depo
    from ethopdepo
    group by 1 order by 1)


    select depo_vol.month, tot_vol_eth_depo, tot_vol_eth_withdraw,
    sum(tot_vol_eth_depo) OVER(ORDER BY depo_vol.month asc ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS cumm_eth_depo,
    sum(tot_vol_eth_withdraw) OVER(ORDER BY depo_vol.month asc ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS cumm_eth_wd,
    cumm_eth_depo - cumm_eth_wd as nett_volume_flow_eth
    from depo_vol inner join wd_vol on depo_vol.month = wd_vol.month

    order by 1 desc
    --where tt.contract_address ='0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
    --group by 1 order by 2 desc
    Run a query to Download Data