New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

Swivel Finance 🛠 A Developer's Guide to Trading Rates

ETHGlobalSun, Oct 9, 2022, 12:00 AM

Join Julian Traversa of Swivel Finance for a workshop titled, "A Developer's Guide to Trading Rates." This workshop is part of ETHNewYork 2022, a three-day in person hackathon that will feature hackers, mentors, enthusiasts, sponsors and speakers who are all gathering in New York June 24-26, 2022 to talk about the future of money, finance, the web, ownership, the way software works and the way power is distributed. We're excited about a new frontier. ---------------------------------------------------- Follow us: https://twitter.com/ETHGlobal​ Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com

Transcript

[Applause] [Music] so i'm julian traversa with swivel finance um just a quick introduction to swivel we were founded ourselves as a hackathon project at east denver 2020 it was a pretty simple idea at the time but you know things kind of just get the ball rolling so hopefully you guys can do similarly as far as the workshop today really really the goals are hopefully a little bit less technical although it's going to be a bit overview of the technical details but the goals are really to kind of explain how developers can trade rates and make applications around these things at the moment this sector is at really largely unexplored beyond the first layer of creating fixed rates so there's there is a big opportunity for people creating hackathon projects that said the two real big goals we have for it are to kind of identify uh the various fixed rate protocols out there and where their yield actually comes from as well as you know a few strategies and kind of how to work around them um i said intro to swivel right and where our yield specifically comes from we take future deposits and money markets like compound ave urine etc and we split them into two components one is the redemption value for your deposit and the other is the actual interest you earn until some future date so the most common use case there is the fixed rate lender will have this cash flow and want to just trade it away immediately for something upfront right and in doing so the lender effectively gets themselves a fixed rate um while the other person is purchasing some future cash flow and this user purchasing the cash flow is effectively speculating that the interest rates will increase over time um and there's this is traditionally the largest mark in the world with interest rate swaps um and d5 it's still pretty small um so yeah i mean the the best example again just walking you through it um you have one lender that has a thousand dollars and you have one other user that is willing to pay effectively a market rate of five percent for one year so that would be fifty dollars you take this deposit you put it into compound and each user gets part of those cash flows thousand dollars in redemption value and a thousand dollars earning interest until one year from today the next step from there is really just calculating okay how much does this user that owns the tokens earn over the entire period right so under the assumption then that the rates moved up from five percent to eight percent um they paid fifty dollars initially they earned eighty dollars so this user is actually profiting that 60 profit um which i mean honestly in today's context this is a pretty old slide it's very different right if rates are one percent and they go up to two percent you're getting 100 profit um so the trading opportunity is better now than it has ever been um but the ecosystem is still not really as mature as it can be um we use an order book which is very important but there's about five other protocols around that try to address the market but completely fail to address what these yield tokens these end tokens really are which is a derivative in the same way an options price is based on some spot asset this yield token that earns future yield the value is going to be based on how much interest it earns it's that simple um so when you look at an amm or otherwise and try to price these assets it's actually nearly impossible the the lps just get arbitraged it really ends up horribly for all parties involved and pretty much everyone right now is just hand waving this fact away saying hey we'll give token incentives uh it kind of works right token incentives work but you know we've seen similar things with options protocols where hedgic had molly wintermute come out and say hey our lps are losing 30 a year but they don't care um and now hedging a lot of you probably don't know it exists so um yeah um that said that there is a wider ecosystem of fixed rates right and and my goal isn't just to show our project but to kind of introduce what developers can do with this ecosystem right um there's about six different fixed-rate protocols they all generate rates or yields in minorly different ways or provide markets for the tokens in mind different ways obviously i'm biased to assume that if it's a derivative you need an order book to properly trade it that said you know when you look at the yield tokenization method um and this is one that is shared across a number of protocols we were the first to come out with it really um but at this point there's there's there's about five others that all use the same model where you take some deposit in a money market you know um compound and you split it into these two components um at the moment there's no standardization whatsoever across all these protocols and it leads to a very very very difficult user experience in general um this is something we're working on and then moreover as well as a liquidity provider or user it is actually very very difficult to even just properly interact with these protocols you don't know who's really providing you the best rate you don't really understand the underlying interactions but regardless you know highlighting the point of the talk where does the yield actually come from in this model it comes from one party that is potentially speculating that the rates could go up or it comes simply from time premium and that um if the rates maintain a consistent rate you know let's say you're willing to take a slightly lower fixed rate than the current variable one uh you're effectively being paid or that you're paying the other user to to release your time premium get a medium capital maybe immediate capital today um and this is obviously worth something the market is pretty naive at this point so it hasn't really been properly pricing these things um but more opportunity for traders the difficulty with these models so the good ones is it's very good for building blocks you can rely on a lot of other stacks and integrate all across the ecosystem it's also really great because regardless of the rates there is a supply and demand on each side um you know the great example is if the rates are high eight percent there's a big incentive for you to lock it in and and kind of get rid of your capital um and alternatively i already gave the example if the rates are very low like they are right now uh it's it's very very attractive for users to come and long them i think really the best example that you know we've been trying to push recently has been the the staked ethereum trade um in that a lot of users are trying to short stake ethereum but you can also just own staked ethereum and lever yourself up on the interest rate which again this is only valuable because of this sort of supply and demand the other really most common and in my opinion viable model is just over collateralized lending um but through the use of a similar instrument with with principal tokens right if you have uh let's say 150 an eth and this is provable same way any sort of money market does prove it at the moment with whatever oracle etc and liquidation you can instead of minting variable yield mint principal tokens these are redeemable at a future date for one dollar and from your point of view if you sell them today you're borrowing at a fixed rate right if you're able to sell your principal token for 95 cents it means that you've borrowed at a fixed rate of roughly five percent a year because you just have to come up with that last five percent five cents um so it's actually also a relatively flexible model um but there are issues with it as well right the supply and demand isn't quite there as much um but the big thing is is that there is an abundance of borrowers in the ecosystem so these markets tend to be a little bit more liquid um and you know they can scale they can scale a little bit easier um so you have this really accessible user base that you kind of just can immediately identify and that's great um and the last and this is one that has been largely growing more recently under collateralized lending uh i'm a little bit more dubious on this end but we've seen some incredible growth out of companies like maple um where they allow a centralized entity to essentially sponsor a pool and they're doing the due diligence upon the borrowers that are lent out to that pool um porter on the other hand similarly they they allow dows to raise debt there's a lot of risk here that make it a lot harder to create trading strategies around but if you're the sort of person that is willing to take on some minor amounts of risk there are large amounts there's a lot of profit just to gain currently there just is um so the question starts to become right how do you start to create strategies that can actually be applied to to this sort of sector and what sort of building blocks can people build next right if fixed rates exist what else can be done um obviously the the most common trading strategy is longing and shorting the rates right if you want to long the rate it's literally as simple as purchasing the token purchasing the end token and holding it and trading it away once prices go up however there's usually some other strategies folded into a long and the most common one is largely uh people that are trying to i don't know if it's on the side yet to borrow at a fixed rate so here's here's a quick code example of exactly that right in this example we're using swivel and we're going to be borrowing directly from compound so in our scheme we use we're off chain with on chain order book or wrestler we have an off chain order book with on chain settlement which means that all of these things are effectively coming from our api all of the the order the amounts and the signatures and then you immediately just input it into your functions we have sdks in pretty much every language for this if you guys are hacking and want to do anything off chain and as well there's other ways to integrate on chain too so what's happening here is effectively there are these arrays that are input this order itself contains it's a bit more of a complicated object that's imported but it effectively includes all of the information on swivel about the order effectively what is the underlying protocol right usdc or something what is the maturity in in unix so let's just say december 23 or 31st and then per order what is the amount um as well that you wish to fill um this is all done with eip712 so this is all pretty familiar for people at this point but you also have to submit all of the signatures in eip2 712 format and then include the c token that you're trying to input we add in here it's honestly in my opinion pretty straightforward after that after you actually input all of the orders is identifying how much you've actually spent right how much did you lend out and and see token exposure um and then after that you can borrow pretty exactly the exact same amount um so so in this scenario you have someone that comes in they lend out total lent to swivel through all these orders and then immediately in the same transaction borrow this actually highlights the big issue with a lot of these amms because let's say you come in and you're a large borrower that is able to move the rates up right so this is completely separate from whatever system um that the rate trading itself is happening on and you can immediately move the rate up and profit from whatever differential on its derivative right this is the same sort of thing you could do if there was an amm trading an option and you were able to move the market um and it's essentially something that is unique to rate markets and that unlike spot markets there's no cost to manipulating oracles right if you want to change the price of uni-swap you you need to spend billions of dollars in capital to maintain it for a block or two this is easy to measure but if you want to abuse and manipulate the the actual rate on compound what does it cost you um it just costs you moving your capital for one second and paying a marginal amount of interest right so it's actually very very important that we're using this order book because it allows people to avoid this attack um but from the user's perspective this is pretty simple you're borrowing at a fixed rate you have bought total lent and c token exposure and then as well had that amount of debt pretty precisely another um and there's a few these are available now so if you want to like get into early mev these are things you can do and there are not actual many participants doing it because there's not a lot of profit here i'm gonna be completely honest but these opportunities grow um i've manually been able to do these arbitrage before and and best example here is we've had these tokens you split them up into principal tokens and interest and yield tokens and inherently because they've been split up into two components well you can combine them back into the same one as well which means at a base and core level one principal token and one yield token is always equivalent to the value of one underlying token so you can inherently assume the price of both however a lot of our these other protocols are quite inefficient like very inefficient they have pools for each of these individually and anytime there's individual pools for two assets that should be trading at the same price you can arbitrage the two so here's a quick code example of doing exactly that and going on to sense and arbitraging the two you come in and this takes a lot of parameters hopefully you've hard-coded some of this or made a more advanced contract but just for brevity's sake it's pretty pretty uh parameterized you input exactly the maturity the underlying and the sort of asset you'd effectively like to lend and the amounts you would like to lend go in identify your starting amount so you can effectively calculate your profit and loss at the end of the transaction buy a certain amount of sense pts by a certain amount of sense yt's hopefully the same amount because you've calculated that off chain um and then immediately combine them right like this seems like such a naive strategy that you would think people are actively doing these things but these protocols are in a nascent state and this means that yes people can go out there and and create contracts that will profit off of this arbitrage your biggest worry at that point is generalized front runners coming and taking your money um but yeah and in this case i returned the profit you make more realistically you probably want to require that profit exists so you do the transaction otherwise you'd revert but i i don't know i didn't decide to do that in my demo um so the next one right this is this is an actual trading strategy rather than immediate arbitrage or an attack which with previous two kind of were in that there should be across all of those different strategies of trading yields over a long term basis i'm giving you a lot of words behind this there should be a trend towards mean reversion right fixed rate protocols regardless of the source of their yield over time should center around the same rate because the people supplying the supply side of the of the formula always should be uh optimizing on on their own accord um so with that in mind there are a lot of opportunities just for creating strategies around uh either immediately arbitraging tokens that are across different protocols with slightly different risks and but that mature at the same time or alternatively being willing to take some amount of time risk there as well so again it's very very important i think that there are a bunch of protocols that have different sources of their yield and these are these are real sources these are not illegitimate sources these are sources that are sustainable because this can create a healthy ecosystem that people can build on top of so the example of that could walk through right so pt arbitrage i'm back to swivel's code base again so there's the same order objects etc um but then in here as well this is the pool for yield protocol and it's its principal token an fy token similarly we start at the front and we get the initial balance we calculate the amount that we actually lent out on swivel and then we see exactly whether we can sell that amount on yield so this entire thing assumes that you already own the yield token but with that said the assumption here is that the rates have oscillated a certain amount and you are reversing your position you are betting on a return to mean and you just easily do this on chain with an action innovation more ideally you'd probably you could you could set the strategy on chain say if the variance is greater than x percent the calculation can actually be executed um at the end of the form or at the end of it you essentially you just close the order and likewise you should really be checking to make sure that your our profit is positive rather than just returning it but there it is um and and the effect here is and i had an entire another deck for this thing but is that you are creating a deeper and wider fixed rate ecosystem um if there are participants that are willing to do this arbitrage and we're actually building an entire protocol around this core concept in addition to swivel that that takes all of these principal tokens and accepts whatever minor amount of time risk you're able to increase the volume of every single individual protocol profit yourself and ensure that the ecosystem itself is healthy right these are the things that are that are actually necessary for the growth of any defy ecosystem and it's what's driven is what it's what drove spot volume is integrations right these are the important things this is honestly a relatively similar strategy and that instead of cross protocol betting on mean reversion between principal tokens this is a cross a within protocol bet that there's just going to be reversion between major stable coins um and we have seen this on on even a short-term basis between dye and usdc with only recently uscc kind of reverting from that um but the idea the idea here is you're just trying to go from one asset and to the other there's a swivel order you come in and and and you try to fill it as quickly as possible and immediately immediately afterwards come and trade on uni swap and trade back into swivel right the result is here you are profiting should there be any more long-term disjoints and rates between stable coins um and this is a relatively basic strategy right uh there's plenty of ideas you can even build on top of this similar stuff i think one great hackathon idea if people are really really looking for one is the ability to just arbitrarily trade from one token into another get it sealed and then trade back at the end of the period just a wrapped product is pretty simple and things like that again are what the ecosystem ecosystem legitimately needs um and i mean i mentioned this kind of a moment ago there are issues with the growth and and if you can find people that are willing to kind of work around these things which we're trying to do um you can fuel and profit massively um traditionally you have things like imm dates around these fixed rate protocols um or not protocols but whatever whatever asset right you have single dates four times a year that all of the contracts for every financial everything mature this makes it so people can actually create structured products on top of them and kind of do the whole building block thing this exists traditionally however our compatriots have been kind of uh reluctant to adopt this sort of standard with us um this is something that we're spearheading now and it seems like we're getting more adoption of but it is extremely important for people to grow and these strategies really to be applicable for there to be shared maturity dates um another really big thing is i mean i showed you some of the code integrations and they look like kind of a pain in the ass because a lot of them are and one of the things we're specifically working on as well is a standard to reduce the the stress of a developer trying to integrate with fixed rates um this is something that i'm spearheading with the the yield team and that anybody that wants to integrate with any fixed yield and honestly i i'd count this in with our bounty as well even though it's kind of a separate thing um anyone that wants to integrate with a fixed yield should just be able to buy this token off an open market and redeem it later on for for the value this makes it so you don't need to do anything other than know how to integrate with uni swap and then use the interface afterwards so again if anyone wants to to learn more about these things in particular please compile booths because i think there is a lot that can be done and there's a lot of opportunities um and yeah i think i'm a bit early but it's fine um if anyone really is looking for hackathon ideas i do think we have a link i'm not i think we've posted it in the eth global discord um but we pretty much have we we have uh sdks in just about every language um we can help everyone out with their integrations and and do some like legwork as well you know just come hang out and yeah i suppose that's that's most of it from my end um we've got bounties for 2500 1500 and 1k i believe um and they're really wide reaching right so anything from minor integrations to dashboards pretty much anything yeah that's about it [Applause]

Automatic transcript — names and jargon may be misspelled.