intensodefi2023-11-22 08:21 PM
Updated 2023-11-22
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 newUsers AS (
SELECT
recipient as wallet_address,
date_trunc('month', min(block_timestamp)::date)::date AS start_month
FROM ethereum.uniswapv3.ez_swaps
GROUP BY wallet_address
),
monthly_activity AS (
SELECT
recipient as wallet_address,
date_trunc('month', block_timestamp::date)::date AS active_month,
amount0_usd,
token0_symbol as token
FROM ethereum.uniswapv3.ez_swaps
),
monthly_user_data AS (
SELECT
active_month as month,
wallet_address,
COUNT(*) as transaction_count,
AVG(ABS(amount0_usd)) as avg_volume_usd,
token
FROM(
SELECT
monthly_activity.active_month,
monthly_activity.wallet_address,
monthly_activity.amount0_usd,
monthly_activity.token,
CASE
WHEN newUsers.start_month = monthly_activity.active_month THEN 'New User'
ELSE 'Existing User'
END AS user_type
FROM monthly_activity
LEFT JOIN newUsers
Run a query to Download Data