Afonso_Diaz2023-09-27 03:17 PM
    Updated 2023-09-27
    with t as (
    select
    tx_id,
    block_timestamp,
    'From CEX' as type,
    tx_to as user,
    amount as amount_usd
    from solana.core.fact_transfers
    join solana.core.dim_labels
    on address = tx_from
    where label_type = 'cex'
    and mint = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
    and block_timestamp::date >= current_date - interval '{{ days }} days'

    union all

    select
    tx_id,
    block_timestamp,
    'To CEX' as type,
    tx_from as user,
    amount as amount_usd
    from solana.core.fact_transfers
    join solana.core.dim_labels
    on address = tx_to
    where label_type = 'cex'
    and mint = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
    and block_timestamp::date >= current_date - interval '{{ days }} days'
    )

    select
    type,
    count(distinct tx_id) as transactions,
    count(distinct user) as users,
    sum(amount_usd) as volume_usd,
    avg(amount_usd) as average_volume_usd,
    Run a query to Download Data