adriaparcerisasdau aptos dex 2
Updated 2024-12-13
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 nfts AS (
SELECT DISTINCT swapper, platform, block_timestamp, tx_hash
FROM aptos.defi.ez_dex_swaps
),
daus as (
SELECT
distinct sender as users,
trunc(block_timestamp,'week') as weeks,
count(distinct trunc(block_timestamp,'day')) as active_days
from aptos.core.fact_transactions
group by 1,2
having active_days>=4
),
new_users AS (
SELECT
distinct swapper,
platform,
min(TRUNC(block_timestamp, 'week')) AS date
FROM nfts where swapper in (select DISTINCT users from daus) and platform is not null
GROUP BY 1, 2
)
SELECT
date,
platform,
new_users,
sum(new_users) over (partition by platform order by date) as total_users,
ranks
FROM (
SELECT
date,
platform,
count(distinct swapper) as new_users,
RANK() OVER (PARTITION BY date ORDER BY new_users DESC) AS ranks
FROM new_users
WHERE date >= CURRENT_DATE - INTERVAL '{{Months}} MONTHS'
AND date < TRUNC(CURRENT_DATE, 'week') and platform is not null
QueryRunArchived: QueryRun has been archived