JhanlycnAVAX TVL
Updated 2023-05-25
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 transactions AS (
SELECT
CASE
WHEN origin_function_signature = '0x3bc1f1ed' THEN 'deposit'
WHEN origin_function_signature = '0x4b2084e3' THEN 'withdraw'
END AS event,
origin_from_address as user,
tx_hash
FROM
avalanche.core.fact_event_logs
WHERE
contract_address = '0x0cd070285380cabfc3be55176928dc8a55e6d2a7'
),
transfers AS (
SELECT
tx_hash,
symbol,
amount_usd
FROM
avalanche.core.ez_token_transfers
WHERE tx_hash in (select tx_hash from transactions)
),
combined AS (
SELECT
t.event,
tr.amount_usd,
tr.symbol
FROM
transactions t
JOIN
transfers tr
ON t.tx_hash = tr.tx_hash
)
SELECT
symbol,
GREATEST(0, sum(case when event = 'deposit' then amount_usd else -amount_usd end)) as tvl_per_token,
Run a query to Download Data