From 1da30812ad43aa3ecc8a90b29dd33d553b6ae475 Mon Sep 17 00:00:00 2001 From: James Grugett Date: Tue, 1 Mar 2022 16:59:46 -0800 Subject: [PATCH] Exclude sold bets from current loan amount --- common/new-bet.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/new-bet.ts b/common/new-bet.ts index 11637792..0e94c85a 100644 --- a/common/new-bet.ts +++ b/common/new-bet.ts @@ -103,7 +103,8 @@ export const getNewMultiBetInfo = ( } export const getLoanAmount = (yourBets: Bet[], newBetAmount: number) => { - const prevLoanAmount = _.sumBy(yourBets, (bet) => bet.loanAmount ?? 0) + const openBets = yourBets.filter((bet) => !bet.isSold && !bet.sale) + const prevLoanAmount = _.sumBy(openBets, (bet) => bet.loanAmount ?? 0) const loanAmount = Math.min( newBetAmount, MAX_LOAN_PER_CONTRACT - prevLoanAmount