cypherLil Nouns voting activity - balance per voter
    Updated 2022-06-21
    with votes as (select
    block_timestamp,
    tx_hash,
    event_inputs:"proposalId"::integer as proposal_id,
    event_inputs:voter as voter,
    case event_inputs:"support"
    when '1' then 'for'
    when '0' then 'against'
    when '2' then 'abstain'
    end as vote,
    case event_inputs:"support"
    when '1' then 1
    when '0' then -1
    when '2' then 0
    end as vote_math,
    event_inputs:votes as n_votes,
    vote_math * n_votes as total_vote
    from ethereum.core.fact_event_logs
    where contract_address = '0x5d2c31ce16924c2a71d317e5bbfd5ce387854039'
    and event_name = 'VoteCast'),

    voters as (select distinct(voter) as unique_voters
    from votes),

    balances as (select balance_date,
    user_address,
    symbol,
    balance,
    amount_usd
    from flipside_prod_db.ethereum.erc20_balances
    where balance_date = current_date()
    and user_address in (select * from voters)),

    total_balances as (select
    user_address as voter,
    sum(amount_usd) as total_balance
    Run a query to Download Data