SocioAnalyticatvl over time
Updated 2024-04-23
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 deposit as (
select
date_trunc('day', block_timestamp) as date,
symbol,
sum(amount) as volume,
sum(volume) over (partition by symbol order by date) as cum_deposit
from blast.blitz.ez_clearing_house_events
where MODIFICATION_TYPE = 'deposit'
group by 1 , 2
)
,
withdraw as (
select
date_trunc('day', block_timestamp) as date,
symbol,
sum(-1 * amount) as volume,
sum(volume) over (partition by symbol order by date) as cum_withdraw
from blast.blitz.ez_clearing_house_events
where MODIFICATION_TYPE = 'withdraw'
group by 1 , 2
)
, final as (
select
a.date,
a.symbol,
cum_deposit - cum_withdraw as tvl
from deposit a
left join withdraw b using(date,symbol)
)
, prices as (
select
date_trunc('day',hour ) as date,
symbol,
avg(price) as price_usd
from blast.price.ez_hourly_token_prices
QueryRunArchived: QueryRun has been archived