HosseinUntitled Query
    Updated 2022-11-09
    with prices as (
    select
    date_trunc('day', timestamp) as day,
    avg(price_usd) as price, symbol
    from near.core.fact_prices
    group by day, symbol
    )

    select
    count(distinct (a.tx_hash)) "Volume",
    count(distinct (tx_signer)) "Users",
    count(distinct (pool_id)) "Pools",
    sum (amount_in * price) as "Volume (USD)"
    from near.core.fact_transactions a
    join near.core.ez_dex_swaps b
    join prices c
    on a.tx_hash = b.tx_hash
    and c.day = a.block_timestamp::date
    and symbol = token_in
    where tx_receiver like any ('v2.ref-%', '%-finance.near')
    and tx_status = 'Success'
    Run a query to Download Data