adriaparcerisasnear dash Jumbo 7 swaps by token
    Updated 2023-04-14

    with
    prices as (
    SELECT
    trunc (timestamp,'day') as month,
    symbol,
    token_contract,
    avg(price_usd) as price
    from near.core.fact_prices
    group by 1,2,3
    ),
    ins as (
    SELECT
    date_trunc('month',block_timestamp) as date,
    y.symbol as token,
    count(distinct tx_hash) as swaps,
    sum(swaps) over (order by date) as total_swaps,
    count (distinct trader) as swappers,
    count(*)/swappers as avg_swaps_per_swapper,
    sum(amount_in)*avg(price) as volume_usd,
    sum(volume_usd) over (order by date) as total_volume_swapped,
    avg(amount_in)*avg(price) as avg_volume_swapped
    FROM near.core.ez_dex_swaps x
    join prices y on x.TOKEN_IN_CONTRACT=y.token_contract and trunc(x.block_timestamp,'day')=month
    join near.core.dim_token_labels z on y.symbol=z.symbol
    where block_timestamp >=current_date - INTERVAL '1 YEAR'
    and platform='token.jumbo_exchange.near'
    and amount_out*price<1e9
    group by 1,2
    order by 1 asc
    ),
    outs as (
    SELECT
    date_trunc('month',block_timestamp) as date,
    y.symbol as token,
    count(distinct tx_hash) as swaps,
    Run a query to Download Data