NavidCopy of Copy of Copy of Copy of Copy of Untitled Query
Updated 2022-11-29Copy Reference Fork
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
›
⌄
with swaps as (
select
date_trunc('week', block_timestamp) as day,
*
from
osmosis.core.fact_swaps
), token_prices as (
select
date_trunc('week', recorded_at) as day,
address,
symbol,
avg(price) as token_price_usd
from
osmosis.core.dim_prices a join osmosis.core.dim_labels b on a.symbol = b.project_name
where
symbol != 'IOV'
group by
1, 2, 3
)
select
p.symbol,
count(distinct s.tx_id) as transactions_count,
count(distinct trader) as uses_count,
sum(to_amount/pow(10,to_decimal)) as "Volume",
sum(to_amount/pow(10,to_decimal)*token_price_usd) as "Volume (USD)",
row_number() over (order by "Volume (USD)" desc) as rn,
concat(lpad(rn,3,'0'),' - ',p.symbol) as symbolrn
from
swaps s
join token_prices p on s.to_currency=p.address and s.day=p.day
where tx_status='SUCCEEDED'
group by p.symbol
order by p.symbol
Run a query to Download Data