Publish your story
EIP-1559 - Gas Volatility
How do we measure gas volatility?
The difference between the gas price paid (per gas unit) by two different transactions in the same block should not be very high.
But, which transactions to pick?
We can use a measure called inter quartile range. By ordering the transactions in the block by gas price, we can pick the 25th percentile and 75th percentile and take their difference.
In the above example, we can see that IQR for block#2 is less than block #1. The less the variation in gas prices in the same block, the smaller the IQR will be.
--Compute the IQR for every block since 2021 WITH blocks_iqr_gas AS ( SELECT block_number, ((PERCENTILE_CONT(0.75) WITHIN GROUP (ORDER BY gas_price)) - (PERCENTILE_CONT(0.25) WITHIN GROUP (ORDER BY gas_price))) / PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY gas_price) AS iqr_gas FROM ethereum.transactions WHERE DATE(block_time)>= '2021-01-01' GROUP BY block_number ) --Compute the median of IQR for every month SELECT DATE_TRUNC('month', time) AS month, PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY iqr_gas) AS median_gas_volatility FROM blocks_iqr_gas blk_iqr INNER JOIN ethereum.blocks blk ON blk_iqr.block_number = blk.number GROUP BY month;
👨🏽💻 Fork the above query and give it a try.
As we can see, since the implementation of EIP 1559, the IQR has significantly decreased. This suggests that EIP 1559 did, in fact, simplify gas estimation.