Fix NaN error

This commit is contained in:
James Grugett 2022-07-09 19:16:35 -05:00
parent 9d9dcea9b5
commit 4dccbddcc5

View File

@ -264,14 +264,11 @@ function BuyPanel(props: {
) )
const resultProb = getCpmmProbability(newPool, newP) const resultProb = getCpmmProbability(newPool, newP)
const matchedAmount = sumBy(newBet.fills, (fill) => fill.amount) const remainingMatched = isLimitOrder
const filledShares = sumBy(newBet.fills, (fill) => fill.shares) ? ((newBet.orderAmount ?? 0) - newBet.amount) /
const overallShares =
filledShares +
((betAmount ?? 0) - matchedAmount) /
(betChoice === 'YES' ? limitProbFrac : 1 - limitProbFrac) (betChoice === 'YES' ? limitProbFrac : 1 - limitProbFrac)
: 0
const currentPayout = overallShares const currentPayout = newBet.shares + remainingMatched
const currentReturn = betAmount ? (currentPayout - betAmount) / betAmount : 0 const currentReturn = betAmount ? (currentPayout - betAmount) / betAmount : 0
const currentReturnPercent = formatPercent(currentReturn) const currentReturnPercent = formatPercent(currentReturn)