diff --git a/web/components/contract/contract-card.tsx b/web/components/contract/contract-card.tsx index 8942aab0..aa18befa 100644 --- a/web/components/contract/contract-card.tsx +++ b/web/components/contract/contract-card.tsx @@ -35,7 +35,7 @@ import { trackCallback } from 'web/lib/service/analytics' import { getMappedValue } from 'common/pseudo-numeric' import { Tooltip } from '../tooltip' import { SiteLink } from '../site-link' -import { ProbChange } from './prob-change-table' +import { ProbOrNumericChange } from './prob-change-table' import { Card } from '../card' import { ProfitBadgeMana } from '../profit-badge' import { floatingEqual } from 'common/util/math' @@ -396,12 +396,17 @@ export function ContractCardProbChange(props: { className?: string }) { const { noLinkAvatar, showPosition, className } = props + const yesOutcomeLabel = + props.contract.outcomeType === 'PSEUDO_NUMERIC' ? 'HIGHER' : 'YES' + const noOutcomeLabel = + props.contract.outcomeType === 'PSEUDO_NUMERIC' ? 'LOWER' : 'NO' + const contract = useContractWithPreload(props.contract) as CPMMBinaryContract const user = useUser() const metrics = useUserContractMetrics(user?.id, contract.id) const dayMetrics = metrics && metrics.from && metrics.from.day - const outcome = + const binaryOutcome = metrics && floatingEqual(metrics.totalShares.NO ?? 0, 0) ? 'YES' : 'NO' return ( @@ -418,7 +423,7 @@ export function ContractCardProbChange(props: { > {contract.question} - + {showPosition && metrics && metrics.hasShares && ( - {Math.floor(metrics.totalShares[outcome])} {outcome} shares + {Math.floor(metrics.totalShares[binaryOutcome])}{' '} + {binaryOutcome === 'YES' ? yesOutcomeLabel : noOutcomeLabel} shares {dayMetrics && ( diff --git a/web/components/contract/prob-change-table.tsx b/web/components/contract/prob-change-table.tsx index 594f0653..727fed35 100644 --- a/web/components/contract/prob-change-table.tsx +++ b/web/components/contract/prob-change-table.tsx @@ -7,6 +7,7 @@ import { formatPercent } from 'common/util/format' import { Col } from '../layout/col' import { LoadingIndicator } from '../loading-indicator' import { ContractCardProbChange } from './contract-card' +import { formatNumericProbability } from 'common/pseudo-numeric' export function ProfitChangeTable(props: { contracts: CPMMBinaryContract[] @@ -118,7 +119,7 @@ export function ProbChangeTable(props: { ) } -export function ProbChange(props: { +export function ProbOrNumericChange(props: { contract: CPMMContract className?: string }) { @@ -127,13 +128,17 @@ export function ProbChange(props: { prob, probChanges: { day: change }, } = contract + const number = + contract.outcomeType === 'PSEUDO_NUMERIC' + ? formatNumericProbability(prob, contract) + : null const color = change >= 0 ? 'text-teal-500' : 'text-red-400' return (
- {formatPercent(Math.round(100 * prob) / 100)} + {number ? number : formatPercent(Math.round(100 * prob) / 100)}
{(change > 0 ? '+' : '') + (change * 100).toFixed(0) + '%'}