Afonso_DiazGrouping txns based on $USD
    Updated 9 days ago
    with pricet as (
    select
    hour::date as date,
    avg(price) as token_price_usd
    from avalanche.price.ez_prices_hourly
    where token_address = '0xb8d7710f7d8349a506b75dd184f05777c82dad0c'
    group by 1
    ),

    main as (
    select
    tx_hash,
    block_timestamp,
    iff(token_in = '0xb8d7710f7d8349a506b75dd184f05777c82dad0c', amount_in, amount_out) as amount,
    coalesce(amount_in_usd, amount_out_usd, amount * token_price_usd) as amount_usd,
    origin_from_address as trader,
    symbol_in,
    symbol_out,
    iff(token_in = '0xb8d7710f7d8349a506b75dd184f05777c82dad0c', 'Sell', 'Buy') as trade_side,
    date_trunc('month', block_timestamp) as trade_date
    from avalanche.defi.ez_dex_swaps
    left join pricet on block_timestamp::date = date
    where '0xb8d7710f7d8349a506b75dd184f05777c82dad0c' in (token_in, token_out)
    )

    select
    case
    when amount_usd < 10 then '$0-9 USD'
    when amount_usd between 10 and 49 then '$10-49 USD'
    when amount_usd between 50 and 99 then '$50-99 USD'
    when amount_usd between 100 and 499 then '$100-499 USD'
    when amount_usd between 500 and 999 then '$500-999 USD'
    when amount_usd between 1000 and 4999 then '$1K-4.9K USD'
    when amount_usd between 5000 and 9999 then '$5K-9.9K USD'
    when amount_usd between 10000 and 49999 then '$10K-49.9K USD'
    when amount_usd between 50000 and 99999 then '$50K-99.9K USD'
    Last run: 9 days ago
    AMOUNT_USD_CATEGORY
    TXN_COUNT
    TOTAL_VOLUME_USD
    1
    $0-9 USD79795403200.980770475
    2
    $10-49 USD405931233939.90647322
    3
    $100K+ USD1007102963.432492212
    4
    $50-99 USD136801106604.32094519
    5
    $100-499 USD277737983181.14316073
    6
    $500-999 USD94927766450.53499942
    7
    $1K-4.9K USD944220732763.2737694
    8
    $5K-9.9K USD5963930060.12
    9
    $10K-49.9K USD1021645874.82
    10
    $50K-99.9K USD155167.92
    10
    364B
    4s