scottincryptoAave BAL Treasury Balances
Updated 2023-01-01
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 dates as (
select
date_day as block_day
from crosschain.core.dim_dates
where date_day > '2022-07-18'
and date_day < current_date
)
, bal_in as (
select
date_trunc('day', block_timestamp) as block_day
, sum(amount) as amount_bal
from ethereum.core.ez_token_transfers
where to_address = '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c'
and symbol = 'BAL'
and block_timestamp > (select min(block_day) from dates)
group by block_day
)
, bal_out as (
select
date_trunc('day', block_timestamp) as block_day
, sum(amount) as amount_bal
from ethereum.core.ez_token_transfers
where from_address = '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c'
and symbol = 'BAL'
and block_timestamp > (select min(block_day) from dates)
group by block_day
)
select
d.block_day
, coalesce(i.amount_bal, 0) as bal_in
, coalesce(o.amount_bal, 0) as bal_out
, coalesce(i.amount_bal, 0) - coalesce(o.amount_bal, 0) as net_bal_in
, sum(net_bal_in) over (order by d.block_day rows between unbounded preceding and current row) as token_balance_end_of_day
Run a query to Download Data