Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should we use a non-view function for the borrow rate? #150

Closed
MerlinEgalite opened this issue Jul 20, 2023 · 12 comments
Closed

Should we use a non-view function for the borrow rate? #150

MerlinEgalite opened this issue Jul 20, 2023 · 12 comments
Labels

Comments

@MerlinEgalite
Copy link
Contributor

This may not be possible to have a view function to get the borrow rate. Maybe we should consider that it won't be a view function at some point

Originally posted by @MerlinEgalite in #138 (comment)

@Rubilmax
Copy link
Collaborator

Rubilmax commented Jul 20, 2023

It is necessary to have a permissionless view function on the IRM to be able to calculate accrued interests on-chain, without having to update the market on Blue.

So if the borrowRate function cannot be a view, we need to expect the IRM to provide another view function so that integrators (including MetaMorpho vaults) have the ability to calculate accrued interests without updating the market on Blue. Or else, we can just discard the issue we're trying to solve, because it would simply be impossible to calculate interests accrued without updating the market on Blue.

Additional thoughts on this:

If it's not a view, it needs to be only accessible by Blue, otherwise anyone can change the storage of the IRM without updating Blue (just like Morpho optimizers on Compound/Aave).
Or we need to have some additional storage on Blue (just like Morpho optimizers have additional storage to keep up with Compound/Aave independent updates).

I'd like to have @morpho-labs/research's POV on this

@makcandrov
Copy link
Contributor

Could you give an example of an IRM that would need to update storage at each borrowRate call? I can't think of any

@Rubilmax
Copy link
Collaborator

Rubilmax commented Jul 20, 2023

Could you give an example of an IRM that would need to update storage at each borrowRate call? I can't think of any

I believe a canonic example would be a second-order controller IRM, which would require storing the first-order derivative of the rate somewhere (the rate being always stored and accessible on Blue).

@MerlinEgalite
Copy link
Contributor Author

Could you give an example of an IRM that would need to update storage at each borrowRate call? I can't think of any

Maybe one that is depending on something external like the votality of the different assets, the available liquidity onchain, etc. This might be the first IRM that we implement obviously but if it's a view then it's clear that it won't be possible.

@MerlinEgalite
Copy link
Contributor Author

Btw this is possible using solidity so I don't really see the blocker of not removing view.

@Rubilmax
Copy link
Collaborator

Rubilmax commented Jul 20, 2023

Btw this is possible using solidity so I don't really see the blocker of not removing view.

If the function as defined in the interface doesn't have the view modifier, it cannot be called inside the context of a view function. Your example does not indicate otherwise.

@MerlinEgalite
Copy link
Contributor Author

Is it a requirement for borrowRate to be view?

@Rubilmax
Copy link
Collaborator

In the PR this issue originates from yes, in order to expose a getter for accrued interests, which requires querying the borrow rate.

@MerlinEgalite
Copy link
Contributor Author

in order to expose a getter for accrued interests

I recently changed my mind and I'm questioning the relevance of such getter 😅

@MerlinEgalite MerlinEgalite closed this as not planned Won't fix, can't repro, duplicate, stale Aug 3, 2023
@MathisGD MathisGD reopened this Aug 3, 2023
@MerlinEgalite
Copy link
Contributor Author

MerlinEgalite commented Aug 3, 2023

why? Seems that everyone was against

@MathisGD
Copy link
Contributor

MathisGD commented Aug 3, 2023

Sorry, I didn't have time to answer but we need to change something here. I'm focusing on #194 vs #123 for the moment and then I answer.

@MathisGD
Copy link
Contributor

MathisGD commented Aug 9, 2023

We should allow for non-view IRM, and it's current state of the code so I'm closing.

@MathisGD MathisGD closed this as completed Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants