Euler Vault Kit: A Lending Ecosystem Built on ERC-4626 Vaults | Doug Hoyte - Euler
Ethereum Denver·Wed, Oct 9, 2024, 12:00 AM
We’ll explore the Ethereum Vault Connector (EVC) and Euler Lending vault-creation kit. We'll cover the fundamentals of lending markets, show how to use our vault-creation kit for interconnected liquidity, teach vault creation with custom oracles and risk profiles, and go over advanced EVC features. APPLICATIONS FOR ETHDenver 2024: #YearOfTheSpork ARE OPEN APPLY NOW https://ethdenver.com/apply
Transcript
[Music] hello everyone I'm Doug hoit one of the co-founders of Oiler labs and uh this is the presentation about Oiler volt kit um Casper also on the oiler team helped me a lot with this so uh also um his work this uh talk I've sectioned into three different uh top uh first we're going to go do a little bit of introduction to defi Landing I wasn't entirely sure who the audience was from this so some of it might be things you already know but uh it's a little bit of a description on who are using these products and why are they are doing that uh next we're going to talk about a project that we've developed called the oiler ethereum Vault connector H and then finally another project that brings it all together called the oiler Vault kit um kicking off the introduction to defi lending uh there's this concept the time value of money right and if you ask the question of yourself you know would you rather have a $100 right now or $100 a year from now well there's actually a correct answer and it's it's right now because of this time value of money right obviously you will earn interest over that year uh and that interest has a quantifiable amount right and in this case $10 per year time is money is the expression um and lending markets the way I like to think about it is that they're kind of um exchanges between that time and money tradeoff right and the passive lending pools like compound and a and Oiler and so on are built in a way uh similar to Unis swap they're automated market makers right so the smart contract code defines the actual exchange between time and money right and uh almost all of the systems work with this concept of over collateralization and the idea behind that is that borrowers have to put more value in as collateral than they can take out as a loan okay and uh usually when I explain that to people it uh doesn't quite come through so I like to use this example of a mortgage right with a a mortgage is a you know loan you take out typically to buy a house or something um let's say you want to buy a house of a million dollars save up a down payment 50,000 and then you take out alone that's your mortgage of 950,000 and then we take a look at uh and then you buy the house let's look at what you have in your assets and debt columns here right you have a house that's worth a million dollars now because you it but you have a $950,000 debt right and you can see here that in this very typical uh case your assets value exceeds the value of your liability so you're over collateralized right um but let's examine what happens if the price of your host changes okay if it remember it started at a million dollars let's say uh the value drops to 950,000 um that's a 5% drop then you will no longer be over collateralized because you look at column the debt and asset qualities will be identical right you're you're wiped out in fact right because if you sold your house and repaid your loan you'd end up with nothing okay losing your down payment okay on the other hand if it goes up 5% then you know if you uh close out your you sell your house and so forth then you actually doubled your down deposit right so how is it possible that such a small percent change in the price results in such a large gain or loss uh it's because of this concept Leverage okay uh there's several different ways to quantify leverage depending on your field if you're accountant or investor and so on um but the one that I think makes the most sense in um defi context is the debt to equity measure uh Equity is just your assets minus your debt right what you would be left with if you sold off your assets and repaid all your debts okay uh so then to compute leverage it's simply that your debt divided by that Equity okay so in our morage example we have um 19 xage okay and um that as we see in this slide corresponds to your gain and losses right this is the um the physical analogy for leverage how it happens right a small price movement can end up with a large effect on your profit and loss um so often uh traditionally these leverage deposits were set up with this um method called looping and uh looping is basic just depositing into a lending pool borrowing as much as you can uh swapping it back into the collateral and depositing that again and going back and repeating and repeating okay and that will end up with um a position as leveraged as you desire and also Allowed by The Lending pool um however this is as you probably understand gas in efficient right because you're doing many many swaps um so that's why there's many different other ways of solving this uh most uh famously I would say is Flash loans where you take out a in one autonomic transaction a big borrow and use that to set up your position and repay it at the end but as you'll see weide of a little bit of a better way of doing that with the generalized concept of flash liquidity um like like all markets The Lending markets are uh two-sided right there's two different participants acting in them so there are the borrowers of course that we've talked about that want to set up these leverage positions and there's also on the other side lenders that want to earn interest okay um and sometimes we call those depositors because they depos into these passive lending pools okay and um in most um designs including Oilers and a and compounds Etc interest is compounding right which means that interest is also paid on previously earned interest with no action to yourself um and one of the one of the very advantagous things that uh people like to do that has a net benefit of improving the system by improving its efficiency is um arbitraging interest rates right so the idea is that if you see you know one particular lending Market has a low interest rate another has a high interest rate you can take advantage of that um for a profit right so in this case you're you know the obvious one is you take a lever position on a low interest borrow it's high interest collateral okay uh and you know the uh classic example in um traditional Finance is you know you borrow Japanese Yen which has pays you charges almost zero interest rate and borrow um or sorry you uh uh you take advantage of the Japanese Yen that has a very low interest rate and something like Australian dollar which has a very high interest uh ERC 4626 is a emerging standard and uh we think it's very going to be very important moving forward and uh what they are what it is is a specification for creating field bearing vaults right that's um you know smart contract that you deposit into and it will do something for you earn yield and then you can deposit out in the end okay uh the great thing about standard is that there's many different um if many different protocols implement the same standard then one integration suffices to interact with all the different protocols okay um and we think that the network effects of VC 4626 will be uh you know will be very important for the future of planing markets um just because of Network effects right um one thing I like to say is that you know erc20 had to come before unit well before you could have something like Unis swap a good application you need the standard that all these tokens can kind of agree on right and we think 4626 has the potential potential to do that for Lending markets um in the typical formulation of 4626 um vaults are active right the idea behind that is that you as a depositor put your money into a default and and it does some kind of uh actions on your behalf like reinvesting them elsewhere you know maybe LP tokens or other lending markets or so forth um according to its strategy right and then later on when you want to withdraw it goes and unwinds those positions and uh lets you withdraw um our concept while still being interface compatible is uh what we call passive Vault and the idea behind that is that you deposit your funds into these vaults but it the Vault doesn't itself do anything with it it waits for borrowers to come around and form from you and this is the standard uh compound uh model Etc when you deposit into a 4626 Vault you receive shares back okay those are kind of like your deposit tokens or receipts and um they themselves are erc20 compatible tokens right another great thing about 4626 backwards compatible with the rc20 um and uh one thing that the standard uh mandates that's important is that the uh Shares are not rebasing right in other words if you don't perform any action the amount of shares you hold will not change time right that makes Integrations a lot easier um but instead uh as interest is acred every share becomes more and more valuable right exchangeable for a larger and larger amount of quantity of the underlying asset um and how do you conf how do you figure out that uh that uh quantity of underlying asset it's due to the it's based on the exchange rate the exchange rate is just um simply taking a look at the um ratio of the assets to the total number of shares the assets of the and the assets of the pool are two components right you have the the cach which is actually what the Vault owns in terms of the token balance and you have the total amount that's been borrowed out right both of those are uh assets that the The Vault owns and when you sum them together you get the the total value uh due to this pool ultimately so then it's just simply you know dividing that asset by the total number of share to figure out the number of um shares that the number of assets that you share is wor notice that I've got a little asteris there this is a slightly simplified exchange rate because it doesn't use this virtual share protection shortly um so our concept with Oiler is to use ERC 4626 for uh everything or for all parts of the so not only is the borrow the the asset being loaned out 46.6 but also e collaterals right so if you um when you uh want to take out a loan obviously you need to put collateral right so those collaterals will themselves be held in Arc 436 that's the idea but probably uh you know first description of this concept you've heard you you have to just thinking about the obvious problem with this right well if that's the case how what's preventing the user from just simply withdrawing that collateral right that's supposed to be posted as as an asset or escrow or this um or this uh or The Boro well you need to coordinate the vaults they need to work together in some way right and that's where ethereum Vault connector EVC comes in okay the EVC is designed to be very non-invasive uh and what we hope is that it's very easy to integrate with existing systems or to make new systems that don't have a lot of extra crof cluttering of the code and um uh We've created integration layer that helps with that and we've also created some erc20 wrappers uh and integration points as well H so it should be uh quite a simple action to take any existing Vault or token and turn it into something that could be used is collateral in the syst um if let's go through the mechanics of how the EVC works so inside the EVC it maintains this thing called the collateral set and that's basically just a list of vaults that a user has um entered as collateral as it's chosen to post as collateral uh so users themselves manage this you know they they dep vaults and they pick which vaults they want to use for for their account it's collateral in the E uh and then next when they actually want to perform a borrow um they will select the Vault and uh set it as uh the control for for the account an account can only have one controler okay this is an important property for a lot of reasons um but uh but uh it will usually be theault that you're about to create a borrow form okay so um after you set up your collaterals and Associated them in the EVC you now select a controller and that's tracked for you in the EVC as well and uh the important thing is that when you have selected a vault as a controller you are giving over control of your account to the B okay and um that sounds quite a bit scary of course but um the way I like to say is that it's not actually U semantically any different than creating a you know taking a borrow on a or compound or so on right they won't let you remove your collaterals either until um until you have uh paid back the loan right so that that's the same kind of effect right uh yes your controller will be able to prevent you from removing collaterals from your collateral vaults but but that's exactly the same semantic as any other Landing or okay so when you uh do try to withdraw from a collateral Vault what happens is that collateral Vault goes via the EVC uh and asks the controller Vault if this action is allowed right and if uh if not it will um you know if you're trying to withdraw a small amount might be okay but if you're trying to draw too much that would put you in violation of your loan terms it might be prohibited um and uh yes only the controller itself can release the control that happens when you repay your loan uh and the other side of the uh the trust Dimension is that the vaults um have to are trusting their collaterals right they're trusting that these are you know well behaved tokens that aren't Mal acting maliciously and will keep up there and then integrate correctly with the EVC as well um the way it works is that uh usually vaults um are configured to use accept only a subset of vaults like only a particular list of vaults is the allowed collateral right it um you know anyone adds any other Vault to the cladal set that will be ignored for the purpose of if determining if a loan is healthy or not um because the collateral volts are also 46 26 volts they may in fact support borrowing as well right so your collateral could be earning interest right this is kind of critical for the carry trade that we talked about earlier um but in some cases uh you don't necessarily want that you don't want that rehypothecation right this might be because you always want to make sure you can withdraw your collateral on time without any um you know without worrying about if the amount is currently loaned out or not um and also some of the Integrations are easier if you just use collateral only Vault right collateral only vault is one that does not support borrowing but still can be posted as collateral right um our terminology for that is in quotequote escr at a high level the EVC um has this sort of split uh that we've kind of uh devised uh for responsibilities allocating the responsibilities the EVC is responsible for the authentication right in other words who is requesting this action right and as we'll see there's a whole bunch of features that this opens up if by delegating that responsibility Toc right however the vaults are uh responsible authorization right when an action is um requested uh EVC validates who it is vaults validate whether it's allowed right the most obvious uh example of this is if someone tries to withdraw more than their balance it should be prevented right so since the EVC is hand uh in charge of authentication uh one of the things that enables is the liquidation mechanism okay liquidation is obviously critical uh and this is how uh it's um performed in PC system uh because you've given control over your account to a controller uh the EVC will allow it to invoke Vault on your behalf right that's the that's the mechanism that allows liquidation right so if a controller has decided that you are in violation of your loan terms it will actually have the ability to call into the collateral Vault and call a method on your behalf right typically it will call withdraw or transfer or whatever uh in order to you know perform liquidation and repay your debt okay um but the nice thing is that this is kind of in some level in a bit of an emergent property of the uh how the controllers work right uh it's it's basically just because you've given this sort of control to the controller uh to interact with your collateral vaults you handles that authentication the collateral um Vault don't even know that they're being participating in a liquidation right they just see that the user itself uh is withdrawing or transferring its right so no special action needs to no special logic needs to be put inside of the F Revolt to support liquidation so uh the EVC authentication responsibilities also open up a bunch of other possibilities I like to say the evci is a a glorified multi call right probably most of you are familiar with multi calls you just create a bunch of operations put them into a single transaction and execute them in one transaction right EVC supports that uh with some extra okay uh what we we call these uh these multi indications batches okay um and one of the things that uhb also supports via batches is the use of sub accounts right if you're if you've seen other one we actually allow you to have 256 virtual accounts underneath your main account even if you're just regular EA using metamask or something right you can have multiple independent isolated accounts each with their own position setups right batches also allow you to perform operations atomically right in other words you know both of them will succeed or none of them will right and uh finally maybe most important is that you can actually defer the liquidity checking until the very end of your batch right so in most cases uh vaults when they're asked if this is all allowed or not will only be asked after all of the batch items have uh progressed have have completed um and uh that lets you thing that that enables The Flash liquidity we're talking about we'll just talk about in a second this is the interface for the batch for batch method it's pretty much as you see a standard multi call you have the target contractor calling and the the you know the the value that's amount of native currency ether you want to transfer and the bytes data that's the actual call data you want to pass it however it also has this one thing on behalf of account right um often that will just be your address but uh you know if you are um want to do a sub or uh we'll talk about a second these the concepts of operators you'll pass in a different address there uh as we were talking about that liquidity or the deferral of checks uh is is quite powerful and what we call this is like flash liquidity or deferred liquidity or something like that and as I was saying accounts can temporarily violate their liquidity as long as they solve at the end of the batch right and that leted to avoid you know set up leverage positions without doing any kind of looping or Flash loans or anything like this it's just built in natively the system um H yeah batches also support nesting so that um you can have batches created inside of another batch uh the only reason this is really useful is that um contracts themselves can use batching for the purposes of liquidity right so you don't need any kind of special casing on your contracts to to to actually take advantage of that it's just uh built in there you just always create a batch and you know that the checks will happen at the end of your batch or later right uh the EVC guarantees it'll happen eventually okay operators are a very cool concept we think and uh what it is is uh a way to allow a um particular address du a smart contract to perform operations on your behalf right and um obviously you should be very careful with that because uh they could do something that you don't want them to do so you should be very careful which contracts you enable and they should be well a well audited and securely deployed and so forth um but in principle they could just be an EA right so another so um you know there's some examples where you would do that too there's a little bit of a crossover between controllers and operators because both of them are like giving control to your account but the important bit is that um uh as a user you can always remove an operator any time not necessarily true of a controller remember a controller you have to repay your loan uh here's some use cases for operators if you wanted to just simply have a hot wallet that could do some like subset of actions on your account uh you could install that as an operator uh you know if you wanted to actually do a subset it would be a contract that like kind of firewalls and determines what actions are actually allowed it could also be an emergency close contract uh that you know if price is di to some level or some you know alerts are issued it can close your positions for you um or it could do it that based on Market condition um and it things like stop loss right so uh you know here's just an example of price conditions that would cause actions to be triggered by an operator right uh you know you have take profit where um you know if a a price goes in your favor a certain degree then an operator is allowed to close out your position you have another words to lock in your gains or similarly you know but like symmetrically if the price goes against you a certain amount it might close a position to protect you from further and another one that's very popular in a lot of trading system is triing stop right this is a stop loss but the stop floor is adjusted over time as the price moves in your fav right so the idea is that you can ride a really high a really large price string in your favor and then if the price goes down again take the profit of it right and this can all happen without your interaction because an operator will be able to do this on your behalf right this is kind of our our vision for the offchain system component of the one thing that kind of occurred to us as we were building this is that uh liquidations and stop losses have a lot in common right they're really just if a price you know at the end of the day if a price drips down dips down against the user a certain amount um or the price of their liability goes uh up then um then they are have their position closed right so uh the only difference is that um stop losses are typically based on the price level of some particular asset whereas uh the liquidation levels are triggered at overall health of your account right that's taking into account of your collateral and your liabilities right but um because we have this General system of building stop losses you can kind of think about installing those on all of your positions uh in order to customize your liquidation right so you might be able to kind of uh have like bespoke liquidation arguments right maybe using different Oracles obviously as I was saying based on price triggers instead of Health scores uh you know maybe hard-coded dexes that you're allowed to swap on and so on and so on right so you could really kind of with the collaboration of the other uh entities in system uh has these sort of bespoke liquidation which I think is sort of cool and that uh brings us to the next part of this is the oiler Vault kit and uh the oiler Vault kit is what we've been building a little bit uh to interact with it's kind of the uh mechanism we expect to um to create Oiler uh like ERC 462 compatible vaults that can be used and uh it's what we like to think of is a very flexible and unimpeded software package so it's really uh you know got a lot of knobs you can turn and a lot of settings you can uh configure and it really allows you to create bespoken custom vaults uh uh and by extension lending products on top of them H and whenever you create a vault you become the governor at first okay and this brings us to the first distinction is you have managed or a mutable Vault and that comes down to what you uh deploy as your uh what you do with the governor ultim right so if after you create a a vault you retain that Governor you can think of it as a managed Vault right and you know ideally it would be best if that governor was some kind of multisig or governance contract or time lock or whatever um but it doesn't necessarily have to be um and many different vaults could be managed by the same multi TIG uh for example to create a a cluster like type Landing product uh or they could uh you know be individually controlled uh and be a very contained isolated on the other end of the spectrum if you take that governor and you throw it away other words you set the governor's address to be address zero meaning no one can invoke the governance methods we call those immutable vaults okay in which case the configuration that was set up for the vault at its creation is now fixed it will not change uh and there's 's also a spectrum of of different uh Vault governance strategies in between that right you can accomplish something that um allows only a subset of the government's actions to be triggered by installing a contract on top of the um uh on top as the governor uh and acting as a proxy right so if you wanted to make it that let's say only pausing operations Could Happen uh or or let's say uh only LTV changes that's the loan value that that are allowed uh to change then you would have a contract that um only allows that uh but no nothing else right and that contract could also have time lock things built into it right so really a whole spectrum of fully fully governed and um you know managed all the way through a mutable and all all that in between one of the things that we've uh spent quite a bit of time on with the Vault K implementation is being able to price the shares of the Vault okay uh and that's really just as we were talking about the exchange rate right reading the exchange rate of a pool right it's not quite as easy as it sounds because there's a lot of different attack vectors like donations to the pool and so forth but um but you know we've designed it so that evk EV evk vaults shares can be securely priced by ver okay uh and in according to the 4626 standard the the way you read the exchange rate indirectly it's with this convert to assets function right so it's given amount of shares how many assets will I get from that and uh yeah the protections that facilitate this are internal balance tracking and virtual deposit um one of the things that secure share pricing enables is this concept of Nest Vol and uh this is something we're still formulating exactly how it's going to work but uh we're pretty infused by the potential the idea is that um imagine you create another vault that's underlying asset that it contains are the shares from a separate Vault right just as example let's say you have usdc that's underlying asset you create a new Vault that's called e usdc right and uh its underlying asset of course is usdc and it Shares are that usdc token right and if you remember 4626 uh volts are erc20 compatible so they themselves can be used as um as tokens in any place that a token would be used right so you create another Vault based on that and now the interesting thing about this is that uh if you hold e usdc tokens you will be getting the yield from uh e usdc vault as well as the yield from E usdc Vault right the idea the idea is that um you can create a lending pool based on the shares of another lending pool and attract people to deposit into it without them paying the opportunity cost of not receiving the heeld from the parent Vault because there's still doing that right they hold still have title to the E token right and we think this will allow people uh to create Ling products um and Sol partially solve the bootstrapping problem right like how do you attract initial depositors right you know you create a new pool and it's earning 0% yield um why would anyone deposit into that when they could earn 5% yield over here right so now you make it so that my pool is offering 5% yield right now and maybe if more borrowers come you'll get something on top of that right so that's one of the things we hope to accomplish um another feature that we've added to the evk compatible vaults is this LTV ramping um LTV stands for loan to value ratio and uh as we were talking about um there's uh this concept of Leverage and if the Leverage is too high or like allowable leverage on a pool too high then even a tiny price movement would cause a wiped out right so um vaults will typically well not just vaults but any lending product will typically limit that amount of Leverage right and the way they typically do that is with this uh by limiting the LTB uh you may have also heard of this as a collateral Factor that's what compound calls it for example um and uh one of the problems we saw with that was that um in a managed pool where ltvs can change for various reasons right like let's say that uh um previously believed secure collateral is no long longer secure or less secure uh then you'd want to reduce the ltp right the problem we saw with that though is that uh if you in most designs if you reduce the LTB immediately A lot of people with existing loan will be instantly liquidated at a very unfavorable um uh under very unfavorable condition right because they're deeply in violation however uh what we've come up with is LTV ramping is to split the ltvs uh used for liquidations from the ltvs that are used for the existing right so a managed Vault the governor can install uh a new LTV that will come into effect for everyone let's say mon right that ramp is called that duration is called the ramp duration new uh uh new loans um sorry yeah like I guess I haven't call it existing loans here but this is like uh you know the that means that the loans that have already currently in effect in the pool and also any any new loans that will be initiated are uh under this new LTV immediately right however with all the existing loan all the previous loans that had this uh iner the liquidation will go under this ramp will will be used according to this ramp right and um I don't uh have any slides to talk about right now but the way that Oiler V1 liquidation worked is that um How Deeply in liquid in violation you are corresponds to how uh much you will be um uh losing in the liquidation Okay so in this case at the exact point down that ramp where you go get uh in violation is where you will be liquidated right meaning you'll be liquidated under the very most favorable uh condition for you right so you'll usually lose very little or nothing uh relative to closing out the position yourself on that so it's a it's a good way to um to if it's the manage pool change the LTD without unfairly impacting War Earth uh and you know there's been other approaches to this like for for example a has a system but their their uh with their design those uh loans are on on the books forever basically there's no ramp that ends up correcting them uh so the pool Theory could stand with loans at the previous LTB for indefinite amount of time right we think this is a better way for managers to correct that um yeah another thing that we've developed is this uh reward streaming concept and um this is uh kind of a us taking a step back and looking at how the previous like liquidity Mining and bonusing systems and so on have previously worked and think if we can generalize this a little bit make it a little bit more permissionless a little bit more flexible uh and essentially what it is is a way for vaults to notify an external contract about balance changes inside this and um if users opt into this their balances will you know every time their balances change that external Vault will be notified right and uh this allows us to create fully is mining reward right um what we want is that uh bolts um can be like VA depositors can be rewarded by anyone in any token at any time right so uh you don't have to interact with the Vault uh Creator to reward depositors on the token right uh and some maximally flexible system and the Really key part of that is that uh even uh you know because there's no staking required you're not taking your your Shar is out of the vault in order to earn rewards that means that leveraged amounts can also be rewarded right so that um you know if you have a large lever leverage position you can be earning um rewards based on the full nominal value of your collateral right even though that is several times leveraged um yeah so that's the that's the sum of the talk here um we have some bounties for the hackathon uh going on here uh two bounties uh the first one is uh to create um uh ERC 721 uh or vaults that accept RC71 tokens that's collateral uh and you know integrate them with the EC right we have the some helpful wrappers in our EVC playground uh repo that uh can help you get started helpful examples um I just want to say that uh we're actually a little bit flexible on what you use collateral right nfts are probably the easiest to describe uh most know a very obvious use case of it but uh like of something that's different but uh I think we would be interested in seeing any kind of Dey product in collateral you know uh think that's pretty cool to Bounty number two is uh building an operator on top of the top of the EV uh and that's what we were talking about earlier where you give another contract control over your account uh and allow it to perform actions on your behalf um many possibilities here uh something like a security Guardian you know that is able to hold the conditions uh under you know if receive some kind of alert or something like that uh or you know talked about it could be based on uh chain onchain observable uh things like prices in which case that would Implement stop losses and so forth uh position rebalancer there's a lot of uh a lot of possibilities there and uh please you know talk to us for uh for more details there happy to walk through any uh concept you have and uh that's it these uh two your L are the documentation uh Pages for the EVC and the WEA Vault kit respectively um and the the bottom link has a link to our light paper as well as the white paper light paper is more of a higher level product concept where we talk about you know the different deployment techniques for um uh for for their vault kits and what we intend to accomplish with them and the white paper itself is a more technical Deep dive that talks about all the things we discussed today but uh also a bunch of other features I didn't get into there's a lot of features uh addition additional features we did talk about today in the VA kit and the EVC uh so if you're interested in them check out the white papers um or come talk to us at the conference today and that's it thank you very much if there's any questions uh we can try to do that
Automatic transcript — names and jargon may be misspelled.