Skip to content

Commit 2081f43

Browse files
authored
feat(release): maxPriorityFee (#35)
1 parent d7fbd10 commit 2081f43

File tree

3 files changed

+288
-331
lines changed

3 files changed

+288
-331
lines changed

.github/workflows/nodejs.yml

+20-12
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,44 @@
11
name: nodejs
22

3-
on: ['push']
3+
on:
4+
push:
5+
paths:
6+
- "**/**"
7+
- "!**/*.yml/**"
48

59
jobs:
6-
build:
7-
runs-on: ubuntu-latest
10+
pipeline:
11+
name: Node ${{ matrix.node-version }} on ${{ matrix.os }}
12+
runs-on: ${{ matrix.os }}
813

914
strategy:
15+
fail-fast: false
1016
matrix:
11-
node-version: ['14.x']
17+
node-version: ['16.x']
18+
os: ['ubuntu-latest']
1219

1320
steps:
14-
- uses: actions/checkout@v2
21+
- uses: actions/checkout@v3.0.2
1522
- name: Use Node.js ${{ matrix.node-version }}
16-
uses: actions/setup-node@v2
23+
uses: actions/setup-node@v3.3.0
1724
with:
1825
node-version: ${{ matrix.node-version }}
26+
1927
- name: Get yarn cache directory path
2028
id: yarn-cache-dir-path
2129
run: echo "::set-output name=dir::$(yarn cache dir)"
2230

23-
- name: Get yarn cache directory path
24-
uses: actions/cache@v2
31+
- uses: actions/[email protected]
2532
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
2633
with:
2734
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
2835
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
2936
restore-keys: |
3037
${{ runner.os }}-yarn-
31-
- name: webpage install, build, and test
32-
uses: actions/setup-node@v2
33-
- run: yarn install
38+
- name: Install project dependencies
39+
run: yarn --prefer-offline
3440
id: install
35-
- run: yarn run build
41+
42+
- name: Install project dependencies
43+
run: yarn run build
3644
id: production
+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
![](https://storage.googleapis.com/ethereum-hackmd/upload_61fd15eacb8798e9efa5ba04fb4d57fc.png)
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

Comments
 (0)