StangFAST05 - Swap all Aurora on all types copy copy
    Updated 2023-04-23
    with

    token_price AS
    (
    SELECT
    date_trunc( 'day' , a.timestamp ) AS day
    , avg( a.price_usd ) AS price_usd
    , a.symbol AS symbol
    FROM
    near.core.fact_prices a

    GROUP BY
    1 , 3
    )

    SELECT
    date_trunc( 'month' , a.block_timestamp ) AS date
    , sum(
    CASE
    when a.token_in = 'AURORA' then a.amount_in * c.price_usd
    when a.token_out = 'AURORA' then a.amount_out * d.price_usd
    END
    ) AS swap_volume

    , b.label_type AS type

    , count( a.trader ) AS users
    , count( a.tx_hash ) AS transactions
    , sum( swap_volume ) over ( partition BY type ORDER BY date ASC ) AS total_swap_volume

    FROM
    near.core.ez_dex_swaps a

    INNER JOIN
    near.core.dim_address_labels b
    Run a query to Download Data