with votes as (select
block_timestamp,
tx_hash,
event_inputs:"proposalId" as proposal_id,
event_inputs:voter as voter,
case event_inputs:"support"
when '1' then 'for'
when '0' then 'against'
end as side,
event_inputs:votes as n_votes
from ethereum.core.fact_event_logs
where contract_address = '0x5d2c31ce16924c2a71d317e5bbfd5ce387854039'
and event_name = 'VoteCast'),
vote_fee as (
select * from ethereum.core.fact_transactions
where tx_hash in (select tx_hash from votes)
)
select avg(tx_fee) as avg_fee_voting_fee from vote_fee
-- where block_number = 14887882 and tx_hash = '0x783d64b2146de10f7545e1053a6fa58d2846ee78fb5dc30ed635182ac5313e9b'