CartanGroupAptos Base - [chain] staking balances
Updated 2023-12-08
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
stake_txs as (
select
date_trunc('day', block_timestamp) as date
, version
, address as pool_address
, change_data :active :value ::int / pow(10,8) as active_stake
, change_data :pending_active :value ::int / pow(10,8) as active_pending
, change_data :inactive :value ::int / pow(10,8) as inactive_stake
, change_data :pending_inactive :value ::int / pow(10,8) as inactive_pending
from aptos.core.fact_changes
where success
and change_type = 'write_resource'
and inner_change_type = '0x1::stake::StakePool'
and block_timestamp > '2022-10-19' -- oldest stake pool change
qualify row_number() over (partition by address, date order by version desc, change_index desc) = 1
),
delegate_txs as (
select
date_trunc('day', block_timestamp) as date
, version
, address as pool_address
, change_data :active_shares :total_coins ::int / pow(10, 8) as active_delegated
, change_data :total_coins_inactive ::int / pow(10, 8) as inactive_delegated
from aptos.core.fact_changes
where success
and change_type = 'write_resource'
and inner_change_type = '0x1::delegation_pool::DelegationPool'
Run a query to Download Data