h4wkAVAX inflow and outflow CEX
    Updated 2023-04-17
    -- forked from AVAX inflow and outflow @ https://flipsidecrypto.xyz/edit/queries/f3a52f4d-26f3-4b39-9e0c-654ac98dcd06

    with cex_address as (
    select address
    from crosschain.core.address_labels
    where blockchain = 'avalanche'
    and label_type = 'cex'
    ),

    avax_price as (
    select hour::date as price_date,
    avg(price) as avax_price
    from avalanche.core.fact_hourly_token_prices
    where symbol = 'WAVAX'
    group by 1
    ),

    inflow as (
    select *, eth_to_address as user_address from avalanche.core.ez_avax_transfers
    where eth_from_address in (select address from cex_address)
    ),

    outflow as (
    select *, eth_from_address as user_address from avalanche.core.ez_avax_transfers
    where eth_to_address in (select address from cex_address)
    )

    , base as (
    select *, 'Inflow' as type from inflow
    UNION
    select *, 'Outflow' as type from outflow
    )

    select
    type,
    count(distinct user_address) as total_address,
    Run a query to Download Data