protocol-subgraphs icon indicating copy to clipboard operation
protocol-subgraphs copied to clipboard

UserReserve currentATokenBalance/currentXXDebt don't count interest

Open wmwqyvon opened this issue 2 years ago • 2 comments

Describe the bug currentATokenBalance, currentStableDebt, currentVariableDebt and currentTotalDebt return values without counting interest in.

To Reproduce For example, one user borrowed 1,000 USDC and his debt increased to 1,005 later, the currentTotalDebt will return 1,000,000,000 instead of 1,005,000,000.

wmwqyvon avatar Feb 18 '23 20:02 wmwqyvon

Current balances will only update for a specific user on the subgraph when that user performs an action. To compute the current aToken balance you multiply the users scaledATokenBalance by reserve.liquidityIndex. liquidityIndex is a continuously increasing variable which tracks accrued interest for all suppliers, and is updated whenever any user interacts with the reserve

defispartan avatar Mar 01 '23 00:03 defispartan

Much appreciated. Is there any way to calculate the current stable debt balance?

wmwqyvon avatar Mar 01 '23 09:03 wmwqyvon

Yes, this explains the variables used in this calculation

defispartan avatar Aug 04 '24 03:08 defispartan