SocioAnalyticaswap
Updated 2024-04-15
999
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 sei_network as (
with swaps as (
select
tx_id,
block_timestamp
from sei.defi.fact_dex_swaps
where block_timestamp::date >= dateadd('day', -{{past_days}}, current_date)
)
,
sei_price as (
SELECT 'SEI' as network,
RECORDED_HOUR as date,
price as last_price
FROM osmosis.price.ez_prices
WHERE symbol = 'SEI'
qualify row_number () over (order by date DESC) = 1
)
,
fee_sei as (
select
count(DISTINCT a.tx_id) as n_swaps,
sum(split(fee,'usei')[0] / pow(10,6)) as total_fee_sei,
avg(split(fee,'usei')[0] / pow(10,6)) as avg_fee_sei,
median(split(fee,'usei')[0] / pow(10,6)) as median_fee_sei
from sei.core.fact_transactions a
inner join swaps b using(tx_id, block_timestamp)
where block_timestamp::date >= dateadd('day', -{{past_days}}, current_date)
)
select
network
,date
,last_price
,n_swaps
,total_fee_sei
QueryRunArchived: QueryRun has been archived