freemartianSwap To Amount USD
Updated 2022-11-16
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 prices as (select
recorded_at::date as day,
symbol,
avg(price) as price_usd
from osmosis.core.dim_prices
where recorded_at > CURRENT_DATE - 60
group by 1, 2),
source as (
select
block_timestamp::date as day,
to_currency,
to_amount/pow(10,to_decimal) as to_adj_amount,
to_adj_amount * c.price_usd as to_usd
from osmosis.core.fact_swaps a LEFT JOIN osmosis.core.dim_labels b on a.to_currency = b.ADDRESS
left join prices c on LOWER(b.PROJECT_NAME) = lower(c.symbol) and c.day = a.block_timestamp::date
where block_timestamp > CURRENT_DATE - 60
and tx_status = 'SUCCEEDED')
select
day,
to_currency,
project_name,
sum(to_usd) as to_amount
from source s inner join osmosis.core.dim_labels l on l.address = s.to_currency
group by 1, 2, 3
having to_amount is not null
Run a query to Download Data