Boost _ Folks Finance 33596 - [Smart Contract - Low] Incorrect rounding direction in HubPoolLogicupd
Description
Description
File: /contracts/hub/logic/HubPoolLogic.sol
function updateWithRepayWithCollateral(
HubPoolState.PoolData storage pool,
uint256 principalPaid,
uint256 interestPaid,
uint256 loanStableRate
) external returns (DataTypes.RepayWithCollateralPoolParams memory repayWithCollateralPoolParams) {
if (loanStableRate > 0) {
pool.stableBorrowData.averageInterestRate = MathUtils.calcDecreasingAverageStableBorrowInterestRate(
principalPaid,
loanStableRate,
pool.stableBorrowData.totalAmount,
pool.stableBorrowData.averageInterestRate
);
pool.stableBorrowData.totalAmount -= principalPaid;
} else pool.variableBorrowData.totalAmount -= principalPaid;
pool.depositData.totalAmount -= principalPaid - interestPaid;
repayWithCollateralPoolParams.fAmount = (principalPaid + interestPaid).toFAmount(
pool.depositData.interestIndex
);
pool.updateInterestRates();
}
File: /contracts/hub/libraries/MathUtils.sol
function toFAmount(uint256 underlyingAmount, uint256 depositInterestIndexAtT) internal pure returns (uint256) {
return underlyingAmount.mulDiv(ONE_18_DP, depositInterestIndexAtT);
}
File: /contracts/hub/logic/LoanManagerLogic.sol
function executeRepayWithCollateral(
...
... snipped
...
// update the pool
DataTypes.RepayWithCollateralPoolParams memory repayWithCollateralPoolParams = pool
.updatePoolWithRepayWithCollateral(principalPaid, interestPaid, loanStableRate);
// decrease the user loan collateral and global collateral used for loan type
userLoan.decreaseCollateral(params.poolId, repayWithCollateralPoolParams.fAmount);
loanPool.decreaseCollateral(repayWithCollateralPoolParams.fAmount);
...
... snipped
...Impact
Proof of concept
Proof-of-Concept
PreviousBoost _ Folks Finance 33589 - [Smart Contract - Medium] Anyone can call the BridgeRouter Recieve funNextBoost _ Folks Finance 33609 - [Smart Contract - Medium] Account creation can be frontrun making the
Last updated
Was this helpful?