hessMonthly Net
Updated 2023-05-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
›
⌄
with transaction as ( select trunc(block_timestamp,'month') as date, case when mint = 'So11111111111111111111111111111111111111112' then 'SOL'
when mint = 'RLBxxFkseAZ4RgJH3Sqn8jXxhmGoz9jWxDNJMh8pL7a' then 'RLB' end as token, 'Deposit' as type,
tx_id, tx_from as user, amount
from solana.core.fact_transfers
where tx_to = 'RBHdGVfDfMjfU6iUfCb1LczMJcQLx7hGnxbzRsoDNvx'
UNION
select trunc(block_timestamp,'month') as date, case when mint = 'So11111111111111111111111111111111111111112' then 'SOL'
when mint = 'RLBxxFkseAZ4RgJH3Sqn8jXxhmGoz9jWxDNJMh8pL7a' then 'RLB' end as token, 'Withdraw' as type,
tx_id, tx_to as user, amount
from solana.core.fact_transfers
where tx_from = 'RBHdGVfDfMjfU6iUfCb1LczMJcQLx7hGnxbzRsoDNvx'
)
,
price as ( select date(recorded_hour) as date, symbol, avg(close) as price
from solana.core.fact_token_prices_hourly
where symbol in ('SOL', 'RLB')
group by 1,2)
,
final as ( select a.date, type, symbol, price, tx_id, user, amount,
amount*price as volume
from transaction a left outer join price b on a.date = b.date and a.token = b.symbol )
,
deposit as ( select date, sum(volume) as deposit_volume
from final
where type ='Deposit'
group by 1)
,
withdraw as ( select date, sum(volume)*-1 as withdraw_volume
from final
where type ='Withdraw'
group by 1)
select a.date, deposit_volume, withdraw_volume, deposit_volume+withdraw_volume as net
from deposit a left outer join withdraw b on a.date = b.date
Run a query to Download Data