Query editor
-- methodid tracking-- 0x5f398a14 -- castVoteWithReasonAndParams/*select bytearray_substring(data,1,4) as method_id, count(distinct hash)from arbitrum.transactionswhere to=0x8a1cDA8dee421cD06023470608605934c16A05a0group by 1*/-- logs/*select *from arbitrum.logswhere to=0x8a1cDA8dee421cD06023470608605934c16A05a0and topic0=0x322749465d05e1108aa7ed0309dc429e4d139164e4fd32c5a5d4fd887cfff3c8and evt_tx_hash=0x2d3e3ba3ba5a0118cf8d4ab8a0e7da550aac0d0978734a29ef2d5932ace677cb --eg tx 0x2d3e3ba3ba5a0118cf8d4ab8a0e7da550aac0d0978734a29ef2d5932ace677cb (klausbrave- 0x0393931783b1d0ead3b8b0e0f44c1f23ec3c4af5)and tx_from=0x0393931783b1d0ead3b8b0e0f44c1f23ec3c4af5*/-- deocded data for sc voting, use the totalUsedVotes column as how much votes they have used, and usableVotes as how much votes they have leftWITH latest AS (SELECTa.*,ROW_NUMBER() OVER (PARTITION BY voterORDER BY evt_block_time DESC, evt_block_number DESC, evt_index DESC) AS rn,sum(votes) over(partition by voter order by evt_block_time,evt_block_number,evt_index asc) as votes_cast_cumuFROM arbitrum_arbitrum.SecurityCouncilMemberElectionGovernor_evt_VoteCastForNominee a -- arbitrum_arbitrum.SecurityCouncilNomineeElectionGovernor_evt_VoteCastForContender awhere evt_block_time>= timestamp '2024-10-12'),vote_stats as (select voter as voter_vs, count(distinct evt_tx_hash) as no_votes_tx,count(distinct nominee) as no_contenders_voted_for, sum(votes) as vp_used_votesFROM arbitrum_arbitrum.SecurityCouncilMemberElectionGovernor_evt_VoteCastForNominee a -- arbitrum_arbitrum.SecurityCouncilNomineeElectionGovernor_evt_VoteCastForContender awhere evt_block_time>= timestamp '2024-10-12'group by 1)SELECTrank() OVER (ORDER BY del.votes DESC) AS "rank",del.delegate,voter,COALESCE(b.name, d.name) AS identity,evt_block_time as latest_tx_time,evt_tx_hash as latest_tx_hash,votes_cast_cumu/power(10,18) AS totalusedvotes_t, --using the cumulative votes from the SC (cte)del.votes as usablevotes_t, -- using the delegate's total vp from the other delegate vp query(votes_cast_cumu/power(10,18))/del.votes AS votingpower_remaining_t,totalUsedVotes / POWER(10, 18) AS totalusedvotes, -- using the SC securitycouncil totalusedvotes fieldUsableVotes / POWER(10, 18) AS usablevotes, -- usng the SC securitycouncil UsableVotes field(totalUsedVotes / POWER(10, 18)) / (UsableVotes / POWER(10, 18)) AS votingpower_remaining,(votes_cast_cumu / POWER(10, 18)) / (UsableVotes / POWER(10, 18)) AS votingpower_remaining_f,no_votes_tx,no_contenders_voted_for--vp_used_votes/POWER(10, 18) as vp_used_votes