From 405604adef80d6206f38c11e3162bcd5f43d1fd4 Mon Sep 17 00:00:00 2001 From: James Grugett Date: Wed, 2 Mar 2022 14:02:44 -0800 Subject: [PATCH] Fix insufficient balance error to use bet amount net loan --- web/components/amount-input.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/components/amount-input.tsx b/web/components/amount-input.tsx index a29811e9..8f20c0ab 100644 --- a/web/components/amount-input.tsx +++ b/web/components/amount-input.tsx @@ -57,7 +57,12 @@ export function AmountInput(props: { onChange(str ? amount : undefined) - if (user && user.balance < amount) { + const loanAmount = contractIdForLoan + ? Math.min(amount, MAX_LOAN_PER_CONTRACT - prevLoanAmount) + : 0 + const amountNetLoan = amount - loanAmount + + if (user && user.balance < amountNetLoan) { setError('Insufficient balance') } else if (minimumAmount && amount < minimumAmount) { setError('Minimum amount: ' + formatMoney(minimumAmount))