store initialProbability in contracts
This commit is contained in:
parent
82c5eb85d3
commit
1dfc108ae4
|
@ -31,7 +31,7 @@ export function getProbability(contract: FullContract<DPM | CPMM, Binary>) {
|
|||
export function getInitialProbability(
|
||||
contract: FullContract<DPM | CPMM, Binary>
|
||||
) {
|
||||
return contract.mechanism === 'cpmm-1'
|
||||
return contract.initialProbability ?? contract.mechanism === 'cpmm-1'
|
||||
? getCpmmProbability(contract.pool)
|
||||
: getDpmProbability(contract.phantomShares ?? contract.totalShares)
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ export type FixedPayouts = CPMM
|
|||
|
||||
export type Binary = {
|
||||
outcomeType: 'BINARY'
|
||||
initialProbability: number
|
||||
resolutionProbability?: number // Used for BINARY markets resolved to MKT
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ export function getNewContract(
|
|||
|
||||
const propsByOutcomeType =
|
||||
outcomeType === 'BINARY'
|
||||
? getBinaryCpmmProps(initialProb, ante, creator.id) // getBinaryDpmProps(initialProb, ante)
|
||||
? getBinaryCpmmProps(initialProb, ante) // getBinaryDpmProps(initialProb, ante)
|
||||
: getFreeAnswerProps(ante)
|
||||
|
||||
const contract = removeUndefinedProps({
|
||||
|
@ -69,6 +69,7 @@ const getBinaryDpmProps = (initialProb: number, ante: number) => {
|
|||
const system: DPM & Binary = {
|
||||
mechanism: 'dpm-2',
|
||||
outcomeType: 'BINARY',
|
||||
initialProbability: initialProb / 100,
|
||||
phantomShares: { YES: phantomYes, NO: phantomNo },
|
||||
pool: { YES: poolYes, NO: poolNo },
|
||||
totalShares: { YES: sharesYes, NO: sharesNo },
|
||||
|
@ -78,17 +79,14 @@ const getBinaryDpmProps = (initialProb: number, ante: number) => {
|
|||
return system
|
||||
}
|
||||
|
||||
const getBinaryCpmmProps = (
|
||||
initialProb: number,
|
||||
ante: number,
|
||||
userId: string
|
||||
) => {
|
||||
const getBinaryCpmmProps = (initialProb: number, ante: number) => {
|
||||
const { poolYes, poolNo } = calcCpmmInitialPool(initialProb, ante)
|
||||
const pool = { YES: poolYes, NO: poolNo }
|
||||
|
||||
const system: CPMM & Binary = {
|
||||
mechanism: 'cpmm-1',
|
||||
outcomeType: 'BINARY',
|
||||
initialProbability: initialProb / 100,
|
||||
pool: pool,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user