shreexbase
    Updated 2023-04-03
    with
    delegates as (
    select
    event_inputs:delegator as delegator,
    event_inputs:fromDelegate as from_delegate,
    event_inputs:toDelegate as to_delegate,
    tx_hash as hash,
    block_timestamp as timestamp
    from
    arbitrum.core.fact_event_logs
    WHERE
    contract_address = '0x912ce59144191c1204e64559fe8253a0e49e6548'
    and event_name = 'DelegateChanged'
    -- select
    -- *
    -- from
    -- arbitrum.core.fact_event_logs
    -- where
    -- tx_hash = '0x14989d0c694d6f3cb4c20c3bc0402413d45addcaae7245371576b5d63508df32'
    -- and event_name in ('DelegateVotesChanged', 'DelegateChanged')
    ),
    votes as (
    select
    block_timestamp as date1,
    hash,
    delegator,
    from_delegate,
    to_delegate,
    event_inputs:delegate as delegate,
    event_inputs:newBalance / pow(10, 18) as new_balance,
    event_inputs:previousBalance / pow(10, 18) as previous_balance,
    new_balance-previous_balance as change,
    case when change < 0 then 'Undelegation' else 'Delegation' end as type
    FROM
    arbitrum.core.fact_event_logs
    inner join delegates on hash = tx_hash
    Run a query to Download Data