Afonso_Diaz2023-06-17 02:35 AM
Updated 2023-06-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
29
30
31
32
33
34
35
36
›
⌄
with
t as (
select
a.recorded_at::date as date,
symbol,
avg(a.price) as price_usd
from osmosis.core.dim_prices a
where a.symbol in('ATOM')
group by 1, 2
),
t2 as (
select
tx_id,
'Cosmos' as chain,
a.block_timestamp,
tx_from as user,
(split(attribute_value,'uatom')[0]::numeric * price_usd)/1e6 as stake_amount_atom,
stake_amount_atom * price_usd as amount_usd
from cosmos.core.fact_msg_attributes a
join t on block_timestamp::date = t.date and symbol = 'ATOM'
join cosmos.core.fact_transactions b
using(tx_id)
where msg_type = 'delegate'
and a.tx_succeeded = 1
and attribute_key = 'amount'
),
t3 as (
select
date_trunc('month', block_timestamp)::date as month,
count(distinct tx_id) as transactions,
count(distinct user) as stakers,
sum(amount_usd) as volume_usd,
avg(amount_usd) as average_volume_usd,
Run a query to Download Data