datavortexWEEKLY NEW TRADES
Updated 2025-02-03
999
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 price AS (
SELECT
price,
hour,
token_address
FROM
kaia.price.ez_prices_hourly
),
first_swaps AS (
-- Find the first swap date for each new swapper
SELECT
origin_from_address,
MIN(block_timestamp) AS first_swap_time
FROM
kaia.defi.ez_dex_swaps
WHERE
token_in = '0x19aac5f612f524b754ca7e7c41cbfa2e981a4432'
GROUP BY
origin_from_address
),
new_weekly_swaps AS (
-- Get all swaps for new swappers in their first week
SELECT
date_trunc('week', s.block_timestamp) AS Week,
s.origin_from_address,
s.symbol_in,
s.symbol_out,
s.amount_in,
p_in.price AS price_in,
(s.amount_in * p_in.price) AS amount_usd
FROM
kaia.defi.ez_dex_swaps s
JOIN first_swaps f
ON s.origin_from_address = f.origin_from_address
AND date_trunc('week', s.block_timestamp) = date_trunc('week', f.first_swap_time)
QueryRunArchived: QueryRun has been archived