MLDZMNdep2eth
    Updated 2023-05-26
    -- forked from dep2 @ https://flipsidecrypto.xyz/edit/queries/c67e954e-5ebd-47c0-921b-d12c5b5da86d

    with t1 as ( select
    hour::date as day,
    avg(price) as avg_price
    from ethereum.core.fact_hourly_token_prices
    where symbol = 'WETH'
    group by 1)

    select
    s.block_timestamp::date as date,
    'USDC' as token,
    count(distinct x.FROM_ADDRESS) as depositors,
    count(distinct a.tx_hash) as no_deposit,
    sum(tx_fee) as paid_fee,
    sum(tx_fee*avg_price) as paid_fee_usd,
    sum(paid_fee_usd) over (order by date) as total_fee_usd,
    sum(amount_usd) as volume_deposit_usd,
    avg(amount_usd) as avg_deposit_usd,
    sum(volume_deposit_usd) over (order by date) as total_volume_usd
    from ethereum.core.fact_event_logs s
    left join ethereum.core.fact_transactions a on s.tx_hash=a.tx_hash
    join ethereum.core.ez_token_transfers x on s.tx_hash=x.tx_hash
    left join t1 on s.block_timestamp::date=t1.day
    where s.CONTRACT_ADDRESS= lower('0xfb3330531E3f98671296f905cd82CC407d90CE97')
    and s.ORIGIN_FUNCTION_SIGNATURE in ('0x3bc1f1ed')
    --and s.tx_hash='0x4dcf1ce24a0ddef9cfa3ab5434de5af9e2e9ac8b10fb5bc34003ab918eb39037'
    group by 1

    union all

    select
    s.block_timestamp::date as date,
    'ETH' as token,
    count(distinct x.ETH_FROM_ADDRESS) as depositors,
    count(distinct a.tx_hash) as no_deposit,
    Run a query to Download Data