omer939-Inflows and Outflows (redux)
    Updated 2022-11-01
    select
    date_trunc('month', block_timestamp) as date,
    CASE
    when contract_address = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' then 'USDC'
    when contract_address = '0xdac17f958d2ee523a2206206994597c13d831ec7' then 'USDT'
    when contract_address = '0x5f98805a4e8be255a32880fdec7f6728c6568ba0' then 'LUSD'
    end as name,
    count (DISTINCT tx_hash) tx_count,
    count (DISTINCT ORIGIN_FROM_ADDRESS ) wallets,
    sum (amount_usd) as usd_vol,
    avg(amount_usd) as avg_usd_vol,
    sum (amount) as vol,
    sum(usd_vol) over (partition by name order by date) as cumu_usd_vol,
    sum(tx_count) over (partition by name order by date) as cumu_tx_count
    from ethereum.core.ez_token_transfers
    where to_address ='0x99c9fc46f92e8a1c0dec1b1747d010903e884be1'
    group by date, name HAVING name is not NULL
    UNION

    select
    date_trunc('month', block_timestamp) as date,
    'ETH' as name,
    count (DISTINCT tx_hash) tx_count,
    count (DISTINCT eth_from_address ) wallets,
    sum (amount_usd) as usd_vol,
    avg(amount_usd) as avg_usd_vol,
    sum (amount) as vol,
    sum(usd_vol) over (partition by name order by date) as cumu_usd_vol,
    sum(tx_count) over (partition by name order by date) as cumu_tx_count
    from ethereum.core.ez_eth_transfers
    where eth_to_address = '0x99c9fc46f92e8a1c0dec1b1747d010903e884be1'
    group by date, name
    Run a query to Download Data