bachilil nouns voting
Updated 2022-06-21Copy Reference Fork
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
›
⌄
⌄
WITH txns AS
(
SELECT tx_hash,
Round(Sum(gas_used * gas_price),2) AS gas_fees
FROM ethereum.core.fact_transactions
GROUP BY tx_hash ), votingdtls AS
(
SELECT tx_hash,
origin_from_address AS voter,
EVENT_INPUTS:proposalid AS proposal,
EVENT_INPUTS:votes AS votes
FROM ethereum.core.fact_event_logs
WHERE contract_address = '0x5d2c31ce16924c2a71d317e5bbfd5ce387854039'
AND event_name = 'VoteCast' ), gasfees AS
(
SELECT a.voter,
a.proposal,
a.votes,
b.gas_fees
FROM votingdtls a
JOIN txns b
ON a.tx_hash = b.tx_hash ), holdingdtls AS
(
SELECT user_address,
amount_usd
FROM flipside_prod_db.ethereum.erc20_balances
WHERE amount_usd > 0
AND amount_usd IS NOT NULL )
/*select count(distinct voter) as voters, sum(votes) as votes_casted, proposal
from gasfees group by proposal*/
SELECT DISTINCT a.voter,
round(b.amount_usd,2) AS holdings_usd
FROM votingdtls a
JOIN holdingdtls b
ON a.voter = b.user_address
AND b.amount_usd >= 1
Run a query to Download Data