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