You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it seems the passed in scaledVariableDebt has already multiplied by the reserve.variableBorrowIndex factor in ReserveLogic.sol, why do multiply it by previousVariableBorrowIndex (and newVariableBorrowIndex) again in _mintToTreasury()? the resulting variable debt would be the principal debt supply multiply twice the variableBorrowIndex
//calculate the last principal variable debt
vars.previousVariableDebt = scaledVariableDebt.rayMul(previousVariableBorrowIndex);
//calculate the new total supply after accumulation of the index
vars.currentVariableDebt = scaledVariableDebt.rayMul(newVariableBorrowIndex);
For stable debt, vars.currentStableDebt and vars.previousStableDebt seem to be the same, where IStableDebtToken(reserve.stableDebtTokenAddress).getSupplyData() calculates the current stable debt by multiply the principleSupply and the compoundedInterest, whereas previousStableDebt is calculated using exactly the same formula with the same avgrate and same stableSupplyUpdatedTimestamp, so these two variables should be always the same?
The text was updated successfully, but these errors were encountered:
Have a question about the stable and variable debt calculating logic in the
_mintToTreasury()
function.https://github.com/aave/protocol-v2/blob/release/aave-v2-ethereum/contracts/protocol/libraries/logic/ReserveLogic.sol#L274-L311
it seems the passed in scaledVariableDebt has already multiplied by the reserve.variableBorrowIndex factor in ReserveLogic.sol, why do multiply it by
previousVariableBorrowIndex
(andnewVariableBorrowIndex
) again in_mintToTreasury()
? the resulting variable debt would be the principal debt supply multiply twice thevariableBorrowIndex
For stable debt,
vars.currentStableDebt
andvars.previousStableDebt
seem to be the same, whereIStableDebtToken(reserve.stableDebtTokenAddress).getSupplyData()
calculates the current stable debt by multiply the principleSupply and the compoundedInterest, whereaspreviousStableDebt
is calculated using exactly the same formula with the same avgrate and same stableSupplyUpdatedTimestamp, so these two variables should be always the same?The text was updated successfully, but these errors were encountered: