 Good morning everybody. My name is Joseph. I'll be your emcee this morning. How are you enjoying Defcon so far? I guess this is the group of people that didn't party or did party hard and just didn't go to sleep and just continued with the drill. So I appreciate you for being here in the morning. I know it's tough, but without further ado, because we are getting to our time, we are going to start with some heavy topics right in the morning. Matt's Diable, the research and product lead at Otus, is going to present his talk about an overview of automated market-making mechanisms. So please put your hands together for Matt. All right. Hey everyone. So Otus is a DEX aggregator and so while building it, I've had the unique opportunity to really do a deep dive into the different automated market maker mechanisms that control billions in DeFi TVL every day. So the aim of this talk is going to be to try to cover as many of these as possible, primarily the ones that currently control a large amount of TVL. So it's not going to be completely exhaustive, but hopefully it's close, as close as possible in 25 minutes. And then we're going to tie that back into DEX aggregation, why it's needed, and what it's for. So to start off, I want to briefly cover some of the basic principles that we can think about while we're going over these many different mechanisms. So first I think it's useful to clearly define what we're actually trying to do with these market-making mechanisms. So we can start off by clearly defining what a market maker is. So a market maker has a portfolio of assets and they're trying to earn yield on that portfolio and they do that by allowing people to trade through it. And so essentially what happens is they offer to sell an asset at a slightly higher value than they will buy it back and that creates this spread that serves as revenue that they earn on the volume that goes through their platform. Now the catch is that this revenue is not risk-free, right? People are, when trading is happening we're actually changing the composition of the portfolio and this also leads to a change in value in the portfolio. And so what can happen is if the change in value in the portfolio as a result of the trading outweighs the revenue then you're now losing money and you're not actually earning any yield. And so we really need to do a good job designing the strategy and how we're actually pricing and allowing people to trade. So with that objective in mind we can now think about what tools we can use to actually decide on the pricing, right? So there's many different types and strategies of course but we can sort of simplify it down to two basic paradigms. So the first of which is price discovery. So this is essentially reacting to what's happening in the market. So if we think of a simple example if at the current price lots of people are buying that means the price is probably a bit too low and you should raise it up. And so by reacting to how people are interacting with the prices you set you can sort of follow around the market price and discover what the market thinks the price is which is a very powerful mechanism but of course if you're following around what the actual market price is you're not actually really providing the best price at any given time because you're always trailing behind. And so ideally what we'd like to do is just be providing the price that people actually want to buy and sell at right? We want the real market price and so we can try to approximate that by leveraging price oracles. So trying to leverage some external knowledge to decide on the price without actually having to discover it ourselves. And so this can be extremely powerful because you can really then concentrate your liquidity and general pricing strategy around what people actually value an asset at but it can also be very detrimental because if you're setting if your price oracle is wrong well then you have the same problem with price discovery except quite a bit worse potentially right? So real quick to give some concrete examples one thing we can leverage is the pegged value of the asset so if you have two stablecoins USDC and USDT they're both worth a dollar and they should be exchanged one to one right? And we can leverage that knowledge as sort of an oracle and use that to inform our pricing and market making decisions. Some other examples are chain link oracles and the pricing of other DEXs as well. So last thing before we get into the actual AMMs I do want to concretely cover what where how I'm actually going to be showing these AMMs right? I'm going to avoid the math it's very interesting but it's not it's not fit for a 25 minute talk on nine different AMMs so instead I'm going to show this trading function which is hopefully a bit more intuitive and basically what this trading function shows is it shows the space of possible trades that this market maker will actually allow right? So on the x-axis we have on the x-axis we have the input amount and on the y-axis we have the output amount and this curve is the space of trades that you can make so this point for instance is one trade you can make if you have 100 of the input asset this market maker will give you out 200 of the output asset and at any given point the slope sort of shows you the marginal price that you're getting if you keep on putting input into this market maker so with all of that in mind we can we can now cover our very first AMM and this one is the constant product market maker so this one's huge it's very important it's been it's probably well it is the most popular one it was introduced by Bankor originally then Uniswap v1 and Uniswap v2 both used it and popularized it a lot it's also important for the context of this talk because it essentially embodies full-on price discovery right? Uniswap v2 has no notion of what a value or what an asset should be valued at it simply discovers that price and how it does that is it sets the price as the ratio of how much of each asset it owns and that allows the price to essentially respond to demand so you can see in the trading curve as you put more and more in the slope of the curve continues to decrease and that's showing the price responding to the trading so it's discovering the price now on the other hand as we said if you can leverage an oracle that can lead to much better pricing and so a constant sum market maker is sort of the full-on embodiment of this right so a constant sum market maker will provide a fixed rate of exchange at whatever the oracle is so you can see on the trading function on the right there is now a completely constant slope so a constant price all the way up until the market maker runs out of assets at which point you can't trade anymore right because the market maker no longer owns any of this output asset and this turns out to be a very precarious position for the market maker to be in for one they're not earning revenue from trading anymore because they're a liquid and for two they now don't have a portfolio right they own all of one asset and there's a lot higher risk of portfolio value change there which generally they want to avoid so there are some examples of this technically any wrapper contract is a constant sum market maker like Aave maker has a peg stability module that allows one-to-one exchange of other stable coins for dye which sort of keeps the stability of that peg and synthetics has a fixed rate of exchange using other external oracles for their synthetic assets which is also quite powerful so those serve as both models that are used in practice but for the purposes of this talk they sort of serve more as boundaries right they both have some big weaknesses the constant sum is if your oracle is even slightly off you're going to just lose all of one asset and you're not actually going to be market making anymore while the constant product while extremely powerful is not very efficient with its money because it knows nothing about what the asset should be worth and so essentially what the rest of this talk is going to cover is different types of mechanisms they can cover that middle ground and these are these can be known as hybrid AMMs the first of which will be stable swap so stable swap was introduced by curve and essentially what stable swap is trying to do is it is moving from a constant sum market maker so from a really a fixed rate of exchange to a constant product as the reserves get more and more out of balance because as the reserves get more and more out of balance you can imagine that your price is probably a bit off right and so you want to start adjusting that price while still taking advantage of that one-to-one exchange rate and so this equation also has this amplification parameter and that's what you're seeing in the animation on the right and you're seeing that as that amplification parameter increases the stable swap curve in purple moves from the constant product in blue to the constant sum very quickly closely approximating the constant sum because again we want to leverage this one-to-one exchange rate as much as possible so other than stable swap there are some other stable solutions stable swaps generally the industry standard more recently though there's been a solidly introduced an alternative equation for stable swap which is generally a bit more slightly simpler simpler to use as well because it doesn't have that amplification parameter for the purposes of this talk we can compare it to stable swap and that's what you're seeing on the in the trading functions on the right you're seeing solidly stable in purple compared to stable swap with an amplification of two and they're still different but they're about the same at that parameterization now an amplification of two is actually quite low typically it's much higher than this so solidly stable essentially represents a low risk sort of stable swap that's still a big improvement over the constant product when there is that one-to-one exchange rate to leverage next up we have dodo's proactive market maker so dodo has a mechanism again leveraging some external oracle this can be chain link this can be this one-to-one exchange rate and they introduce this parameter k that allows you to continuously adjust from the constant sum to the constant product as k is increased and it does this in a bit of a smoother way than stable swap with which makes more dynamic oracles possible to use in general you can sort of think of k as representing your confidence in the oracle right so if you have if you're extremely confident that the oracle is correct you can set k to zero and you get a constant sum you just get that fixed exchange rate whereas if your oracle is less reliable let's say it's a chain link oracle that can't update super often you may set k somewhere in between these two and the curve will leverage that oracle to inform its pricing but it will also discover the price if that oracle turns out to be incorrect or there's large trade volume a clipper is another one that actually has a k parameter that serves a very similar purpose the math behind it is very different and very interesting but end result is again you get this curve and this parameter k that allows you to adjust the curve between the constant sum and the constant product market maker now the interpretation of k as confidence in the oracle sort of has some extra meaning here in that clipper originally deployed their amm fully on chain leveraging a non-chain chain link oracle now as i mentioned the limitation with a chain link oracle is that it can't possibly update faster than the block time and so you can't have full confidence in the oracle uh when its update time is limited so more recently what they've done is they've actually built a another version that can leverage a fully off chain oracle and we're gonna come back to how that's possible later in the talk but for now the the context of that is that this allowed them to set k much lower and so this is sort of a concrete example of k being the confidence you have in this oracle price so last uh hybrid amm we're gonna cover today is crypto swap um we covered stable swap as the first one and stable swaps fantastic for stable assets uh unfortunately it's not very good for more volatile pegs um because it so closely uh matches that constant sum curve so what curve did is they took that stable swap curve and they essentially added another degree of freedom to it called the gamma parameter and this parameter allows the curve to more quickly adjust from the constant sum to the constant product as the reserves get more and more out of balance and so on the right in the trading curves what you're seeing is the stable swap curve for reference in green uh next to the crypto swap curve in purple and you can see for very small inputs the crypto swap curve is actually closer to the constant sum uh whereas for very large inputs it's much quicker to adjust away from the constant sum towards the constant product as it switches over to price discovery right so this allows it to uh be used for uh more volatile oracles non one-to-one pegs uh which makes it um very powerful and allows curve to essentially expand to other options now there are quite a few other interesting things about crypto swap that sort of break the mold that we unfortunately don't have time to get into so i encourage anyone who's interested to look more into that um for now we're gonna move into another sort of type of amm uh these amm still live in between the constant sum and constant product but uh the thinking and concepts behind them are a bit different and so i think it's worth approaching them from another direction and that is through virtual reserves so kyber dmm is one example of a mechanism that utilizes virtual reserves and what virtual reserves are are essentially just pretending to have more of the assets than you actually have right so we're still using the constant product equation but we are saying we have five times more of each asset than we actually have and so you plug these virtual reserves into the constant product equation and you get what we see on the right where uh we have that constant product curve that moves closer and closer to the constant sum as this amplification increases um with the trade off obviously being that you are introducing this zone of illiquidity because you don't actually have as much money as you're pretending to have and so you have to be careful of course uh how much and where you're concentrating this liquidity and you really need to use pairs of assets that are going to trade within some price range because once you exit this price range you become illiquid and you can no longer market make make which as we discussed is is very bad so what we really need is to be able to leverage this powerful virtual reserve mechanism but to also have some freedom to move it around right and so that's exactly what uniswap v3 provides so uniswap v3 utilizes these virtual reserves but it basically says each individual liquidity provider can choose their own price range and implicitly amplification and concentration as well um and so this is super interesting to me because it's essentially outsourcing this hard problem of deciding where to provide liquidity to the liquidity providers themselves so the mechanism no longer has to solve this problem specifically but instead it's simply general enough to let liquidity providers decide what risk uh and reward um payoffs they want to take by deciding where to concentrate the liquidity um now the there is not a trading function for this one as you probably noticed uh it's hard to appreciate the complexity that uniswap v3 can provide with a trading function instead what you're seeing is a liquidity graph so um on the x-axis is essentially the price and on the y-axis is the liquidity at any given point which is essentially um how flat the trading function is there and you can see for reference just for fun we have uniswap v2 which is just flat because it's uniform whereas uniswap v3 has this very complex shape because this is sort of the combination of all these different ranges uh that all these uniswap v3 liquidity providers are providing liquidity in and so um as everyone's probably aware this has become extremely popular and uh is responsible for a huge proportion of the defi trading volume because of how powerful this this mechanism is so that concludes all the uh specific AMM types i'm gonna cover today um to close things out i'd like to briefly cover how uh we can build on top of these great on-chain mechanisms uh and leverage off-chain computation as well to um improve upon them even more so the first thing i want to cover are requests for quote systems so i alluded to this earlier and essentially what this is um is it allows the uh market maker to do completely off-chain pricing right so uh you can either leverage a real-time oracle or you can leverage actual traditional professional market makers that are constantly manipulating the order book um and you can then provide an api that anyone can hit and they can get a quote and a signature with that quote and you can then take that quote and signature on-chain um and you can then execute it and compose it with all these other AMMs as well um and so this becomes a powerful mechanism where we can leverage uh this these off-chain resources which often allow for more efficient pricing um while still maintaining a lot of these on-chain benefits that we get from AMMs um and so we have a few examples there one is clipper rfq which i mentioned uh which leverages that off-chain oracle hash flow is another one that leverages these uh traditional essentially market making tactics and provides that as a uh rfq api that can then be leveraged on-chain so with all of that in mind uh i'd like to close things out by asking the question now from the trader's point of view um how do we actually navigate this complex landscape and figure out where and how much to trade right and just to summarize um what we've covered here are many different types of AMMs which all have different purposes um each type of AMM is actually implemented many many times on chain um sometimes thousands of times in the case of uniswap v2 so you have many choices there as well uh it turns out since these trading functions are always adjusting their prices as you trade through them uh for any direct pair of assets the best place to trade is actually usually a combination of different uh liquidity pools instead of just picking one so your problem is not just picking one place it's actually picking some arbitrary combination right and if all that wasn't enough uh the best trading price is often actually routing through other tokens as well um and so the answer to all this uh as you may guess is of course dex aggregators right we have a very hard optimization problem and we can essentially leverage off-chain computation to solve this problem and provide again a transaction that still maintains a lot of the great qualities of on-chain um AMMs by still allowing for atomic execution self custody still you still have protection from slippage um and so this is an incredibly powerful mechanism and I have an example of a particular trade you can execute with otos specifically now with otos we visualize these uh aggregation paths with what's called a sanki diagram and it's essentially showing the flow uh from the left hand side to the right hand side through all these other assets and all these other dexes uh this one in particular actually has about 40 different swaps so 40 different dex integration um interactions that you can execute all atomically um this one is also showing multiple assets being traded at once so this is another benefit that we can get from uh sort of combining these AMMs like building blocks into a bigger transaction to execute a given trade um and so yeah dex aggregators very powerful and sort of an example again of leveraging uh this off-chain execution or uh even better experience over these amazing AMM mechanisms and so that concludes things um a few final notes uh the parent company of otos semiotic labs is actually giving a couple other talks today so uh I encourage you to check those out they're related to artificial intelligence and cryptography work uh related to um our work as core devs for the graph um and we are also hiring so you can feel free to reach out if any of that sounds interesting um so yeah that's time