0xHaM-dCommunity Pool Spend Proposals Overview
    Updated 2023-02-16
    WITH proposals_detail as (
    select
    block_timestamp,
    attributes:transfer:amount/1e6 as amt,
    attributes:transfer:currency as currency,
    attributes:transfer:recipient as recipient,
    attributes:transfer:sender as sender,
    message_value:contract as contract
    from terra.core.ez_messages
    where message_value:msg:execute:proposal_id is not null
    and amt > 0
    )
    , priceTb as (
    select
    date_trunc('day', recorded_hour) as date,
    avg(close) as luna_price
    from crosschain.core.fact_hourly_prices
    where id = 'terra-luna-2'
    group by 1
    )
    , proposal_vote as (
    SELECT
    PROPOSAL_ID,
    COUNT(DISTINCT tx_id) as vote,
    COUNT(DISTINCT VOTER) as voter,
    sum(CASE
    WHEN VOTE_OPTION_TEXT = 'Yes' THEN 1
    ELSE -1 end) as vote_count
    from terra.core.fact_governance_votes
    where tx_succeeded = 'TRUE'
    and proposal_id not in ('3460')
    group by 1
    -- HAVING vote_count > 0
    )
    , proposals as (
    select
    Run a query to Download Data