bachiflowusers1
Updated 2022-11-28
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
›
⌄
with flow_deposits as (
select date(block_timestamp) as day,
event_data:to as wallet,
round(sum (event_data:amount),2) as deposited_vol
from flow.core.fact_events
where event_contract = 'A.1654653399040a61.FlowToken'
and event_type like '%TokensDeposited%'
and tx_succeeded = 'TRUE'
and event_data:to != null
and event_data:amount is not null
and event_data:amount > 0
group by day, wallet,
order by day desc
),
flow_withdrawals as (
select date(block_timestamp) as day,
event_data:from as wallet,
round(sum (event_data:amount),2) as withdrawn_vol
from flow.core.fact_events
where event_contract = 'A.1654653399040a61.FlowToken'
and event_type like '%TokensWithdrawn%'
and tx_succeeded = 'TRUE'
and event_data:to != null
and event_data:amount is not null
and event_data:amount > 0
group by day, wallet
order by day desc
)
select d.wallet,
(deposited_vol - withdrawn_vol) as total_balance
from flow_deposits d left outer join flow_withdrawals w on d.wallet = w.wallet
and d.wallet != null and (deposited_vol - withdrawn_vol) > 0
order by total_balance desc
Run a query to Download Data