# Cost of Feudalism: Towards a Theory of MEV | Devcon Bogotá

- Channel: [Devcon](https://streameth.org/devcon)
- Date: 2023-10-07
- Duration: 30:05
- Watch: https://streameth.org/watch/yt-6JA4_5QWG0s
- YouTube: https://www.youtube.com/watch?v=6JA4_5QWG0s

## Description

Visit the https://archive.devcon.org/ to gain access to the entire library of Devcon talks with the ease of filtering, playlists, personalized suggestions, decentralized access on Swarm, IPFS and more.
https://archive.devcon.org/archive/watch/6/cost-of-feudalism-towards-a-theory-of-mev/

Maximal Extractable Value (MEV) is excess value captured by miners/validator. This excess value often comes from reordering, censoring, or inserting new transactions that allow a miner to front-run users' transactions. Is MEV *always* bad? Can it sometimes lead to good equilibria for users? We modify tools from algorithmic game theory and probability to prove some surprising paradoxes — *some* MEV improves trading efficiency in networks of automated market makers.

Speaker(s): Tarun Chitra, Guillermo Angeris
Skill level: Advanced
Track: Cryptoeconomics
Keywords: MEV,algorithmic game theory

Follow us: https://twitter.com/efdevcon, https://twitter.com/ethereum
Learn more about devcon: https://www.devcon.org/
Learn more about ethereum: https://ethereum.org/ 

Devcon is the Ethereum conference for developers, researchers, thinkers, and makers. 
Devcon 6 was held in Bogotá, Colombia on Oct 11 - 14, 2022.
Devcon is organized and presented by the Ethereum Foundation, with the support of our sponsors. To find out more, please visit https://ethereum.foundation/

## Transcript

foreign [Music] you know I probably don't need to talk about what Mev is as much uh given that there were if I remember right 17 or 18 talks about Mev um but you know I think in the spirit of trying to understand the incentives uh hidden in a lot of these these systems one question you might ask is does there exist sort of some type of formal theory for Mev does there exist some type of mathematical structure to this thing that seems to be you know Captivate people's imaginations yet no one can describe it and so I'm going to talk a little bit about different ways of addressing this problem including some work we've done and um I I like to call any analysis of Mev sort of measuring the cost of feudalism so that's that's sort of where the title comes from let's start with the operative definition of Mev you know when you see it like the of course the famous Supreme Court ruling on porn uh and uh you know Mev comes in many shapes and sizes uh you know of course we have everything from Sandwich attacks liquidations Arbitrage nft front running and cross chain um and as you can see there's it's sort of quite a variable form of revenue for for validators and Searchers uh and somehow we because we know there are many examples and we feel like we can't enumerate all of them it might feel like the space of all mevs super big so how do you analyze it you know I know there were two talks yesterday about what is and isn't uh Mev but I think we're going to focus on uh kind of an operative definition that can be used and uh we could we could sort of say Mev is any excess value that can be captured by validators by reordering transactions strategically adding or removing transactions the idea is most of this is currently managed via off-chain auction so people bid on transaction priority atomicity you know and within bundles uh and you know if we take a step back and look at the history of ethereum of as to why we got to the auction world um part of the reason is the blockchain was just getting spammed by people doing liquidations and back running oracles and instead of normal users being able to get their transactions in you'd have the you know entire blocks filled with people's you know spam background transactions on the other hand of course as the previous talk was focused on uh there's a lot of centralization risk with off-chain auction so let's you know try to maybe schematically look at you know what how Mev works we have users who submit transactions which are the Deltas we have a mempool uh the Searcher has sort of their own view of the mempool and maybe they have some transactions that are directly given to them which you know people would call Private order flow and then the Searcher sends their bundle which uh they're willing to pay for to the validator and the validator added to the block the philosophical question here though is how do we know value captured by Mev is excessive or in a notion of excess you know in this sort of first definition I said any excess value well how excessive is excess describing value Flows In Mev is actually quite difficult so in in algorithmic Game Theory you usually have two main ways of thinking about the world one is optimizing social welfare social welfare means if everyone has some notion of utility some notion of how happy they are with the world you want to maximize the sum of everyone's utilities on the other hand revenue is you know the the the person selling the good uh you know maximizing how much they earn and and then in cryptocurrency it's actually interesting that you have to optimize both jointly so obviously user welfare is important for the success of any network I don't need to really convince anyone of that but validator Revenue being optimized is actually important for Economic Security if validators are not making sufficient income from it then they're unable to to Really secure the network and in decentralized networks versus centralized networks these are two competing goals and I think the one reason there's a broad view of how Theory you know algorithmic Game Theory it's different for crypto is that you have to sort of balance these two goals instead of trying to optimize one of them so what pieces are sort of missing so how would we kind of describe welfare as how would we describe Revenue um you know one thing is understanding the user's utilities what is the user getting out what is their notion individual notion of value and that can vary over the entire network the other thing is some notion of transaction fees and payments that you know the distribution of payment sizes that users are willing to handle and the last thing is an understanding of how an Auctioneer so in flashbots or you know in PBS how they allocate block space is to users and that that last part is actually quite complicated and these three things are quite entangled when you want to try to write a mathematical theory for me being and these sort of things actually depend a lot on the application right the user's utility for minting in nft is extremely different for a user's utility for borrowing uh against some collateral uh and inevitably that means that the allocation mechanism should somehow be tied to that okay so let's let's try to do kind of like the eli5 simple version of those which is uh you know we have a notion of block space which is sort of a notion of Max number of transactions or slots or size or gas you can choose a unit but for Simplicity just assume they're sort of fixed number of units there's sort of a notion of a binary allocation to a user of whether a particular user gets a particular slot the users have the utility functions I'm unspecifying the domain and range because of course it's actually quite complicated in a world of cross-chain bridging and we see here that social welfare is defined as sort of the expected total utility of all the users given an allocation so these X variables are effectively whether that slot is given to a certain person then this is sort of measuring their sort of net happiness let's say uh Revenue however is just the expected value of the payments and notice these are quite different um in in particular the social welfare includes the utility of the auctioneer which means that all of the payments that the the users send are subtracted or sorry our negative terms for the bidders and it's a positive term for the auctioneer so the payments cancel out in social welfare so you have no dependence on payments explicitly whereas in revenue of course you you depend on payments so you know if we wanted to try to formulate what is an economic equilibria for the system you might say okay well let's try to find joint up you know Maxima of the social welfare and revenue functions however given an allocation that optimizes social welfare it implies a set of payments and it can be true that the payments that you get from optimal social welfare are very far from the payments that you you get from optimal Revenue right that there's some intuition to that right like if if flashbots just basically gave every bundle for free obviously the there's a lot of user gains but like you know the auctioneer is pretty pissed aka the validator slash minors and this happens all the time in mud the the idea that the optimal revenue equilibria and the optimal social welfare equilibria are sort of disjoint so you know the the name cost of fee or cost of feudalism is really a pun on the concept of the price of Anarchy which is sort of a common Concept in algorithmic gain Theory roughly speaking you can think of the price of Anarchy as if I take if I have a set of many equilibria I want to look at the ratio of the worst case behavior of an equilibria to the best case Behavior it's an approximation ratio and so what this for instance this formula says is what's the worst case that the equilibria the payments earned by the validator deviate from the payments earned at optimal welfare and what's the best case and what's the ratio of those and you could basically think of this as if this is really large or depends on the number of transactions or users that's really bad and so you know uh tongue-in-cheek uh you know of course nothing in real life is asymptotic but you know I I Feel Like These are good heuristics which is constant price of Anarchy is really good it means that even if you get to a shitty equilibria uh it's not that much worse it's not that much uh worse than the best equilibria if the price of Anarchy is is weekly growing uh so little o of n so like maybe it's logarithmic in the number of users or slots maybe it's square root of the number of user slots that's okay it's you can deal with that um and if the price of Anarchy is linear in the number of users that's horrible that that basically means that the more users join the system the worse the equilibria is for everyone which is like the opposite of a network effect it's like the anti-network effect right no one wants that um and the interesting thing is that this quantity if you try to write it out depends a lot on your choice of how you what applications you're modeling because to compute the prices you need to sort of know these utilities of the user and that of course depends not to keep belaboring that point but I think the the one of the reasons Mev has this you know both meme ability and inability for anyone to write down equations for it is because it's so dependent on the application which is something I think you know the early designers of cryptocurrency networks did not you know Divine at that time so let's go through an example a stylized example of kind of what this looks like how would you analyze this for amms um there's a very famous Paradox in algorithmic Game Theory called braces Paradox and braces Paradox is really about how traffic flows on a network so we have this network on the left and we have a source City s we have a destination city d and imagine that there's a bunch of traffic that needs to go from source to destination each Edge that it takes is a latency and so when you see a latency of one that's sort of like a a link that can take arbitrary capacity it takes the same amount of time for everyone to to cross that link when you see a link of X it's dependent on the amount of flow in that Network so you could basically imagine that say we have 100 cars um if 100 cars all go down the route X then it's proportional to the number of cars that are going on there and so what you can do is you can say Hey what if everyone is selfish or greedy they're not cooperating they don't have Google Maps so Google Maps effectively gets around this because it it sort of implicitly coordinates people whether you you know you're thinking about it or not uh but assume everyone's selfish and they they know this map how would they how would they choose which path to take and the the thing you can show is basically it they would split themselves up 50 50. the traffic would go half on the upper path half on the lower path and so the the time it would take is three half you know we choose some units uh such that X's from zero to one on the other hand you might think that adding more roads always you know decreases traffic and this is not true so there's this interesting thing of if everyone's selfishly optimizing if you add a link between the two middle cities that lets you teleport um then everyone just takes the X middle link X path and the total congestion that everyone realizes goes up and so the the this sort of you know paradoxical Behavior Uh I think philosophers would not call this a paradox but but uh economists call the Paradox uh is that you know even though you added a road you've actually worsened congestion because people aren't routing themselves across the network well because they're not coordinating so you might say okay great what does traffic have to do with crypto well you know first before we even get to that you may think Med is always bad you know there's always these articles that people are writing that are like front running is theft it's bribery it's you know whatever you will pick your favorite negatively connotated weasel weasel word and you might just say okay like yeah it we we need to get rid of it at all costs with that instead of thinking hey maybe maybe it's just endemic to such systems we we saw abrasive Paradox and what we're going to see is we're going to see that for some examples of applications in crypto you can get around braces Paradox by having nav which sort of says Mev has some positive externality in some situations which is you know the opposite of front running is theft as a service or whatever um and again not all applications are the same so that that's where the the conundrum in defining your sort of optimization problem shows up um another thing that's actually really important to pay attention to is if we classify users into two types of users strategic users who are Mev Searchers or people who are trying to optimize routes on chain and non-strategic user like the person who pays 80 bips for a metamask swap if we kind of look at you know those two two sides routing is actually one of the hardest problems for non-strategic users so non-strategic users actually in fact Outsource that to third parties right now right so if I want to trade token a for token B but there's no pool directly from A to B or there's not enough liquidity you know I go to one inch matcha gem I'm including gem from the you know you could argue nfts have the same properties um and you know routing is actually quite complicated so you know algorithmic game theory is studied routing in fact braces Paradox is a great example of of how how to study routing uh and one question you might ask is hey does this apply to amms does this apply to one inch to supply the mantra and the interesting thing that you'll see is now imagine in this prior example instead of teleporting in the middle link we actually add a small amount of congestion Epsilon times the traffic now you can show that equilibria basically approaches something uh as Epsilon gets really large you go back to the condition where everyone routes themselves across the two paths and when Epsilon is really small you get back to the the purely selfish thing and the idea is the Mev Searchers are actually adding this extra Epsilon so that people route themselves across the graph more efficiently and that's something that's a weird positive externality that if you write out the math you know I I try to not add a lot of the equations to this talk but if you write out the math it's actually quite compelling that the social welfare somehow has improved by Mev in some scenarios right that's not the narrative you hear right the narrative you hear is like oh I'm just grannies are getting robbed in metamask and that's just not true always so I uh like I said I'm not gonna go through how you show such a thing but I'll at least give you an idea of like what such the theorem statement looks like for such thing and the idea is is we we showed that even when they're sandwichers the price of Anarchy is constant remember price of Anarchy constant that's good that's very surprising you would think that hey as more users come to network sandwich attackers make more of a profit they cause more of a loss but in some liquidity conditions they do not and this this sort of bottom chart shows you the expected profit on the y-axis and it shows you sort of the amount of slippage in your by the the user and you'll see that it has a Maxima it's not like it keeps growing and that that's the thing that's actually quite interesting and nice about this example so you've listened to me try to convince you that mev's not bad it can have these positive externalities maybe there's something really interesting uh about it and maybe you can direct it into uh being used for some particular applications that uh are just net net beneficial to your network so one question is what do you do to to harness it for good so one thing I think that's interesting and and this goes a little bit to Alex's talk before is suppose you did have a mechanism where it was just extremely expensive for people to bribe a validator off chain and in fact people were willing to basically uh share their Mev Revenue imagine like a mining pool for Mev Revenue now the reason that that's very hard to design is it's very hard to make it collusion proof where people pay one minor ahead of time who in the pool and they don't share Revenue with everyone but suppose you have a way of doing that and there's a lot of people working on really really interesting stuff both on the cryptography side as well as on the sort of distributed system side for for trying to to to do such a thing but suppose you have such a mechanism then you can redistribute Mev to all the validators in the system and one very interesting thing is you can show in some some sort of different types of for different types of Mev you actually can lower the overall inflation rate of the network if the Mev subsidy is large enough so the x-axis on this plot is the percentage of Mev Revenue shared and the y-axis sort of is a measure of how much people are adjusting their stake so let's say there's sort of opportunities outside of uh staking that people can earn yield on their assets with uh one question you might ask is like what what are the incentives that keep people staking and the interesting thing is that Mev actually adds this feedback loop such that you can lower your inflation but also ensure that people stay staked and so you know the y-axis is sort of a notion of percentage of how much is of the network is staked and you can see that at around 25 to 50 in this stylus model of Revenue sharing you actually get people to continue staking which is just you know it's just kind of surprising right like everyone's always like oh we've always needed kind of hyperinflationary economics and there's lots of reasons for that but but but Mev distribution also allows you to avoid having to do that so that's sort of like a kind of amazing blessing in disguise and there's a lot more research that can be done in this space that I think we we mainly looked at how liquidations impact uh Staker incentives uh another interesting thing and I think this is the type of thing that we're seeing in multiple ecosystems whether it's ethereum especially with roll-up auctions whether it's in Cosmos um but everyone sort of is starting to realize the Mev auction of having a single Mev auction for everyone to kind of compete in may not be the best form of an auction you may want to have an auction per roll up you may want to have an auction per application and so that you can tune the aux you can tune the social welfare versus Revenue trade-off right now if you think about it everyone who's making a flashbulance bundle for an nft mint is competing with everyone who's sandwiching for the same sort of block space but they may actually if you segment to the block space and say only this amount goes for sandwiching in this amount goes for nfts you might have a very different equilibria uh and I think you know a lot of the roll-up developers are are basically kind of talking with us but an interesting thing is and some some current work is you can actually show that disaggregating uh a single auction into many auctions can actually have better social welfare for the end user and that's sort of like an interesting kind of trade-off uh that I think as things like PBS get developed you have to sort of analyze these types of incentives um so you know I uh I think I want to just at least impress upon people that theoretical foundations for Mev are really important and I think we've sort of started with this thing as this like emergent unstudied phenomena we sort of backed our way into some mechanisms for like you know doing an auction coming up with sort of rough reputation scores which you know it's not totally clear exactly how that whole system can be analyzed uh to a point where we actually are really able to start thinking about okay how do we optimize for things like redistribution how do we optimize for social welfare how do we optimize for validator Revenue in a sort of joint manner and formalism uh I think it provides us this way of finding these truths about Mev where which show that hey it's not always robbing grannies in metamask and the interesting thing is I think people you know this is sort of the beginning of this kind of new branch in my mind of algorithmic Game Theory where you're really focused on the joint optimization of social welfare and revenue because both of them are extremely important to network survival in cryptocurrencies and so I I want to leave you with some open problems in case anyone kind of is is interested in this type of stuff uh the first thing is what's a notion of optimality for an auction right right now if you look at flashbots it's sort of a first price auction with some filtering because they use a scoring function that removes some public mempool transactions is that optimal does that work when you have multiple chains or multiple this sort of hierarchical system um also does it does it sort of uh deal with uh some of the problems of hey how do I trust the auctioneer right now we have a system where everyone basically trusts the auctioneer and you know economists have copied cryptocurrency enthusiasts and made some trilemmas recently on proving things about when auctions uh when you when you when and when you can't trust an Auctioneer and a lot of that work you know I think if the right people were focused on it could really determine how PBS functions as an auction and what sort of like the expected properties of it are on the other hand there's sort of some notion of lower bounds like in an open permissionless system with a some notion of value there sort of has to be some lower bound to the amount that's extracted because within without any extraction it's very hard to imagine validators being able to to continue to sustain the network and so one question is how do you construct those lower bounds you know in information Theory and in theoretical computer science the lower bounds are extremely hard upper bounds are always easy lower bounds are are really sort of some of the hardest kind of things to show and I think the Mev space of lower balances is still quite open I think you know in in spite of kind of there being some a camp of some people who believe with sort of fair ordering that there exists no such lower bound I I would I would argue I would argue just proving that the lower bound's not zero is already a quite difficult problem that would you know be worth solving and the last thing that's a very big uh open problem research-wise in Mev is this concept of aggregation versus disaggregation effects and so I think a lot of people in in the Mev parlance we'll focus on talking about things like private order flow order flow aggregation like what happens when a builder has all of a certain type of order flow there are ways to to talk about what the equilibria of the system are what's the distribution of Revenue to different participants uh based on these kind of aggregation versus disaggregation effects but if I were to kind of give you the stylized version of what this question is asking and saying what is the coast theorem for Mev so cos theorem for for for those who don't know is sort of a a very famous thing that I think basically says imagine you have a company now suppose the company had everyone at the company as an individual contractor why is it more inefficient why is it more efficient to actually organize as a group versus individual contractors who are giving payments to each other and the coast theorem sort of says there's some equilibrium the Middle where there's aggregation effects where it's cheaper for people to work together and share common infrastructure up to some point and then after that point the overhead of managing that many people starts causing you to to lower your welfare and this notion of aggregation versus disaggregation and Mev is is completely unsolved yet people are always talking about it it's it's kind of implied in people's language yet yet not formalized cool and so that with that I'll leave you for questions and also yeah thank you uh do you have any questions for tarun if so please raise your hand we'll get you a mic we got one question on this side we'll get to you in a second got another question at the back hi uh so my question is you gave an example of uh you gave first theoretical example of how uh removing an edge from a network can make traffic more efficient and then you give an analogy for how this can also happen with amms and you gave a practical example of how it could happen with amms but I I did not understand how this practical example works so could could you explain more like how could Mev improve the efficiency of trading on this scenario with three two pairs yeah so so think of it this way I imagine that there's uh people who want to trade from token a token B and there's an order flow of n orders from A to B uh if I look at how to optimally route the orders from A to B um if everyone gets routed on the same route the price that everyone pays on average could be a lot higher right if everyone gets routed on different routes throughout the network you could have sort of your your load balancing what the price impact is and the point is that the med Searchers are sort of acting in some weird capacity is almost like air traffic controllers when there's a bunch of traffic going on the same route it increases the Mev profit but as the Mev profit goes up then people start routing away from that and you could effectively think of it as a way of sort of having a decentralized coordinator where where it comes from the fact that the more traffic going on one route the more the sandwich profit but then once people start realizing the sandwich profit they route elsewhere and so this routing problem is actually you know the quintessential example of uh these cases where congestion sort of you can you can add in some sort of like incentives to avoid congestion and and you know a lot of internet routing traffic routing on the internet a lot of that kind of work is like where this initially started and this is sort of making an analog about here but the key is that someone is getting the worst price by being sandwiched there's no doubt but everyone going across the graph is getting a better price on average and that that's the social welfare versus Revenue trade-off if that makes sense awesome we have another question at the back hello uh good afternoon I love the presentation as usual my question is have you made any studies around uh Central Bank digital currencies or even Fiat currencies using the same Theory yeah I mean I think the hard part with any of these sort of like pseudo centralized Federated type of things is well I I mean the validator should can just always do the Mev themselves right like the limit of of the centralized thing is like well what does Facebook what are Facebooking Google doing they're just doing Mev on their own auctions right they're constructing the bidding strategies for you they're like we're using the highest machine learning to give you optimal like targeting it's like it actually means actually we're just going to front run you in our auction but it's too complicated to explain how so in the centralized World these types of things are not that interesting to analyze from that perspective in the sense that the centralized coordinator will just like choose the most expensive route for you all the time right but in the decentralized world is actually quite interesting because the user has to choose their own way uh through the network um so yeah that that sort of you great well one last question on that side and we'll move on to the next talk so please go ahead cool yeah hi I'm following up on the first question in the brass example the conditions under which the routing would actually or in which Mev would be beneficial is and if you can teleport right these conditions are usually not met what are the you said under certain conditions this applies for MMS what are those conditions does it mean if I can trade you know if I can print free money or trade it unlimited or zero exchange rate or what are the conditions in which no yeah actually that's a good point so so the the zero uh is in the traffic example in the amm example you can never have zero effectively in that Edge there's always some amount of liquidity uh price impact unless it's like you know a linear amm I I think the main thing we showed is that the liquidity difference on certain edges on that graph relative to the center edge has to be large so it's not necessarily that it's saying that hey you're teleporting or it's like you're you're you have some sort of like non-balanced budget Condition it's actually just that the liquidity relative liquidity differences on different edges has to be high and that those are the conditions and you know I'd say our proof is pretty pessimistic in our conditions and there definitely were ways of like getting much better bounds on it um yeah awesome thank you so much please give a big round of applause for tarun [Applause]
