KuramaQuery for cosmos sankey
    Updated 2022-12-12
    with table_8 as (
    select distinct tx_id from cosmos.core.fact_msg_attributes
    where tx_succeeded = 'TRUE'
    and msg_type = 'message'
    and attribute_key = 'action'
    and attribute_value = '/cosmos.staking.v1beta1.MsgBeginRedelegate'
    and to_date(block_timestamp) between '2022-10-31' and current_date
    ),

    table_9 as (select distinct tx_id, attribute_value as address from cosmos.core.fact_msg_attributes
    where tx_succeeded = 'TRUE'
    and msg_type = 'transfer'
    and attribute_key = 'sender'
    and msg_index = '2'
    and tx_id in (select * from table_8)),

    table_10 as (select distinct tx_id, attribute_value as validator_from from cosmos.core.fact_msg_attributes
    where tx_succeeded = 'TRUE'
    and msg_type = 'redelegate'
    and attribute_key = 'source_validator'
    and tx_id in (select * from table_8)),

    table_11 as (select distinct tx_id, attribute_value as validator_to from cosmos.core.fact_msg_attributes
    where tx_succeeded = 'TRUE'
    and msg_type = 'redelegate'
    and attribute_key = 'destination_validator'
    and tx_id in (select * from table_8)),

    table_12 as (select distinct tx_id, to_number(SUBSTRING(attribute_value,0,CHARINDEX('uatom',attribute_value)-1))/pow(10,6) as amount from cosmos.core.fact_msg_attributes
    where tx_succeeded = 'TRUE'
    and msg_type = 'redelegate'
    and attribute_key = 'amount'
    and tx_id in (select * from table_8))


    Run a query to Download Data