banbannardOsmosis Roles 3
    Updated 2022-07-11
    with base as (select
    delegator_address,
    sum(amount/pow(10,decimal)) as osmo_entered
    from osmosis.core.fact_staking
    where blockchain = 'osmosis'
    and tx_status = 'SUCCEEDED'
    and currency = 'uosmo'
    and action in ('redelegate', 'delegate')
    group by 1),
    base2 as (select
    delegator_address,
    sum(amount/pow(10,decimal)) as osmo_exited
    from osmosis.core.fact_staking
    where blockchain = 'osmosis'
    and tx_status = 'SUCCEEDED'
    and currency = 'uosmo'
    and action = 'undelegate'
    group by 1),

    base3 as (select
    delegator_address,
    min(block_timestamp) as first_enter
    from osmosis.core.fact_staking
    where blockchain = 'osmosis'
    and tx_status = 'SUCCEEDED'
    and amount > 0
    and currency = 'uosmo'
    and action in ('redelegate', 'delegate')
    group by 1),

    base4 as (select
    a.delegator_address,
    sum(amount/pow(10,decimal)) as first_osmo_entered
    from osmosis.core.fact_staking a
    join base3 b
    Run a query to Download Data