Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi!
First of all, thank you for the dedication your putting on this project, the new protocol is awesome and well documented, it's a pleasure to work with.
I'm using
aave-js
and more specifically thepool-math
helper to approximate users reserves balances from data previously fetched from the blockchain.I found the library very useful to compute current
stableBorrows
with thegetCompoundedStableBalance
method, and currentvariableBorrows
with thegetCompoundedBalance
method.However I couldn't verify in my tests that the
getCompoundedBalance
method could be used to reliably compute the currentunderlyingBalance
. With this in mind I tried to debug the method and to find a fix.Test case
First of all I added a (failing) test case to try to verify the claim I'm bringing forward. You can checkout to the "add failing test case" commit to run it: cd01845
Fix
After that I basically translated to Javascript the logic found in the protocol:
calculateLinearInterest
of MathUtilsgetNormalizedIncome
of ReserveLogic; to create a new function
currentATokenBalance
specifically to compute theunderlyingBalance
.You can find the new code in the commit "fix compute underlyingBalance": 3e2edb6.
Please give me your opinion on this, I may have overlooked something. Tell me what you think :)
Misc
I had to fix the
eslint
config to be able to commit because, as you can see here in the CI the commandyarn lint
is broken.The issue comes from the fact that
prettier/@typescript-eslint
is still used in the project while it has been deprecated (see here).However, I could not make it work by just modifying the
.eslintrc.json
, I think it is due to this issue: jaredpalmer/tsdx#498 (comment).tsdx
doesn't seem to take into account theextends
part of the.eslintrc.json
config file. I had to migrate the config to thepackage.json
file. It works for me now!