diff --git a/common/calculate.ts b/common/calculate.ts index 5baeb9a3..323e8027 100644 --- a/common/calculate.ts +++ b/common/calculate.ts @@ -28,9 +28,12 @@ export function getProbability(contract: FullContract) { export function getInitialProbability( contract: FullContract ) { - return contract.initialProbability ?? contract.mechanism === 'cpmm-1' - ? getCpmmProbability(contract.pool) - : getDpmProbability(contract.phantomShares ?? contract.totalShares) + return ( + contract.initialProbability ?? + (contract.mechanism === 'cpmm-1' + ? getCpmmProbability(contract.pool) + : getDpmProbability(contract.phantomShares ?? contract.totalShares)) + ) } export function getOutcomeProbability(contract: Contract, outcome: string) { diff --git a/web/components/contract-prob-graph.tsx b/web/components/contract-prob-graph.tsx index 9158f8db..56b03a0b 100644 --- a/web/components/contract-prob-graph.tsx +++ b/web/components/contract-prob-graph.tsx @@ -20,12 +20,11 @@ export function ContractProbGraph(props: { const startProb = getInitialProbability(contract) - const times = bets - ? [contract.createdTime, ...bets.map((bet) => bet.createdTime)].map( - (time) => new Date(time) - ) - : [] - const probs = bets ? [startProb, ...bets.map((bet) => bet.probAfter)] : [] + const times = [ + contract.createdTime, + ...bets.map((bet) => bet.createdTime), + ].map((time) => new Date(time)) + const probs = [startProb, ...bets.map((bet) => bet.probAfter)] const isClosed = !!closeTime && Date.now() > closeTime const latestTime = dayjs(