freemartianTop 50 Profitable traders
Updated 2023-07-27
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
›
⌄
with source AS
(SELECT
tx_hash,
data,
regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data,
ethereum.public.udf_hex_to_int(segmented_data [4] :: STRING)/pow(10,8) AS fee,
CONCAT('0x', substr(topics[2] :: STRING, 27, 42)) AS user_address,
ethereum.public.udf_hex_to_int(segmented_data [5] :: STRING)/pow(10,8) AS PNL,
CASE
when substr(segmented_data [5] :: STRING, 1, 1) IN ('8' , '9' , 'a' , 'b', 'c', 'd', 'e', 'f')
then (ethereum.public.udf_hex_to_int(
translate(segmented_data [5] :: STRING,'fedcba9876543210','0123456789abcdef')
) / pow(10,8)) * -1
else ethereum.public.udf_hex_to_int(segmented_data [5] :: STRING)/pow(10,8)
end AS adjusted_PNL
FROM optimism.core.fact_event_logs
WHERE topics[0] = '0x980658f6b65b51ce7d353bc2f9110e33617a69ab8dd85ed76e70546542ebea25')
SELECT
user_address,
sum(adjusted_PNL) AS PNL
FROM source
GROUP BY 1
ORDER by 2 DESC
LIMIT 50
Run a query to Download Data