APWine 🛠Your first Future Yield strategy - Ulysse Ramage
ETHGlobal·Fri, Oct 21, 2022, 12:00 AM
Join Ulysse Ramage from APWine for a workshop titled "Your first Future Yield strategy." Thank you to everyone who joined us for ETHBogotá 🇨🇴 and helped us kick off Devcon Week. With over 1400 attendees from 62 different countries, ETHBogotá was our biggest hackathon in Latin America ever! ----------------------------------------- Follow us: https://twitter.com/ETHGlobal​ Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com #ethereum #web3 #blockchain #eth
Transcript
Hello everyone. Thank you for visiting. I'm Jules from APWine, one of the co-founders of APWine Finance. And today I will be presenting this seminar, and basically three different points. What is APWine, how does it work, and how can you integrate it into your own hackathon project to win prizes.
So, let's start with what APWine is and why we created it in the first place. It all started in the summer of 2020 for DeFi, you know, when APYs were just crazy triple digits. And we thought we saw an opportunity here, because there was no way to bet on losses while profitability was growing. So, essentially, reduce your risk. That's why we came up with a new primitive in DeFi called yield tokenization.
And now, the tokenization of returns, you know, is basically the core of APWine Finance. And this is what allows you to get your profits in advance or trade for profits. So, yield tokenization allows you to buy, sell, and hedge risks in DeFi based on your yield. How does it work? It all starts with the fact that if you use certain funds on Aave or Compound or any other yield-generating platform, you have certain assets that earn interest earn interest .
Interest-bearing assets are Interest-bearing assets are , you know, you just hold your tokens. Their value either increases, or simply the yield in your wallet increases. For example, I took A Dai, a fairly common asset that can be held in a wallet. Its value simply increases, and it is an interest-bearing token. If you deposit it on APWine, it will be part of the tokenization of the yield.
We will split it into two tokens. One of them will be the main token. And this represents the value of your deposit at the time of deposit. So, imagine you deposit 100 cubes on APWine, you will receive 100 PT tokens. And these core tokens will always represent 100 on the die, right?
It is always the same cost. And now the interesting thing is that this is a future profitability token, the second token that you get. And this happens all the time, when Cube generates returns, you know, from Ave, it invests that return not in the underlying token, but in a future return token. So, essentially, we are separating capital and future profitability. And that's what allows us to, um, you know, launch this whole future profitability market.
So you can mine, ahem, PT and FYT with your interest tokens interest tokens , and you 'll never be locked into the platform. You can always withdraw funds if you still have PT and FYT. And then we have the APWine AMM, which is the core part of the protocol, and the APY1AMM allows you to, you know, sell that FYT or buy PT, or just trade between any of the three A Die assets, PTFYT, to create your own strategies, get your yield upfront or lock in your rate, and so on. Uh, our APY1AMM is the result of many months of research. Uh, this is APY1AMM V1.
Uh, we have a temporary loss protection mechanism for LP. So, if you want to become a liquidity provider at APY1, that's also very easy to do. And maybe we can talk about it, uh talk about it, uh , after the seminar. But to jump right into the workshop, I'll just mention a few strategies here, and then we'll move on to what we're going to create today. Uh create today.
Uh , some of the strategies you can create with APY1, uh, include PT trading. So, this is the equivalent of a fixed rate. Er fixed rate. Er , essentially buying PT at a discount. Imagine that you buy PT for 0.
9, that is, for 90% of its real value. This means that if you wait until the end of the period, for example, 3 months, which we work with, you will get 10% profit, because you know for sure that you are buying something that will cost more in the future. And this is how you set your bet. Now, without getting into too much strategy, here's what we're going to do today. Today's seminar is about going back to the future to set your rate, er, based on your profitability.
So, we will use part of the APWine yield tokenization plus APWine AMM to build a strategy build a strategy . So, some prerequisites, and you know, if you have a computer if you have a computer , that's great. If you do n't have one, you can just follow the instructions, but it's also very easy to do using the GitHub repository. So GitHub repository. So , you need Yarn, Node.
js, and we'll start now by setting up the repository. Okay, here it is. Okay, everything's fine. I'll just leave like this. Okay, this will be a one-handed workshop that will be interesting.
Um, let's move on to setting up the repository. Um, I'll just take it a little higher and we'll get clone. And if we clone this repository and go to it, let's open it up in code to see it better, and you can see everything it contains. The first step you will need to take is to copy the uh to um environment file from the example file to your local environment file. So, .
env.example in .env. I have set up an API key for you to try. Um, please don't use it for anything else.
This won't work. Okay won't work. Okay . And then we just want to install all the dependencies. So, you just need to use Yarn.
This will install all the packages, just like npm. And while we're at it, let's consider how we're going to proceed. So, the first step we'll take is Yarn Start Node. This will trigger a fork of the node on the main network. So, essentially, we will be simulating our strategy without actually using any money, which is very helpful.
Because if your strategy isn't working, you'll probably just want to simulate it sooner. So, if we make a Yarn Start Node, it will make a local fork of the blockchain. And then we want to open a new tab. And every time we want to continue a step, you can just do the first Yarn step, the second Yarn step, all the way to the fifth. So, just as an example, let's take the first step of Yarn.
And then we can look into the code to see what it does. So here we see that it initializes the SDK, and that's the first step we're going to look at. So, the first step is to create an SDK, very simple, just one line. This will be a JavaScript workshop, not a Solidity workshop, but if you are interested in integrating our contracts into Solidity, we can talk about it . This is also very easy to do.
First step, the SDK is equivalent to the new APWine SDK. You want to host your ISP, your signer, everything you need, a network that will be the main network. And that's it. A new world opens up to you , a world of future profitability. So, this is the first step that we just took.
The SDK is now initialized and ready to go. Second step. So just to explain how this would work. First, we will look at how we can implement a very basic PT trading strategy. So, we buy PT cheaply and wait until the end to see end to see how many annuities we get.
And the second step, the second step, which is the real workshop that we're going to do, is look at future profitability. So, essentially, tokenizing into PTFYT and then exchanging our future returns for fixed rates. And we will see that it is much more efficient from a capital perspective from a capital perspective . So, wait. This is the first step.
How do we get all the support for the futures API, all the assets we support, all the platforms, etc.? Hmm, what we can do is this . Futures are equivalent to SDK.fetch all future aggregates. Very simple, you get all the information you need.
Let's try. And while we're taking this step, meaning this will actually work on the mainnet, we can look at what it's doing, uh, here. So if we go to the scripts and then in step two we get all the futures, we can see exactly what it's doing. So, here we get the future aggregate from the address. And we just bet on any future storage address we want.
And if we come back here, we can see here the results of all the assets that we support at this point in the fork. This was a fork a few months ago. We currently support many assets across two chains and many different platforms. But here we have, for example, the one we will consider. We staking ETH from Lido Finance.
Has anyone ever used staked ETH? Yes. So you can generate an annual percentage rate (APR) of 5%-6%, depending on what you get, right? And this is a period that ends, to be exact, on March 23, 2022 . So, it's, you know, an older fork, but the principle remains the same .
You can try with a new block number and it will work just as well . Hmm. And the next step we want to do is calculate the annual interest rate we would receive if we bought PT for this particular ETH futures stake. So, how do we do this? This time we will use AMM because we need a special price, right?
If you want to buy or sell something, you will have to go through APY and AMM. So, the price is equal to SDK.fetchSpotPrice. You go through the storage, so this will be our ETH pinned storage, and then from and to. These are two different lines.
So you can put the underlying asset, PT, or if I make it very simple. And that's what we're going to do now and see the results. So, step three. And we can look at what this does here, calculate the PT APR. So, the result here is that we get an APR of 35%.
Remember, this was before Remember, this was before ... How is this possible? The magic of DeFi. It was, you know, very close to the launch of APWine. So there was still, you know, a lot of room for arbitration.
There are still plenty of possibilities, but just keep in mind that this was an old, er, date. So, essentially, at this time you could have gotten 35% just by buying PT. And this is a fixed rate. So, you are guaranteed to get your annual percentage rate, leaving life hacks aside. So, how do we do this?
We simply calculate the annual interest rate. This is an auxiliary method that, depending on the price and expiration date, allows you to calculate how much interest it will give you. For example, if you earn 1% for 1 month, that means you earn 12% per year. Very simple. Here's what it does.
We get 35% per annum. This is very good. But there is one detail. The spot price is never equal to what you actually get. So, if you bought $ 1 million worth of PT , you would have a lot of slippage because liquidity was much lower at the time .
So . So , we need to use a different strategy that is much more capital efficient. By capital efficiency, I mean that you can have much more volume for the same annual interest rate. Or very similar. So, the efficiency we get is good, but it could be better.
With fewer resources, i.e. lower liquidity, we can get the same or better result. And that's what we're going to do in this new step. We are going to not only buy BT with our ETH, but also directly stake it on Lido Finance, i.
e. ETH, pledge the ETH, and then deposit that on APWine. So it would be like this: ETH, pledge ETH, and then tokenize into PT and FYT. So, this is a step we're going to take right now. Let's do this.
Step four (yarn). And we can see what it does. So, basically, we deposit...I created another useful function here, very simple, to deposit, uh simple, to deposit, uh , ETH on Lido Finance. So, this converts your ETH into pledged ETH.
Uh, and then we're going to put this on our future storage. And what will you get as a result, if you deposit 10 ETH on Lido Finance deposit 10 ETH on Lido Finance , you will receive 9.93 PT and 9.93 FYT. Why is that?
Why not? Why don't I get exactly 10 PT and 10 fYT? The reason for this is that the future already began a few days ago. So, it has already generated income, right? So you need to take that into account.
But, if you withdrew everything, you would get back exactly 10 ETH that were for staking. 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 income, it will be exactly 10 ETH that were for staking. Perfectly. Now we are ready for the final step.
We have our PT, our fYT, and we want to go from fYT to PT, i.e. maximize our fixed rate. There are also other strategies you can use. For example, you can do the opposite.
You can just, um, you know, exchange your PT for fYT, which means, um, exchange your fYT for ETH, which means you get your yield upfront. Remember, FYT is a future yield token. If you exchange it for ETH, it essentially means you are selling your future returns for today's returns, right? And this is where it gets extremely interesting, because you can implement so many strategies with it. So, FYT exchange, let's do it.
SDK.swap in. Provide the AMM entity and then from FYT to PT, provide the amount. Very simple. It will automatically route from FYT to PT and then to ETH.
So you don't need to worry about that. Now let's look at the result. Step five yarn. This is the last step, and then we can move on to some questions. So if we do this, it will do a lot of calculations and simulate everything on the blockchain.
And the final guaranteed annual interest rate for this strategy is 34%. Again , that was at the time. Uh, you can try again with a different block number, like today's block number, to see what you get. And it would be interesting, you know, to do it and model it yourself. Or you can just try it with real money.
So, here's what we get. The difference is that it is much more capital efficient . So, less slippage, bigger deals, uh, up to 10x, uh, depending on the API and, you know, the annual percentage yield (APY) and the pool that you've chosen. Uh, and composability, because you can exchange exchange any PT for ETH. So it is very interesting to use AMM in this matter.
Right. So we're just, uh, basically, with a few lines of code, you know, just five very simple steps. If you put it all in one file, it would be even easier, but, you know, I kind of split it up to make it simpler. But all of this is to say that in a few lines you can have your API with a fixed rate and a very simple strategy on APY. So, you know, if your project, if you're still looking for ideas, we could brainstorm together.
But, if there's something from arbitrage, trading bots, leveraging profitability, or, you know, just, there's even some people working on, um, you know, like lenses, social graphs, and they have some equity, um, in the project, which means it's , you know, leveraging DeFi in some way. You could use APY to keep capital from sitting around doing nothing. So you could actually put this into practice. Hmm, this is just one of the ideas you can use APY for, and creative strategies will be rewarded at this hackathon. We are sponsoring several prizes.
Let me show you here me show you here . Good. So, we have three prizes for APY. The first is a wine connoisseur. Uh, this is the first prize, 5 thousand prizes in APW, and the other two, the second place prizes second place prizes , are 2.
5 thousand prizes in APW each. So, again , if you're still considering the situation, we'd be more than happy to help. Some of you have probably already seen our, um, booth, our booth at ETHBogota. So please, anytime over the weekend, please come and chat with us and we can brainstorm together to create an amazing project. I feel like there are so many ideas for different projects, so it's up to you how you can use as many prizes as possible to get the most out of it.
Okay, thank you very much for listening to this seminar. Very grateful to see you here. I also want to mention that we are hiring, um, frontend developers frontend developers , Solidity developers. So if you're interested, you know, even after the hackathon is over, to talk to us more, please contact us. We would be very happy to chat.
Thank you very much for listening today, and happy hacking. Are there any questions? We have a few minutes for questions, but again , uh, there will be time over the weekend to answer any of your...Yes, please. Yes, good comments.
Yes, apy1 works like this: you start with your A Dai, for example, a very simple interest-bearing asset. An interest-bearing asset means that it generates income over time. You enter it on apy1. And the primitive that it on apy1. And the primitive that we came up with we came up with is the tokenization of future returns.
So, he splits this interest-bearing token into two tokens. If you deposit $100, your PT will be exactly $100, no more, no less, all the time. And since this generates revenue, all revenue over $100 will go not to PT, but to FYT. So, from point zero to point, you know, 1 month later, all revenue will go inside FYT. That's right.
Um, no, no, please. Um, what I meant to say is that you can use Compound use Compound , uh, to generate returns and then switch to APY. To tokenize this yield. It's very interesting that you mentioned a loan with PT as collateral. Yeah, well, you can definitely try doing that during a hackathon.
This is a very good first idea. Definitely something that, you know, we're considering, but please try it please try it . Perfectly. Thank you very much for your question. Are there any more questions?
Yes, please. Yes. Yes. Yes, that's a very good point. Um, maybe I can show the interface.
Um, so, so, basically, okay, let me, if you go to APY, you'll see all the futures see all the futures that we support. And what do you mean And what do you mean , uh, that's LP APY, right? So PT, for example, is the underlying asset and then PTFYT, right? Right? Oh, this one?
TVL? Market APR. Okay, that's a very good point. Maybe we can take a few minutes to explain this. So, the market annual percentage rate (APR) is what you will get on APWine if you switch to a PT strategy, i.
e. buy PT, or to a FYT strategy, i.e. sell your future yield. So, let's look at this with an example.
For example, if you register AAVE with a fixed rate on APWine, you will receive 8.1%. OK? This is now. If you sell your future yield and receive it upfront, you will receive 7.
82%. So, essentially, it's a fixed rate on top, PT, versus a fixed rate plus yield up front. So it's lower, right? Because it has a certain discount. And then here's the LP APY–that would be the APY that you can get by providing liquidity to any of these pools.
So, there are two pools of APY 1 for each AMM. You know, you have two tokens on Uniswap, right? Uh, on Balancer you have three tokens, and on APY 1 we also have three tokens. So, PT, underlying asset, and then FYT. For example, it's PT, DAI, or ETH, or whatever, and FYT.
There are two pools where you can contribute funds. So, if you provide funds to the first pool, which is the underlying asset of the PT, it is the most stable and risk-free pool, as you are only exposed to minimal temporary losses. Er temporary losses. Er , that will give you 0.6% , that will give you 0.
6% plus 95% of the ABW reward. If you provide funds to the PT FYT pool, which is a bit riskier but is also another strategy because you are exposed to the volatility of returns, you get 6.1% plus that amount in APW. Uh, I hope this answers your question. Perfectly.
Yes, this is an arbitrage opportunity now. This either means that liquidity is, ahem, low enough that there could be opportunities for arbitrage right now because, for example, larger volumes can't, you know, keep up. Or it could mean that we are very close to the end of the period. So, with only a few days left, there is also this opportunity for arbitration. So if you see something negative, it could also be a hackathon project.
You know, a bot that exploits any opportunity to arbitrage on APWine. So that's a very good remark. So essentially you just, um, tokenize and then sell your PT. This means that PT is above unity. So, arbitration is needed.
Yes, you need to switch to APY1 AMM. Yes. But it's the same concept as SushiSwap or Uniswap, or whatever you're already sure of. Yes. Perfectly.
Thank you for your question. Anyone else? Good. Again , um, I just want to mention, um, you know, thank you guys so much for coming. Our stand is open all week, all weekend.
So please don't hesitate, even if you are still brainstorming ideas, or if you are building on top of APY1, would like feedback and suggestions, don't hesitate to reach out to us and we will be more than happy to help you. Perfectly. Thank you very much. Happy hacking again.
Automatic transcript — names and jargon may be misspelled.