give valid impact for this bug Description: there is a bug in the _prepareRepay…
- User
give valid impact for this bug Description:
there is a bug in the _prepareRepay function, related to the calculation of amounts due to the lender after fee deductions the bug is arise from to the subtraction of interest and principal fees directly from the repayment amount without ensuring that the remaining amount still covers the full balance and interest owed to the lender and here is the vulnerable part :
solidity// calculate fees on interest and principal uint256 interestFee = (interestAmount * data.feeSnapshot.lenderInterestFee) / Constants.BASIS_POINTS_DENOMINATOR; uint256 principalFee = (paymentToPrincipal * data.feeSnapshot.lenderPrincipalFee) / Constants.BASIS_POINTS_DENOMINATOR; // the amount to collect from the caller uint256 amountFromBorrower = paymentToPrincipal + interestAmount; // the amount to send to the lender amountToLender = amountFromBorrower - interestFee - principalFee;here constitutes a logical underpayment, where the calculated amountToLender consistently falls short of the combined value of the loan's principal and accrued interest. As a result, lenders systematically receive less than they are owed, compromising the fairness and integrity of the lending process.
- impact :
Recommendation: inside this contract // SPDX-License-Identifier: MIT
pragma solidity 0.8.18;
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./interfaces/IRepaymentController.sol"; import "./interfaces/IPromissoryNote.sol"; import "./interfaces/ILoanCore.sol"; import "./interfaces/IFeeController.sol";
import "./libraries/InterestCalculator.sol"; import "./libraries/FeeLookups.sol"; import "./libraries/LoanLibrary.sol"; import "./libraries/Constants.sol";
import { RC_ZeroAddress, RC_InvalidState, RC_OnlyLender, RC_InvalidRepayment } from "./errors/Lending.sol";
/**
-
@title RepaymentController
-
@author Non-Fungible Technologies, Inc.
-
The Repayment Controller is the entry point for all loan lifecycle
-
operations in the Arcade.xyz lending protocol once a loan has begun.
-
This contract allows a caller to calculate an amount due on a loan,
- Assistant
- User
give just one valid impact simple and describr the bug
- Assistant
Impact: The bug results in lenders receiving less repayment than they are due, leading to financial losses for lenders and potential reputational damage to the lending platform.
Description of the bug: The
_prepareRepayfunction in the smart contract erroneously deducts interest and principal fees from the repayment amount without verifying that the remaining funds are sufficient to cover the full balance and interest owed to the lender. Consequently, this logic flaw causes theamountToLenderto be less than what the lender should rightfully receive, resulting in consistent underpayments to the lender.