diff --git a/MEV_on_Ethereum/eip-1559.md b/MEV_on_Ethereum/eip-1559.md index fb84602..12cc287 100644 --- a/MEV_on_Ethereum/eip-1559.md +++ b/MEV_on_Ethereum/eip-1559.md @@ -1,4 +1,7 @@ -## 🍩 mev and eip-1559 +## mev and eip-1559 + + +### tl; dr
@@ -6,26 +9,6 @@
-##### dune query - -``` -SELECT - DATE_TRUNC('month',block_time) AS month, - -- For every month, Compute Number of eip 1559 transactions / Total transactions - COUNT(*) FILTER ( WHERE `type` = 'DynamicFee') / COUNT(*) AS eip1559_tx, - COUNT(*) FILTER ( WHERE `type` = 'Legacy' ) / COUNT(*) AS legacy_tx, - COUNT(*) FILTER ( WHERE `type` NOT IN ('DynamicFee', 'Legacy') ) / COUNT(*) AS other_tx -FROM - ethereum.transactions -WHERE - block_number >= 12965000 --London upgrade block number -GROUP BY - month -``` - - -
- - The incorporation of EIP-1559 in the London hardfork brought a major restructuring of the Ethereum fee mechanism, aiming to allow for easier @@ -49,6 +32,113 @@ protection in some DEXes, where miner fees are taken directly from the transferr +
+ +--- + +### dune queries + +#### eip-1559 adoption + +``` +SELECT + DATE_TRUNC('month',block_time) AS month, + COUNT(*) FILTER ( WHERE `type` = 'DynamicFee') / COUNT(*) AS eip1559_tx, + COUNT(*) FILTER ( WHERE `type` = 'Legacy' ) / COUNT(*) AS legacy_tx, + COUNT(*) FILTER ( WHERE `type` NOT IN ('DynamicFee', 'Legacy') ) / COUNT(*) AS other_tx +FROM + ethereum.transactions +WHERE + block_number >= 12965000 --London upgrade block number +GROUP BY + month +``` + +
+ +#### split base fee / priority fee + +``` +SELECT + DATE_TRUNC('month', tx.block_time) AS month, + SUM( + CASE + WHEN tx.block_number < 12965000 THEN tx.gas_used * tx.gas_price/1e18 + ELSE tx.gas_used * tx.priority_fee_per_gas/1e18 + END + ) as fees_miner_eth, + SUM(tx.gas_used * blk.base_fee_per_gas/1e18) AS fees_burnt_eth +FROM + ethereum.transactions tx + INNER JOIN ethereum.blocks blk ON tx.block_number = blk.number +WHERE + tx.block_time >= '2021-01-01' +GROUP BY + month; + +``` + + +
+ +#### price impact + +``` +SELECT + DATE_TRUNC('month', block_time) as month, + PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY gas_price)/1e9 as median_gas_price +FROM + ethereum.transactions +WHERE + DATE(block_time)>= '2021-01-01' +GROUP BY + month +```` + +
+ +#### gas volatility + +``` +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; + +``` + +
+ +#### tx gas limits (looking at traces) + +``` +SELECT + block_number, + tx_hash, + error, + 'https://etherscan.io/tx/' || tx_hash AS etherscan_tx_link, + 'https://etherscan.io/vmtrace?txhash=' || tx_hash || '&type=gethtrace2' AS etherscan_trace_link +FROM + ethereum.traces +WHERE + error = "Out of gas" +AND block_time > NOW() - INTERVAL '1 hour' +ORDER BY block_time DESC +LIMIT 10; +``` + +
----