contrain liquidity paramter p to [0.1, 0.9]

This commit is contained in:
mantikoros 2022-04-28 10:30:44 -04:00
parent 45aa6646fa
commit 1bd4267773

View File

@ -87,15 +87,22 @@ const getBinaryDpmProps = (initialProb: number, ante: number) => {
return system return system
} }
const getBinaryCpmmProps = (initialProb: number, ante: number) => { const getBinaryCpmmProps = (initialProbInt: number, ante: number) => {
const pool = { YES: ante, NO: ante } const prob = initialProbInt / 100
const p = initialProb / 100
// constrain parameter to [0.1, 0.9]
const p = prob > 0.9 ? 0.9 : prob < 0.1 ? 0.1 : prob
const pool = {
YES: prob > 0.9 ? (ante * p * (prob - 1)) / ((p - 1) * prob) : ante,
NO: prob < 0.1 ? (ante * (p - 1) * prob) / (p * (prob - 1)) : ante,
}
const system: CPMM & Binary = { const system: CPMM & Binary = {
mechanism: 'cpmm-1', mechanism: 'cpmm-1',
outcomeType: 'BINARY', outcomeType: 'BINARY',
totalLiquidity: ante, totalLiquidity: ante,
initialProbability: p, initialProbability: prob,
p, p,
pool: pool, pool: pool,
} }