Skip to content

Latest commit

 

History

History
150 lines (108 loc) · 4.95 KB

File metadata and controls

150 lines (108 loc) · 4.95 KB

mev and eip-1559

tl; dr


Screen Shot 2022-12-21 at 8 53 03 PM


  • The incorporation of EIP-1559 in the London hardfork brought a major restructuring of the Ethereum fee mechanism, aiming to allow for easier fee estimation by users and consolidate ETH as the base currency of the network by burning part of the transaction fees.

  • EIP-1559 changed this fee market. Users now pay a fee consisting of a base fee, which is burned, and a tip, that goes to the block builder. The maximum block size doubled to 30 million gas units, however, the target block size is half of that. If there are few users willing to pay the base fee and the block size is below the target, the base fee decreases. Similarly, if the block size is above the target, the base fee increases.

  • In other words, under the new fee mechanism, instead of choosing a gas price for their transactions, users set a "priority fee" for miners to incentivize inclusion, alongside a "max fee", stating the absolute maximum price that they are willing to pay. The protocol now sets a per-block "basefee", computed programmatically from the amount of gas used in the block immediately before, in a negative feedback loop meant for block sizes to stabilize around a target size $s_0$ (initially equal to the maximum current block size).

  • Valid transactions pay a gas price equal to the basefee plus the prioirity fee (only up to the max fee needed in case of sudden basefee increases). The prioirity fee goes to the miner, and, crucially, the basefee is burnt.

  • Implications for MEV-related infrastructure: eliminate the possibility of zero-Gwei transactions, which are presently used for frontrunning protection in some DEXes, where miner fees are taken directly from the transferred tokens.

  • eip1559 is kind of a perpetual second-price auction. The basefee floats to price out exactly enough users such that the remaining ones fill the block to capacity. Sometimes it increases (as in English auctions), when the demand is higher than the supply, and sometimes it decreases (as in Dutch auctions), when the demand is lower than the supply.


Screen Shot 2022-11-17 at 1 18 14 PM



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;


resources