yearn / yearn-api-archived

Collection of serverless API
23 stars 24 forks source link

fix: extrapolate vault annual ROI correctly #74

Closed southseacompany closed 3 years ago

southseacompany commented 3 years ago

The flaw in the original calculation is explained in detail in a blog post.

ghost commented 3 years ago

f = investment plus return g = ppfs x = blockheight f(g(x)) = shares * g(x); the only portion here that affects your return is g(x), and only g(x), you should calculatef'(g(x)) instead of doing some exponentials \ though i guess if my doc (which btw i didn't invent but andre) couldn't explain that, it's a lost cause

southseacompany commented 3 years ago

you should calculatef'(g(x)) instead of doing some exponentials \

That is indeed how it would work if f were a linear function.

ghost commented 3 years ago

you should calculatef'(g(x)) instead of doing some exponentials \

That is indeed how it would work if f were a linear function.

actually no, since f is in function of g(x) - g(x) could be quadratic, square whatever, the concept is still valid, if you know the derivative of g(x), you know the rate by which f will increase and thus can extrapolate the returns. the issue is not whether f is linear, but whether g is linear in function of blocks.

and the thing is there's no indication as to how ppfs and blockheight are related since that's totally variable, and depends solely on the strategies returns which are influenced by a ton of factors, so given that this is unknown you can't do much more than assume a linear relationship for small periods (which kind of holds true actually, as i think i mentioned) and just forget trying to give a valid estimate for a longer period than say a month, since that's pretty much impossible

yanncks commented 3 years ago

@thegismar bro this is gonna make vault APY numbas bigger. just trust.

say returns per time period (call it a day) is .1%. with linear extrapolation, you get 36.5% APY. but, in fact the returns compound, so using this new formula, it's actually 100*((1+.1)^365-1) = 44% APY.

win win win

ghost commented 3 years ago

@thegismar bro this is gonna make vault APY numbas bigger. just trust.

say returns per time period (call it a day) is .1%. with linear extrapolation, you get 36.5% APY. but, in fact the returns compound, so using this new formula, it's actually 100*((1+.1)^365-1) = 44% APY.

win win win

can't argue against that.

DarkGhost7 commented 3 years ago

@thegismar bro this is gonna make vault APY numbas bigger. just trust.

say returns per time period (call it a day) is .1%. with linear extrapolation, you get 36.5% APY. but, in fact the returns compound, so using this new formula, it's actually 100*((1+.1)^365-1) = 44% APY.

win win win

We don't want bigger fake apys. We want accurate ones. And no the vaults don't compound continuously they compound during harvests discreetly. Yearn is one of the few in the space that doesn't inflate their apy's with garbage like the other protocols do. I hope this doesn't change.

southseacompany commented 3 years ago

Actually the error is not systematically in one direction, so the change would not only increase yield numbers. For example, if one year growth (looking back) was 120% and you computed the "monthly growth" number based on the previous year, the old formula would give you 10% instead of the actual monthly growth of 6.8%. Basically, when the estimation period is longer than the sampling period, yields are currently understated. When the estimation period is shorter, they are overstated.

yanncks commented 3 years ago

@thegismar bro this is gonna make vault APY numbas bigger. just trust. say returns per time period (call it a day) is .1%. with linear extrapolation, you get 36.5% APY. but, in fact the returns compound, so using this new formula, it's actually 100*((1+.1)^365-1) = 44% APY. win win win

We don't want bigger fake apys. We want accurate ones. And no the vaults don't compound continuously they compound during harvests discreetly. Yearn is one of the few in the space that doesn't inflate their apy's with garbage like the other protocols do. I hope this doesn't change.

nobody said anything about continuous compounding. do you even know what you're talking about?

read the blog post. your rates are currently clearly wrong with an easy disproving example. for a site that's supposed to deal with finance, this is embarrassing. the numbers aren't even right ex-post. best is to just calculate irr though.

ghost commented 3 years ago

@thegismar bro this is gonna make vault APY numbas bigger. just trust. say returns per time period (call it a day) is .1%. with linear extrapolation, you get 36.5% APY. but, in fact the returns compound, so using this new formula, it's actually 100*((1+.1)^365-1) = 44% APY. win win win

We don't want bigger fake apys. We want accurate ones. And no the vaults don't compound continuously they compound during harvests discreetly. Yearn is one of the few in the space that doesn't inflate their apy's with garbage like the other protocols do. I hope this doesn't change.

nobody said anything about continuous compounding. do you even know what you're talking about?

read the blog post. your rates are currently clearly wrong with an easy disproving example. for a site that's supposed to deal with finance, this is embarrassing. the numbers aren't even right ex-post. best is to just calculate irr though.

ehh. this is rather pathetic tbh. you yourself said that 'in fact the returns compound'. nothing could be further from the truth, your future returns do not care at all about your current returns.

let me state that again because it seems people do not get how the vaults work.

your future returns aren't a function of your current returns.

your current returns increase balance and thus ppfs since ppfs=balance/totalsupply . next cycle the strategy takes your added returns and would ideally be able to generate more profits than the last one (bc it has more funds, see that would be compounding)

that's totally hypothetical though, since it could be that the strategy this cycle is only half as effective as in the previous one, because of one of the myriad of external factors, so if balance increased by 5% last cycle, it can easily increase by less this one or more, or even decrement (shouldn't happen, ever, but does) - in which case you now look at negative returns for this cycle.

and again this is just balance we're talking about, your returns are affected by balance according to

shares * balance/totalSupply

really please read the yearn provided documentation.

yanncks commented 3 years ago

first, I really hope you and others on the project understand the difference between continuous compounding and discrete compounding (that was brought up earlier). hopefully you're not confused by the difference.

second, nobody is confused about how returns accrue to vaults, so you don't need to explain that. it doesn't matter how/when it accrues since this is an accounting issue, not a modeling issue.

nobody knows for sure what the yield curve will be going forward. that's also not the point of the argument. the problem is you're trying to figure out a rate from one observation and the correct formulation of the rate for that is what @southseacompany proposes. if you use the previous formulation, the rate accruing daily will not intersect with your observation point. just read his blog post. maybe an alternative dumbed down way to view it is when you talk about APY and you essentially have one observation, you want the rate to be compared to a savings account that got the same returns by that time.

ghost commented 3 years ago

first, I really hope you and others on the project understand the difference between continuous compounding and discrete compounding (that was brought up earlier). hopefully you're not confused by the difference.

second, nobody is confused about how returns accrue to vaults, so you don't need to explain that. it doesn't matter how/when it accrues since this is an accounting issue, not a modeling issue.

nobody knows for sure what the yield curve will be going forward. that's also not the point of the argument. the problem is you're trying to figure out a rate from one observation and the correct formulation of the rate for that is what @southseacompany proposes. if you use the previous formulation, the rate accruing daily will not intersect with your observation point. just read his blog post. maybe an alternative dumbed down way to view it is when you talk about APY and you essentially have one observation, you want the rate to be compared to a savings account that got the same returns by that time.

you're right, i'm tired of trying to teach basic algebra here