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

Balance getter discussion #3

Closed
MathisGD opened this issue Jun 27, 2023 · 14 comments
Closed

Balance getter discussion #3

MathisGD opened this issue Jun 27, 2023 · 14 comments
Assignees
Labels

Comments

@MathisGD
Copy link
Contributor

  • should the contract has a public getter for underlying balance ? or a simple library that is not used in the contract ?
  • should the accrue interests function be public ?

References:

@julien-devatom
Copy link
Contributor

If you are using this getter internally, so.

I'm against creating external getters only for external usage.

@QGarchery
Copy link
Contributor

I'm against creating external getters only for external usage.

Last time we talked you liked that idea, no ? The idea would be to avoid having to rewrite the logic in javascript

@Rubilmax
Copy link
Collaborator

Rubilmax commented Jul 12, 2023

I believe we're leaning towards minimalism in Blue, so I'd instead suggest to only expose the contract's accounting variables (shares, totalShares, totalAssets) and expose a getter to know how many interests have to be accrued to storage at next accrual.
These getters should be enough to calculate anything related to a Blue market so we shouldn't have to add any other getter.

In fact, even the accruedInterests getter isn't required: one could mimic the logic. But this intermediary function would be used by the contract itself, so I'm just suggesting extracting it and making it public.

I am also ok to expose the accrueInterests function, but I don't think it's necessary. We could also make accrueInterests public and return the accruedInterests, so it can be staticcall and enables everything at once:

  • query interests to accrue (STATICCALL)
  • accrue interests (CALL)

@MerlinEgalite
Copy link
Contributor

Is there a problem of exposing the accrueInterests function to public? It's ok in my mind but we must be sure

@julien-devatom
Copy link
Contributor

Is there a problem of exposing the accrueInterests function to public? It's ok in my mind but we must be sure

accrueInterests is not a view, so this vision is like compound v2: You cannot query the up-to-date balance without making a call.
I'm more in favor to split the interest accruing logic & the storage as @Rubilmax suggested

@Rubilmax
Copy link
Collaborator

Rubilmax commented Jul 13, 2023

accrueInterests is not a view, so this vision is like compound v2: You cannot query the up-to-date balance without making a call.

I want to emphasize this, because it would be minimalist (and may thus please @MathisGD):

We could also make accrueInterests public and return the accruedInterests, so it can be staticcall and enables everything at once:

  • query interests to accrue (STATICCALL)
  • accrue interests (CALL)

@MathisGD
Copy link
Contributor Author

MathisGD commented Jul 14, 2023

In fact, even the accruedInterests getter isn't required: one could mimic the logic. But this intermediary function would be used by the contract itself, so I'm just suggesting extracting it and making it public.

At a first sight, I don't see any issue with putting it public (effect really similar to supplying and withdrawing 1 wei of collat).

We could also make accrueInterests public and return the accruedInterests, so it can be staticcall and enables everything at once:
query interests to accrue (STATICCALL)
accrue interests (CALL)

Interesting idea !

@Rubilmax
Copy link
Collaborator

Rubilmax commented Jul 17, 2023

So this discussion is now only about whether to expose getters, and which one of them. I'll highlight some comment I made above:

I believe we're leaning towards minimalism in Blue, so I'd instead suggest to only expose the contract's accounting variables (shares, totalShares, totalAssets) [...].
These getters should be enough to calculate anything related to a Blue market so we shouldn't have to add any other getter.

So a getter for the amount of collateral, a getter for the supply shares and a getter for the borrow shares is enough to me. It is also necessary to isolate accounting to logic to appropriate libraries, so integrators only have to copy-paste/import isolated logic.

@Rubilmax
Copy link
Collaborator

Rubilmax commented Aug 3, 2023

Should we close this?

@Jean-Grimal
Copy link
Contributor

Should we close this?

What is the final decision about getters ?

@Rubilmax
Copy link
Collaborator

Rubilmax commented Aug 3, 2023

What is the final decision about getters ?

The current code expose storage getters and should be enough, provided #129 is resolved or anything similar. I'd argue this issue is thus redundant now

Balancer getters seem to be overkill as an integrator is in most usecases better off querying the shares, total supply (resp. borrow), total shares and calculate it themselves ; which also enables them to calculate the balance based on hypothetical market changes

@Jean-Grimal
Copy link
Contributor

The current code expose storage getters and should be enough, provided #129 is resolved or anything similar. I'd argue this issue is thus redundant now

Ok so we won't expose getters for underlying balances and assume that integrators will compute it themselves via the shares storage getters and the shareMath lib ?

@MerlinEgalite
Copy link
Contributor

Yes I think we can provide libraries or code snippets for that

@Rubilmax
Copy link
Collaborator

Rubilmax commented Aug 3, 2023

And we already do, via SharesMath!
But we're missing a way to calculate interests to be accrued. #129 is about this, and attached PRs are:

@Rubilmax Rubilmax closed this as not planned Won't fix, can't repro, duplicate, stale Aug 3, 2023
@MathisGD MathisGD reopened this Aug 13, 2023
@MerlinEgalite MerlinEgalite self-assigned this Aug 15, 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

6 participants