Moeosmosis - swap distribution
Updated 2024-03-05
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 price_tb as (select
RECORDED_HOUR::date as day,
CURRENCY,
avg (price) as price
from osmosis.price.ez_prices
group by 1,2)
, swap_table as (
select
s.*,
p1.price * FROM_AMOUNT / pow(10, from_decimal) as FROM_AMOUNT_USD
from
osmosis.defi.fact_swaps s
left join price_tb p1 on p1.day = block_timestamp :: date
and p1.CURRENCY = from_currency
where
block_timestamp >= current_date - 90
and s.from_decimal is not NULL
and s.from_decimal>0
)
,
base as (
select
tx_id,
sum(FROM_AMOUNT_USD) as swap_amt
from
swap_table
where
FROM_AMOUNT_USD is not null
group by
1
having
swap_amt > 0
QueryRunArchived: QueryRun has been archived