Element Finance Deep Dive - Jonny Rhea - [Toronto Ethereum Developers Meetup]

ETH Toronto Talks · 29 Apr 2021 · 36:44

Element Finance CTO Jonny Rhea gives a deep dive into the new DeFi protocol, which aims to bring high fixed yield income to the market with a focus on ETH, BTC, USDC and DAI. Using an interactive hackmd document, he shows different ways yield and APY can be optimally calculated. The talk was given at the Toronto Ethereum Developers Meetup.

Speakers

Topics

From ETH Toronto Talks, hosted by ETH Toronto.

Transcript

oh actually i should probably share this i'm going to share a link um my slides are a hacking d um let me just stop sharing because i don't know if i can type in the chat one sec okay um y'all can follow along uh to the slides or sorry to this hack and d it's um it's kind of interactive about some interactive graphs has some links that might be useful um so let's share my screen again okay can y'all see um element deep dive all right okay so um okay so yeah i'm

johnny ray of element finance um this talk is gonna be centered around some of the more like foundational pieces of the protocol i'm going to touch on like the analysis and simulations and like towards the end like kind of some ideation we've done in order to kind of like give you all like a more intuitive feel maybe not just like how to use element but maybe how you can build on it um but kind of to start out um i figured maybe i should talk about like how element works just like kind of like a a quick little intro there um so what we do is we take like a yield bearing asset like a urine vault um we wrap it and we create like two tokens like a principal token

and a yield token and the principal token is like going to be redeemable at the end of the fixed term for the original amount that's deposited and the yield token is redeemable for whatever yield's been earned um and so like the idea behind splitting the principle on the yield token is that's supposed to like you know you know basically it's going to open up some like interesting possibilities so like principal tokens can be like sold at a discount to free up capital um that can be used to like reinvest and increase exposure to like variable yield basically just help like you be more like capital efficient with your investments um and buyers of the principal tokens actually get a great deal because it's just a simple way to like lock in a fixed interest rate um okay so uh that's that's basically

like the tl dr of the of the protocol but you know kind of the next thing to learn about is really just like how do we actually like price these principal tokens um and the way we do it is by actually like we build on the ideas um that were presented and talked about in the yield space paper if you guys haven't read that paper i suggest checking it out it's not like a prerequisite to using element or like um you know or building on it even um but it's actually just a really good paper so um i think i will link to it in here somewhere um uh now when i was like preparing for this talk what i wanted to do was like i wanted to like dive into like the math of the element construction paper but i wasn't

really sure that 30 minutes of like long division um was gonna be that interesting or compelling uh to people so what i tried to do instead is like um i'm trying to like provide some like interactive visualizations that kind of like capture the essence of like some of the more academic like aspects of the construction paper um so we'll see how that goes so um uh basically like um you know the first important thing to understand like you know on how principle tokens are priced is like we use these this constant power sum and variant this constant power sum invariant was defined and and what it does is it includes a time parameter

that allows its behavior to change as the principle token reaches the terms maturity so like initially like the about what the invariants gonna do is it's gonna like allow for like more price discovery but is t you know near zero near the maturity date um the invariant kind of forces that principle token and the underlying asset to converge in price um so like here i have this um this cool little like desmos plot um it's like a uh and basically uh i've parameterized time here and so you can see like so you think in the beginning of like when the you know when the term first launches like t is going to be like one okay and you can see how uh the constant

power um you know some formula you know is is essentially like converging behaving very similar to the constant product rule um you know which is the invariant that like unit swap like uses so um what it does is it's going to allow for more price discovery early on in the term um and i think if you're if you're interested in a proof actually because like that that it converges on the constant product sum i think the yield space paper actually like has a proof that is like t approaches one you get this constant product function so um so check that out if you're interested now um as t approaches zero um it's kind of trivial to see just looking at the the equation but as t approaches zero you can see

um you know that it's going to actually just converge on x plus y equals k which is the constant sum formula so um anyway so like now in order to like actually use this formula to like um i guess to like price the tokens what we can do is solve for like the output you know given some input amount um you know next there's fees and honestly like what we do with fees is like dead simple we literally just take like a percent of the yield and like just a quick note the fee calculation um is a little bit different than what they talk about in the yield space um both methods both methods essentially like price fees and yield space so the closer you get towards maturity

the less that these are however we felt like this approach was like a little bit more straightforward more gas efficient to implement in solidity so that's why we kind of went this direction um and if you want to like know more about um how we use the um you know this invariant you can check out like appendix a in the element construction paper it's got some more details um okay so uh now to actually like uh you know we know the basics about how the curve works you know like how we use it like the next thing to understand is how do we configure the curve parameters to meet our needs so like when when configuring like a pool the price principle tokens um it's important to like consider the

the effect of the underlying vault apy um you know like on the reserves required to price the principal token appropriately so like the lower the apy the larger the proportion of the underlying assets got to be in order to provide um in order basically like the larger the proportion of the underlying assets must be provided to you know to the staking pool in order for that pool to like represent this apy so um it sounds bad but fortunately we can actually mitigate this problem by introducing like a time stretch parameter so um the best way really to understand what i mean by time stretch is like just look at this formula

here um so i mean if say we have like a term that's like 12 months and we're saying we're using a two year time stretch what i mean is that that the time parameter is going to be initialized at 0.5 if the time stretch parameter is 4 years it's going to start at 0.25 so um so that's that's fairly simple okay um you know really like what we want to do first of all like when configuring this curve is we want to optimize the staking requirements for a particular apy um you know if you look at this plot here you can see like the x-axis is like the principal token apy and the y-axis is going to be the ratio um the ratio of the reserves um

to actually like represent this apy you can see with like a time stretch of equal you know a time switch of one it's going to take like four times as much of the base asset so like eth um you're gonna have to do like a four to one ratio of eth to like the principal token in order to actually participate in staking which is like not very capital efficient and um and so what we can do is um you know is uh is actually like tweak this time stretch parameter and you can see like say we want to like if we kind of like search for a time stretch we want to look for one to where the reserve ratio is gonna be about one to one so you can see

like assuming like a twenty percent apy um at a time stretch of around three years um we end up with like a one to um you know base asset you know uh to principal token reserve ratio which seems pretty reasonable and it's a lot more you know capital efficient um okay so goal number two um now like keep in mind like the apy um of the underlying yield bearing asset is gonna change over time uh so it's gonna be important to like select a time stretch that allows this invariant to like adapt accordingly so we want to make sure that we don't select a time stretch parameter

that's like so big we can't properly price discover okay so um you know if you obviously call from like the last plot we determined that like a time stretch of three will allow stakers to provide a one-to-one ratio um so what we can do here is like now we have a plot same you know x-axis is like the principal token apy this time the y-axis represents like the max percent change in apy so let's play with the time stretch parameter and see if we move it to three um basically what does that do to our you know ability to price discover and so it looks like at a time stretch of three um 20 apy the max percent change in apy like given

these parameters is going to be like a 200 so it's going to be able to price discover to like you know like a 60 apy um and so so that's you know in this case like i would say this this particular apy um in what we consider like a desirable ratio of reserves like we can see that like price discovery isn't really going to be an issue right but the reason why we keep that in mind um is that later on we might want to decide we might decide to like further relax the staking requirements so like the reserve ratio is even more favor of like stakers and capital efficiency so um given that scenario like depending on the apy in question we really just want to ensure that the price discovery is still part of the

constraints and methodology used when configuring these concerns sorry these curves um so um you know with that in mind like you know we've you know we can see how we can like modify this time stretch parameter to ensure that like staking requirements are reasonable um excuse me um and also ensure that the curve can still function well enough to enable proper price discovery really the next thing we want to do is like um we just want to like be able to synthesize this information into some sort of like reasonable like constraints that we can define in order to search for like feasible time stretches for any apy so like looking at this plot um basically like what we have is like

a range of like feasible time stretches that satisfy like these following constraints which is like we're about close to one to one reserve ratio and then price discovery in this case is like about 50 like plus or minus 50 of the apy so like the way you would use this is like say um say like the apy of the principal tokens like ten percent um say that's what we think it's going to trade at so what we want to do is we want to configure this curve so we look up on the x-axis where 10 is and then we kind of like walk up you know the y-axis and and see kind of like where the red line starts so it looks like somewhere between four and 11-year time stretch is going to um

essentially like meet these requirements um now keep in mind like this is this is kind of like a like a discovery science sort of explanation um of how we do this like curve configuration so but if you want to like look at appendix v in the element construction paper um there's like more details and there i'll walk you through like some of the math like on how we calculate like price discoverability like what some of the assumptions we've made are like how you can solve for max feasible trade basically like the max feasible trade um so check that out if you want to actually see the you know the actual like um you know arithmetic or whatever um but the idea here is just basically

kind of give you an idea of like what our methodology is for like actually configure these like at kind of more of an intuitive level so um so next like um i want to talk about like market simulations and like the purpose of this section isn't like to show you guys on like how profitable staking is going to be an element i mean it's going to be profitable and i think a lot of people are going to want to participate but this is more about like the mechanics of simulating the market um and and um excuse me um and and basically like um making sure like things behave as expected sorry let me get a drink of water

so like these are similar these simulations essentially like assume that the purchasing activity is going to decline as the maturity period of the term like draws closer so it's going to simulate sort of like the kind of price um or volume that you'd see like in a real bond market however we don't really like know what the trade volume is going to look like so so this particular simulation kind of just like picks like a worst case scenario and the way it works sort of is like as follows basically like we load up like the market price um you know like the apy curve parameters um you know of the asset and then we calculate the reserves required to represent

like a specific target liquidity that we're trying to like um simulate the price action on and and then we calculate like a target volume for each day and as i mentioned earlier um basically it's that's going to be a function of like the maturity ratio so so then for each day like in the term we're going to simulate the trades basically needed to meet that day's like target volume the way we do is we basically like will randomly select like a target order size and like for simplicity it's just like a simulated sort of like quasi-normally distribution like a mean order size that like roughly matches what you'll see on like unit swap and like we don't know like what these orders are going to look like on mainnet right

so you know we've we've tried a variety of distributions and order sizes and and whatnot and so really like the idea here is just to sort of like start developing the methodology um so that we can kind of plug in real numbers once we get um once we get to like um the mainnet um so you know next then we'll like randomly select like an input and output token um and then the direction of the trade and these trades are going to kind of like continue until like the daily volume has been met at which point we'll like increment the day and start over so like rinse and repeat until the entire term has been simulated um so like this data is not like just used in like our analysis and to like validate like some of the

you know the the curve parameter configuration it's actually used to like test the smart contract to ensure that they behave as expected um you know and like like we're happy like the simulation is like nice and it's like a good start and everything but there's so much more we can do like going forward so like for example like we could like start adding in like simulation of like adding and removing liquidity and this could be part of like a deeper and like more dynamic simulation of like the underlying yield bearing asset and like the effect that deposits and withdrawals are gonna have on yield and this is like sort of like just the most obvious like first order interactions and there's like much more interaction there's like much more interesting interactions happening like within these yield bearing assets

as a result of like like broader trends in d5 and so like for example like say we're looking at like the curve steak e fault so like what happens if the lidar rewards change like what happens to yield there's like a hiccup beneath two staking um like what's the effect of the validator activation queue on the stake youth token like we know the max like activation rate um you know you know given a certain demand like so we should be able to simulate like this activation cue and then the resulting effect on that yield bearing asset um and so um another thing we can do is like sort of like close the loop between like the curve parameters sorry configuration like price initialization these simulations there's some like

really really fascinating market forces that we think will drive like the price action of the principal token and the yield tokens um and actually like i didn't mention this earlier but like because users can deposit into an open term um and essentially like pay for yield that's already been accrued like this links the price of the yield token and the principal token so it'll be really interesting to see like how different like trading strategies can take advantage of this coupling like in order to like like arb the prices and maximize yield and i mean really like the great thing about all this is it's like healthy for like the element protocol that's why we spend a lot of time like thinking about these interactions and like

writing about them and encouraging people to like get involved and build excuse me and build on element um and one of like the um oh and by the way like uh section four three of the element construction paper we'll talk a little bit more about the simulation if you're interested and you want to follow through to that um so one of the um so one of the like the the first things we thought of um uh the first strategies we thought of that you could build on the element protocol is what we call like um it's kind of like a form of leveraging it's called yield token compounding and so what that is the process of like repeatedly selling the principal and then depositing it redeposing it to getting further exposure to the yield

so yield token compounding is unique to element provides a way for for you to like gain like a levered exposure to variable interest without really any additional risk so so this analysis like honestly could be like a talk all by itself um so what i'm going to do is like make some simplifying assumption here like like the calculations of this example they're not going to take count you know like gas fees or like slippage or trading fees sort of just to maintain simplicity um but but the formulas you see here are actually still pretty useful so um so i right off the bat you know like given like the number of times you want to compound and like your fixed rate and the principal you can calculate right away like

um the number of principal tokens you'll be left with number of yield tokens you've you know accumulated and this last formula basically is your resulting apy boost um okay so so taking a look at this action this plot here um really it's just designed to sort of like drive home like how profitable like yield to you you'll coupon yield token um could be so let's say you have like a year like a urine vault that's making like a 20 apy you can deposit in that vault and be happy with your 20 apy right um or you could just you know decide to like play this yield token compounding game

so um let's say that the principal tokens are selling at you know a 10 um discount um and then the yield on the underlying vault is expected to be like an average of like a 20 apy um for the term so what this plot does is it shows that after like 10 compounds you'll end up with like um you know rather than instead of like a 20 apy um you'll end up with like a 70 apy um and and we have these little sliders here to demonstrate like um one thing to keep in mind is in order for yield token compounding to be profitable the fixed rates got to be lower than the

variable rate okay so keep that in mind um so this is like a simple example but really it's just designed to sort of like make us think about like um like what market forces are like really at play here so like the more you yield token compound the more you flood the market with principal tokens right so like the more principal tokens you have um you know the lower the price is going to be the higher the apy so like eventually that apy is going to get close to or higher than you know the expected yield of the underlying vault and that sounds bad right because now yield took and compounding is not going to be profitable um but it's actually not it's actually cool because what's going to happen is people are going to like rush to buy these principal tokens that

are like ridiculously discounted with like high apys so this in turn is going to like drive down the price um you know so someone's going to be really happy playing these market gradients so um you know there's actually a really cool section in in the element construction paper that talks more about this appendix c and d actually so um an appendix d is going to like provide like a closed form equation that's gonna answer one question that i think will be like interesting to people who are who are you know interested in building like a bot um to kind of play this game and like that question would be like what is the max market api that allows someone to hit a target apy after in compounds you know let's assuming some sort of like speculated

apy for a particular token input and tote and turn link so i think it'll be useful you know for those ytc bots and honestly like stay tuned like for updates and like articles that we're gonna have coming out we're gonna have like a calculator that'll help you know like in some like nice explainer posts to like help you dig into this um we kind of like make the information a little bit more digestible and of course like the the construction paper really talks about this ad nauseam as well so um okay so this next uh this next section i'm i'm calling just for fun like the element state machine um so really like i just included this diagram of the element state machine it's sort of like a fun visualization to look at um you know so while you're thinking

about things that can be built on element you can think of like you know like the diamonds here like decision points right so like they'll be like the output of like uh um some sort of like simulation or like a heuristic or some sort of like you know analytical um you know model that you might be using um and then the square is going to be like an interaction with the element smart contract um so keeping that in mind like what can be built on element um you know just reading the list you know automated leveraging self-paying loans um yield ladders and actually like yield batteries like are interesting like because they could represent like a like an advocate target like an average maturity for example and like

targeting this average maturity could be like a powerful piece of collateral um so like having a consistent maturity date could really eliminate some variance on yield and kind of taking this further you could even construct like a yield ladder to like actually like target a stable apy or perhaps like target like a you know a risk level across yield types um and they're they're super useful also just as like a you know an instrument for like investing you just throw your money in some strategy you know that defines a yield ladder and then it um you don't have to worry about like redeeming at the end of the term or whatnot so um so okay so this is basically it but like i want to like mention a couple things

before um before i kind of like yield to questions one um uh you know we're hiring so if this stuff like um interests you uh you know hit us up um also like we're interested in working you know with people in the community different protocols um so uh you know please reach out to us um you know like we're going to be releasing a lot of educational materials um you know we built you know element you know to be open you know to be built on um so you know so please reach out and then finally what i wanted to say is like i just wanted to like acknowledge and say thank you to like a few teams like um that element was like really inspired

by and like so like the balance routine first of all we build like directly on balancer v2 like we were a launch partner um balancer v2 has like a ton of great features um but the fact that it allows us to define our own like pricing invariants or whatever is like really just it's like it's key to our protocol um next is like the urine team right so i mean element needs some sort of yield bearing like in order to like work and like early on we considered um honestly like rolling our own strategies and kind of like covering this ground ourselves um but we kind of like eventually came to our senses and realized it's just better to like build on projects like

urine um so the strategy actually worked out great like um the urine team like really goes out of their way to like ensure deposits are safe um for their users um you know ensure that they you know users withdraw more than they deposit they've been super helpful like with integrations um and helping us integrate with urine b2 and looking looking over at our contract so um definitely appreciative of them and then finally like the yield space authors um just a shout out to them um our principal token like uses the curve and like most of our analysis um you know it's based on extends ideas in their paper um i i really can't say enough about it like they're they're just brilliant so

um big thanks to them and um that is it i'll leave it with picture of uh greg that's a that's a solid ending to your talk thank you for that johnny i don't know greg if you have any comments about that but um we have some questions from uh from the audience here um you may have answers i don't know thomas uh asks what's the difference between this and alcoholics for self-paying loans um well alchemists could use us um so um i guess that would be the difference right so alchemics like i guess what do

they use like a yield they are trying to use like urine underneath the hood they could use us okay and then i guess the next question is so the overarching goal is to maximize apy and allow users to leverage their yield returns um i would say the like the goal is to um basically create like access to like fixed yield returns that's really it um so you know yield token compounding is just like one thing you can

like build on top of it um basically you know what we do is like when you when you come to element you like deposit and you like comment a principle token so say you have like 100 eth right and say you want to like mint um you want to you know deposit that into our protocol you'll get 100 you get 100 principal tokens and 100 yield tokens that principle token is going to be redeemable at the end of the term for 108 and the 100 yield tokens are going to be redeemable at the end of the term for whatever interest has been accrued um but it's not locked actually because you can actually sell the principal tokens right away at a discount so the market's

going to decide like what um you know what that discount is going to be so if i want to get a hundred east exposure to like that variable interest um i can you know mint hundred principal tokens 100 yield tokens and then sell the principal tokens right away and say like the discounts whatever percent maybe i get 95 each back well now i have like the 100 eth exposure um you know you know to the yield but i also have my capital it's freed up too so i guess maybe that's the point that makes sense and then just like it's sort of a choose your own adventure right like um you saw my weird diagram or whatever like you probably can't see

it but you all can click on the link and play with it or whatever but just do what you want with it you know that's that's why we built it we built it so y'all can play with it so um cool and then um eric asks i don't understand why fixed rate won't just tend to zero in other words the principal token price is equal to the base token price um oh i mean it will like as it matures it will it uh you know it will like so i guess he's asking why it's worth less initially that's because you lock up um you know when you deposit and meant these tokens like they're they're locked for like a term

like let's say like three months um or six months so um because it's locked there's going to be some discount if you want to sell it right so if you sell it and you sell it um you know at a a five percent discount or a ten percent discount well whoever's buying that basically just locked in a guaranteed 10 fixed interest rate right and you freed up your capital so and then the next time and as it starts to mature and gets closer to you know maturity the prices are going to converge so um in the end they will be they will be one to one so that's actually like a good question i probably didn't explain that well thank you for that and um i don't know

if you just answered this question from brendan but if someone sells their um pts wouldn't the buyer just immediately sell them one to one um if someone well oh okay yeah same thing it's the same deal so because it's locked up right like there's gonna be a there's gonna be a um so cool um and then uh last question from um if you use this across a layer two um and uh fraud proof on optimism gets triggered wouldn't wouldn't there be a double spend i don't know pass [Laughter]

you guys tell me um i i haven't i haven't started thinking about um you know l2 um so i don't know the answer to that uh there's a lot of l2 experts on the skull maybe they know the answer yeah i don't know mark if you want to answer that um i think it's kind of implementation specific per l2 but i can talk a little bit about in the case of optimism in particular so with optimism as soon as there's a fraud proof um transactions themselves don't get reorganized it's just the state routes get like optimism is two arrays basically of

of transaction and state route so fraud proof uh happens reorg's all of the state routes uh after including the uh fraudulent state route and then the correct state routes get filled in so um like you'll only get double spent if you did not uh if you did a if you did not wait the fraud proof window of one week that's like really the only way to get double spent or you did a fast liquidity withdrawal without doing the like off chain validation yourself wicked thank you for that uh yeah thanks for being here

i've got one more question can i jump in really quickly johnny thanks for the presentation that's great really interesting um i feel like this this and pool together can work together in some way i'm sure um yeah we should chat dude yeah for sure um one thing i maybe i missed in the presentation like are all the pt tokens fungible and if they have different maturity dates like how is that um reconciled like if they're if certain ones are locked up others aren't or are there actually different pt tokens for each yeah there's different ones yeah okay okay let's see great well thank you for that do we have time i kind of want to follow up on my question earlier i don't know if you have time though

yeah we do oh cool yes i asked about the the the the fixed rate tending to zero and you're saying that you know initially before the uh i guess before immatures then you know people are most likely going to sell it at a but i mean i still don't understand why you would sell it at a discount i mean it makes sense for something like eats where you actually have to use beef to like make transactions and has like utility and stuff but if it was something like i don't know if i was locking up i mean i don't think this would make sense for locking up like stable coins but for something that's like a stable coin for example that doesn't have

much utility except for like paying for like why if i was like you know accepting payments why should i not be able to just accept the principal token as payments and then just redeem it for that token later effectively the price difference like zero you can accept it as a payment you could use it as collateral and it'd be really close you know you could use it as a form of collateral that's like pretty freaking close to like uh you know the value of the underlying asset so um you're i don't know like and maybe i like maybe i don't totally understand the nature of your question like um if you're arguing that like the time value of money isn't real or something i don't know maybe

i mean i i like i like i i'm not a philosopher or whatever but like um but like one practical reason like why it would be worth less is the other thing is like because um will allow you to like mint into an open tranche right and so like if you meant into an open tranche is it fair that like you waited towards the end and uh or like you you meant into an open trunk you have to pay for the yield that's already accrued right so like you're going to receive a few less principal tokens as a result of any yield that's been accrued so that like natural coupling between the yield that's been accrued and the principal token there's gonna be a feedback there

so like if that's gonna also cause a discount um it's a good question i i don't know if like my answer like satisfies you but like we're gonna find out soon we're gonna launch so um well i mean honestly i was just kind of throwing some words around anyways i'm still like on section 2 of that paper are we all just throwing words around i mean yeah there's there's definitely great conversation um uh coming out of this uh austin but i was gonna say like it's it's not like uh don't take my answers like being like a flippant response it's actually like one of like the it's one thing that we like sit

and like you know talk about is these weird interactions between the tokens like what are they gonna work you know what's the market dynamics gonna be like we don't know you know what i mean like that's why it's like interesting it's fascinating so you know stay tuned