TtuffWeekly Kaia ii
Updated 2024-07-05
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
prices AS (
SELECT
date_trunc('week', hour) AS date,
token_address,
decimals,
avg(price) AS price
FROM
blast.price.ez_prices_hourly
GROUP BY 1, 2, 3
),
weekly_swap_stats AS (
SELECT
date_trunc('week', BLOCK_TIMESTAMP) AS week,
COUNT(DISTINCT TX_HASH) AS num_swap_transactions,
COUNT(DISTINCT ORIGIN_FROM_ADDRESS) AS num_swap_users,
LAG(num_swap_transactions) OVER (ORDER BY week ASC) AS num_swap_transactions_last_week,
LAG(num_swap_users) OVER (ORDER BY week ASC) AS num_swap_users_last_week
FROM
kaia.core.fact_event_logs x
JOIN
ethereum.core.dim_function_signatures sig
ON
x.ORIGIN_FUNCTION_SIGNATURE = sig.BYTES_SIGNATURE
AND
text_signature ILIKE '%swap%'
WHERE
block_timestamp < current_date
GROUP BY 1
)
SELECT
week,
num_swap_transactions AS num_swap_transactionss,
num_swap_transactions_last_week AS num_swap_transactions_last_weeks,
(num_swap_transactions - num_swap_transactions_last_week) / num_swap_transactions_last_week * 100 AS num_transactions_diff,
QueryRunArchived: QueryRun has been archived