StangFAST05 - Swap all Aurora on all types copy copy
Updated 2023-04-23
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
29
30
31
32
33
34
35
36
›
⌄
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