TOTAL_SWAP_FEES_IN_APT | TOTAL_SWAP_FEES_IN_USD | TOTAL_NUMBER_OF_SWAPS | AVG_FEE_PER_SWAP_IN_APT | AVG_FEE_PER_SWAP_IN_USD | |
---|---|---|---|---|---|
1 | 1410.412528 | 7588.01940064 | 6355606 | 0.00022192 | 0.0012 |
datavortexaptos
Updated 2025-05-12
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
›
⌄
WITH SwapFees AS (
SELECT
SUM((t.gas_used * t.gas_unit_price) / 1e8) AS fee_in_apt,
COUNT(s.tx_hash) AS number_of_swaps
FROM
aptos.core.fact_transactions t
JOIN
aptos.defi.ez_dex_swaps s ON t.tx_hash = s.tx_hash
WHERE
t.success = True
AND t.block_timestamp >= DATE_TRUNC('month', CURRENT_DATE)
AND t.block_timestamp < DATE_TRUNC('month', CURRENT_DATE) + INTERVAL '1 MONTH'
GROUP BY t.tx_hash
),
APTPrice AS (
SELECT
MEDIAN(price) AS apt_price
FROM
aptos.price.ez_prices_hourly
WHERE
symbol = 'APT'
AND hour >= DATE_TRUNC('month', CURRENT_DATE)
AND hour < DATE_TRUNC('month', CURRENT_DATE) + INTERVAL '1 MONTH'
)
SELECT
SUM(sf.fee_in_apt) AS total_swap_fees_in_apt,
SUM(sf.fee_in_apt) * (SELECT ap.apt_price FROM APTPrice ap) AS total_swap_fees_in_usd,
SUM(sf.number_of_swaps) AS total_number_of_swaps,
ROUND(SUM(sf.fee_in_apt) / SUM(sf.number_of_swaps), 8) AS avg_fee_per_swap_in_apt,
ROUND((SUM(sf.fee_in_apt) / SUM(sf.number_of_swaps)) * (SELECT ap.apt_price FROM APTPrice ap), 4) AS avg_fee_per_swap_in_usd
FROM
SwapFees sf;
Last run: 16 days ago
1
55B
19s