Decentralized Market Making How does it Work, What is it, and Why we need it - Ari Rodriguez
Ethereum Denver·Mon, Oct 9, 2023, 12:00 AM
With the recent events of Luna, 3AC, FTX, and Alameda Research it is pretty apparent that existing market makers need to be disrupted. Market making should be transparent, non custodial and permissionless. In this talk I will explore what the challenges of existing market making are, and how market making can be done on UniswapV3. Explaining how market making strategies that have existed for 20+ years can actually also be executed and applied to UniswapV3 LPing. https://twitter.com/kassandraETH Ari Rodriguez CTO Arrakis Finance Ari is the CTO of Arrakis and thus leads development. He is an experienced web3 engineer with a background in mathematics and cryptography. Before designing and building Arrakis he was a senior smart contract engineer at Gelato Network where we focussed on smart contract security, protocol design & smart contract integrations. Before joining Gelato, Ari was a cryptography researcher focussing on privacy and state channels.
Transcript
foreign hi there so um I'm Ari Rodriguez cassandra.eth online and uh I'm the CTO and founder of Iraqis Finance um what we do is mostly build on-chain infrastructure to help liquidity providers provide liquidity to decentralized exchanges and more efficient more sophisticated more interesting ways this talk though is about um looking forward about the future of Market making specifically about the world we live in today with centralized market makers many of them having often a very bad stigma and uh at least in our space and how we can reduce this bad stigma and make Market making more transparent and trustless in the future with defy so let's get started so yeah to give this talk a little bit of motivation I'm sure many of you have heard of uh uh these uh companies up here or I suppose X companies um and they were major market makers in the crypto space um and potentially uh like seems likely we're doing some very shady things behind the scenes um and uh crashed and burned in different manners so uh I think for those uh people in the audience around here who have ever worked um to help to have liquidity goals for some crypto token trying to get a token listed on a centralized exchange if you've ever interacted with any traditional market makers in traditional Finance um oh my God my dad is going to be telegramming me in the upper corner there so enjoy that um uh I think uh you will have noticed that uh it's not a great relationship or um I think protocols often have problems with these centralized Market making actors so I think first of all to talk about uh traditional Market making and traditional Finance um there's just some limitations about how traditional Finance Works which makes all market makers entirely custodial and fully trusted right so if if you have assets if you have some inventory in a couple of tokens and uh you would like to make a certain Market liquid via a central uh a central traditional Market maker you hand over those assets they have custody of them and you can't limit what they do with them maybe you can try you can make legal agreements but basically they are the custodians of these assets and they do what they like with them including sometimes maybe secretly using as the uh using them as collateral for uh build you know getting loans for themselves things like this that you might not want the market maker to be doing so right with crypto with smart contracts already we can at least use Smart contracts to um to more tightly Define what it is that the manager of these assets the the one who you want to be placing orders in the book to make the market liquid but is not the owner of them what they can do so you can you can make this less uh less custodial but so that they're fully trusted and custodial they take your money and they say we promise we'll make the market liquid for you on some exchange or some exchanges it's also very intransparent you don't know how they are making the market you don't know which orders they're placing in these uh in these exchanges and whether they're even filling orders sometimes you can see Central uh centralized actors will place orders so that it looks like there is liquidity in the book but they don't actually want to trade so they don't facilitate any trades they'll cancel all their orders whenever a real Trader arrives who uh who uh wants to be a taker and they don't want to actually make the market and you so you're basically giving these tokens over to market makers to do nothing for for you or paint pretty pictures on the chart lastly I think so to me those are the biggest and most important difficulties the the what protocols have when they try to try to work with a traditional Market maker finally I think um there's a very very high switching cost because of the tremendous the tremendous social coordination that's needed between the market making partner and the inventory provider so very unlikely that you'll have an easy time you know switching and saying I don't like this Market maker I want to work with a different one often it's very costly um and you and worst of all you don't know what you're paying for because you don't know exactly what they're doing so um hopefully that provides a little bit of the idea I think again if you've ever worked with a with a traditional Market maker you might know about some of these pain points but I think it's very important that even though market makers can have this bad stigma sometimes a shady stigma nobody knows what they're doing and they have the ability to manipulate these markets and maybe that it maybe they're doing that um it's important to remember that market making is is is a good thing it's good for all of us we uh we want these markets to be more liquid and more mature and if people want the ability to buy and trade different assets you need market makers right there will be major coordination failures if every time you wanted to trade anything you needed to find a buyer yourself and call them up and coordinate this so so in traditional Finance market makers uh provide bids and offers on on a certain uh asset pair and in crypto we also we've already or we have been trying to solve this problem and we have something called automated market makers which I'm sure most of you have already heard about so in an automated Market maker the uh the inventory providers don't place that inventory in bid and ask orders around the current spot price they actually place um they Place their inventory across a price range or in the case of uniswap V2 style decentralized exchanges which most people are familiar with as the classical model of the decentralized exchange they PL they provide these assets over an infinite set of prices um and so Traders can trade and the price automatically algorithmically updates thus you have an automated Market maker and you think maybe we we've already solved this problem uh but we'll talk about why just a simple automated Market maker smart contract might not be enough to rival uh traditional market makers and actually be efficient enough to make markets liquid but it's very important to know that without without infrastructure like this without these um hedge funds and traditional Financial um uh companies providing these bids and offers in these centralized exchanges or without these liquidity providers into automated market makers you don't have you don't have liquid markets you can't trade assets so we need Market making it's a good thing for both sides of the market however I think the the major issue that we noticed with uh with the original designs for the automated market makers that we have which had a flowering explosion of um of uh I think use and proliferation and understanding from the community however the automated Market maker is not efficient especially the the traditional ones that we had a few years ago were not very efficient at routing trades at providing good pricing for people who wanted to trade assets a traditional Financial Market maker can be extremely efficient placing placing bids and uh placing orders on both sides of the price to help people um uh uh you know trade the assets they want to trade and giving them really good price execution constantly updating these prices to uh to make the market extremely efficient so basically we have this trade-off today which is you can work with a more traditional type structure you have a very efficient market or you can you can have a trustless market making activity going on with these inventory providers providing liquidity to these decentralized exchanges the only problem is the pricing is really inefficient you you leave a lot um a lot of value gets extracted in Mev by arbitragers also the the spot pricing is simply uh not nearly as good as what you can have by someone who can rearrange the orders in the central limit order books at very small time frames so this is where we finally get to what we do at Iraqis Finance which is we're working on top of uniswap version three to basically try to reach something like The Best of Both Worlds have the efficiency of a traditional Financial Market maker but on top of automated Market making infrastructure on top of smart contracts entirely trustless entirely transparent um and so uh yeah this is what we're hoping to achieve at aracas and where we think potentially um uh on trade on-chain trading and Market making is headed so how can you actually do this I think before we get there yeah I'm gonna go on a tiny bit of a tangent I'll try to go fast here um but decentralized exchanges have been going through a major Evolution um I think most people's mental model for a decentralized exchange for an automated Market maker is a the classical x times y equals k um uh constant function Market maker or even the full class of constant function market makers like curve curve Finance um is also just you know it has a different uh a different constant function but the same idea the contract can update the pricing for the for orders coming in based on a uh preserving some constant function the price updates as a Trader trades always on that constant function now the biggest I think what cracked things open in the decentralized exchange space was um uh the introduction of uniswap V3 and the idea of concentrated liquidity which allows us to create any sort of liquidity distribution um in in a much more flexible way and and just to really briefly talk about it what you can do is use you set a position which now when you provide assets to the automated Market maker or smart contract you no longer provide your assets across the entire price range but you actually get to decide across which price weight range will your assets be traded which can be in some certain band and beyond that I think we see a lot more coming this this sort of uh opened up the problem space of how do we make automated market makers more efficient and we see a lot of new ideas um uh Beyond unit swap E3 as well so I think um While most people's mental model for the decentralized exchange is still probably something like a uniswap V2 I think um the world of on-chain trading and uh and liquidity providing is is quickly getting more sophisticated and updating so now since Iraqis is built entirely on uh uniswap V3 and uh so to understand how we will make truly trustless and truly efficient market making happen on top of this decks we have to talk about how the decks works so I see uniswap V3 as kind of like a liquidity computer it's um the the interesting thing that happens when you allow there to be concentrated liquidity is that each liquidity provider provides uh liquidity evenly across some price range for a specific token pair on a specific feature we won't talk much about the features here but um this is what we'll Define as a position what the unit swap smart contracts Define as a position what's really cool about unib3 is it can efficiently on chain aggregate all of these overlapping positions where each look each position provides liquidity over a different price range to create an overall liquidity distribution for that market and what's very what what was like the zero to one change between earlier decentralized exchanges in this new model is that now every single Market can have a custom liquidity distribution that fits that specific trading pair and if you have this you can now start to approach the kind of efficiency we have in central limit order books in traditional Finance so the the last thing that I find very important here is that I think that these single price banned positions are actually a very low level primitive they're almost like I would say like the Assembly Language of this of uniswap's general purpose liquidity computer I believe that we should be looking in general when you think about uh uniswap V3 one liquidity provider is not necessarily one position right you might want a certain liquidity distribution in the market and the way you would do this is by creating a pattern of these positions right um and so in my view I think right now again the mental model is maybe a little bit coarse grained in in how we can even utilize this uh uniswap V3 decks of this I want to tell you about arrakis V2 which I think can be the basis for truly trustless Market making infrastructure that's both efficient and transparent so what we build with arrakis V2 is a set of smart contracts which is somehow a middleware for you as a uniswap V3 liquidity provider it allows you to with a very simple set of interfaces track a collection of uniswap V3 positions on the same token pair even across V tiers so you can um you can for instance if you've ever been a liquidity provider on univ3 and you would try to do this by yourself just using the the the basic interfaces and and the UI you'd be tracking a couple of different uniswap V3 nfts each one would be earning its own fees which you might want to harvest and then put into new positions you might want to update these positions and you have to burn the nfts and create new ones with arrakis V2 you can track all of these uh all of this collection of these positions in one contract see the the sort of total holistic view of this multi-position that you have and with a nice interface completely reposition or redistribute your your inventory into and out of the uniswap V3 market so you can kind of think of a rack as V2 as like a proxy wallet for a specific token pair that you use for interacting with uniswap V3 which will give you you know a lot of convenience gas efficiency gains in terms of you'll save a lot of gas using these interfaces rather than the others and the ability I think a much more streamlined ability to automate what you're doing as a liquidity provider if you want to have a dynamic strategy so um I would say one last thing that's quite important about what you can do with arrakis V2 is you can actually leave assets on the side so all the assets that are in your arrakis V2 vault don't necessarily need to be in uniswap which can be useful for managing your inventory sometimes you want to place a very concentrated order but not with all of your assets with a small piece of your assets um so uh last I think really useful benefit of using rackus V2 is if you want to rebalance the inventory that you currently have let's say I have a few positions on the eth usdc pair one between a position between uh 500 eth and five thousand dollar each and a more concentrated one between a thousand dollar each and two thousand dollars um so I've got some usdc and eth in the uniswap market maybe I've earned some fees and now I want to rebalance this I want to take all of that out Swap all SWAP everything for eth and then put a single eth order at 2000 uh so I have entirely eat now and I place it at a strike price of 2000 so that when when the unit swap Market starts trading above 2000 I'll sell all my ether two thousand dollars let's say this is my strategy for some reason well when you when you want to do this kind of rebalancing you you also need to swap this means I need to swap some of the usdc in my Holdings in My Vault for eth so what's really great about what you can do with the Rex V2 is you have this low level interface for swapping so that you could uh you can Source liquidity not just from uniswap but from any other exchange or even some sort of custom Smart contract which would deal with a primary Market of your token if let's say there were ways to um to sort of generate or wrap and unwrap it in on some other primary market so I think these are the benefits of using an aracus V2 Vault even for yourself as just a personal liquidity manager if you want to if if you will be placing multiple liquidity positions on the same token pair you will eventually be saving a lot of money and gas just by uh providing liquidity through a rack sv2 and here there's nothing public right this is just your private proxy wallet um Vault for interacting with unit swap E3 on that token pair um you can also use a rackets V2 in a public setting since we also erc20 tokenize the entire position so uh in that way you can aggregate liquidity from many different sources everyone who provides assets to the Vault gets an erc20 which represents their fractional position of that Vault and then all all of the inventory in that Vault can all conform to the same strategy um and and this is also quite an interesting setting so that's what you can do with Iraqis V2 and the first uh you can again because it's entirely neutral uh smart contract infrastructure you can build on top of rackets V2 and build whatever you would like but but we at Iraqis are building the first product that we've built on top of our V2 system is what we are calling Palm Iraq is Palm which is stands for protocol automated liquidity management and I think uh it's important to give the context of I would think of this as coming from sort of the uh the next step of protocol owned liquidity so if you've heard of Pol protocol and liquidity Palm takes takes that idea and extends it because if you're a protocol that owns assets and wants to deploy them as liquidity into the market maybe you'd like to do that more efficiently but maybe you're not you don't have someone in your team uh who's uh or you don't want to have to trust somebody to constantly be the one to manage the protocol owned liquidity to place it in the right kind of price bands so that it efficiently routes trades so the idea of Iraqis Palm is to allow protocols to um to basically provide let's say they have a treasury they have some inventory they want to inject into the uniswap market they can use Iraqis Palm to provide that inventory into uniswap via our Iraqis contracts they can set the sort of strategy flavor they would like to use and also set some custom parameters to the strategy this the market making strategy they would like to utilize we'll talk about what these strategies might look like in a second but once once the protocol does this they can now simply look at a you know see the metrics and a dashboard which lets them see exactly how the automated strategy is running how it moves liquidity in the unit swap uh in the uniswap order book um and uh it'll simply run automatically with a keeper system that uh that you know the keepers are running some code in the background which is taking the uh the strategy parameters that the protocol set on chain and using that to constantly Monitor and check the chain if it's time to rebalance it'll send a transaction and uh rebalance the inventory but the very interesting thing is that because of how this Iraqis V2 Vault works you can set who the manager is but you can tightly Define what that manager can do so even though these Keepers even though these keepers are the one who are who are actually moving liquidity in and out of uniswap V3 this is the only thing that they can do they are not the custodians of your assets and you have the ability to basically Define exactly how tight or how loose you uh you um want to constrain the manager and again no switching costs now if if you decide whoever uh whatever system is doing the management of your of the Assets in your inventory you can change this manager address and thus uh immediately switch from one make it Market maker to another so the switching costs go down almost to zero so yeah basically arrakis Palm is permissionless active automated LP strategies for anybody The Vault owner assigns the manager deposits and withdraws funds uh decides on the strategy that they'd like to use the strategy type and the custom parameters to that strategy what can the multi vault manager do the vault manager can only execute the agreed upon Market making strategy if the Vault owner would like they could delegate the setting or tuning of these strategy parameters to another third party to the manager themselves but then of course you're adding some trust to the manager since now the manager gets to decide what exactly how your Market making strategy will work um so to me the future of Market making is permissionless it's automated and customizable there are low switching costs you're not putting the manager of the funds in total custody of them and it's entirely transparent you can see exactly what these automated executions are doing in real time see how your liquidity is being utilized unlike this very intransparent centralized Market maker who simply says I promise to you I'm routing orders uh in the central limit order book here you can actually see how much volume is going through uh through and Etc thanks to the power of permissionless transparent blockchains right so I'm already over time so thanks so much for coming I'm cassandra.eath you can follow me on Twitter follow arrakis.finance if you are a protocol looking to automate uh and uh the management of your liquidity or bootstrap liquidity for your tokens certainly come talk to us and check us out and if you'd like some really beautiful Iraqis socks thank you so much for being here and listening to my talk so please come if you're if you're interested in uh in some 100 cotton socks we've got those for you so you can come make a line over here thanks so much guys foreign [Music]
Automatic transcript — names and jargon may be misspelled.