freemartianAAVE Price Effect on Regular Users Votes
    Updated 2023-05-10

    with ETH_price AS (
    SELECT
    hour,
    price AS ETH_P
    FROM ethereum.core.fact_hourly_token_prices
    WHERE token_address = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
    AND hour > current_date - 180
    ),

    average_tx_fee AS (
    SELECT
    date_trunc('day', block_timestamp::date) AS time,
    avg(tx_fee) * avg(ETH_P) AS Average_Fee_USD
    FROM ethereum.core.fact_transactions t inner JOIN ETH_price p
    on p.hour::date = block_timestamp::date
    GROUP BY 1),

    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
    ),

    delegate_votes AS (
    SELECT
    date_trunc('day', block_timestamp::date) AS time,
    count(tx_hash) AS Vote_count,
    sum(voting_power)/pow(10,18) AS Voting_powerr
    FROM ethereum.aave.ez_votes
    WHERE voter IN (SELECT delegatee FROM delegatees)
    Run a query to Download Data