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.
TLDR
In v3, there are a bunch of wallets that have wrong balances in the subgraph compared to the on-chain data.
Example
For example, 0xbc1631afcb916bda28af42955fc970bf004596f8 on Polygon has 0 on-chain balance:
but, querying this user from the subgraph and using aave-utilities formatter, the user has balances.
Same goes for wallets that still have dust balance on chain: 0xee2826453a4fd5afeb7ceffeef3ffa2320081268 on Avalanche : 0.00000018 WETH.e on chain- comparing to 1+ WETH.e using the subgraph.
Root cause - account balance computation updated in v3
It seems like the
Burn
andMint
events were changed in AAVE v3. In v3, The event value reports the amount that should be minted/burned while taking into account the interest which was accumulated (which impact the amount of mint/burned) since the last update.In v2, the events reported the amount which was supplied/withdrawn, and the interest could be calculated using other fields in the subgraph like
liquidityIndex
,liquidityRate
, etc.Scope of Issue
supply
method twice or a combination ofwithdraw
andsupply
.totalSupply
andtotalBorrow
per asset.Impact
Proposed Fix
In order to keep consistency and backward compatibility to the structure of v2 (and to aave-utilities functions), we need to sum up the
Burn.value
andBurn.balanceIncrease
and use this value for all the calculations. The opposite goes for Mint - we need to subtractMint.balanceIncrease
fromMint.value
.