elsina✅ 1. Transactions: fee
Updated 2023-03-15Copy 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
›
⌄
with price as (
select
date_trunc('day', recorded_at) as date,
avg(price) as osmo_usd
from osmosis.core.dim_prices
where
symbol = 'OSMO'
group by 1
),
info as (
select
date_trunc('week', block_timestamp) as "Day",
sum((substring (fee,0,charindex('uosmo',fee)-1)/pow(10,6)) * osmo_usd) as "fee",
avg((substring (fee,0,charindex('uosmo',fee)-1)/pow(10,6)) * osmo_usd) as "Avg tx fee",
avg("fee") over (order by "Day", "Day" rows between 6 preceding and current row) as "MA7 fee",
sum("fee") over (order by "Day") as "Cum fee"
from osmosis.core.fact_transactions join price on block_timestamp::date = date
where fee like '%uosmo%'
group by 1
),
avg_info as (
select
avg("fee") as "AVG fee",
avg("Avg tx fee") as "AVG tx fee per day"
from info
)
select *
from info, avg_info
order by "Day"
Run a query to Download Data