flyingfishLFG Voting totals
    Updated 2024-04-19
    with all_votes AS (
    SELECT
    block_timestamp
    , decoded_instruction :accounts[1] :pubkey ::string AS proposal
    , signers[0] AS signer
    , decoded_instruction:accounts[2]:pubkey AS vote_account
    , decoded_instruction:args:side::int as side
    , decoded_instruction:args:weight / pow(10, 6) as vote_power
    , tx_id
    FROM solana.core.fact_decoded_instructions
    WHERE 1 = 1
    AND block_timestamp > '2024-03-07'
    AND program_id = 'GovaE4iu227srtG2s3tZzB4RmWBzw8sTwrCLZz7kN7rY'
    AND proposal = '6txWyf3guJrhnNJXcAHxnV2oVxBcvebuSbfYsgB3yUKc'
    AND side != 0
    QUALIFY row_number() OVER (PARTITION BY vote_account, signer ORDER BY block_timestamp desc) = 1
    )

    SELECT
    sum(vote_power) AS total_votes
    , count(DISTINCT signer) as unique_voters
    , avg(vote_power) AS avg_votes
    , median(vote_power) as median_votes
    , max(vote_power) AS max_votes
    , min(block_timestamp) as first_vote
    , max(block_timestamp) AS last_vote

    FROM all_votes


    select *
    from ethereum.defi.ez_dex_swaps
    where token_in = lower('0xd1d2eb1b1e90b638588728b4130137d262c87cae')
    limit 10
    QueryRunArchived: QueryRun has been archived