osmosis-labs / isotonic

Smart Contracts for the Lendex Protocol
MIT License
1 stars 0 forks source link

isotonic-market: APY query #123

Closed hashedone closed 2 years ago

hashedone commented 2 years ago

Closes #117

Simple change, more time was spend on understanding underlying math (in particular: rate calculation).

I really took a shoot to commonize it with calculate_intrest, but actually the only line which is not just call to some utility function and is reasonably complex slightly differs, and handling it would be probably strange. Also commonizing it would probably hide intermediate utilisation calculation, so it would be redone for the later lender apy calculation, which is not complicated but kind of waste.

At the end I didn't add the period to be calculated, mostly because the actual default period is not 356 days, but some not even number of seconds (which makes sense to avoid handling any odd years or so), and I don't like that default case cannot be expressed by some fixed value, so I decided to drop it (it is actually easy to add, but I feel like not exactly proper for this). If it would be needed it is possible to add query like "simulate_yield" with more configuration options.

It is ready for the review now, I am double checking math on tests (and will check it probably again at morning - more to better understand it than to verify).

hashedone commented 2 years ago

Doesn't matter, it is just to make test working ;) I can easly verify if this one is correct, only problem in verification is to figure out a rate to put in them.