shreexDelegations + Proposals
    Updated 2022-12-14
    with shares as (
    select
    tx_from as delegator,
    a.tx_id as txx
    from cosmos.core.fact_msg_attributes a left join cosmos.core.fact_transactions t on t.tx_id=a.tx_id
    where a.tx_succeeded = 'TRUE'
    and msg_type = 'message'
    and attribute_key = 'action'
    and attribute_value = '/cosmos.staking.v1beta1.MsgDelegate'
    ),
    daily_delegates as (
    select
    block_timestamp::date as day,
    trim(attribute_value,'uatom')/pow(10,6) as amount,
    txx,
    delegator
    from cosmos.core.fact_msg_attributes,shares where txx=tx_id
    and tx_succeeded='TRUE' and msg_type='coin_spent' and msg_group='0:0' and attribute_key='amount'
    ),
    validators as (
    select
    day,
    attribute_value as validator,
    delegator,
    amount as delegated_amount,
    txx
    from cosmos.core.fact_msg_attributes left join daily_delegates on txx=tx_id where txx=tx_id
    and attribute_key='validator' and msg_type='delegate' and msg_group='0:0' and tx_succeeded='TRUE'
    ),
    last_step as (
    select
    day,
    validator,
    Run a query to Download Data