diff --git a/web/components/bets-list.tsx b/web/components/bets-list.tsx index 97d11758..4e2f60e0 100644 --- a/web/components/bets-list.tsx +++ b/web/components/bets-list.tsx @@ -33,12 +33,12 @@ import { getContractBetMetrics, resolvedPayout, getContractBetNullMetrics, + getProbability, } from 'common/calculate' import { NumericContract } from 'common/contract' import { formatNumericProbability } from 'common/pseudo-numeric' import { useUser } from 'web/hooks/use-user' import { useUserBets } from 'web/hooks/use-user-bets' -import { SellSharesModal } from './sell-modal' import { useUnfilledBets } from 'web/hooks/use-bets' import { LimitBet } from 'common/bet' import { floatingEqual } from 'common/util/math' @@ -46,6 +46,7 @@ import { Pagination } from './pagination' import { LimitOrderTable } from './limit-bets' import { UserLink } from 'web/components/user-link' import { useUserBetContracts } from 'web/hooks/use-contracts' +import { InfoTooltip } from './info-tooltip' type BetSort = 'newest' | 'profit' | 'closeTime' | 'value' type BetFilter = 'open' | 'limit_bet' | 'sold' | 'closed' | 'resolved' | 'all' @@ -379,16 +380,15 @@ export function BetsSummary(props: { isYourBets: boolean className?: string }) { - const { contract, isYourBets, className } = props - const { resolution, closeTime, outcomeType, mechanism } = contract + const { contract, className } = props + const { resolution, outcomeType } = contract const isBinary = outcomeType === 'BINARY' - const isPseudoNumeric = outcomeType === 'PSEUDO_NUMERIC' - const isCpmm = mechanism === 'cpmm-1' - const isClosed = closeTime && Date.now() > closeTime const bets = props.bets.filter((b) => !b.isAnte) - const { hasShares, invested, profitPercent, payout, profit, totalShares } = - getContractBetMetrics(contract, bets) + const { profitPercent, payout, profit, totalShares } = getContractBetMetrics( + contract, + bets + ) const excludeSales = bets.filter((b) => !b.isSold && !b.sale) const yesWinnings = sumBy(excludeSales, (bet) => @@ -398,62 +398,19 @@ export function BetsSummary(props: { calculatePayout(contract, bet, 'NO') ) - const [showSellModal, setShowSellModal] = useState(false) - const user = useUser() + const prob = isBinary ? getProbability(contract) : 0 + const expectation = prob * yesWinnings + (1 - prob) * noWinnings - const sharesOutcome = floatingEqual(totalShares.YES ?? 0, 0) - ? floatingEqual(totalShares.NO ?? 0, 0) - ? undefined - : 'NO' - : 'YES' - - const canSell = - isYourBets && - isCpmm && - (isBinary || isPseudoNumeric) && - !isClosed && - !resolution && - hasShares && - sharesOutcome && - user + if ( + isBinary && + floatingEqual(totalShares.YES ?? 0, 0) && + floatingEqual(totalShares.NO ?? 0, 0) + ) + return <>> return (