andreafiandroSOL-USDC Hourly TVL
Updated 2024-02-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
36
›
⌄
WITH tab1 AS (
SELECT
date_trunc('hour', block_timestamp) as hour,
'in' as flow,
mint,
amount
FROM solana.core.fact_transfers
WHERE tx_to IN ('3msVd34R5KxonDzyNSV5nT19UtUeJ2RF1NaQhvVPNLxL')
AND block_timestamp > '2023-10-01'
UNION ALL
SELECT
date_trunc('hour', block_timestamp) as hour,
'out' as flow,
mint,
amount
FROM solana.core.fact_transfers
WHERE tx_from IN ('3msVd34R5KxonDzyNSV5nT19UtUeJ2RF1NaQhvVPNLxL')
AND block_timestamp > '2023-10-01'
)
SELECT
*,
balance * price as balance_usd
FROM (
SELECT
hour,
mint,
sum(CASE WHEN flow LIKE 'in' THEN amount ELSE -amount END) as net_amt,
sum(net_amt) OVER (PARTITION BY mint ORDER BY hour) as balance
FROM tab1
GROUP BY 1, 2
) AS a
LEFT OUTER JOIN (
SELECT
date_trunc('hour', RECORDED_HOUR) as date,
token_address as token,
QueryRunArchived: QueryRun has been archived