From a1f94fb4d1b737fd30cec2ad02f00c9701d907ad Mon Sep 17 00:00:00 2001 From: Onno Visser <23527729+onnovisser@users.noreply.github.com> Date: Fri, 8 Nov 2024 10:13:53 +0100 Subject: [PATCH 1/3] fix withdraw --- centrifuge-app/src/pages/Loan/FinanceForm.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/centrifuge-app/src/pages/Loan/FinanceForm.tsx b/centrifuge-app/src/pages/Loan/FinanceForm.tsx index 78e8a8236e..ca82b7463a 100644 --- a/centrifuge-app/src/pages/Loan/FinanceForm.tsx +++ b/centrifuge-app/src/pages/Loan/FinanceForm.tsx @@ -577,12 +577,11 @@ export function useWithdraw(poolId: string, borrower: CombinedSubstrateAccount, amount={amount} /> ), - isValid: (_: { values: Pick }) => { + isValid: () => { const withdrawalAddresses = Object.values(selectedAddressIndexByCurrency).filter((index) => index !== -1) return source === 'reserve' ? amount.lte(totalAvailable) && !!withdrawalAddresses.length : true }, - getBatch: ({ values }: { values: Pick }) => { - if (!values.withdraw) return of([]) + getBatch: () => { const withdrawalAddresses = Object.values(selectedAddressIndexByCurrency).filter((index) => index !== -1) if (!withdrawalAddresses.length) return of([]) return combineLatest( From 84cd9d00f38e50c015b06287263c6cb7eec1b6a7 Mon Sep 17 00:00:00 2001 From: Onno Visser <23527729+onnovisser@users.noreply.github.com> Date: Fri, 8 Nov 2024 14:30:50 +0100 Subject: [PATCH 2/3] fix submit button --- centrifuge-app/src/pages/Loan/FinanceForm.tsx | 288 +++++++++--------- 1 file changed, 146 insertions(+), 142 deletions(-) diff --git a/centrifuge-app/src/pages/Loan/FinanceForm.tsx b/centrifuge-app/src/pages/Loan/FinanceForm.tsx index ca82b7463a..b7900cb844 100644 --- a/centrifuge-app/src/pages/Loan/FinanceForm.tsx +++ b/centrifuge-app/src/pages/Loan/FinanceForm.tsx @@ -83,7 +83,7 @@ export function FinanceForm({ loan }: { loan: LoanType }) { return ( - {isCashLoan(loan) ? 'Deposit' : 'Finance'} + {isCashLoan(loan) ? 'Deposit' : 'Financier'} ) @@ -197,160 +197,164 @@ function InternalFinanceForm({ <> {!maturityDatePassed && ( - - - - { - const principalValue = typeof val === 'number' ? Dec(val) : (val as Decimal) - if (maxAvailable !== UNLIMITED && principalValue.gt(maxAvailable)) { - return `Principal exceeds available financing` - } - return '' - })} - > - {({ field, form }: FieldProps) => { - return ( - form.setFieldValue('principal', value)} - onSetMax={ - maxAvailable !== UNLIMITED ? () => form.setFieldValue('principal', maxAvailable) : undefined - } - /> - ) - }} - - {source === 'other' && ( - - {({ field }: FieldProps) => { +
+ + + + { + const principalValue = typeof val === 'number' ? Dec(val) : (val as Decimal) + if (maxAvailable !== UNLIMITED && principalValue.gt(maxAvailable)) { + return `Principal exceeds available financing` + } + return '' + })} + > + {({ field, form }: FieldProps) => { return ( - + ) + }} + + )} + {source === 'reserve' && withdraw.render()} + + {poolFees.render()} + + + {isCashLoan(loan) ? 'Deposit amount' : 'Financing amount'} ( + {formatBalance(totalFinance, displayCurrency, 2)}) is greater than the available balance ( + {formatBalance(maxAvailable, displayCurrency, 2)}). + + + + There is an additional{' '} + {formatBalance( + new CurrencyBalance(pool.reserve.total.sub(pool.reserve.available), pool.currency.decimals), + displayCurrency + )}{' '} + available from repayments or deposits. This requires first executing the orders on the{' '} + Liquidity tab. + + + - + + Transaction summary + + - - {isCashLoan(loan) ? 'Deposit amount' : 'Financing amount'} + + + Available balance + + + + {maxAvailable === UNLIMITED ? 'No limit' : formatBalance(maxAvailable, displayCurrency, 2)} - {formatBalance(totalFinance, displayCurrency, 2)} - - {poolFees.renderSummary()} - + + + + {isCashLoan(loan) ? 'Deposit amount' : 'Financing amount'} + + {formatBalance(totalFinance, displayCurrency, 2)} + + - {source === 'reserve' ? ( - - - Stablecoins will be transferred to the designated withdrawal addresses on the specified networks. A - delay may occur before the transfer is completed. - - - ) : source === 'other' ? ( - - - Virtual accounting process. No onchain stablecoin transfers are expected. This action will lead to - an increase in the NAV of the pool. - - - ) : ( - - - Virtual accounting process. No onchain stablecoin transfers are expected. - - - )} - - + {poolFees.renderSummary()} + - - - + {source === 'reserve' ? ( + + + Stablecoins will be transferred to the designated withdrawal addresses on the specified networks. + A delay may occur before the transfer is completed. + + + ) : source === 'other' ? ( + + + Virtual accounting process. No onchain stablecoin transfers are expected. This action will lead to + an increase in the NAV of the pool. + + + ) : ( + + + Virtual accounting process. No onchain stablecoin transfers are expected. + + + )} + + + + + + +
)} From ad3bc264f801f31ec800e185b350e890491d59ab Mon Sep 17 00:00:00 2001 From: Onno Visser <23527729+onnovisser@users.noreply.github.com> Date: Fri, 8 Nov 2024 14:32:06 +0100 Subject: [PATCH 3/3] typo --- centrifuge-app/src/pages/Loan/FinanceForm.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centrifuge-app/src/pages/Loan/FinanceForm.tsx b/centrifuge-app/src/pages/Loan/FinanceForm.tsx index b7900cb844..d13c48df9b 100644 --- a/centrifuge-app/src/pages/Loan/FinanceForm.tsx +++ b/centrifuge-app/src/pages/Loan/FinanceForm.tsx @@ -83,7 +83,7 @@ export function FinanceForm({ loan }: { loan: LoanType }) { return ( - {isCashLoan(loan) ? 'Deposit' : 'Financier'} + {isCashLoan(loan) ? 'Deposit' : 'Finance'} )