APWine 🛠 Your first Future Yield strategy - Ulysse Ramage

ETHGlobal Bogotá 2022 · October 2022 · 24:07

Ulysse Ramage, co-founder of APWine Finance, explains yield tokenization and how it splits an interest-bearing asset into a principal token and a future yield token. The workshop covers the APWine AMM, strategies such as buying principal tokens at a discount to fix a rate, and a hands-on JavaScript SDK walkthrough on a mainnet fork using staked ETH from Lido. It closes with questions on market APR, liquidity provision and arbitrage opportunities.

Speakers

Topics

From ETHGlobal Bogotá 2022, hosted by ETHGlobal.

Transcript

foreign [Applause] [Music] thank you for coming uh I'm Euless from apwine one of the co-founders of AP1 finance and today I'm going to be presenting this workshop and mainly three different points uh you know how what AP1 is how it works and how you can integrate it into your own hackathon project in order to win some prizes so we're going to begin with you know what is AP1 and why did we build it in the first place it all started during the D5 summer of 2020 you know where apis were just crazy three digits and we thought we just saw the opportunity here because there was no way to bet on the

loss on the rise of yield so essentially reduce your risk the this is why we came up with a new primitive in D5 called yield tokenization and now yield tokenization is you know mainly the core of AP wine finance and this is what allows you to get your yield in advance or trade yield so yield tokenization allows you to buy sell and hedge your risk in defy on your yield now how does it work it all begins with you know if if you use some phones on Ave or you know compound or any yield generating platform you have some interest bearing assets interest bearing assets is you know you just hold your

tokens and it increases in value where it just increases you know yield in your wallet so as an example I've taken you know a die a pretty common asset to to hold in your wallet it just increases in value and this is an interest building token now if you deposit that on AP1 this is the yield tokenization part we're going to split it into two tokens so one of them is going to be the Principal token and this represents the value of your deposit at the time when you deposit so essentially imagine you deposit a hundred a die on AP1 you're gonna get 100 PT principal tokens and these principal tokens are always going to represent 100 a die right it's always the same value

and now what's interesting is the future your token the second token that you get and this is going to constantly when the a die is generating yield you know from Ave it's going to put this yield not into the principal token but into the future yield token so essentially we're splitting the capital and the future yield and this is what allows us um you know to get this entire Marketplace of future yield going on so you can mint uh PT and fit with your interest bearing tokens and you're never locked in the platform you can always withdraw if you still have the PT and the A40 and then we have the AP1 amm which is a core part of the protocol and the AP1

amm allows you to you know sell this fyt or buy PT or just trade between any of the three assets of ADI ptfit in order to build your own strategies or get your yield in advance in advance or fix your rate or so on uh our ap1imm is the result of many months of research this is the AP1 ammv1 we have impermanent loss protection mechanism for LPS so if you want to become a liquidity provider on AP1 it's also very easy to do so and maybe we can chat about it after the workshop but in order to get straight into the workshop I'm just going to mention a few strategies here and then we're going to get into what we're going to build today some of the strategies you can build

with AP1 include PT trading so this is like equivalent to a fixed rate um essentially buying PT at a discount imagine if you're buying PT at 0.9 so 90 of what it's really worth it means that if you wait till the end of the period for example three months this is what we work with you're going to make a 10 profit because you know for sure you're buying something that is going to be worth more in the future and this is how you fix your rate now without going into too many strategies uh this is what we're going to be doing today today's Workshop is about going back to the future to fix your rate uh on your yield so we're going to be leveraging the yield tokenization part of AP1 plus the

AP1 amm in order to build this strategy so some of the prerequisites and and you know if you have your computer it's great if you don't you can just follow along but it's also very easy to follow with the GitHub repo um so you need yarn node.js and we're going to be starting now with the repository setup [Music] all right it's fine I'll just keep like this um all right this this is going to be a one-handed Workshop which is going to be interesting uh let's go with the repository setup um I'm just gonna get this a little bit higher and we're gonna get clone

github.com Workshop and if we clone this repo and we navigate to it let's open it in code to better see it and you're going to be able to see everything that it contains the first step you're going to want to do is copy the environment file into from the example file to your environment local file so dot app.example2.10 I've set up an API key for you to try please don't use it for anything else it's not going to work all right and then we just want to install all the dependencies so you just want to go with yarn this is going to install all the packages just like npm

and while we do this let's take a look at how we are going to follow along so first step we're going to do is yarn start node this is going to start a node a fork on mainnet so essentially we're going to be simulating our strategy without actually using money which is which is very useful because if your strategy doesn't work you likely just want to simulate it before so if we do yarn start node this is going to do a local blockchain fork and then we want to open a new tab and every time we want to follow a longer step you can just do yarn step one yarn step two all the way to five so just as an example let's do yarn step one

and then we can go look into the code to see what it does so here we can see that that it initializes the SDK and this is the first step that we're gonna take a look at it so first step is the SDK creation very simple just one liner this is going to be a JavaScript Workshop not a solidity Workshop but if you're interested in you know integrating within solidity our contracts we can chat about it it's also very easy to do so First Step SDK is equal to new AP1 SDK you want to put your provider your signer everything that you need the network which is going to be mainnet and that's it a new world opens to you the more the future yield so this is the first step that we just

did the SDK is now initialized and ready to work Second Step so just to explain how this is going to work what we're going to do is first see how we can do the very basic PT trading strategy so buying PT for cheap and waiting till the end and seeing how much APR do we get and the Second Step sit step which is the the real Workshop that we're going to do is go through future yield so essentially tokenizing into ptfyt and then swapping our future yield for fixed rate and we're gonna see that this is much more Capital efficient so hang on this is the first step how do we

retrieve all the Futures AP1 supports all the assets that we support all the platforms and so on um what we can do is this Futures is equal to SDK dot fetch all future Aggregates very simple you get all the information that you need let's try out and while we do this step so this is going to actually you know run on the on the main Network we can take a look at what it does uh here so if we go to scripts and then step two get all futures we can see exactly what it does so here fetch future aggregate from address and we just Pat whatever future vote address we want and if we go back here

we can see here the results of all the assets that we support at this time of the fork this was a fork from a few months ago we now support many many assets around around two chains and many different platforms but here we have for example and this is going to be the one we are going to look at we have state eth from Lido Finance anybody ever used a stake to eat before yeah so you can generate APR you know at five percent six percent depends on you know what you're getting right and this is a period that expires expired rather uh on the 23 of March of 2022. so this is you know an older Fork but the principle stays the same you can

try with a newer block number and it's going to work just as well um and then the next step we want to do is compute the APR that we would get if we were to buy the PT for this specific staked eth future so how do we do this we're going to use the the amm this time because we want a special price right if you want to buy or sell anything you're going to have to go through the apy and amm so price is equal to SDK dot fetch spot price you pass the Vault so this is going to be our stake East volt and then from N2 these are two different strings so you can put underlying PT or fit very simple and this is what we're going to do right

now and see the results so yarn step three and we can take a look at what it does here compute PT APR so here the result is that we get an APR of 35 remember this was before how is that possible the magic of D5 this was you know very close to the launch of apwine so there were still you know many opportunities uh available for Arbitrage there are still many opportunities available um but just keep in mind that this was an older uh date so essentially at this time you could get 35 by just buying PT and this is a fixed rate so you're you're guaranteed you know hacks aside that you're going

to get your your APR so how do we do this we just do compute APR so this is a helper utility method that just you know according to a price and an expiration date you can you can compute how much percentage this is going to give you so for example if you're getting one percent on one month it means you're getting you know 12 per year very simple this is what it does so we are getting a 35 APR this is very very good uh but there's one detail the spot price is never equal to what you're really getting so if you were to buy one million dollars worth of PT you would you would have you know a lot of slippage because the liquidity at this

time was much lower so what we need to do is go through the other strategy which is much more Capital efficient by Capital efficient I mean that you can have much bigger volume for the same exact APR or very similar so the efficiency that we get is good but it can be better with lower resources so lower liquidity we can get a same or better result and this is what we're going to do in this new Step we're going to go through not only buying BT with our if but directly staking on Lido Finance so if state if and then deposit that on AP1 so it's going to go like this if

stake the if and then tokenize into PT and frt so this is the step we're going to do right now let's do it yarn step four and we can take a look at what it does so essentially we're depositing I I made another utility function here very simple to deposit uh eth online to finance so this is going to convert your eth into state eth and then we're gonna deposit on our future Vault here and what you get at the end is if you deposit 10 if online to finance you are getting 9.93 PT and 9.93 fyt why is that why not why don't I get

exactly 10 PT and 10 ft the reason for this is that the future already started you know a few days ago so it already generated yield right so you need to account for this but if you were to withdraw everything you would get your exact 10 state to eat back this is because one fyt in this case already has some value so if you add the value of your PT and the value of your future yield it's going to be exactly 10 steak eth nice now we're ready for the last step we have our PT our fyt and what we want to do is go from fyt to PT so maximize our fixed rate there are also other strategies you can do for example you could do the other

way around you could just um you know swap your PT for fyt which means that um swap your fyt for eth which means that you would get your yield in advance remember fyt is the future real token if you swap it for eth it means essentially that you're selling your future yield for yield today right and this is where it gets super interesting because you can do so many strategies with it so swapping f4t let's do it SDK dot swap in provide the amm entity and then from fyt to BT provide the amount very simple it's going to do the routing automatically from fit to PT and then eth so you don't need to care

about it now let's look at the results yarn step five this is the last step and then we can go with some questions so if we do this it's going to do a lot of computations and simulate everything on the blockchain and final guaranteed API with this strategy is 34 again this was during the time you can try again with a different block number for example today's block number to see what you would get and it could be interesting you know to do so and simulate by your own or you can just try with real money um so this is what we get the difference with this is that this is much more Capital efficient so lower slippage bigger trades up to 10 times uh

depending on the APR and the you know the apy and the pool that you're yet that you've selected um and the composibility because you can swap from any of PT fite so it's very interesting to use the amm in that matter right so we just uh basically with a few lines of code you know just five very simple step if you put it all in one file it's going to be even simpler but you know I've kind of split it to make it easier but all of this to say that in a few lines you can have your fixed rate API with a very simple strategy on AP1 so you know if your project if if you're still looking for ideas we could brainstorm together but if there is you know anything from Arbitrage trading

bots leveraging of yield or you know just um there's even some people there who are working on you know lens like social graphs and they have some Capital uh in the project which means that it uses you know Define some way you could use AP1 to not have the capital sit around and do nothing so you could actually put it to work um so this is just one of the ideas that you could leverage ap14 and creative strategies are going to get rewarded for this hackathon we are uh sponsoring with a few prizes let me show you here all right so we have three prizes for AP

wine first is the wine connoisseur this is the first prize 5K in apwu and the two other ones the runner up prizes are 2.5 k in APW each um so again if you are still brainstorming we would be super happy to help uh some of you have probably already seen our um stand our booth at East Bogota so please you know anytime during the the weekend please feel feel free to come along uh chat with us and we can brainstorm together to make an amazing project um I feel like you know there are so many ideas possible with different projects so it's up to you to really leverage as as many you know kind of prices as you

can uh to get the best out of it all right thank you so much for listening to this Workshop I really appreciate seeing you here um also a note that we are hiring uh front-end developers solidity developers as well so if you're interested you know even at the end of the hackathon uh to talk more with us please reach out we'd be super happy to to chat thank you so much for listening today and good hacking any questions so far we have a few minutes for questions um but again there's going to be time during the weekend to answer any of your yes please yeah good point

yeah so Huawei P1 works is you start with your a die for example like very simple interest-bearing asset interest bearing asset means that it generates yield over time you deposit that on AP1 and the Primitive that we came up with is the future yield tokenization so it splits this interest bearing token into two tokens if you deposit a hundred dollars your PT is going to be worth exactly a hundred dollars not more not less all the time and because this generates yield all the yield over a hundred dollars is gonna go not in the PT but into the fyt so from the time zero to the time you know one month after all the yield is going to go inside of the fyt

exactly um no no please um what I meant to say is you can use compound to generate yield and then go on AP1 to tokenize that yield it's very interesting though that you mentioned borrowing with pts collateral yeah well you could definitely try doing this during the hackathon this is very good first idea definitely something that you know we're looking into but please feel free to try awesome thank you so much for the question any other um question so far yes please yep

yep yeah that's a very good point uh maybe I can show the interface so so basically all right let me if you go on AP1 you're going to see all the features that we support and what you mean is uh here the the lpapy right so PT for example underlying and then ptfyt right correct oh this one the tvl the market APR okay that's a very good

point maybe we can take the few minutes to explain this so the market APR is what you're going to get on AP wine uh if you go into the either the PT strategy so buying PT or into the fyt strategy so selling your future yield so let's look at it at an example uh staked Ave for example if you go on AP1 and you get a fixed rate you're going to get 8.1 percent okay this is this is right now if you sell your future yield and you get it in advance you're going to get 7.82 percent so essentially it's fixed rate on top BT versus fixed rate plus yield in advance so it's lower right because it's had some discount

and then here the lpapy this is going to be the apy that you can get um by providing liquidity on either of those pools so there are two pools on AP1 for for each amm there's you know on uni swap you have two tokens right on balance so you have three tokens and on AP1 we also have three tokens so the PT the underlying and then the fyt so it for example PT die or eth or whatever and fyt there's two pools you can provide to so if you provide to the first one which is PT underlying this is the most stable and like risk-less pool because you you only get exposed to minimal and

permanent loss this is going to give you 0.6 plus 95 in rewards of APW if you provide to the PTA 5T pool which is a little bit more risky but it's also another strategy because you get exposed to the volatility of the yield you get 6.1 percent plus this amount in APW um I hope that answers your question awesome yes that's an Arbitrage opportunity right now it either means that the liquidity is um is low enough that there might be arbitrary opportunities right now to take because like higher volumes can't

you know keep up or it can mean that we're very close to the period being expired so like because there's like only a few days left there's like this Arbitrage opportunity also so if you see anything negative it can also be a hackathon project you know a bot that takes advantage of any Arbitrage opportunities on AP1 so that's a very good point so essentially you just um you would just tokenize and then sell your BT it means the PT is above one so there's Arbitrage to be made yes you need to go on the AP1 amm though

yeah but same same concept as uh as Sushi swap or uni swap or anything you're comfortable you know with already using yeah awesome thanks for the question anyone else all right again I just want to mention uh you know thank you guys so much for coming we have the booth uh all week uh all weekend and uh so please feel free even if you're still brainstorming ideas or if you're building on top of AP1 want to get some feedback and input uh feel free to reach out to us and we would be super happy to help you guys awesome thank you so much happy hacking again