Mangrove: the offer-is-code approach to DEXes

ETHCC 6 · July 2023 · 12:44

Gabija Tuinaite explains Mangrove's offer-is-code market design. The speaker examines its implications for decentralized exchanges, liquidity provision and trading strategies.

Speakers

Topics

From ETHCC 6, hosted by Ethereum France.

Transcript

foreign my name is gabia I'm core contributor and head of product at Mangrove and today I would like to talk with you about our offer is code approach So currently Defy is facing two main issues in terms of liquidity fragmentation and capital efficiency you have liquidity scattered across various protocols multiple markets for the same assets and we have aggregators that aim to solve this issue but fail

you have added up latency and aggregators make huge profits by capitalizing on slippage however what mangroves offer is code approach liquidity fragmentation can be reduced and capital efficiency increased so to begin with I would just like to briefly cover what Mangrove is so Mangrove is an order book based Decks that allows liquidity providers to post arbitrary smart contracts as offers what exactly that means let's consider the following diagram so maker comes to Mangrove and posts an offer in other words he promises to deliver a specified amount of liquidity when an

offer is matched maker is able to embed any type of logic into this offer and essentially all offers on Mangrove are just Promises of liquidity therefore liquidity is not locked maker is able to put this liquidity into some other D5 protocol let's say borrowland protocol morphle and earn additional yield on his assets when the ticker comes and takes this offer maker can decide to fulfill or to withdraw the choice to withdraw is what we call last look mechanism and I will cover it in more details later on but in case maker decides to fulfill this offer liquidity is sourced and the

offer is executed now I would like to dig a little bit deeper into smart offers and how transactions occur at mangrove so whenever offer is matched the smart offer code execution starts with last look so the code of last look checks whether it's actually beneficial to fulfill an offer Because by the time the offer was matched market conditions might have changed in case the code detects that it's actually beneficial we move to the second part which is liquidity sourcing again depending on the weather liquidity sourcing is successful or not the the trade will be executed or not there could be various reasons for

unsuccessful liquidity sourcing but the most simple example could be that liquidity was moved elsewhere and when the code tries to Source it it's just not there anymore now I would like to talk a little bit about specific features that you can embed into your smart offers so we just spoke about last look mechanism which gives maker an option to withdraw from executing the trade I will give you a very quick example but I won't go into too much details here if you like to chat or ask some questions come visit us at our booth in Building B but the key work example is as follows let's see user a wants to buy some eth and he is matched with 1000 usdc of user

B user B can check this price on some other exchange let's say uniswap if the price is higher there user B says no to user a and sells on uniswap if it's lower there user B can choose to sell to user a on Mangrove or he can also perform an Arbitrage by buying from uniswap but in both of those two cases user B wins now the second feature worth mentioning is what we call liquidity amplification so again all offers on Mangrove are just Promises of liquidity so this liquidity can be promised on multiple markets at the same time again here I included a very simple example where maker has 1000 usdc and he

promises this liquidity on three markets but again it's not limited to three markets right you can promise this liquidity or on 10 or n markets at the same time and this particular feature could be compared to the traditional leverage feature you have on other exchanges now the last feature worth mentioning is multi-liquidity sourcing so makers are able to embed any type of logic they wish into smart offers essentially that means that liquidity can be sourced from literally anywhere within D5 space here I included couple of the examples such as borrow land protocol Morpho other compound liquidity pools like unit

swap or balancer or active yield management protocols like B4 tattoo again just a couple of the examples of the various possibilities out there but now all these features that I have mentioned open a very wide design space for sophisticated trading strategies and here at Mangrove we figured what is a better way to Showcase this than introducing simple easy to understand yet super powerful strategy so let me introduce you to candle candle is an automated Market making strategy that uses on-chain order flow to repost offers instantly with zero latency so Kendall posts bits and asks within a

predetermined price range if an ask is taken Kendall posts a bit on the other side of the book and vice versa essentially the main goal of the strategy is to buy low sell High therefore it makes profit from a spread in a sense candle could be compared to continuous emfs such as uniswap V3 however with candle you can adjust your spread or as we call it the size of the grid and this spread or the size of the grid could be used to directly address volatility but how can you choose the right spread well let's consider the following diagrams so on x-axis you have different

levels of the spread on y-axis you have mean daily return and different curves indicate different levels of the volatility so let's say you exhibit 9.5 percent volatility which is the top white curve on the diagram so I would say the most logical thing to do would be to maximize your return right so therefore you would just pick the max point of the curve and choose the corresponding grid size the general idea here is that if the volatility is increasing you increase your spread or the size of the grid and

I think here the main or the most obvious difference between continuous emm and discrete emm is that with discrete emm you can use the size of the spread to directly address volatility of course choosing the spread for stars with answering the question what is the volatility if you can estimate or predict a 12 month the only thing left to do is choose the spread yeah so as I've mentioned candle is very similar to continuous emms such as uniswap V3 however with continuous emms there is no

way to address liquidity to address volatility there is nothing in the functioning of such amms apart from increasing the price range when volatility is increasing you may ask so what well I guess shout out to the our best research team that provided us with these simulations but based on our simulations discrete emms such as candle or in other words fee as a spread significantly outperform continuous emms such as uniswap B3 I guess it's a bit funny to talk about this right after unit swap presentation but the simple explanation here could be is that if you go back and forth in the

continuous emm you lose each time because of the fees with discrete emms such as candle you can trade on both sides of the book and you can tune your spread according to your volatility which leads to better return but lastly I guess mangroves infrastructure might sound familiar to those who took a deeper look at uniswap V4 we're happy to see that uniswap is confirming our D5 approach but here I would like to compare One Market multiple contracts and one market one contract approach so with one market one contract approach each market has its own rules for

liquidity provision that means each time you imagine a new way to operate a market or a new way to provide liquidity to the market you would have to create a new market which still leads to liquidity fragmentation aggregating 100 of I don't know let's say usdc usdt markets it's just not sustainable there's no perfect aggregator in terms of latency and economic value and the proof of that is that you pay them because you need them you split markets into little pieces and then takers have to pay for it essentially the demand for aggregation is the frustration of the fragmentation so why should we fragment again and again and then try to

aggregate D5 won't be able to scale this way and we reduce the composibility of the whole Space so Mangrove recognizes the need to have Smart liquidity sourcing and therefore we use one market multiple contracts approach allowing liquidity to be drawn from multiple contracts within a single Market essentially that means you have as many contracts slps on the same Market and you don't have to create a new market each time you can Implement any logic you wish independent of the market you choose and it goes both ways right you have one market multiple contracts as well as with one contract you can address multiple markets at the same time as

I've mentioned liquidity amplification feature so to summarize I would say there's more economic value in continuous liquidity by allowing liquidity providers to embed any logic into their smart offers Mangrove provides a solution to reduce liquidity fragmentation in D5 space at the same time features such as last look liquidity amplification or multi-liquidity sourcing provide greater flexibility and capital efficiency to liquidity providers so thank you very much and lastly I would like to take an opportunity here

and to announce that Mangrove is live on polycon Maynard starting from today and you can try out our better version of the UI via app.mangrove.exchange where you could try and place very simple market and limit orders at the same time for those who are interested in building on top of Mangrove which is the most interesting part we have contracts as the case stratliff documentation available via docs.mangrove.exchange and again as I've said earlier if you would like to chat with us have some questions come visit us at Building B in our booth next next entrance so thank you foreign

[Music]