getInitialProbability: use totalShares to calculate prob for ported contracts

This commit is contained in:
mantikoros 2022-04-18 17:15:25 -05:00
parent 790aec9baf
commit 7abc11c146

View File

@ -29,12 +29,15 @@ export function getProbability(contract: FullContract<DPM | CPMM, Binary>) {
export function getInitialProbability( export function getInitialProbability(
contract: FullContract<DPM | CPMM, Binary> contract: FullContract<DPM | CPMM, Binary>
) { ) {
return ( if (contract.initialProbability) return contract.initialProbability
contract.initialProbability ??
(contract.mechanism === 'cpmm-1' if (contract.mechanism === 'dpm-2' || (contract as any).totalShares)
? getCpmmProbability(contract.pool, contract.p) // use totalShares to calculate prob for ported contracts
: getDpmProbability(contract.phantomShares ?? contract.totalShares)) return getDpmProbability(
(contract as any).phantomShares ?? (contract as any).totalShares
) )
return getCpmmProbability(contract.pool, contract.p)
} }
export function getOutcomeProbability(contract: Contract, outcome: string) { export function getOutcomeProbability(contract: Contract, outcome: string) {