Boost _ Folks Finance 33807 - [Smart Contract - Low] updateInterestRate uses incorrect reference of
Description
Summary
Description
File: /contracts/hub/logic/HubPoolLogic.sol
function updateInterestRates(HubPoolState.PoolData storage poolData) internal {
HubPoolState.PoolAmountDataCache memory poolAmountDataCache = getPoolAmountDataCache(poolData);
uint256 totalDebt = poolAmountDataCache.variableBorrowTotalAmount + poolAmountDataCache.stableBorrowTotalAmount;
uint256 utilisationRatio = MathUtils.calcUtilisationRatio(totalDebt, poolData.depositData.totalAmount);
uint32 vr1 = poolData.variableBorrowData.vr1;
// calculate new interest rates
uint256 variableBorrowInterestRate = MathUtils.calcVariableBorrowInterestRate(
poolData.variableBorrowData.vr0,
vr1,
poolData.variableBorrowData.vr2,
utilisationRatio,
poolData.depositData.optimalUtilisationRatio
);
uint256 stableBorrowInterestRate = MathUtils.calcStableBorrowInterestRate(
vr1,
poolData.stableBorrowData.sr0,
poolData.stableBorrowData.sr1,
poolData.stableBorrowData.sr2,
poolData.stableBorrowData.sr3,
utilisationRatio,
poolData.depositData.optimalUtilisationRatio,
MathUtils.calcStableDebtToTotalDebtRatio(poolAmountDataCache.stableBorrowTotalAmount, totalDebt),
poolData.stableBorrowData.optimalStableToTotalDebtRatio
);
uint256 depositInterestRate = MathUtils.calcDepositInterestRate(
utilisationRatio,
MathUtils.calcOverallBorrowInterestRate(
poolAmountDataCache.variableBorrowTotalAmount,
poolAmountDataCache.stableBorrowTotalAmount,
-->@ poolData.variableBorrowData.interestRate, @<-- use an old one
-->@ poolData.stableBorrowData.averageInterestRate @<-- use an old one
),
poolData.feeData.retentionRate
);
// update interest rates
poolData.variableBorrowData.interestRate = variableBorrowInterestRate;
poolData.stableBorrowData.interestRate = stableBorrowInterestRate;
poolData.depositData.interestRate = depositInterestRate;
emit InterestRatesUpdated(variableBorrowInterestRate, stableBorrowInterestRate, depositInterestRate);
File: /contracts/hub/libraries/MathUtils.sol
function calcOverallBorrowInterestRate(
uint256 totalVarDebt,
uint256 totalStblDebt,
uint256 variableBorrowInterestRateAtT,
uint256 avgStableBorrowInterestRateAtT
) internal pure returns (uint256) {
uint256 totalDebt = totalVarDebt + totalStblDebt;
return
totalDebt > 0
? (totalVarDebt.mulDiv(variableBorrowInterestRateAtT, ONE_18_DP) +
totalStblDebt.mulDiv(avgStableBorrowInterestRateAtT, ONE_18_DP)).mulDiv(ONE_18_DP, totalDebt)
: 0;
}
function calcDepositInterestRate(
uint256 utilisationRatioAtT,
uint256 overallBorrowInterestRateAtT,
uint32 retentionRate
) internal pure returns (uint256) {
return
utilisationRatioAtT.mulDiv(overallBorrowInterestRateAtT, ONE_18_DP).mulDiv(
ONE_6_DP - retentionRate,
ONE_6_DP
);
}Pool's state
Pool's state
Impact
Proof of concept
Proof-of-Concept
PreviousBoost _ Folks Finance 33787 - [Smart Contract - Low] Function PythNodeprocess doesnt handle correctlNextBoost _ Folks Finance 33816 - [Smart Contract - Critical] Attacker can get unlimited loan for some m
Last updated
Was this helpful?