0-MIDCopy of Top 20 Validators By Stake Count That Mars Borrowers Staked Their $OSMO
    Updated 2023-03-04
    with tab1 as (
    select SENDER
    from osmosis.mars.ez_redbank_actions
    where TX_SUCCEEDED='TRUE'
    and ACTION='borrow'
    and CURRENCY='uosmo'),
    tab2 as (
    select ADDRESS
    ,LABEL_TYPE
    ,PROJECT_NAME
    from osmosis.core.dim_labels
    ),
    tab3 as (
    select RECEIVER
    ,SENDER
    ,TX_ID
    from osmosis.core.fact_transfers
    where TX_SUCCEEDED='TRUE')
    select LABEL_TYPE
    ,PROJECT_NAME
    ,count( TX_ID) as tx_count
    from tab2
    left join tab3
    on tab2.ADDRESS=tab3.RECEIVER
    and tab3.sender in(select sender from tab1)
    group by 1,2

    Run a query to Download Data