LittlerDataFlow holding
Updated 2022-11-29
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 receiving as (
select
event_data:to as receiver
,sum(event_data:amount) as deposits
from flow.core.fact_events
where event_contract = 'A.1654653399040a61.FlowToken'
and event_type = 'TokensDeposited'
and tx_succeeded = 'TRUE'
and receiver != 'null'
group by 1
),
sending_out as (
select
event_data:from as sender
,sum(event_data:amount) as withdrawns
from flow.core.fact_events
where event_contract = 'A.1654653399040a61.FlowToken'
and event_type = 'TokensWithdrawn'
and tx_succeeded = 'TRUE'
and sender != 'null'
group by 1
),
joining as (
select
receiver as wallet
,sum (deposits - withdrawns) as current_balance
from receiving
join sending_out on receiving.receiver = sending_out.sender
full outer join flow.core.dim_contract_labels labels on receiving.receiver = labels.account_address
where wallet != 'null'
group by 1
),