mondov# of swaps by gas price
Updated 2024-08-24
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 uniswap_swaps_gas_price AS (
SELECT DISTINCT s.tx_hash as tx_hash,
gas_price AS gas_price_gwei,
DATE_TRUNC('month', s.block_timestamp) AS month
FROM crosschain.defi.ez_dex_swaps s
JOIN ethereum.core.fact_transactions t ON s.tx_hash = t.tx_hash
WHERE lower(platform) LIKE 'uniswap%'
AND s.blockchain = 'ethereum'
AND s.block_timestamp >= '2020-01-01'
),
average_gas_price_per_month AS (
SELECT
DATE_TRUNC('month', block_timestamp) AS month,
AVG(gas_price) AS avg_gas_price_gwei
FROM ethereum.core.fact_transactions
WHERE block_timestamp >= '2020-01-01'
GROUP BY month
)
SELECT
u.month,
CASE
WHEN u.gas_price_gwei > 200 THEN '200+ gwei'
WHEN u.gas_price_gwei > 100 AND u.gas_price_gwei <= 200 THEN '100-200 gwei'
WHEN u.gas_price_gwei > 50 AND u.gas_price_gwei <= 100 THEN '50-100 gwei'
WHEN u.gas_price_gwei > 25 AND u.gas_price_gwei <= 50 THEN '25-50 gwei'
WHEN u.gas_price_gwei > 10 AND u.gas_price_gwei <= 25 THEN '10-25 gwei'
ELSE '0-10 gwei'
END AS category,
COUNT(u.tx_hash) AS number_of_swaps,
a.avg_gas_price_gwei / 6 as avg_gas_price -- due to aggregation on the bar chart
FROM uniswap_swaps_gas_price u
JOIN average_gas_price_per_month a ON u.month = a.month
GROUP BY u.month, category, a.avg_gas_price_gwei
ORDER BY
QueryRunArchived: QueryRun has been archived