MLDZMNWGF3
Updated 2022-11-28Copy 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 tb1 as (select
distinct recipient as user1,
sum(amount) as total_recieved
from flow.core.ez_token_transfers
where token_contract = 'A.1654653399040a61.FlowToken'
and tx_succeeded = 'TRUE'
group by 1),
tb2 as (select
distinct sender as user2,
sum(amount) as total_sent
from flow.core.ez_token_transfers s left join tb1 b on s.sender=b.user1
where token_contract = 'A.1654653399040a61.FlowToken'
and tx_succeeded = 'TRUE'
and sender in (select user1 from tb1)
group by 1),
tb3 as (select
distinct user1 as users,
total_recieved - total_sent as net_flow
from tb1 s left join tb2 b on s.user1 = b.user2
left join flow.core.dim_contract_labels c on s.user1 = c.account_address
where total_recieved>total_sent
and CONTRACT_NAME is null
order by 2 desc limit 20
),
tb4 as (select
date_trunc('month',BLOCK_TIMESTAMP) as date,
recipient as top_wallets1,
sum(amount)+net_flow as total_recieved
from flow.core.ez_token_transfers a left join tb3 b on a.recipient=b.users
where token_contract = 'A.1654653399040a61.FlowToken'
and tx_succeeded = 'TRUE'
and BLOCK_TIMESTAMP>'2022-05-01'
and recipient in (select users from tb3)
Run a query to Download Data