samMost tokens sold by usd amount and swap count
Updated 2022-08-22Copy 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
35
36
›
⌄
with raw_swap as (
select
block_timestamp,
block_timestamp::date as day,
tx_id,
from_amount/ pow(10,from_decimal) as from_token_amount,
case when fl.project_name = 'USDC.axl' then 'axlUSDC'
when fl.project_name = 'DAI.axl' then 'axlDAI'
when fl.project_name = 'WBTC.axl' then 'axlWBTC'
when fl.project_name = 'WETH.axl' then 'axlWETH'
else fl.project_name end as from_token_denom,
concat(from_token_denom, ' - ', fl.label) as from_token_denom_name,
to_amount/ pow(10,to_decimal) as to_token_amount,
case when tl.project_name = 'USDC.axl' then 'axlUSDC'
when tl.project_name = 'DAI.axl' then 'axlDAI'
when tl.project_name = 'WBTC.axl' then 'axlWBTC'
when tl.project_name = 'WETH.axl' then 'axlWETH'
else tl.project_name end as to_token_denom,
concat(to_token_denom, ' - ', tl.label) as to_token_denom_name
from osmosis.core.fact_swaps
left join osmosis.core.dim_labels fl on from_currency = fl.address
left join osmosis.core.dim_labels tl on to_currency = tl.address
where trader = '{{address}}'
and tx_status = 'SUCCEEDED'
),
raw_prices as (
select
recorded_at::date as day,
symbol,
avg(price) as average_price
from osmosis.core.dim_prices
group by day, symbol
Run a query to Download Data