Elprognerd12 - daily swap
Updated 2023-02-06
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
›
⌄
with token_price as (select
symbol,
date_trunc('day', TIMESTAMP) AS DATE,
avg(PRICE_USD) as price
from near.core.fact_prices
GROUP BY 1, 2
ORDER BY 2),
t1 as (SELECT
TX_HASH,
BLOCK_TIMESTAMP,
TRADER,
PLATFORM,
TOKEN_IN,
AMOUNT_IN*y.price as usd_price
from near.core.ez_dex_swaps x join token_price y on x.BLOCK_TIMESTAMP::date = y.DATE AND x.TOKEN_IN = y.symbol
)
SELECT
date_trunc('day', BLOCK_TIMESTAMP) as "day",
COUNT(DISTINCT tx_hash) as "Total Number of Swaps",
COUNT(DISTINCT trader) as "Total Number of Swappers",
sum(usd_price) as "Total Volume of Daily Swap (USD)",
avg(usd_price) as "Average Volume of Daily Swap (USD)"
from t1
where block_timestamp >= CURRENT_DATE - INTERVAL '14 days'
GROUP BY 1
ORDER BY 1
Run a query to Download Data