Exclude sold bets from current loan amount

This commit is contained in:
James Grugett 2022-03-01 16:59:46 -08:00
parent d5ae4a2377
commit 1da30812ad

View File

@ -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