mhmDelegates
Updated 2022-11-17Copy 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
›
⌄
with claims as (
select block_timestamp::date as claim_date, tx_hash, EVENT_INPUTS:recipient as claimer, EVENT_INPUTS:amount/1e18 as op_amount
from optimism.core.fact_event_logs
where EVENT_NAME = 'Claimed'
and CONTRACT_ADDRESS = '0xfedfaf1a10335448b7fa0268f56d2b44dbd357de'
and claim_date < CURRENT_DATE
), delegates as (
select
block_timestamp::date as delegate_date,
l.tx_hash,
EVENT_INPUTS:delegator as delegator,
EVENT_INPUTS:fromDelegate as from_Delegate,
EVENT_INPUTS:toDelegate as to_delegate,
claim_date,
DATEDIFF(day, claim_date, delegate_date) as diff_days
from optimism.core.fact_event_logs l left join claims c on EVENT_INPUTS:delegator = claimer
where CONTRACT_ADDRESS = '0x4200000000000000000000000000000000000042'
and EVENT_NAME = 'DelegateChanged'
and ORIGIN_FUNCTION_SIGNATURE = '0x5c19a95c'
and ORIGIN_FROM_ADDRESS in (select claimer from claims)
), final_data as (
select distinct delegator as user, 'Yes' as delegate from delegates
union all
select distinct claimer as user, 'No' as delegate from claims where claimer not in (select delegator from delegates)
)
select delegate, count(user) as users
from final_data
group by 1
Run a query to Download Data