MajorM11103_ get ROI for 1 token
Updated 2024-11-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 investments AS (
SELECT
swapper,
SUM(swap_from_amount_usd) AS total_investment
FROM
solana.defi.ez_dex_swaps
WHERE
swap_from_mint = 'So11111111111111111111111111111111111111112' -- l'adresse va recevoir token
AND
swap_to_mint = '7S2R1dU8w3JdU63Etq2h81yJhV89YF4r78QJdBtWpump' -- token program pour un token donnée
GROUP BY
swapper
),
sales AS (
SELECT
swapper,
SUM(swap_to_amount_usd) AS total_return
FROM
solana.defi.ez_dex_swaps
WHERE
swap_from_mint = '7S2R1dU8w3JdU63Etq2h81yJhV89YF4r78QJdBtWpump' -- l'addresse revend des tokens
and
swap_to_mint = 'So11111111111111111111111111111111111111112' -- token program pour un token donnée
GROUP BY
swapper
)
SELECT
i.swapper,
i.total_investment,
s.total_return,
CASE
WHEN i.total_investment > 0 THEN ((s.total_return - i.total_investment) / i.total_investment) * 100
ELSE NULL
END AS roi_percentage
FROM
investments i
QueryRunArchived: QueryRun has been archived