jkhuhnke11Delegated AAVE By Month
    Updated 2023-05-13
    WITH monthly_v AS (
    SELECT
    voter,
    date_trunc('month', vote_timestamp) as date,
    median(voting_power) as voted_aave
    FROM ethereum.core.ez_snapshot
    WHERE space_id = 'aave.eth'
    GROUP BY voter, date_trunc('month', vote_timestamp)

    UNION

    SELECT
    voter,
    date_trunc('month', block_timestamp) as date,
    median(voting_power / POW(10, 18)) as voted_aave
    FROM ethereum.aave.ez_votes
    GROUP BY voter, date_trunc('month', block_timestamp)
    ),
    monthly_s AS (
    SELECT
    date,
    sum(voted_aave) as tot_aave
    FROM monthly_v
    GROUP BY date
    ),
    delegatees AS (
    SELECT
    decoded_log:delegatee AS Delegatee,
    count(distinct decoded_log:delegator) AS delegated_wallets
    FROM ethereum.core.fact_decoded_event_logs
    WHERE contract_address = '0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9'
    AND event_name in ('DelegateChanged')
    GROUP BY delegatee
    HAVING delegated_wallets > 2
    ),
    cnts AS (
    Run a query to Download Data