datavortexprospective-plum
Updated 2024-09-16
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
›
⌄
WITH aggregated_totals AS (
SELECT
COUNT(DISTINCT tx_hash) AS total_transactions_all,
COUNT(DISTINCT origin_from_address) AS total_swappers_all,
SUM(amount_in_usd) AS total_volume_all,
COUNT(DISTINCT CASE WHEN symbol_in IN ('USDT', 'USDC', 'EURS', 'DAI', 'UST', 'BUSD', 'TUSD') THEN tx_hash ELSE NULL END) AS total_transactions_stable,
COUNT(DISTINCT CASE WHEN symbol_in IN ('USDT', 'USDC', 'EURS', 'DAI', 'UST', 'BUSD', 'TUSD') THEN origin_from_address ELSE NULL END) AS total_swappers_stable,
SUM(CASE WHEN symbol_in IN ('USDT', 'USDC', 'EURS', 'DAI', 'UST', 'BUSD', 'TUSD') THEN amount_in_usd ELSE 0 END) AS total_volume_stable
FROM polygon.defi.ez_dex_swaps
WHERE block_timestamp >= '{{ start_date }}'
AND block_timestamp < '{{ end_date }}'
)
SELECT
ROUND(
total_transactions_stable * 100.0 / total_transactions_all,
2
) AS percentage_transactions_stable_all,
ROUND(
total_swappers_stable * 100.0 / total_swappers_all,
2
) AS percentage_swappers_stable_all,
ROUND(
total_volume_stable * 100.0 / total_volume_all,
2
) AS percentage_volume_stable_all
FROM aggregated_totals;