可能是最好的MEV入门文章: 《I'm new to MEV》,FlashBot社区的大佬写的文章,涵盖了MEV介绍,术语介绍,常见策略区别,如何开始写一个MEV Bot,推荐的工具和学习资源等内容,特别是推荐的资源都很不错,两个多月前看的了,今天整理资料又看了一遍,感觉非常清晰。
原文:https://t.co/1JVBybj0fd
你也可以直接看我贴的中文翻译👇:
—
引言(Introduction)
欢迎!如果你正在阅读这篇文章,你很可能刚进入 MEV 领域。
这篇帖子旨在为任何新入场的人提供指南。
我不会尝试讲解 MEV 的基础是什么,但我会链接相关资源。
我会覆盖你需要知道的术语、该领域的社交规范,以及运行 bot 的一些更技术性的细节。
—
你很有可能是为了盈利而被 MEV 吸引。
也许你听说过 jaredfromsubway 通过 sandwiching bot 赚了数百万,或者通过其他方式了解到 MEV。
无论如何,我希望这篇文章能帮助你上路。
—
本文是对(https://t.co/wWOr4DLH30)和(https://t.co/fctSphAjgG)的扩展。
我建议把这两篇文章和本文一起阅读。
前两篇将更聚焦于 MEV 本身,而本文更关注 MEV 社区的文化与术语。
—
什么是 MEV?(What is MEV?)
MEV 是 Maximum Extractable Value,指可从任何系统中的特权角色提取的任何价值(经济或其他)。
在区块链中,MEV 变得突出,是因为对区块内交易排序的特权(属于网络 validators)所能提取的价值。
—
想要一个优秀的 MEV 入门,我推荐阅读 Ethereum Foundation 关于该主题的文章,以及 Paradigm 的《Ethereum is a Dark Forest》。
—
MEV 供应链是提取 MEV 的过程。它包括:
Searchers:发现以 bundles 形式存在的 MEV。
Bundles:包含提取 MEV 的交易。
Builders:从 bundles 构建区块。
Relays:将 builders 的区块提交给 validators。
Validators/Proposers:向区块链提议区块。
—
MEV bot 是一种试图提取 MEV 的自动化程序。运行这些 bot 的人我们称为 searchers。
我建议阅读我的其他文章以了解更多 MEV 类型。
—
“黑话”(The “lingo”)
MEV 是一个新领域,因此也有很多新术语。以下是一些最重要的术语:
—
Searchers
Searchers 是 MEV 领域的关键角色。他们负责构建和运行 MEV bots 以盈利地提取 MEV。
“a large portion of MEV is extracted by independent network participants referred to as ‘searchers.’ Searchers run complex algorithms on blockchain data to detect profitable MEV opportunities and have bots to automatically submit those profitable transactions to the network.” — The Ethereum Foundation
(相当大一部分 MEV 是由被称为“搜索者”的独立网络参与者提取的。搜索者在区块链数据上运行复杂算法以检测有利可图的 MEV 机会,并通过机器人自动将这些有利交易提交到网络。)
Bell Curve 播客的估计将活跃 searchers的数量仅定在 500 名左右。
—
Ops
Ops(opportunities) 指任何可被利用来提取 MEV 的情形或事件。
当 searcher 成功从其中获利时,称为“hit”一个 op。
—
Alpha
我引用我自己的话:
Alpha 是能够创造竞争优势的独家知识或信息。
在此语境下,Alpha 指一种让 searcher 能发现新 ops 的技术或策略。
想理解该词的来源,我建议阅读 Scott Patterson 的《The Quants》。
—
【注:以下的几个策略给出英文原文以便精确理解】
Sandwiching(夹子)
Sandwiching 是 searchers(如 jaredfromsubway.eth)常用的一种 MEV 策略。
“A sandwich attack involves ‘sandwiching’ the victim’s transactions between two transactions initiated by the searchers/attackers, whose reordering of the transactions inflicts an implicit loss on the victimized users and possibly benefits the attacker.” — EigenPhi Classroom
(夹击攻击涉及将受害者的交易“夹”在由 searchers/攻击者发起的两笔交易之间,攻击者通过重新排序这些交易对受害用户造成隐性损失,并可能为攻击者带来收益。)
—
Arbitrage
Arbitrage(套利)是许多 searchers 采用的另一种常见 MEV 策略。
“In economics and finance, arbitrage is the practice of taking advantage of a difference in prices in two or more markets; striking a combination of matching deals to capitalize on the difference, the profit being the difference between the market prices at which the unit is traded.” — Wikipedia: Arbitrage
(在经济学和金融学中,套利是利用两个或多个市场之间价格差异的做法;通过促成一组相互匹配的交易来利用差价,利润即为单位交易所对应的市场价格差额。)
“Decentralized exchange (DEX) arbitrage is the simplest and most well-known MEV opportunity. As a result, it is also the most competitive. It works like this: if two DEXes are offering a token at two different prices, someone can buy the token on the lower-priced DEX and sell it on the higher-priced DEX in a single, atomic transaction. Thanks to the mechanics of the blockchain, this is true, riskless arbitrage.” — The Ethereum Foundation
(去中心化交易所(DEX)套利是最简单且最知名的 MEV 机会。因此,它也是竞争最激烈的。其工作原理如下:如果两个 DEX 对同一代币报价不同,就可以在价格较低的 DEX 购买该代币,然后在价格较高的 DEX 出售,且在单个原子交易中完成。得益于区块链的机制,这种套利是真实的、无风险的套利。)
—
Liquidations
Liquidations(清算)是 searchers 常用的另一类 MEV 策略。
“As the value of a borrower’s collateral [in DeFi applications] fluctuates, so too does their borrowing power. If, due to market fluctuations, the value of borrowed assets exceeds say, 30% of the value of their collateral (again, the exact percentage is determined by the protocol), the protocol typically allows anyone to liquidate the collateral, instantly paying off the lenders (this is similar to how margin calls work in traditional finance). If liquidated, the borrower usually has to pay a hefty liquidation fee, some of which goes to the liquidator — which is where the MEV opportunity comes in.” — The Ethereum Foundation
(随着借款人在 DeFi 应用中抵押物价值的波动,他们的借贷能力也会随之变化。如果因为市场波动,借出资产的价值超过了抵押物价值的某个比例(例如 30%,具体百分比由协议决定),协议通常允许任何人发起清算,立即偿还出借方(这类似于传统金融中的追加保证金)。被清算时,借款人通常需要支付高额的清算费用,其中一部分归清算者所有——这就产生了 MEV 机会。)
—
Long vs short tail MEV
Ethereum Foundation 给出了对不同类型 MEV 的出色分类:
“DEX arbitrage, liquidations, and sandwich trading are all very well-known MEV opportunities and are unlikely to be profitable for new searchers. However, there is a long tail of lesser known MEV opportunities (NFT MEV is arguably one such opportunity).” — The Ethereum Foundation
(DEX 套利、清算和夹心交易都是众所周知的 MEV 机会,对于新进入的搜索者而言不太可能盈利。然而,还存在大量较少为人知的 MEV 机会(可以说 NFT MEV 就是其中之一))
当 searchers 提到 long tail MEV 时,他们通常指较少人知、触发不那么频繁的 MEV 策略。
—
Flashbots
Flashbots 是一个在以太坊上对 MEV 产生广泛影响的研发组织。
他们推出了:
Flashbots Auction
MEV Explore
Flashbots Protect
MEV-Boost
MEV-Share
Flashbots Discord
Flashbots Forum
Realized Extractable Value Dashboard
—
Bundle
Bundle 是提交到 Flashbots Auction 的一组交易。
Bundles 由 searchers 提交,并按矿工接收到的顺序执行。
Bundles 是 searchers 提取 MEV、命中 ops 的主要方式。
—
社交规范(Social Norms)
以下社交规则与期望的行为来自我在 Flashbots Discord(MEV searchers 与其他感兴趣者常聚之地)的个人经验。
—
不要索要 MEV bot
这点很重要。请不要索要 MEV bot。
拥有盈利 bot 的 searcher 不会愿意把 bot 卖给你。
如果你想运行 bot,你很可能需要自己构建。
这样问通常只会让你被忽略,或被骗子联系。
—
不要诈骗他人
看似显而易见?确实会发生。
不要尝试诈骗。不要就诈骗寻求帮助。就……别这样。
—
不要 dox 他人
大多数 searchers 是匿名的,并希望保持匿名。
不要索要个人信息。不要分享个人信息。不要试图查找个人信息。
—
不要炫耀你的 bot
更像是一种社交惯例而非硬性规则,但炫耀你的 bot 通常会被反感。
分享 bot 的表现可以,但别当个混蛋。
我也不建议发布任何可识别你 bot 的信息。
—
不要随便 DM
除非对方让你这么做,否则别 DM。
有问题,请在相应频道提问。
若要问特定的人,也在相应频道提问并 @TA。
如果你不想公开问,先问对方能否 DM;若对方说不行,就别 DM。就这么简单。
—
保持尊重与感恩
这是一个聚集了通常极其聪明、且往往很忙的人们的社区。
有人未回复你,不要往心里去。
有人对你无礼,不要以牙还牙。
有人帮助了你,记得感谢。
有人求助,如果你能,帮一把。通用的社交准则在这里也适用。
—
我想做一个 MEV bot。从哪里开始?(I want to make an MEV bot. Where do I start?)
首先要说,构建并维护一个有竞争力的 MEV bot 极其困难。
需要大量时间、精力与技能。
() 大多数 searchers 会被“rekt”并亏钱。MEV 是强者赢多数的游戏。若你不是最强,就不会盈利。
如果你仍然感兴趣,请继续。
读完本文后,查看我那篇关于用 Rust 编写 MEV bot 的文章:How to use the Artemis MEV framework。(https://t.co/rwOTymy7yO)
—
编程(Programming)
要做出有竞争力的 MEV bot,你需要非常扎实的编程能力。
选择一门语言是第一步。你应当熟悉以下之一:
Rust
Go
JavaScript / TypeScript
我推荐 The Go Ethereum Book(用于 Go)。
我不知道有与之相当的 Rust 与 JavaScript/TypeScript 资源,如果找到会更新此处。
—
一些有用的开源 Rust bots 包括:
Rusty-sando(https://t.co/yu3dYrelsz)
Subway-rs
(https://t.co/HT1nDGDICX)
Opensea-sudo-arb
(https://t.co/ArUiBxz0ee)
一个流行的开源 JavaScript bot 是 Subway。
理解 Solidity 对于许多类型的 MEV bot 是必要的。
—
工具(Tools)
有不少工具对 MEV searchers 很有用。这里列出一些最常见的:
EigenPhi(用于 MEV 分析)
(https://t.co/ZIvpAZstgA)
Flashbots Transparency Dashboard(用于 MEV 分析)
(https://t.co/3gmZvcdGp2)
Tenderly(用于 bundle 仿真)
(https://t.co/ZdIm7zsLXs)
Flashbots(用于在以太坊上提交 bundle)
(https://t.co/bDzWLGr1RO)
—
Bot 最佳实践(Bot best practices)
在从零写 bot 之前,你需要知道一些事情。
我会在这里概述一些常见陷阱与最佳实践。
未来计划写更深入的指南。
—
Bot 架构(Bot Architecture)
MEV bot 的架构通常类似 Artemis 文档中的下述结构:
Collectors:接收外部事件(如 pending txs、新区块、市场挂单等),并将其转换为内部事件表示。
Strategies:包含每类 MEV 机会所需的核心逻辑。它们以事件为输入,计算是否存在机会(例如,某策略监听市场挂单流来寻找跨市场 arbs)。Strategies 产出 actions。
Executors:处理 actions,负责在不同域中执行(例如,提交 txs、发布链下订单等)。
—
Gas 与 Bribing(Gas & Bribing)
在被称为 MEV Auction 的系统中,searchers 通过**支付贿赂(bribe)**来激励 validators 将他们的 bundles 包含进区块。
这些 bribes 通常占到 bundle 中 >99% 的 MEV 利润。
这意味着 searchers 通常最终只能拿到每次命中机会利润的 <5%。
—
你可能听过 gas wars 或 bribe wars。
当多个 searchers 竞争同一机会时,就会出现这种情况。
此时 searchers 会不断提高 bribe,bribe 可能非常高。
为击败竞争对手,bot 支付 >100% bribe 也并不罕见。
—
Salmonella Poisoning
Salmonella attack 是专门为“爆锤”设计不良的 MEV bots 的攻击。
我强烈建议阅读所链接的文章以了解更多信息。()
—
Smart Contracts
从技术上讲,不用自定义智能合约也能做出盈利的 MEV bot,但这样做的人很少。
大多数 searchers 使用自定义智能合约与区块链交互。
这使他们能够:
在一笔交易中与多个合约交互
在一笔交易中批量抓取链上信息
通过批量化节省 gas
回滚无利可图的交易以避免资产负债表风险
—
链重组 与 重组 保护(Reorgs and Reorg Protection)
Reorgs 是以太坊上涉及改变区块链的事件。
对 MEV searchers 来说,reorg 可能带来风险:
被 reorg 的区块不再对 bundle 隐私与排序提供保证。
这意味着 validators 可能“拆包(unbundle)”searcher 的 bundle,并从 bot 中偷走资金。
这被称为 reorg attack。
—
MEV bots 通过在智能合约中使用**运行时检查(runtime checks)**来防护 reorgs。
这些检查包括:校验区块号、校验上一个区块的 block hash 等。
建议阅读 Flashbots 的相关文章以了解更多关于 reorgs 与其防护的信息。
(https://t.co/7Gysv7v66b)
—
结语与延伸阅读(Conclusion and Further Reading)
希望这份指南对你有帮助。
在 MEV 社区中请保持常识;也欢迎把这篇文章分享给任何新入场的人。
另外也看看那篇指导如何用 Rust 创建 MEV bot 的文章。
—
我最喜欢的一些 MEV 相关文章与资源如下:
Flash Boys: A Wall Street Revolt
(https://t.co/2C0Qt7jdUH)
Flash Boys 2.0
(https://t.co/JLURNTrie0)
Flashbots — Frontrunning the MEV crisis
(https://t.co/R9bsfiNbYT)
MEV for the next trillion
(https://t.co/oIgxYPWI7b)
Bell Curve Podcast
(https://t.co/8ZdsPUaR7M)
Bell Curve: Interview with a Searcher 2.0
(https://t.co/mI8CX4retH)
0xResearch Podcast
(https://t.co/DnQSODuQkm)
Anish Agnihotri
(https://t.co/LyhAyG9eAO)
The Flashbots Forum
(https://t.co/X6Uw115Xnc)
—
@teaprotocol has launched #teaBASE, an all-in-one toolkit & first platform to make secure, signed commits, & user-contributed dev tool extensions easily accessible to developers of all levels
Learn more: https://t.co/4wdoDtLaDp
Star us on GitHub: https://t.co/A8OTEc7QrB ⭐