0-MIDmain
    Updated 2023-04-13
    with tab1 as(
    select BLOCK_TIMESTAMP::date as date,tx_hash,AMOUNT_DEPOSITED
    from ethereum.maker.ez_deposits
    where TOKEN_DEPOSITED='0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
    group by 1,2,3),
    tab2 as (
    select BLOCK_TIMESTAMP::date as date,tx_hash,AMOUNT_WITHDRAWN
    from ethereum.maker.ez_withdrawals
    where TOKEN_WITHDRAWN='0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
    group by 1,2,3)
    select tab2.date,count(distinct tab1.tx_hash),sum(AMOUNT_DEPOSITED)as eth_deposited,sum(AMOUNT_WITHDRAWN)as eth_withdrawn
    ,eth_deposited-eth_withdrawn as eth_tvl,sum(eth_tvl)over(order by tab2.date asc)as total_eth_tvl
    from tab1
    left join tab2
    on tab1.date=tab2.date
    group by 1



    Run a query to Download Data