Money Markets: Reducing External Dependencies / Jogundas Armaitis

Prague DeFi Summit 2023 · June 2023 · 19:00

Jogundas Armaitis looks at the centralization risks that external dependencies, such as price oracles and liquidators, create for DeFi money markets. He introduces a lending architecture built on immutable smart contracts that minimizes these dependencies while keeping the market secure, and lets any token serve as collateral.

Speakers

Topics

From Prague DeFi Summit 2023, hosted by Prague DeFi Summit 2023.

Transcript

um so I'm talking right after a panel on regulation and the guys there had a very nice thought they said that uh one of ways to move away from C5 is regulations but another one is um basically being more decentralized and uh that I liked very much I liked that thought um now coming to the topic at hand I'm gonna talk about money markets on how to do away with at least some of external dependencies that uh these smart contracts typically rely on so this talk is mostly about kind of making money markets available to more and more tokens expanding uh what they apply to

so just to be on the same page even though we are in a D5 conference just to kind of uh set the stage of what I mean by a money market so for me a money market is any sort of a smart contract that takes one sort of tokens as deposits so token a here and uh after you deposit this token into this money market smart contract you're then able to borrow another token so that's uh token B so if a smart contract can do that for me it's a money market and some of the brands that are well known in the space are other and compound um one of my motivations of thinking about this problem is that basically

nobody understands Banks and this year this memory of some of the banks going down in the US is still very fresh um even some very old people talk about it people who are definitely not crypto balls are concerned that uh the public at large does not understand Banks there's not enough transparency in the space and even The Regulators often do not understand what they're regulating my kind of takeaway from this is that maybe we should move away from extremely complex systems and maybe we should move towards or something that we can understand a bit uh easier so I think that these D5 money markets are somewhat straightforward to

understand uh at least the current architecture is uh rather straightforward so uh at the center of this diagram uh we have uh the the money market uh it's right here uh there are some supporting pieces around it so uh the money market in order to perform its function it needs to know the price of the asset that is being used for collateral so uh in order to know this price the money market stock price are cool but this price Oracle itself is a smart contract on a blockchain so it by default doesn't know anything uh somebody or some bath has to push this information onto this price article so that's what data providers or Keepers do

they they push data onto price oracles and they get paid for this now they don't have the data themselves so they have to query other data sources they can try to query markets where the asset is being treated that's centralized exchanges or maybe decentralized exchanges here so these decentralized exchanges they do know the price at which the assets is being created and that's how the data provider gets the price pushes it onto the Press article and that's how the money market gets to discover the price of the collateral asset now if a loan goes bad if the collateral becomes less valuable than the loan that the smart contract issued uh this loan has to be liquidated and there is a role for that there is a

specific uh player in the ecosystem called the Liquidator who then takes care of these bad loans and basically that's how Define money markets work at the moment that's how other compound roughly works so one could think that okay it's easy to understand so maybe it's really secure maybe there is no problem at all well um that's not really the case I mean the attack surface of the system is very large even though the money market itself is very much kind of a limited smart contract there is all this infrastructure around it and anything in this scheme can go wrong which I indicate by these are Goombas all around uh here so basically any of these parts

can go wrong somebody could corrupt the Dex smart contract and then the money market would not function correctly because I mean the price would be wrong and at the end it wouldn't know if the loans are bad truly or if they are bad just because of the Dex problems same goes for the price article smart contracts same goes for the off chain infrastructure like data providers like the Liquidators and also uh there are all sorts of other attacks that have to be uh taken into consideration when it comes to moving information around so all of these price updates liquidations those are transactions that can in principle be censored they might be delayed and that's again a problem for the for the money market

um one might think that this is theoretical but actually these attacks happen all the time I mean there have been quite a few kind of high profile attacks even of bigger money markets there has been some price manipulation related to some tokens on other and people are even making GitHub repos uh talking about uh Oracle manipulation attacks in general so how does a typical attack look like well I mean very simply and and this is not a very sophisticated attack but it has been seen in the wild uh first of all you artificially increase the price of the collateral token so of the token a then in the same transaction for

example you deposit this token a as collateral into the smart uh contract that is the money market then you borrow this other asset price B you are able to borrow quite a bit of it because the uh collateral is worth a lot and then finally since you know that this collateral is only worth a lot artificially you're able to just simply run away with the asset that you have borrowed and never repay your loan now this attack is possible because the money market typically does not know anything about the level of liquidity of your collateral asset I mean it knows the price hopefully hopefully the price is up to date if everything is working

correctly but uh it does not know anything about the level of liquidity and that is a huge problem because if you want to liquidate something there has to be enough liquidity available in the system um so this slide just shows kind of inconcrete numbers the same attack I won't go through it but basically it's an illustration that it is possible to kind of go through all of the steps that I showed on the previous slide and implement this attack as a single kind of atomic transaction without risking any of the attackers funds in the end so basically instead of starting with your

own collateral you take a flash loan and that is available in in the Market at the moment and then at the end of the attack you kind of wind down the flash loan and you end up with profit which is basically riskless that's why why that's why people find these money market uh smart contracts so attractive when it comes to looking for exploits well one might conclude from uh the story so far that perhaps it's just an inherent kind of uh property of the system of finance that as soon as you start having debt you become kind of more fragile in the uh terminology of

Talib who talks about robustness and fragility and then fragility maybe that just makes you more fragile maybe if you have debt there is not much you can do you just add that to your system just like fractional Reserve Banking and then you become vulnerable to certain types of attacks and maybe you should just be fine with it maybe you should live with it now uh the biggest money markets go around this risk somehow and the the way they uh closed or tried to close those risks down is they limit the assets that are available as collateral so for example if I I went to these uh two big money markets uh just the other day like chose

some random chain and I mean looked at the lists of assets available as color so compound has five assets available as collateral on on some chains that's not a lot if you think that there are like tens of thousands of tokens in the crypto ecosystem at the moment five is not a very large number but that's one way to solve the problem so only focus on collateral that has sufficient liquidity and just ignore the rest uh I think that we can do much better than that and I have a wish list or I mean how a really nice money market would work in particular today I'm talking about two things so I would like this uh money market to have no on-chain dependencies

so I wouldn't like it to depend on any external smart contracts and uh then I would like it to depend on nothing off chain so I don't don't want the smart contract to depend on people like Liquidators or data providers I mean I want this to have a very limited attack surface and then these are the requirements that uh are very much uh applicable there are some other items on the wish list but I'm not going to go into detail on those ones I think it's really possible to come up with an architecture which answers all of the items on the wish list and one

very simple mechanical way of doing it is basically taking a decentralized exchange component taking a money market component and then putting it putting those two components into the same box into the same set of smart contracts which are interacting this has a nice property of the money market part knowing how much liquidity there is on the decentralized exchange part and then making its decisions accordingly so for example not giving out too much uh too many loans not taking on too much debt uh if the debt cannot be liquidated on the decentralized exchange part of it um the the way this works uh for example

is that the swaps on the decentralized exchange part then automatically do the liquidations uh so then the external Liquidators are not needed and then uh the uh again other trades on the Dax updates to update the price so then the Oracle component is not really required uh and of course the liquidations on the money market side use the liquidity that is already available on the on the deck side when it comes to these Goombas I mean the picture again is much nicer so they instead of residing inside various blocks of your uh of your system uh These Guys these bad guys are then just uh walking around the outskirts so of

course they can try to attack your system nevertheless but they uh then are not able to control the state of various uh parts of your system they are not able to censor the information flow instead of that they are just uh gonna try to perhaps go after your users or try to find bugs in the implementation of of your smart contracts um now the attack that I described beforehand is actually not possible anymore with this architecture and again the key reason the Deep reason for that is because the money market now knows about the liquidity that is available on a decentralized Exchange and uh of

course since this is something that we are creating from the ground up we are able to design it in a way where uh it's always more profitable to just take your your collateral and swap it on the deck side rather than try to design kind of a involved way where you deposit this collateral as deposit these tokens as collateral then you take out loan then you kind of run away with this loan I mean we can design it so that this attack is strictly less profitable than simply swapping your tokens and that I think is a a very nice property of the system so kind of to summarize first of all currently in the market

most of the smart contracts most of the protocols that help this functionality of using one token as collateral and giving out loans these guys depend on external components vast majority of them do now this architecture where they depend on this external uh components this impairs security and also Limits The Tokens that are available as collateral so basically either you have low security or you have a low breadth of applications these both are not ideal and there is a Continuum between the two of course as always

now we think that external money market dependencies can be reduced to zero the system can be made completely self-contained and we are not the only team working on it there are other people uh doing similar work we think that it's just a matter of 12 months or so well until these uh novel architectures start coming on to blockchains uh nearest to you uh so please reach out to me on Twitter on other or other sources if you like it uh I really love discussing this topic and otherwise thanks a ton for listening thank you there is a question

thanks for presentation so um if I understand correctly like the way how you limited the price for alcohol manipulation is by measuring the liquid available liquidity on the decks so let's say if I will manipulate the price right like the liquidity will change significantly um then like if you have different price feeds um I mean the available liquidity changes based on like algorithm used by Index right so if you have concentrated liquidity you you have like a significant smaller need for like having a good price Source than um with non-concentrated liquidity schemes and same like

yeah so how do you reconcile between like different mechanisms or like even a centralized exchanges yeah so so uh this makes a lot of sense what you're saying and uh definitely if you're thinking about protocols that have a lot of liquidity on really like concentrated ticks in the terminology of uni swap E3 then this is not a very robust system but again if you look at the space of all the tokens all the crypto tokens currently the the guys who are going to use uni swap V3 uh mostly these are larger tokens that are already being supported by these larger money markets so what I am mostly thinking about is I'm mostly thinking

about about these smaller tokens which typically trade on a single univ2 pool maybe single sushi swap pool or something like that so instead of trading on a random kind of non-concentrated uh liquidity amm they could trade on this a m and then just be able to use their token as collateral okay so what price sources do you use today um so this is still on paper this is not a functioning protocol for now but the idea is to just not have any external price sources on lead access so only this single decks which has no concentrated liquidity which is basically a vanilla a m which is uh you could criticize that because it's like

fragmenting liquidity it's uh kind of very inefficient in terms of how liquidity is being provided but on the other hand it's very robust in the sense that I can change the price and I will always know uh the price impact of my swap a priori because like the liquidity is fixed before the swap I do the swap and I know how much the price is going to change so that's a very useful property okay thanks thanks any other question yeah I mean doesn't this seem like you're just trying to like bootstrap liquidity and tokens that don't have liquidity like isn't it like usually the reason that all of these really small

coins don't have a whole lot of liquidity is because the team holds the vast majority and can throw the price or can come on and borrow like in like should a lot of these tokens have money markets I guess would be my question well I mean I guess it's a philosophical question but a very nice question Nick so my thinking is that many of these teams I mean maybe they they have a tiny token maybe they are working on it and I mean they're already providing this liquidity themselves maybe they're manipulating the price and maybe they're trying to engineer some attacks or something and that's fine so with this protocol uh they are able to try to do that but on the other hand the game is very transparent so if they still want

to play the game that's fine but I think that there are also some legitimate use cases for for this sort of technology and I think there are people who just want to do that so um of course it's kind of a large large space to explore uh nothing is sure a priori but yeah this is something that I appreciate exploring any final question okay in that case a big round of applause for ugundas thank you so much thank you and we've got a about five minute break and then we'll start with an expert [Music]