alitaslimiPowers Over Time
    Updated 2023-05-27
    with
    delegated_power_changes as (
    select
    block_timestamp,
    tx_hash,
    case contract_address
    when '0x92d6c1e31e14520e676a687f0a93788b716beff5' then 'DYDX'
    when '0x65f7ba4ec257af7c55fd5854e5f6356bbd0fb8ec' then 'stkDYDX'
    end as symbol,
    decoded_log:amount / 1e18 as amount,
    decoded_log:delegationType as delegation_type,
    decoded_log:user as user
    from
    ethereum.core.ez_decoded_event_logs
    where
    tx_status = 'SUCCESS'
    and event_name = 'DelegatedPowerChanged'
    and contract_address in (
    '0x92d6c1e31e14520e676a687f0a93788b716beff5',
    '0x65f7ba4ec257af7c55fd5854e5f6356bbd0fb8ec'
    )
    ),
    dydx_delegations as (
    select
    block_timestamp,
    tx_hash,
    user,
    delegation_type,
    amount as power,
    amount - zeroifnull(lag(amount) over (partition by user, delegation_type order by block_timestamp)) AS power_change
    from
    delegated_power_changes
    where
    symbol = 'DYDX'
    ),
    stkdydx_delegations as (
    Run a query to Download Data