with actions as (
select
date(block_timestamp) as day,
action,
TX_SIGNER,
stake_amount/1e24 as amount
from
near.core.dim_staking_actions
where block_timestamp>='2022-11-01'
), stakes as (
select
day,
count(distinct TX_SIGNER) as signers
from
actions
where action='Stake'
group by
action, day
), unstakes as (
select
day,
count(distinct TX_SIGNER) as signers
from
actions
where action='Unstake'
group by
action, day
)
select
s.day,
s.signers/u.signers as ratio
from
stakes s join unstakes u on s.day=u.day