kidaTop 100000 Squid User Swap Stats
    Updated 2023-05-10
    with
    prices as (
    select
    date(block_timestamp) as date,
    lower(replace(feed_name, ' / USD')) as symbol,
    median(coalesce(latest_answer_adj, latest_answer_unadj / pow(10,8))) as price --using median cause there will be some nulls / zeroes
    from ethereum.chainlink.ez_oracle_feeds
    where feed_category = 'Cryptocurrency (USD pairs)'
    and feed_name in ('BTC / USD', 'FIL / USD')
    group by 1,2
    order by 1
    ),

    users as (
    select
    sender as address,
    sum(
    case when contains(lower(token_symbol), p.symbol) then amount * p.price
    else amount
    end
    ) as squid_total_amount_usd_bridged
    from axelar.core.ez_squid s
    left join prices p
    on p.date = s.block_timestamp::date and contains(lower(token_symbol), p.symbol) -- using contains cause wbtc contains btc and axlfil contains fil
    group by 1
    order by 2 desc nulls last
    -- only get top 100000 cause that's the max returned
    limit 100000
    )


    select
    trader as address,
    sum(case when amount_in_usd > amount_out_usd then amount_out_usd
    else amount_in_usd
    end) as total_swap_amount_usd,
    Run a query to Download Data