Flash Loans: The Good, the Bad, and the Ugly

ETHCC 3 · March 2020 · 26:49

Stani Kulechov examines the benefits, drawbacks and risks of flash loans.

Speakers

Topics

From ETHCC 3, hosted by Ethereum France.

Transcript

he basically said that I have to come with a joke but uh well as everyone had a good time so far I mean yay hate to see all right flash loans you to keep image but yeah okay I think we

can start so my name is Donnie I'm from Ave Ave basically does lending dfi products and and we have this cold thing called flash loans just a quick check how many of you guys have heard about - loans oh pretty cold that's why you're probably here so yeah what I want to do today is is basically go a few points about flash loans so kind of a bit of like misconceptions and and also what kind of different varieties there are of flash loans so what you can actually do

with them and I have made a category categorization of the good the bad and the ugly the idea is kind of to show that flash loans is a interesting tool but it could be used in a like good way or in a bad way and some of you have already seen like different kinds of way of using them now in essence what is a flash loan and how it difference from just normal defy loan and by Normandy file on what I'm trying to refer is to a over collateralized loans so as we know dfi decentralized finance is pretty much

about trust list trust less transactions which basically means that you make transactions where you don't need to trust the other party so you need to protect somehow the transaction and one way is to over collateralize a long position now how basically the flash loans differ from this kind of like over colorized non position is that you are taking alone and you're returning the loan without any collateral and the ability to do this kind of transaction in in in in the trustless and environment is a way of using the atomicity of

of the etherium network so basically there's three steps first you take the lone second is pretty much to do whatever you want to do but with that loan and you return the loan and the key part of the flash loan is basically the condition set in the planning protocols that basically if you don't return the loan you're basically nested transactions will eventually fail so that's the condition now between this borrowing and returning you can actually do pretty much everything that you can in the atomic nature typical use cases for

flash loan could be arbitrage so what what helps you what flash loans in general helps you to do is to innovate in terms of the compressibility of dfi without actually needing that capital so I'm quoting here also a bit of my friend Mark Zeller within the crowd some it's there nice weather by the way it used to be in this way that there was nerves and now we have nerds with money and not just like with money but whale-like liquidity so the only thing you actually need now is to pretty much have enough technical skills to do different kinds of

transactions without actually having that whale-like capital and you can book very interesting things like arbitrage sports collateral swaps interest rate swaps currency swaps self liquidations will go a bit deeper like what are these different things and leverage aggregators the first thing we need to understand is pretty much that in the current form using flash loans is a pretty much developer tool at this moment but once the developer community starts to build different kinds of interesting things products on hackathons for the end users we actually see some interesting utilization beyond the the arbitrage sports or any

kind of like a trading strategies which we have seen in in the in the good category and in the even in the bad category yeah and one of the interesting parts for example is the self liquidation use case where you are building a boat or a service for end users who have CDP's that they can actually liquidate their own loan positions without returning the loan which basically means that you're not in the position of relying upon the liquid liquidation networks of the lending protocols for example the the make it out system and that basically is a product that helps end-users to save on

the discounts on liquidations and and basically effects a bit the way that the whole liquidation system is used so if everyone is liquidating themselves it pretty much kind of destroys a bit the liquidation network incentives that we have in in many lending protocols today and of course these use cases that we we go today they're just an examples what you can do so this is something that our team just try to figure out within the past months and I'm pretty sure that there is something else to add and a lot of things that could be build upon but today is not only about the kind of like what kind of products you can build but

also like how these ideas came and how we made them possible so this is a very cool thing that happens so in normal arbitrage situation which basically means that you are trying to rely upon inefficiencies in the trading network so you have a decentralized exchange one and they centralized exchange to you or liquidate pools whatever you want to call them you are buying an asset in arbitrage I mean in the decks one and selling in the decks to you for a higher price and and trying to gain for the price price

in efficiency and to do that you basically have to have capital and what flash loans unable to do the the arbitrage Dow and Julian who started the the project was basically to make this arbitrage opportunities I take advantage of them without actually having any capital and that's like very cool initiative to see and and and the point here is that you borrow first under collateralized loan you you buy from one place and sell the another place and then you reimburse the loan and here's an example of the arbitrage del

transaction so all of the these are nested transaction within the transaction that Julian made that was the the first flash loan basically done with our protocol and and this I'm not going too much into details but what can I say from this particular set of transaction is that Julia basically took a flash lon and he went into a trade between sy and died where he followed a inefficiency in the price and and basically bought it both one of the currency in one place and sold it in another place and return the loan and you can of course configure your boat to make opportunities that

actually make sense to you and in the pairs that you actually want so you don't need to just borrow die but you can borrow any currency that there's excess liquidity available and and you have that excess liquidity in the protocol you have to incentivize somehow the liquidity providers to bring your flash capital so it's pretty simple transaction there's multiple components at this point but the key here is to see that between the the borrowing transaction and the repay transaction you can actually put all kinds of things in between and actually build very very complex things and the thing that things that we are seeing now currently in different

for example the the flash phone attack attacks as well the transactions are getting complex but this is just kind of like a starting point of what we will see in the future because you can actually put a lot of things in between there and you're basically limited solely by the the block size of a aetherium lock this was another cool thing called collateral swaps and I was brainstorming with Mariana contine in telegram the place where we all hang usually and one of the things where I was asking Mariana that can I can I can I open a Walt with with two collateral

so I have for example in the same world collateral a let's say 30 M collateral B dat and and then just change the collaterals and that pretty much wasn't available and without returning the loan and I said basically that okay what could be actually cool you could use flash loans to return you can close your Walt let's say you have Walt with collateral that is B 80 which is basically your long position you got your die and your basic is already spent that died and you want to change your long position from be 82 to 88 for some particular reason for example do you see more upside there or increased risk in in but or what not and basically with

flash loan you can actually borrow die in same transaction close a dat CDP and open a the GDP of each and and return that in the same flash loan transaction and I actually asked that could someone basically build this thing and I will start to use it and a bunch of my other friends and I think it was yeah David came and said hey I want to build this thing and I want to try to build it just like this was just an idea from nowhere and just an interesting way of utilizing flash loans and the compressibility of video the defy and David basically created the whole thing

he did a tweet with a couple of example transactions between swathes be 80 and aetherium and etherion be 80 and then he had the hashtags Yolo not audited we just know I mean it's a it's a start but you know it's just a proof of concept and then Fiona came also and tried what David actually built and and got interested in the whole flash loans and and what we were building and I think the the cool part in this particular project was that what we made was David who is basically developer and he doesn't have way like capital or

liquidity it could actually build something something very cool and let other people's like Fiona to utilize that product and when we start to see more and more these kind of things and compressibility and and an ethereal without the much need of a capital we will see more sparks in the innovation and that was like very interesting like story behind of this particular flash lon use case here's the the transaction pretty much so there was the I borrowed be IT world was closed and then the ETH rate vault was open and the die was returned so pretty cool stuff here's the

the the kind of like a bad example well not not bad example but let's say like this was a attack used by flash loans so what happened there was recently a few attacks on the busy axe protocol and what happened is that the the borrower took a flash loan by the way this is made by by friend of ours chairman but the the flash one wasn't from office so that's a all the information but how it basically work that the the attacker took a very large amount of flash liquidity and converted those portion of that liquidity into a

WBT see which is a low liquid asset and and basically sold that asset in a particular decent let's exchanges which affected this price of unis flop liquidity pool and he had at the same time a short position on WB TC with leverage so he needed less actually funds to take that position and and gained yield by crashing the the price feed and making a pretty substantial amount of money in that attack so this is a pretty interesting example like how the flash loan affected the whole

ecosystem because previously we always thought about that you can have this kind of like attacks if you are very well funded and what flash known actually allows you to do is that it takes out of the funding equation and funds every attacker so your system needs to be resilient as well this kind of attacks so that any kind of disability with with big amount of funds can be used against your system and that's why when you are planning your systems and building before you need to basically take that into account and the the very problematic part is that the more you have decks liquidity the more you actually have also the lending

liquidity so the ratio will not never change and you need to find different ways to protect your system and you can't rely particularly in the decks liquidity I mean the decks even the growth of the decks liquidity some other stuff related to the flash loan is that there's possible to do a governance attacks there wasn't yet any this kind of attacks in place but was lot of discussed discussion about the the governance attack in maker when you can actually get a lot of em care liquidity and and and make an attack and I think

this was funny tweet from ruin that maker baker governor was well planned and a lot of effort was put it there yada-yada-yada twitter mob and then fade in humanity drained by a flash loan so it's for me the funny part is that like we're Design Systems in very careful manner but the thing with flash loans is that actually they always existed in the form of attacks and what they actually did the deflation on liquid it itself it's basically made them just available to everyone to try it out so that's why I like it's important to take always nice cases when you design systems yeah so there was the

discussion went even further and I mean wanted to do kind of like spark more conversation and and was planning a takedown and and and partly without flashlights and weight depending on the polling polling model and and to kind of like make sure that there isn't this kind of attack on on the megiddo system but it was very interesting discussion and it just shows like how flash loans like affected everyone and not just basically the default protocol level but on the governance level as well so that was a pretty pretty cool stuff and I know I didn't have much time but this is was like kind of like a le5 a quick

intro into flash loans so I got something for you if you want to follow the National activity on our way we have a dashboard there and there's some stuff there you can inspect the different flash loans there's not a daily basis I would say from five to ten different kinds of flash loans and some of them are refinancing for example from one protocol to another so you could basically refinance one quick example about interesting use case in flash loans is that you might be on a let's say eight percent interest on die borrowing you could refinance that to another landing protocol let's say to compound where US DC might be for example 4% without returning the loan by

using flash loans so you borrow from the other protocol and end of the day before you turn the USD see you you are converting it to back to dine returning to Alba and this is like the cool part like how the compressibility is is getting even like step further in India fine so so this first one pure code here you can follow it's over overwatch it's made by our community member and you can find there one section with all flash loans and and for all your hackers developers and and if you want to do some cool stuff with the flash loans that's QR code there that will help you go to the documentation of our way and you have a

tutorial example how you could do your very first flash loan and it's very particular and if you have any interesting use cases or discussions just reach reach me out or or our team and we would really like to talk about this I personally think that the topic of the flash loans is not settled yet there's still many issues to be solved and I think people just need to think this harder and I think I think there's that now a lot of effort put in security other things particularly into flash loans and and also people are building pretty cool stuff in terms of first ones that's it about if you guys have any

questions we'll be happy to answer as well thank you [Applause] I think we don't have much time for questions so it has to be one or two mics and you wanted a really good question yeah if you remember the financial crisis of 2008 on Wall Street right there were all kinds of financial innovation and collateralized obligations and loans and then it turned out there were these nonlinear dependences the pretty much broad interesting to zero so I just want to under to hear your opinion when people start creating this very complex

securities and most of users don't understand that being collateralized doesn't mean at all it's secure you can go to zero so can we approach a point that someone creates a in algorithm and you wake up and there is no compound finance there's no maker Dow how do we create kind of some kind of a self-regulation or regulation not to create systemic risk in the system that will literally bring like in several minutes the entire defy you know down that's an interesting question I think they with the 2008 what's interesting a bit different that we have now is that

this point is that all this like there's different banks with the so-called toxic assets and and basically there wasn't no one was actually sure how many assets there was this particular asset class so they the risk of the exposure was unknown and what's cool about defy is that you kind of know the exposure in the defy board but once you are starting to tokenize things and you're putting more things into the fight that's are not completely let's say cryptographic or relying to cryptography let's say for example a tokenization of fiat currencies so we are not sure like how

much there's actually fiat in some bank accounts so we have like a very similar problem but the good thing is that there's like very big accountability within the the defy system and you can track everything and see everything but once we talk a nice thing which is probably something that will come as well in a larger spectrum then we will see the same problems and I think system just needs to be more resilient and I think I would like to say that governance is very important because it brings the flexibility to solve issues when things are going wrong and if hearing community is also like we tend to forget that we do we have done very good decisions in the past just to save the systems and I

think that's because of the governance and there are smart people here and and coming to good conclusions and that's why we have the best community ever so anyone else one question following the recent activity with flash loans there has been a lot of wild proposal on Twitter one of those well two ways to integrate flash clone capability directly inside your C 20 tokens is it something you've considered what is your opinion on that

yeah I think if you mean they like one 101 pegged basically that you can tokenize a kind of like a long position by just minting the token right yeah the issue there is that if you have a we can just look at the traditional financial system let's say we have a bank that can mint just unlimited amount of capital for short period of time and if it's accessible to everyone to do those kind of transaction it really it really might break the system because you basically not just the good thing about the current flash loan like architectures is that you have the capital is there you have certain amount of capital but it's

not completely unlimited but if you have unlimited amount of capital you basically can break any system that there is so I don't think it's sustainable I hope no one like tries to push it too far because it might a lot of issues but also yeah I think I think it's just very difficult one to pull you know in a way that it really doesn't harm the systems because at least the current form of flash loans you can mitigate that that that kind of risk but also I would like to see like if it brings any new use cases as well but I've been following that a lot as

well and it's an interesting discussion all right thanks a lot thank you [Applause]