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(
contract: FullContract<DPM | CPMM, Binary>
) {
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) {