zackmendel4c. Total New & Active Users (defi)
Updated 2023-05-31
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 new_users AS (
SELECT DISTINCT
from_address AS user,
min (block_timestamp) AS date1
FROM avalanche.core.fact_transactions t JOIN avalanche.core.dim_labels l
ON t.to_address = l.address
WHERE label_type = 'defi'
-- AND block_timestamp::date >= current_date - 30
GROUP BY 1
),
act_users AS (
SELECT DISTINCT
from_address,
COUNT (DISTINCT tx_hash) AS tx
FROM avalanche.core.fact_transactions t JOIN avalanche.core.dim_labels l
ON t.to_address = l.address
WHERE label_type = 'defi'
AND block_timestamp::date >= current_date - 30
GROUP BY 1
HAVING tx > 5
),
active_users AS (
SELECT DISTINCT
from_address AS active_user,
block_timestamp AS date2
FROM avalanche.core.fact_transactions t JOIN avalanche.core.dim_labels l
ON t.to_address = l.address
WHERE label_type = 'defi'
AND from_address IN (SELECT from_address FROM act_users)
AND block_timestamp::date >= current_date - 30
)
SELECT
-- date(date1::date) AS timespan,
COUNT (DISTINCT user) AS new_users,
COUNT (DISTINCT active_user) AS active_users
FROM new_users n JOIN active_users a ON n.date1::date = a.date2::date
Run a query to Download Data