jackguyCopy of Copy of Untitled Query copy
    Updated 2023-02-18
    -- forked from ad84f4ae-84da-4193-8429-29caea9d9c26

    with redelegates as (
    select tx_id,
    split(ATTRIBUTE_VALUE,'uatom')[0]::numeric/1e6 as Redelegate_Amount
    from cosmos.core.fact_msg_attributes
    where msg_type = 'redelegate'
    and attribute_key = 'amount'
    and ATTRIBUTE_VALUE ilike '%uatom%'
    and tx_succeeded = 'TRUE'),
    redelegators as (
    select block_timestamp,
    tx_id,
    attribute_value as Redelegator
    from cosmos.core.fact_msg_attributes
    where ATTRIBUTE_KEY= 'spender'
    and tx_id in (select tx_id from redelegates)
    and tx_succeeded = 'TRUE'),

    from_valids as (
    select block_timestamp,
    tx_id,
    attribute_value as Source_Validator
    from cosmos.core.fact_msg_attributes
    where ATTRIBUTE_KEY= 'source_validator'
    and tx_id in (select tx_id from redelegates)
    and tx_succeeded = 'TRUE'),

    to_valids as (
    select block_timestamp,
    tx_id,
    attribute_value as Destination_Validator
    from cosmos.core.fact_msg_attributes
    where ATTRIBUTE_KEY= 'destination_validator'
    and tx_id in (select tx_id from redelegates)
    Run a query to Download Data