Afonso_DiazTop symbol
    Updated 2024-12-28
    with

    main as (
    select
    tx_id,
    block_timestamp,
    trader as user,
    nvl(amount_in_usd, amount_out_usd) as amount_usd,
    token_in_symbol as symbol_in,
    token_out_symbol as symbol_out
    from flow.defi.ez_dex_swaps
    where block_timestamp::date between '{{ start_date }}' and '{{ end_date }}'
    and amount_usd <= 1e6
    ),

    symbol_data as (
    select
    symbol,
    count(distinct tx_id) as transactions,
    sum(amount_usd) as total_volume_usd
    from (
    select symbol_in as symbol, tx_id, amount_usd from main
    union all
    select symbol_out as symbol, tx_id, amount_usd from main
    ) combined
    group by symbol
    )

    select
    symbol,
    transactions as total_transactions,
    total_volume_usd
    from symbol_data
    where symbol != 'null'
    order by total_volume_usd desc
    QueryRunArchived: QueryRun has been archived