Fix NaN invested (floating point error)
This commit is contained in:
parent
4b513a894d
commit
d7793841d1
|
@ -140,6 +140,8 @@ function getCpmmInvested(yourBets: Bet[]) {
|
||||||
const sortedBets = sortBy(yourBets, 'createdTime')
|
const sortedBets = sortBy(yourBets, 'createdTime')
|
||||||
for (const bet of sortedBets) {
|
for (const bet of sortedBets) {
|
||||||
const { outcome, shares, amount } = bet
|
const { outcome, shares, amount } = bet
|
||||||
|
if (floatingEqual(shares, 0)) continue
|
||||||
|
|
||||||
if (amount > 0) {
|
if (amount > 0) {
|
||||||
totalShares[outcome] = (totalShares[outcome] ?? 0) + shares
|
totalShares[outcome] = (totalShares[outcome] ?? 0) + shares
|
||||||
totalSpent[outcome] = (totalSpent[outcome] ?? 0) + amount
|
totalSpent[outcome] = (totalSpent[outcome] ?? 0) + amount
|
||||||
|
|
|
@ -405,7 +405,8 @@ export function BetsSummary(props: {
|
||||||
const isClosed = closeTime && Date.now() > closeTime
|
const isClosed = closeTime && Date.now() > closeTime
|
||||||
|
|
||||||
const bets = props.bets.filter((b) => !b.isAnte)
|
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(
|
const excludeSalesAndAntes = bets.filter(
|
||||||
(b) => !b.isAnte && !b.isSold && !b.sale
|
(b) => !b.isAnte && !b.isSold && !b.sale
|
||||||
|
@ -416,8 +417,6 @@ export function BetsSummary(props: {
|
||||||
const noWinnings = sumBy(excludeSalesAndAntes, (bet) =>
|
const noWinnings = sumBy(excludeSalesAndAntes, (bet) =>
|
||||||
calculatePayout(contract, bet, 'NO')
|
calculatePayout(contract, bet, 'NO')
|
||||||
)
|
)
|
||||||
const { invested, profitPercent, payout, profit, totalShares } =
|
|
||||||
getContractBetMetrics(contract, bets)
|
|
||||||
|
|
||||||
const [showSellModal, setShowSellModal] = useState(false)
|
const [showSellModal, setShowSellModal] = useState(false)
|
||||||
const user = useUser()
|
const user = useUser()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user