intensodefitestv1
Updated 2022-08-23Copy 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 claim_tx as (SELECT tx_hash FROM optimism.core.fact_event_logs
where
event_name = 'OptionsExercised'
and origin_function_signature = '0x85149258'
and date(block_timestamp) >CURRENT_DATE - interval '2 weeks'
and
contract_address in (select to_address from optimism.core.fact_token_transfers
where contract_address = '0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9'
and from_address = '0x170a5714112daeff20e798b6e92e25b86ea603c1')
),claimed as (
select to_address as address, sum(raw_amount)/pow(10,18) as amount
from optimism.core.fact_token_transfers
where contract_address = lower('0x8c6f28f2F1A3C87F0f938b96d27520d9751ec8d9') and tx_hash in (select * from claim_tx)
group by 1
)
, used as (
select origin_from_address as address,-sum(raw_amount)/pow(10,18) as amount from optimism.core.fact_token_transfers
where
contract_address ilike '0x8c6f28f2F1A3C87F0f938b96d27520d9751ec8d9' and to_address ilike '0x170a5714112daeff20e798b6e92e25b86ea603c1'
and address in (select origin_from_address from optimism.core.fact_event_logs where origin_function_signature
in ('0x8875eb84','0xec933f83','0x9f916c9f','0x6cc5a6ff') )
and date(block_timestamp) >CURRENT_DATE - interval '2 weeks'
group by 1
), total_amount as (
select * from claimed
union
select * from used
)
select address, sum(amount) as profit from total_amount
group by 1
order by 2 desc
Run a query to Download Data