adriaparcerisasThe Unstakeeeeers on Osmosis 2
    Updated 2022-07-18
    with
    users as (
    select
    tx_caller_address as unstakers,
    min(block_timestamp) as unstake_time
    from osmosis.core.fact_staking
    where action = 'undelegate' and currency = 'uosmo' and tx_status = 'SUCCEEDED'
    group by 1
    ),
    redelegations as (
    select
    tx_caller_address as user
    from osmosis.core.fact_staking x
    join users y on x.tx_caller_address=y.unstakers and x.block_timestamp>y.unstake_time
    where action = 'redelegate' and currency = 'uosmo' and tx_status = 'SUCCEEDED'
    group by 1
    ),
    lps as (
    select
    liquidity_provider_address as user
    from osmosis.core.fact_liquidity_provider_actions x
    join users y on x.liquidity_provider_address=y.unstakers and x.block_timestamp>y.unstake_time
    where action = 'pool_joined' and currency = 'uosmo' and tx_status = 'SUCCEEDED'
    group by 1
    ),
    swappings as (
    select
    trader as user
    from osmosis.core.fact_swaps x
    join users y on x.trader=y.unstakers and x.block_timestamp>y.unstake_time
    where from_currency = 'uosmo' and tx_status = 'SUCCEEDED'
    group by 1
    )
    select 'Redelegators' as users, count(distinct user) as counts from redelegations
    union
    select 'Loopers' as users, count(distinct user) as counts from lps
    Run a query to Download Data