RamaharCEXs flow <>
    Updated 2023-04-13
    with CEXs as (select
    * from ethereum.core.dim_labels
    where label_type ilike 'cex'),
    inflow_table as (
    select DATE(block_timestamp) as dayz,
    sum (amount) as in_vol
    from ethereum.core.ez_eth_transfers
    where eth_to_address in (select distinct address from CEXs)
    and eth_from_address not in (select distinct address from CEXs)
    and block_timestamp >= CURRENT_DATE - {{period}}
    group by 1),

    outflow_table as (
    select DATE(block_timestamp) as dt,
    sum (amount) as out_vol
    from ethereum.core.ez_eth_transfers
    where eth_from_address in (select distinct address from CEXs)
    and eth_to_address not in (select distinct address from CEXs)
    and block_timestamp >= CURRENT_DATE - {{period}}
    group by 1)


    select
    dayz,
    in_vol as Inflow,
    - out_vol as Outflow,
    in_vol - out_vol as netflow
    from inflow_table a join outflow_table b on dayz=dt
    Run a query to Download Data