Flashbots 🛠️ Leveling up the MEV Game with Flashbots
ETHGlobal·Mon, Oct 9, 2023, 12:00 AM
Join Shea Ketsdever for a workshop titled "Leveling up the MEV Game with Flashbots". Thank you to everyone who joined us for ETHGlobal Paris 2023! Paris is the city of light and birthplace of many revolutions. Therefore we were thrilled to be back in one of the most buzzing and free-spirited cities in Europe for ETHGlobal Paris 2023. A lot has changed in the European ecosystem since the last time we hosted a hackathon in 2019. ----------------- Follow us: https://twitter.com/ETHGlobal Check us out: https://ethglobal.com Email us at: hello@ethglobal.com
Transcript
foreign [Music] I'm from flashbots and today we're going to be talking about Mev about the history of strange things in the mempool um briefly um hold on there we go um at a glance this is what we're going to be talking about today I'll share with you kind of the history of interesting things that have happened on chain we'll talk about new emergent phenomenon and then about how you as a user Searcher or an application developer can leverage these tools today um there's a brief introduction if you are not already familiar with flashbots we are a research and development organization dedicated to mitigating the negative externalities of Mev so we develop protocols like the ones you see here boost and web share as well as products like our bundle relay for Searchers the protect our PC for users and wallets and our block builders and purpose of this is to ensure that the Mev supply chain stays decentralized but what does that actually mean um if you will indulge me I want to start by taking a quick walk down memory lane looking at some of the interesting things that historically happened on chain and I'm going to start if you are an OG you may have seen this slide before um it is a deck put together by one of our mates a few years ago to show how Searchers were engaging with the very earliest form of flashbots and I want to share with you some of my favorite anecdotes and stories from this because I think they're quite Illuminating and still true with the market of searching an muv today so to begin with uh way back in the early days of flashbots one of the earliest interesting scenarios we saw was when a Searcher named Nathan entered the chat so Nathan was a very sophisticated Searcher who in this example we see he was able to bait essentially a sandwich bot and steal about 250k from them and this is actually an example of one of the earliest kinds of exploits in muv affectionately known as salmonella essentially the way this works is that you create a token which simulates differently from how it executes so the sandwich bot in this case actually run by miners was able to buy the tokens but then couldn't sell them back and whoever baited them was able to drain the pool we also in the early days saw a lot of PVP games between different Searchers that were competing and fighting with each other so this is a very cute screenshot actually of two of these Searchers who had I think one of them had wrecked the other one left them a nice message on chain saying good game well played and then finally another theme we see is the entrance of new paradigms new protocols for searching so this example is of uniswap V3 it was really interesting actually when uni V3 was launched there basically were very few people who actually upgraded and integrated it it took months before we actually saw like a competitive landscape of uni V3 searchers and I call these examples out because I kind of three key themes here three constants if you will in the history of searching and they are first of all that there are new exploits that emerge uh maybe used to be the salmonella exploit now it's something like the low carb Crusader the second theme is that there's also new paradigms that emerge for searching so different protocols different ways of thinking and the final constant is that despite all of this in the face of all of this change Searchers adapt with style so you know you see the very cute P2P messages this one I don't know how easy it is to see on the screen but this is an example of a Searcher who is actually recently trying to integrate a new protocol called mob share and they realized that their bot was not going to be that profitable when it first launched so they called one of their functions the charity function which I thought was very cute but um what's happening now like what is the new frontier in searching today that was a few years ago what's happening today and I want to share with you a few things I've seen in the past couple of months that I think are quite interesting and allude to maybe a new paradigm in searching and in Mev more generally so I'll start with this one it's like a month maybe two ago uh we saw this token launch happen and it's a pretty standard token launch uh the team announced it on Twitter in advance and immediately after the token was launched we saw this bot essentially background the launch to basically snipe and grab a bunch of the supply um the reason it looks weird is that the token launch contract had a clause that tried to prevent people from basically loading up on this token but as you can see that was no barrier for the Searcher they were able to uh just kind of get around it by making a bunch of requests so all of this is pretty classic token launch token sniping stuff nothing weird here uh but there are two weird things if you take a closer look at the Block where uh that Searcher transaction landed the first is if you actually look at the original transaction that launched the token uh you will see something strange which is that this is a flashbots bundle this is a response from the flashbots Lux API which tells us that this was actually a private transaction it's kind of weird how did this Searcher know to background them the transaction itself was Private what's happening there the second thing you might notice is there's actually a third transaction after the launch transaction and the back run which is a transfer from the Builder to the original launch address of about twenty thousand dollars that's that's weird so some portion of the searcher's bid was actually refunded back to the user weird I have one more example for you uh yeah essentially how did somebody back run a private transaction and generate so much value one more example which is in this block I want to take a quick look at another similar case these three transactions it says about a week ago we saw first a user Make a trade on a DEX they were swapping some eth about 10 each for this random token called woof work they actually got completely wrecked not by an Mev bot just because I think the pool was quite a liquid they basically went from 10 East to almost zero dollars very sad uh you can see this is also a private transaction okay people make bad trades all the time this isn't that unusual uh but what is kind of interesting is again we saw a Searcher back running them in the same block despite this being a private transaction and that Searcher knew which pool the user was trading on weird we also yet again saw a refund from the Builder to the user who made the original trade so what's happening what are these weird phenomena that we're seeing um this is actually not a fluke this is an example of a new emergent phenomenon that's happening today on chain and called an order flow auction so essentially the squat status quo right now is users will either send their transactions to the public mempool or they will send them to private channels like for example flashbots protect which is where these two examples came from and Searchers are able obviously to see what happens in the public mental but they're not able to see what happens in the private mempool and that's actually pretty sub-optimal while these private channels are really great for protecting users from things like front running um as we have seen there's a lot of value that is on the table to extract even just by back running these transactions which is something that's fairly neutral usually to the original user in just these two transactions alone there's about 15 eighth on the table that's just sitting in these private channels so order flow auctions try to find a balance between protecting users and internalizing the value they generate the premise is that when users transact on blockchains they generate value and right now that value is primarily captured as we have seen by Searchers or the validators they have to bid to for inclusion but we want to give users a fair price for their transactions and the way that we do this is by allowing Searchers to bid for the right to execute them essentially allowing us to strike this balance between protecting users and internalizing or refunding them the value that they create through Mev so this is essentially what we're trying to do is allow some valuable actions to be taken on private order flow the the problem though with all of this is that searchers can't exactly be trusted so users are using these private channels for a reason they don't want to get wrecked we need to find a way to kind of balance that concern uh with allowing valuable generate Mev to be generated and the really the trade-offs here really come down to privacy you know the more you information you have as a Searcher the more efficiently you're able to background or bundle some user transaction and this is also good for the user because it means that they're able to get a higher bid in the auction on the other hand if you reveal too much information somebody could you know generalize front run you on another domain or take some other action that negatively impacts the user so a flashbots we have thought a lot about this exact problem this trade-off how much information do you share and what we found is that it's not a one-size-fits-all problem different use cases need to share different amounts of information to strike this balance between protection and value internalization and we call that concept programmable privacy concretely uh the idea behind programmable privacy is that you control what information you share and we call these pieces of information hints so an example of the hints that you might see are things like the contract address or the logs maybe the call data Maybe nothing but transaction hash that a transaction emits and what's very interesting about this is it creates a new paradigm for searching as a Searcher you will have to actually update your strategy to search on these hints in incomplete transactions rather than on complete transactions that you're used to seeing in the mempool so for the rest of the time what I want to talk about is one particular protocol for order flow auctions that uses this concept of programmable privacy I'll talk about what it is how it's architected and then how you as a user more an application developer a wallet or a Searcher can interact with it today and that protocol is called Mev share so if I take a quick step back to orient us if you have seen any flashbots presentation you have probably seen this slide if you have not here's the slide you will see it many more times after this but essentially this is the Mev supply chain in other words it's all the steps that happen from when a user submits a transaction to when that transaction is included on chain and that includes you know the user's intent which is then signed through something like a wallet submitted and bundled by Searchers merged into a block by a block Builder and then finally confirmed by a proposer or validator and to zoom in a bit where Mev share lives is right here so at the very start of the transaction or muv supply chain and the protocol is pretty straightforward it about three steps and there's really one primary actor which is called the Mev share node and the med share node is responsible for doing a few things first of all it receives transactions from users second of all it shares whatever hints that user has asked for with the Searchers that can publicly see this data then it receives partial bundles from Searchers which are just like usual bundles except because we don't share the full signed transaction as a Searcher you're not going to be able to put a transaction in your bundle so instead what you would include is an identifier for the transaction whose hints you thought matched whatever you wanted to put in your bundle so for example that identifier might be the transaction hash so partial bundle would be a normal bundle but with some transactions and some hashes finally step three the Matchmaker will receive all these partial bundles and then it will convert them into full bundles by inserting the signed transactions that correspond to the hashes that Searchers have specified and the the resulting full bundle is then sent on to a block Builder pretty straightforward so how does this fit into the existing flashbots architecture like that protocol is all very interesting and high level but like how do I touch it where does it live today what does it mean for me as a user a wallet application developer or searcher so here is where it sits if we look back at the original diagram flashbots protect is a protected or private channel that users or wallets can submit transactions to and what we've done is flashbot says implemented one instance of a med share node which is that party that sits in the middle of the protocol and that node can be accessed directly through the flashbots protect RPC so these things are now combined together and what this does is allows Searchers to in a safe way try to generate additional value on top of this private order flow so flashbots protect is now upgraded and has a bunch of useful properties for users it gives them both protection and now with Mev share the ability to internalize Mev that they generate and for application developers or wallets it gives you a lot more options about how you actually design your application in an muv aware way through this configurable control panel where you can decide what information is shared with who and how so to go a little bit more specific concretely as a user the way that you would interact with this is really easy there is a button on the flashbot's docks you just click the button it adds the RPC to your wallet I think it takes maybe two or three clicks depending on what wallet you're using and it's fairly straightforward all you have to do is switch out your RPC to get these benefits as a maybe more sophisticated user or an application developer or a wallet you also have more options these are available to everyone but especially recommended to folks who are developing their own applications that want to kind of Tinker with how the med share protocol works so you can select a number of things including the hints or privacy settings that you want to share as well as the other block builders that you might want your transactions to be forwarded to for example to have increased inclusion rates you can also select things like how refunds are distributed what percent of the searcher's bid goes to what address or another and you can also configure even more advanced things which we call validity conditions a refund is one example but it's basically a way of telling a block Builder how it is required to treat your bundle happy to talk more about that after if anyone is interested as a searcher though what does this look like I think this is the biggest step change with something like Med share and for grammable privacy is how Searchers are going to interact with this new paradigm well there are about two or three things that you'll want to think about um and the first is how to consume data you're going to be using hints instead of mempool transactions which means you have to listen to the mebshare event endpoint listen to the nodes hints instead of listening to the public mental and you're also going to need to parse a different object you know you're going to parse something that has these hints in it rather than a full signed transaction this is an example of what some common hints might look like the second thing is you'll have to change the way that you think about sending bundles in particular we talked earlier about partial transactions or sorry partial bundles which just include the hash of a transaction so you'll have to adopt that new paradigm and the way that we do this is through a new API we've gone from Ethan bundle to Mev send bundle and this is roughly the structure that you will care about migrating is very easy it's like three things change the namespace from Eve to mevs rename the transactions field to body which we've generalized to allow for hashes and then we rename block number to block so you'll have to rename that as well but pretty straightforward migration the most interesting piece of this once you've got all the Integrations hooked up is how you actually change the way you think about your searching strategies so you know you're not able to do things like simulate a full transaction anymore which means that you're going to need to move or change the logic that you use as part of your Bot and there are about two ways that we think about this broadly the first approach I would call on chain searching and basically what on chain searching is is moving all of the computation you used to do off-chain into a smart contract that's executed on chain so as an example if you're used to seeing the amount or that somebody is trading in their call data or their logs you might actually have to use the reserve Deltas on chain to run a calculation like at execution time to figure that out now the other way you can think about searching on a programmably private transaction or set of transactions is to do it in a more probabilistic fashion so for example instead of knowing the amounts and the direction that somebody's trading you can just guess basically say well I'll send two transactions one for each direction that they could possibly be trading on this pool and then I'll also you know for each of those directions send a bunch of different possible sizes if this is an ARB for example the thing I would emphasize and stress to all of you is like it took about three months for anyone to really become competitive on using uniswap V3 mem share is also very early and this Paradigm is new and that means that as a scrappy early Searcher you actually have a huge advantage we're sponsoring some prizes for the scrappy Searchers who want to try this new paradigm as well as you know wallet application and other developers who are interested in experimenting with Med share so I'll briefly talk about what those prizes look like the first thing is we're giving a prize for the coolest Med share bot essentially come up with something weird deploy it lend some bundles this should be open source also giving away the prize for a design that uses Med share in an application so really get creative with this it can be fully implemented it can be an architecture spec but the idea is to have some sort of specification for a new configuration a way of using validity conditions or hints in an application also please make it open source there's a theme finally we're giving out a prize for an onboarding viral website for the protect RPC uh so we currently just have this button in our docs we want to see what interesting things you might come up with all these value props we've talked about today and how would you want to communicate that to somebody again we build open source software so please make this open source and that's it um I think to conclude there are like I mentioned at the beginning three things that remain constant in Mev new exploits emerge new paradigms emerge and Searchers adapt with style so we're very excited to see all the stylish ways you will interact with this new paradigm um you can reach out to me and the team will also be in the Discord for the rest of the hackathon yeah that's it [Applause]
Automatic transcript — names and jargon may be misspelled.