mirror of
https://github.com/autistic-symposium/mev-toolkit.git
synced 2025-06-28 08:17:10 -04:00
add a bunch of dune queries for eip-1559 data
This commit is contained in:
parent
558634b2f3
commit
7255a21725
1 changed files with 111 additions and 21 deletions
|
@ -1,4 +1,7 @@
|
|||
## 🍩 mev and eip-1559
|
||||
## mev and eip-1559
|
||||
|
||||
|
||||
### tl; dr
|
||||
|
||||
<br>
|
||||
|
||||
|
@ -6,26 +9,6 @@
|
|||
|
||||
<br>
|
||||
|
||||
##### 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
|
||||
```
|
||||
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
- 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
|
|||
|
||||
|
||||
|
||||
<br>
|
||||
|
||||
---
|
||||
|
||||
### 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
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
#### 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;
|
||||
|
||||
```
|
||||
|
||||
|
||||
<br>
|
||||
|
||||
#### 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
|
||||
````
|
||||
|
||||
<br>
|
||||
|
||||
#### 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;
|
||||
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
#### 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;
|
||||
```
|
||||
|
||||
|
||||
<br>
|
||||
|
||||
----
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue