This repository was archived by the owner on Dec 9, 2025. It is now read-only.
Fix underlyingBalance computing #114
Closed
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-jsand more specifically thepool-mathhelper to approximate users reserves balances from data previously fetched from the blockchain.I found the library very useful to compute current
stableBorrowswith thegetCompoundedStableBalancemethod, and currentvariableBorrowswith thegetCompoundedBalancemethod.However I couldn't verify in my tests that the
getCompoundedBalancemethod 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:
calculateLinearInterestof MathUtilsgetNormalizedIncomeof ReserveLogic; to create a new function
currentATokenBalancespecifically 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
eslintconfig to be able to commit because, as you can see here in the CI the commandyarn lintis broken.The issue comes from the fact that
prettier/@typescript-eslintis 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).tsdxdoesn't seem to take into account theextendspart of the.eslintrc.jsonconfig file. I had to migrate the config to thepackage.jsonfile. It works for me now!