Boost _ Folks Finance 33817 - [Smart Contract - High] Incorrect calculation of effective borrow valu
Description
Brief/Intro
Vulnerability Details
function getLoanLiquidity(
LoanManagerState.UserLoan storage loan,
mapping(uint8 => IHubPool) storage pools,
mapping(uint8 => LoanManagerState.LoanPool) storage loanPools,
IOracleManager oracleManager
) internal view returns (DataTypes.LoanLiquidityParams memory loanLiquidity) {
// declare common variables
uint256 effectiveValue;
uint256 balance;
uint8 poolId;
uint256 poolsLength;
DataTypes.PriceFeed memory priceFeed;
// calc effective collateral value
poolsLength = loan.colPools.length;
for (uint8 i = 0; i < poolsLength; i++) {
poolId = loan.colPools[i];
balance = loan.collaterals[poolId].balance.toUnderlingAmount(
pools[poolId].getUpdatedDepositInterestIndex()
);
priceFeed = oracleManager.processPriceFeed(poolId);
effectiveValue += MathUtils.calcCollateralAssetLoanValue(
balance,
priceFeed.price,
priceFeed.decimals,
loanPools[poolId].collateralFactor
);
}
loanLiquidity.effectiveCollateralValue = effectiveValue;
// calc effective borrow value
effectiveValue = 0;
poolsLength = loan.borPools.length;
for (uint8 i = 0; i < poolsLength; i++) {
poolId = loan.borPools[i];
LoanManagerState.UserLoanBorrow memory loanBorrow = loan.borrows[poolId];
balance = loanBorrow.lastStableUpdateTimestamp > 0
? calcStableBorrowBalance(
loanBorrow.balance,
loanBorrow.lastInterestIndex,
loanBorrow.stableInterestRate,
block.timestamp - loanBorrow.lastStableUpdateTimestamp
)
: calcVariableBorrowBalance(
loanBorrow.balance,
loanBorrow.lastInterestIndex,
pools[poolId].getUpdatedVariableBorrowInterestIndex()
);
priceFeed = oracleManager.processPriceFeed(poolId);
effectiveValue += MathUtils.calcBorrowAssetLoanValue(
balance,
priceFeed.price,
priceFeed.decimals,
loanPools[poolId].borrowFactor
);
}
loanLiquidity.effectiveBorrowValue = effectiveValue;
}Impact Details
References
Proof of concept
Proof of Concept
PreviousBoost _ Folks Finance 33816 - [Smart Contract - Critical] Attacker can get unlimited loan for some mNextBoost _ Folks Finance 33852 - [Smart Contract - Insight] Small positions will not get liquidated
Last updated
Was this helpful?