From 1bd4267773a6368eef86d75242eeb3a2834356fa Mon Sep 17 00:00:00 2001 From: mantikoros Date: Thu, 28 Apr 2022 10:30:44 -0400 Subject: [PATCH] contrain liquidity paramter p to [0.1, 0.9] --- common/new-contract.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/common/new-contract.ts b/common/new-contract.ts index ffd27e3f..79319d01 100644 --- a/common/new-contract.ts +++ b/common/new-contract.ts @@ -87,15 +87,22 @@ const getBinaryDpmProps = (initialProb: number, ante: number) => { return system } -const getBinaryCpmmProps = (initialProb: number, ante: number) => { - const pool = { YES: ante, NO: ante } - const p = initialProb / 100 +const getBinaryCpmmProps = (initialProbInt: number, ante: number) => { + const prob = initialProbInt / 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 = { mechanism: 'cpmm-1', outcomeType: 'BINARY', totalLiquidity: ante, - initialProbability: p, + initialProbability: prob, p, pool: pool, }