davidwallUntitled Query
Updated 2023-01-18Copy Reference Fork
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
›
⌄
--credit : https://app.flipsidecrypto.com/velocity/queries/462268ff-640b-4abe-98f3-5ae76d0fa8b3
select date_trunc (day,block_timestamp) as date,
case when block_timestamp::date = '2022-12-10' then 'December 10'
when block_timestamp::date < '2022-12-10' then 'Previous Days'
when block_timestamp::date > '2022-12-10' then 'Next Days'
end as timespan,
case when from_currency = 'uosmo' and to_currency != 'uosmo' then 'Swaps From LUNA'
when to_currency = 'uosmo' and from_currency != 'uosmo' then 'Swaps To LUNA'
else null end as swap_type,
count (distinct tx_id) as TX_Count,
sum (case when to_currency = 'uosmo' then to_amount/pow(10,to_decimal) end) as "Swap To (BUY) Volume",
sum (case when from_currency = 'uosmo' then from_amount*-1/pow(10,from_decimal) end) as "Swap From (SELL) Volume",
sum (case when to_currency = 'uosmo' then to_amount/pow(10,to_decimal) when from_currency = 'uosmo' then from_amount*-1/pow(10,from_decimal) end) as NET_Volume,
sum (NET_Volume) over (order by date) as Cumulative_NET_Volume
from osmosis.core.fact_swaps
where tx_succeeded = 'TRUE'
and block_timestamp::Date >= '2022-12-03' and block_timestamp::date < '2022-12-18'
and swap_type is not null
group by 1,2,3
order by 1
Run a query to Download Data