DataShogun1. delegators and delegatees
    Updated 2023-03-22
    WITH
    delegator_delegatee_table AS (
    SELECT
    -- DISTINCT EVENT_NAME
    DATE_TRUNC('day', BLOCK_TIMESTAMP)::date as DATE,
    TX_HASH,
    DECODED_LOG:delegator as DELEGATOR,
    DECODED_LOG:delegatee as DELEGATEE,
    CASE
    WHEN DECODED_LOG:delegationType::float = 0 THEN 'Vote'
    WHEN DECODED_LOG:delegationType::float = 1 THEN 'Proposition'
    END AS delegationType,
    CASE
    WHEN CONTRACT_ADDRESS = '0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9' THEN 'stkAAVE'
    WHEN CONTRACT_ADDRESS = '0x4da27a545c0c5b758a6ba100e3a049001de870f5' THEN 'AAVE'
    END AS TOKEN
    FROM
    ethereum.core.fact_decoded_event_logs
    WHERE
    CONTRACT_ADDRESS IN (
    '0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9',
    '0x4da27a545c0c5b758a6ba100e3a049001de870f5'
    )
    AND EVENT_NAME = 'DelegateChanged'
    ORDER BY
    DATE
    ),
    delegatees_votes_transactions AS (
    SELECT
    DISTINCT
    DATE_TRUNC('day', votes_t.BLOCK_TIMESTAMP)::date as DATE,
    votes_t.GOVERNANCE_CONTRACT,
    votes_t.PROPOSAL_ID,
    votes_t.SUPPORT,
    votes_t.VOTING_POWER,
    votes_t.VOTER AS VOTER_DELEGATEE,
    Run a query to Download Data