Dandy Caramel Tortoise
Medium
Taking min when calculating EMI repayment amount is flawed
The amount due in case of EMI repayment is calculated as: https://github.com/sherlock-audit/2024-11-teller-finance-update/blob/0c8535728f97d37a4052d2a25909d28db886a422/teller-protocol-v2-audit-2024/packages/contracts/contracts/libraries/V2Calculations.sol#L124-L138
} else {
// Default to PaymentType.EMI
// Max payable amount in a cycle
// NOTE: the last cycle could have less than the calculated payment amount
//the amount owed for the cycle should never exceed the current payment cycle amount so we use min here
uint256 owedAmountForCycle = Math.min( ((_bid.terms.paymentCycleAmount * owedTime) ) /
_paymentCycleDuration , _bid.terms.paymentCycleAmount+interest_ ) ;
uint256 owedAmount = isLastPaymentCycle
? owedPrincipal_ + interest_
: owedAmountForCycle ;
duePrincipal_ = Math.min(owedAmount - interest_, owedPrincipal_);
}
This is incorrect and leads to lowered payments since _bid.terms.paymentCycleAmount+interest_
will be taken instead of the ratio wise amount
Eg: Principal (P) = 100 Annual Rate (r) = 12% = 0.12 Number of Monthly Payments (n) = 12 monthly EMI = 8.84
But if the repayment occurs after 2 months, this formula calculates the amount due as 8.84 + 2 == 10.84 instead of 8.84 * 2
No response
No response
No response
Incorrectly lowered payments in case of EMI repayments
No response
Dont take the min. Instead use
((_bid.terms.paymentCycleAmount * owedTime) ) /
_paymentCycleDuration