metricsdaoBadger Badge Balances - MDAOACAD
Updated 2023-01-19Copy 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
›
⌄
-- with holders as (
with actions as
(select
case
when event_inputs:"_from"::string = '0x0000000000000000000000000000000000000000'
then event_inputs:"_to"::string
else event_inputs:"_from"::string
end as wallet,
case
when event_inputs:"_from"::string = '0x0000000000000000000000000000000000000000'
then 1
when event_inputs:"_to"::string = '0x0000000000000000000000000000000000000000'
then -1
end as action,
event_inputs:"_id"::string as token_id
from
polygon.core.fact_event_logs
where block_timestamp::date > '2022-01-01'::date
and contract_address = lower('{{Address}}') -- mdaoacad 0x74539714796C0FACc5EA32fB180F7cb04c71e97f
and origin_function_signature = '0xefa43559')
select
token_id,
wallet,
sum(action) as balance
from
actions
where token_id = {{tokenid}} -- token ids available on badger
group by token_id, wallet
order by token_id, wallet
-- )
-- select *
-- from holders
-- where wallet in (lower('0x1409a9ef3450D5d50aAd004f417436e772FbF8fC'),lower('0xda6363c73eeab387a6bd8a3aecaceb742657545c'),lower('0xa0F00e59ef57D82449ACcB05b9512A47b264374b'))
Run a query to Download Data