|
| 1 | +--- |
| 2 | +created: 2022-06-14T20:44:13 (UTC -07:00) |
| 3 | +source: https://notes.ethereum.org/@barnabe/rk5ue1WF_ |
| 4 | +title: maxPriorityFee Calculations |
| 5 | +--- |
| 6 | + |
| 7 | +# maxPriorityFee |
| 8 | + |
| 9 | +`maxPriorityFee` is calculated using the methodology below. |
| 10 | + |
| 11 | +## Overview |
| 12 | + |
| 13 | +For implemntations such as that used in the Sushiswap frontend, it is currently defined as: |
| 14 | + |
| 15 | +```typescript |
| 16 | + maxPriorityFee: BigNumber.from("1750000000") ?? undefined, // 1_750_000_000 in `wei` |
| 17 | +``` |
| 18 | + |
| 19 | +> NOTE. Both Ethersjs and Web3js hardcode this value, [see issue for ethersjs](https://github.com/ethers-io/ethers.js/issues/1817), and [for web3js this issue](https://github.com/ChainSafe/web3.js/pull/4277) |
| 20 | +
|
| 21 | +## Methodology |
| 22 | + |
| 23 | +> Uncle risk/MEV miner fee calculation - Call `T_` the transaction fees netted by MEV transactions |
| 24 | +
|
| 25 | +- Call $T_{MEV}$ the transaction fees netted by MEV transactions (in Gwei) |
| 26 | +- MEV transactions use an amount of gas $g_{MEV}$ |
| 27 | +- Non-MEV transactions pay a miner fee $\delta$ (in Gwei per gas unit) |
| 28 | +- Non-MEV transactions use $g_N$ gas |
| 29 | +- The whole block (MEV + non-MEV) uses $g = g_{MEV} + g_N$ gas |
| 30 | +- The block reward is $R$ (in Gwei) |
| 31 | +- The uncle reward is $U$ (in Gwei) |
| 32 | +- There is a rate $p$ such that for each unit of gas added in the block, the uncle risk increases by $p$. It was once measured that 10M gas adds about 2.5% risk, so we take $p = 2.5 \times 10^{-9}$ |
| 33 | + |
| 34 | +The expected revenue from a block including only MEV transactions is |
| 35 | + |
| 36 | +$$ |
| 37 | +A = (1-pg_{MEV}) (R + T_{MEV}) + pg_{MEV} U |
| 38 | +$$ |
| 39 | + |
| 40 | +The expected revenue from a block providing $g$ gas in total is |
| 41 | + |
| 42 | +$$ |
| 43 | +B = (1-pg) (R + T_{MEV} + \delta g_N) + pgU |
| 44 | +$$ |
| 45 | + |
| 46 | +We look for $\delta$ such that $B \geq A$, which yields |
| 47 | + |
| 48 | +$$ |
| 49 | +\delta \geq \frac{p(R + T_{MEV} - U)}{1-pg} |
| 50 | +$$ |
| 51 | + |
| 52 | +Note that as $p$ decreases, so does the required miner fee. |
| 53 | + |
| 54 | + |
| 55 | +_With $p = 2.0 \times 10^{-9}$_ |
| 56 | + |
| 57 | +### Jupyter Notebook |
| 58 | + |
| 59 | +[Notebook source](https://github.com/ethereum/abm1559/blob/master/notebooks/uncle_risk.ipynb) |
| 60 | + |
| 61 | +## Citations |
| 62 | + |
| 63 | +Barnabe Monnot, Ethereum Foundation: "Uncle risk/MEV miner fee calculation", <br /> |
| 64 | + <https://notes.ethereum.org/@barnabe/rk5ue1WF>; Accessed 2022 June 14th. |
0 commit comments