cypherOsmosis swaps: axlUSDC vs ATOM vs Other stable coins
Updated 2022-11-04
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
›
⌄
-- credits to cryptoicicle
with swap_txns as (
select
s.*,
l1.project_name as token,
from_amount/pow(10, from_decimal) as amount
from osmosis.core.fact_swaps s
join osmosis.core.dim_labels l1 on s.from_currency = l1.address
where token in ('DAI.axl','DAI.grv','USDC.axl','USDC.grv','USDT.axl','USDT.grv', 'USTC','ATOM')
and block_timestamp >= '2022-01-01'
),
atom_price as (select
date_trunc('day', recorded_at) as date,
avg(price) as price
from osmosis.core.dim_prices
where symbol = 'ATOM'
group by date
),
final as (select
date_trunc('day', block_timestamp) as date,
token,
count(distinct(tx_id)) as n_transactions,
count(distinct(trader)) as n_traders,
sum(amount) as amount_swapped
from swap_txns
group by date, token)
select
f.*,
iff(f.token = 'ATOM', f.amount_swapped * p.price, f.amount_swapped) as amount_swapped_usd
from final f, atom_price p
where f.date = p.date
Run a query to Download Data