Afonso_Diaz2023-05-20 07:34 PM
    Updated 2023-05-20
    with t as (
    select
    tx_hash,
    block_timestamp,
    'Outflow' as type,
    to_address as user,
    amount_usd
    from ethereum.core.ez_token_transfers
    join ethereum.core.dim_labels
    on address = from_address
    where symbol = 'UNI'
    and label_type = 'cex'

    union all

    select
    tx_hash,
    block_timestamp,
    'Inflow' as type,
    to_address as user,
    amount_usd
    from ethereum.core.ez_token_transfers
    join ethereum.core.dim_labels
    on address = to_address
    where symbol = 'UNI'
    and label_type = 'cex'
    )

    select
    count(distinct tx_hash) as transactions,
    count(distinct iff(type = 'Inflow', tx_hash, null)) as inflow_transactions,
    count(distinct iff(type = 'Outflow', tx_hash, null)) as outflow_transactions,
    inflow_transactions - outflow_transactions as netflow_transactions,
    count(distinct user) as users,
    count(distinct iff(type = 'Inflow', user, null)) as inflow_users,
    count(distinct iff(type = 'Outflow', user, null)) as outflow_users,
    Run a query to Download Data