From 1fe41c7c8816fdedd97c5a2b1a20e3a5359e3c0b Mon Sep 17 00:00:00 2001 From: Onno Visser Date: Thu, 16 May 2024 21:54:31 +0200 Subject: [PATCH] fix transfer debt (#2134) Co-authored-by: Sophia --- centrifuge-app/src/pages/Loan/TransferDebtForm.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/centrifuge-app/src/pages/Loan/TransferDebtForm.tsx b/centrifuge-app/src/pages/Loan/TransferDebtForm.tsx index ce3e9fed4a..acf23acfb0 100644 --- a/centrifuge-app/src/pages/Loan/TransferDebtForm.tsx +++ b/centrifuge-app/src/pages/Loan/TransferDebtForm.tsx @@ -77,12 +77,12 @@ export function TransferDebtForm({ loan }: { loan: LoanType }) { borrowAmount = borrow.amount } - const outstandingPrincipal = selectedLoan.totalBorrowed.sub(selectedLoan.repaid.principal) - let principal: BN = new BN(borrowAmount) - let interest = new BN(0) - if (principal.gt(outstandingPrincipal)) { - interest = principal.sub(outstandingPrincipal) - principal = outstandingPrincipal + const { outstandingInterest } = selectedLoan + let interest = new BN(borrowAmount) + let principal = new BN(0) + if (interest.gt(outstandingInterest)) { + interest = outstandingInterest + principal = interest.sub(outstandingInterest) } let repay: any = { principal, interest } if (isExternalLoan(selectedLoan)) {