mirror of
https://github.com/autistic-symposium/mev-toolkit.git
synced 2025-05-02 14:56:18 -04:00
💾
This commit is contained in:
parent
bf818f2682
commit
d3a292bfd1
133 changed files with 26 additions and 40 deletions
54
MEV_projects/flashbots/README.md
Normal file
54
MEV_projects/flashbots/README.md
Normal file
|
@ -0,0 +1,54 @@
|
|||
## flashbots
|
||||
|
||||
<br>
|
||||
|
||||
### tl;dr
|
||||
|
||||
<br>
|
||||
|
||||
* **flashbots** is a research and development organization focused on mitigating the negative externalities of current MEV extraction techniques.
|
||||
* after the release of MEV-geth (and later MEV-boost), much of the computation related to MEV was taken off-chain, by a side-relay that allows MEV searchers to communicate directly with nodes and other participants. This lead to a decrease in fee congestion pricing.
|
||||
* however, MEV “marketplaces” like flashbots, are quite centralized, since the vast majority of blocks flow through it.
|
||||
|
||||
<br>
|
||||
|
||||
##### bundles
|
||||
|
||||
* bundle/transaction profitability is determined by: fee per gas used, priority fee, and direct validator payments.
|
||||
|
||||
|
||||
<br>
|
||||
|
||||
----
|
||||
|
||||
### in this dir
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
* [mev-boost](mev-boost)
|
||||
* [suave](suave)
|
||||
* [scripts](scripts)
|
||||
* [tools](tools)
|
||||
|
||||
|
||||
|
||||
|
||||
<br>
|
||||
|
||||
---
|
||||
|
||||
### resources
|
||||
|
||||
<br>
|
||||
|
||||
- [how to use flashbots](https://cryptomarketpool.com/how-to-use-flashbots/)
|
||||
- [bundle pricing docs](https://docs.flashbots.net/flashbots-auction/searchers/advanced/bundle-pricing)
|
||||
- [flashbots bundler explorer](https://flashbots-explorer.marto.lol/)
|
||||
- [flashbots: frontrunning the mev crisis by thegostep](https://ethresear.ch/t/flashbots-frontrunning-the-mev-crisis/8251)
|
||||
- [order flows kingmaker of block builders by noxx](https://noxx.substack.com/p/order-flows-kingmaker-of-the-block)
|
||||
- [data analysis of Flashbots MEV](https://github.com/ivanmolto/mev-flashbots-unleashed)
|
||||
- [flashbots' transparency board](https://transparency.flashbots.net/)
|
||||
- [flashbots' research topics](https://github.com/flashbots/mev-research)
|
||||
|
||||
|
53
MEV_projects/flashbots/mev-boost/README.md
Normal file
53
MEV_projects/flashbots/mev-boost/README.md
Normal file
|
@ -0,0 +1,53 @@
|
|||
## mev-boost
|
||||
|
||||
<br>
|
||||
|
||||
### tl,dr
|
||||
|
||||
<br>
|
||||
|
||||
* [mev-boost](https://github.com/flashbots/mev-boost#installing) is a middleware run by validators to democratize the block-building market with a implementation of [proposer-builder-separation (PBS)](https://ethresear.ch/t/proposer-block-builder-separation-friendly-fee-market-designs/9725) for proof-of-stake Ethereum.
|
||||
* pbs was initially proposed by Ethereum researchers as a response to the risk that MEV poses to decentralization of consensus networks.
|
||||
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
<img width="350" src="https://user-images.githubusercontent.com/1130416/190929561-afe6918f-6f34-459e-9d2b-06902918d4d0.png">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<br>
|
||||
|
||||
<img width="350" src="https://user-images.githubusercontent.com/1130416/208611598-ed51d4e6-b51d-44c4-9d72-cf061aea3690.png">
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
<br>
|
||||
|
||||
---
|
||||
|
||||
### resources
|
||||
|
||||
<br>
|
||||
|
||||
* [mev-boost, relays, self-sovereignty](https://mirror.xyz/mevwaifu.eth/Xo_5rIpRQpFOC__kYfjLJVOFwlSZH2n8tUnHoXo6VyI)
|
||||
* [mev-boost on a goerli validator](https://mirror.xyz/steinkirch.eth/Xo_5rIpRQpFOC__kYfjLJVOFwlSZH2n8tUnHoXo6VyI)
|
||||
* [running mev-boost-relay at scale](https://www.notion.so/Running-mev-boost-relay-at-scale-4040ccd5186c425d9a860cbb29bbfe09)
|
||||
* [install mev-boost in ubuntu](https://github.com/metanull-operator/eth2-ubuntu/blob/master/v2/mev-boost.md)
|
||||
* [mev-boost docker image](https://hub.docker.com/r/flashbots/mev-boost)
|
||||
* [dune mev-boost dashboard](https://dune.com/ChainsightAnalytics/mev-after-ethereum-merge)
|
||||
* [why mev boost](https://writings.flashbots.net/writings/why-run-mevboost/)
|
||||
* [mev-boost post-merge](https://ethresear.ch/t/mev-boost-merge-ready-flashbots-architecture/11177)
|
||||
* [mev-boost builder stats dune](https://dune.com/ChainsightAnalytics/mev-after-ethereum-merge)
|
||||
* [flashbots analysis of mev in eth2](https://github.com/flashbots/eth2-research/blob/main/notebooks/mev-in-eth2/eth2-mev-calc.ipynb)
|
||||
* [ethereum specs for block builder](https://github.com/ethereum/builder-specs)
|
||||
* [list of mev-boost payout addresses](https://gist.github.com/metachris/a4d10ff59cad5ffe3cf0f2c6e91fc0bc)
|
||||
* [merge ready flashbots architecture](https://hackmd.io/@manifold/S1jRmGIPF)
|
||||
|
||||
|
5
MEV_projects/flashbots/scripts/README.md
Normal file
5
MEV_projects/flashbots/scripts/README.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
## scripts
|
||||
|
||||
<br>
|
||||
|
||||
* [flashbots bundle](https://github.com/bt3gl-labs/Blockchain-DeFi-and-MEV/blob/main/MEV/scripts/flashbots-bundle.py) (or full instructions, see [this post](https://lilithsecurity.substack.com/p/-mev-wednesdays-intro-to-flashbots)).
|
111
MEV_projects/flashbots/scripts/flashbots-bundle.py
Normal file
111
MEV_projects/flashbots/scripts/flashbots-bundle.py
Normal file
|
@ -0,0 +1,111 @@
|
|||
#!/usr/bin/env python3
|
||||
# This script sends a bundle of two transactions which transfer ETH into a random account.
|
||||
# Full instructions: https://mirror.xyz/steinkirch.eth/rGyGGoOLek_pCoJVlSFSjjFL-b5_Mw_P5hC3giwUCtc
|
||||
|
||||
|
||||
import os
|
||||
import secrets
|
||||
from pathlib import Path
|
||||
from dotenv import load_dotenv
|
||||
from flashbots import flashbot
|
||||
from eth_account.account import Account
|
||||
from eth_account.signers.local import LocalAccount
|
||||
from web3 import Web3, HTTPProvider
|
||||
from web3.exceptions import TransactionNotFound
|
||||
from web3.types import TxParams
|
||||
|
||||
|
||||
def env(key: str) -> str:
|
||||
load_dotenv(Path('.') / '.env')
|
||||
return os.getenv(key)
|
||||
|
||||
|
||||
def random_account() -> LocalAccount:
|
||||
key = "0x" + secrets.token_hex(32)
|
||||
return Account.from_key(key)
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
SENDER_KEY = env("SENDER_KEY")
|
||||
SIGNER_KEY = env("SIGNER_KEY")
|
||||
PROVIDER_URL = env("PROVIDER_URL")
|
||||
CHAIN_ID = int(env("CHAIN_ID"))
|
||||
|
||||
# 1. account to send the transfer and sign transactions
|
||||
sender: LocalAccount = Account.from_key(SENDER_KEY)
|
||||
|
||||
# 2. account to receive the transfer
|
||||
receiverAddress: str = random_account().address
|
||||
|
||||
# 3. account to sign bundles and flashbots reputation
|
||||
signer: LocalAccount = Account.from_key(SIGNER_KEY)
|
||||
w3 = Web3(HTTPProvider(PROVIDER_URL))
|
||||
flashbot(w3, signer, "https://relay-goerli.flashbots.net")
|
||||
|
||||
print(f"✅ Sender address: {sender.address}")
|
||||
print(f"✅ Receiver address: {receiverAddress}")
|
||||
print(f"✅ Sender account balance: {Web3.fromWei(w3.eth.get_balance(sender.address), 'ether')} ETH")
|
||||
print(f"✅ Receiver account balance: {Web3.fromWei(w3.eth.get_balance(receiverAddress), 'ether')} ETH")
|
||||
|
||||
# 4. bundle two EIP-1559
|
||||
nonce = w3.eth.get_transaction_count(sender.address)
|
||||
tx1: TxParams = {
|
||||
"to": receiverAddress,
|
||||
"value": Web3.toWei(0.005, "ether"),
|
||||
"gas": 21000,
|
||||
"maxFeePerGas": Web3.toWei(300, "gwei"),
|
||||
"maxPriorityFeePerGas": Web3.toWei(50, "gwei"),
|
||||
"nonce": nonce,
|
||||
"chainId": CHAIN_ID,
|
||||
"type": 2,
|
||||
}
|
||||
tx1_signed = sender.sign_transaction(tx1)
|
||||
|
||||
tx2: TxParams = {
|
||||
"to": receiverAddress,
|
||||
"value": Web3.toWei(0.005, "ether"),
|
||||
"gas": 21000,
|
||||
"maxFeePerGas": Web3.toWei(300, "gwei"),
|
||||
"maxPriorityFeePerGas": Web3.toWei(50, "gwei"),
|
||||
"nonce": nonce + 1,
|
||||
"chainId": CHAIN_ID,
|
||||
"type": 2,
|
||||
}
|
||||
|
||||
bundle = [
|
||||
{"signed_transaction": tx1_signed.rawTransaction},
|
||||
{"signer": sender, "transaction": tx2},
|
||||
]
|
||||
|
||||
# 5. Send bundle until it gets mined
|
||||
while True:
|
||||
block = w3.eth.block_number
|
||||
print(f"✨ Simulating on block {block}...")
|
||||
|
||||
try:
|
||||
w3.flashbots.simulate(bundle, block)
|
||||
print("✅ Simulation successful!")
|
||||
|
||||
except Exception as e:
|
||||
print(f"🚨 Simulation error: {e}")
|
||||
return
|
||||
|
||||
print(f"Sending bundle targeting next block: {block+1}...")
|
||||
send_result = w3.flashbots.send_bundle(bundle, target_block_number=block + 1)
|
||||
send_result.wait()
|
||||
|
||||
try:
|
||||
receipts = send_result.receipts()
|
||||
print(f"\n✅ Bundle was mined in block {receipts[0].blockNumber}\a")
|
||||
break
|
||||
|
||||
except Exception as e:
|
||||
print(f"Bundle not found in block {block+1}: {e}")
|
||||
|
||||
print(f"✅ Sender account balance: {Web3.fromWei(w3.eth.get_balance(sender.address), 'ether')} ETH")
|
||||
print(f"✅ Receiver account balance: {Web3.fromWei(w3.eth.get_balance(receiverAddress), 'ether')} ETH")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
16
MEV_projects/flashbots/suave/README.md
Normal file
16
MEV_projects/flashbots/suave/README.md
Normal file
|
@ -0,0 +1,16 @@
|
|||
## suave
|
||||
|
||||
<br>
|
||||
|
||||
### tl; dr
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
<br>
|
||||
|
||||
---
|
||||
|
||||
### resources
|
||||
|
||||
* [first article designing suave](https://writings.flashbots.net/the-future-of-mev-is-suave)
|
7
MEV_projects/flashbots/tools/README.md
Normal file
7
MEV_projects/flashbots/tools/README.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
## tools
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
* [mev-inspect-py](https://github.com/flashbots/mev-inspect-py)
|
||||
* [mev bundle generator](https://github.com/Alcibiades-Capital/mev_bundle_generator).
|
Loading…
Add table
Add a link
Reference in a new issue