Sandeshwhy osmo top rewards ? 5
    Updated 2022-07-17
    with top10 as
    (
    with restakes as
    (
    (
    select block_timestamp,TX_ID,currency,decimal,DELEGATOR_ADDRESS,VALIDATOR_ADDRESS as dest,REDELEGATE_SOURCE_VALIDATOR_ADDRESS as source,'normal_unstake' as "stake",'un' as act from osmosis.core.fact_staking
    where action='redelegate'
    and TX_STATUS='SUCCEEDED'
    and block_timestamp > CURRENT_DATE
    )

    )
    select dest,count(tx_id) as cnt from restakes
    group by 1
    order by cnt desc
    limit 10

    ),
    rewards as (

    select fsr.VALIDATOR_ADDRESS,dl.label, sum(fsr.amount) as total_rewards,row_number() over(order by total_rewards desc) as rn from osmosis.core.fact_staking_rewards fsr inner join osmosis.core.dim_labels dl
    on fsr.validator_address=dl.address
    where block_timestamp > CURRENT_DATE - interval ' 90 days'
    group by 1,2
    order by 3 desc
    )
    select * from rewards
    where validator_address in (
    select dest from top10
    )
    order by 3 desc
    limit 5
    Run a query to Download Data