diff --git a/common/calculate.ts b/common/calculate.ts index 758fc3cd..da4ce13a 100644 --- a/common/calculate.ts +++ b/common/calculate.ts @@ -140,6 +140,8 @@ function getCpmmInvested(yourBets: Bet[]) { const sortedBets = sortBy(yourBets, 'createdTime') for (const bet of sortedBets) { const { outcome, shares, amount } = bet + if (floatingEqual(shares, 0)) continue + if (amount > 0) { totalShares[outcome] = (totalShares[outcome] ?? 0) + shares totalSpent[outcome] = (totalSpent[outcome] ?? 0) + amount diff --git a/web/components/bets-list.tsx b/web/components/bets-list.tsx index 1a31a900..4ac873b4 100644 --- a/web/components/bets-list.tsx +++ b/web/components/bets-list.tsx @@ -405,7 +405,8 @@ export function BetsSummary(props: { const isClosed = closeTime && Date.now() > closeTime const bets = props.bets.filter((b) => !b.isAnte) - const { hasShares } = getContractBetMetrics(contract, bets) + const { hasShares, invested, profitPercent, payout, profit, totalShares } = + getContractBetMetrics(contract, bets) const excludeSalesAndAntes = bets.filter( (b) => !b.isAnte && !b.isSold && !b.sale @@ -416,8 +417,6 @@ export function BetsSummary(props: { const noWinnings = sumBy(excludeSalesAndAntes, (bet) => calculatePayout(contract, bet, 'NO') ) - const { invested, profitPercent, payout, profit, totalShares } = - getContractBetMetrics(contract, bets) const [showSellModal, setShowSellModal] = useState(false) const user = useUser()