superflyIronBank holders
Updated 2022-12-20
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 addresses AS
( SELECT to_address AS adr
FROM optimism.core.fact_token_transfers tr
WHERE contract_address = '0x0000000000' ) ,
transfers AS
( SELECT DAY,
address,
token_address,
sum(amount) AS amount -- Net inflow or outflow per day
FROM
( SELECT BLOCK_TIMESTAMP::date AS DAY,
to_address AS address,
tr.contract_address AS token_address,
raw_amount AS amount
FROM optimism.core.fact_token_transfers tr --INNER JOIN addresses ad ON tr."to" = ad.adr
WHERE contract_address = lower('0x00a35FD824c717879BF370E70AC6868b95870Dfb')
UNION ALL SELECT BLOCK_TIMESTAMP::date AS DAY,
from_address AS address,
tr.contract_address AS token_address, -raw_amount AS amount
FROM optimism.core.fact_token_transfers tr --INNER JOIN addresses ad ON tr."from" = ad.adr
WHERE contract_address = lower('0x00a35FD824c717879BF370E70AC6868b95870Dfb') --Token address
) t
GROUP BY 1,
2,
3 ) ,
balances_with_gap_days AS
( SELECT t.day,
address,
SUM(amount) OVER (PARTITION BY address
ORDER BY t.day) AS balance, -- balance per day with a transfer
lead(DAY, 1, current_date()) OVER (PARTITION BY address
ORDER BY t.day) AS next_day -- the day after a day with a transfer
Run a query to Download Data