JonasoVertex I perp + spot (3)
    Updated 2024-12-19
    with

    A as(
    select block_timestamp, trader, amount_usd, 'spot' as type from arbitrum.vertex.ez_spot_trades union all
    select block_timestamp, trader, amount_usd, 'perp' as type from arbitrum.vertex.ez_perp_trades ),

    B as(
    select trader,
    sum(amount_usd) as volume_all,
    count(*) as txs,
    sum(case when type = 'spot' then amount_usd end) as volume_spot,
    sum(case when type = 'perp' then amount_usd end) as volume_perp
    from A
    where block_timestamp >= current_date - interval '30 days'
    and trader not in ('0x0000000000000000000000000000000000000000')
    group by 1
    order by 2 desc
    limit 100)

    select left(trader,10) as trader,
    to_varchar(volume_all,'$999,999,999,999') as volume
    from B
    order by volume_all desc












    QueryRunArchived: QueryRun has been archived