HitmonleeCrypto2024-06-27 03:08 PM
Updated 2024-06-28
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
-- Filtered swaps data for relevant address and conditions
filtered_swaps AS (
SELECT
DATE_TRUNC('month', block_timestamp) AS month,
swap_from_amount_usd,
swapper,
swap_program,
tx_id
FROM
solana.defi.ez_dex_swaps
WHERE
(swapper = '{{Address}}' AND swap_program LIKE 'jupiter%')
OR swapper ILIKE 'DCA%'
OR (swapper ILIKE 'j1%' AND swap_program ILIKE '%jupiter%')
),
-- Monthly trade volume
monthly_trade_volume AS (
SELECT
month,
SUM(swap_from_amount_usd) AS monthly_trade_total
FROM
filtered_swaps
WHERE
swapper = '{{Address}}' AND swap_program LIKE 'jupiter%'
GROUP BY
month
),
-- Monthly DCA volume
monthly_dca_volume AS (
SELECT
DATE_TRUNC('month', s.block_timestamp) AS month,
SUM(s.swap_from_amount_usd) AS monthly_dca_total
FROM
solana.defi.ez_dex_swaps AS s
INNER JOIN
QueryRunArchived: QueryRun has been archived