From 7abc11c14662b6f25f4390d37eec82aa86eb8093 Mon Sep 17 00:00:00 2001 From: mantikoros Date: Mon, 18 Apr 2022 17:15:25 -0500 Subject: [PATCH] getInitialProbability: use totalShares to calculate prob for ported contracts --- common/calculate.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/common/calculate.ts b/common/calculate.ts index 09aa6483..d6834295 100644 --- a/common/calculate.ts +++ b/common/calculate.ts @@ -29,12 +29,15 @@ export function getProbability(contract: FullContract) { export function getInitialProbability( contract: FullContract ) { - return ( - contract.initialProbability ?? - (contract.mechanism === 'cpmm-1' - ? getCpmmProbability(contract.pool, contract.p) - : getDpmProbability(contract.phantomShares ?? contract.totalShares)) - ) + if (contract.initialProbability) return contract.initialProbability + + if (contract.mechanism === 'dpm-2' || (contract as any).totalShares) + // use totalShares to calculate prob for ported contracts + return getDpmProbability( + (contract as any).phantomShares ?? (contract as any).totalShares + ) + + return getCpmmProbability(contract.pool, contract.p) } export function getOutcomeProbability(contract: Contract, outcome: string) {