zakkisyedEthereum: MDAO Treasury Balance
Updated 2023-02-13
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
›
⌄
with
inbound_tx as (
select
sum(amount / 1e6) as amount_in,
date_trunc(month, block_timestamp) as dt
from
ethereum.core.ez_token_transfers
where
to_address = '0x4fafb87de15cff7448bd0658112f4e4b0d53332c'
group by
2
),
outbound_tx as (
select
sum(amount / 1e6) as amount_out,
date_trunc(month, block_timestamp) as dt
from
ethereum.core.ez_token_transfers
where
from_address = '0x4fafb87de15cff7448bd0658112f4e4b0d53332c'
group by
2
)
select
t1.amount_in,
t2.amount_out,
case when amount_out != null
then amount_in - t2.amount_out
else amount_in
end as current_balance,
from
inbound_tx t1
left join outbound_tx t2 on t1.dt = t2.dt
Run a query to Download Data