From 3283b2b24bf2592158d53e969d7018b1493f2036 Mon Sep 17 00:00:00 2001 From: James Grugett Date: Sat, 9 Jul 2022 15:22:53 -0500 Subject: [PATCH] Add note that there might be closed form --- common/calculate-cpmm.ts | 4 +++- common/new-bet.ts | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/common/calculate-cpmm.ts b/common/calculate-cpmm.ts index ce46cc34..3470088a 100644 --- a/common/calculate-cpmm.ts +++ b/common/calculate-cpmm.ts @@ -116,7 +116,9 @@ export function calculateCpmmPurchase( return { shares, newPool, newP, fees } } -export function calculateCpmmAmount( +// Note: there might be a closed form solution for this. +// If so, feel free to switch out this implementation. +export function calculateCpmmAmountToProb( state: CpmmState, prob: number, outcome: 'YES' | 'NO' diff --git a/common/new-bet.ts b/common/new-bet.ts index ea5c7f89..6c3e6856 100644 --- a/common/new-bet.ts +++ b/common/new-bet.ts @@ -9,7 +9,7 @@ import { calculateNumericDpmShares, } from './calculate-dpm' import { - calculateCpmmAmount, + calculateCpmmAmountToProb, calculateCpmmPurchase, CpmmState, getCpmmProbability, @@ -79,7 +79,7 @@ const computeFill = ( const buyAmount = limit === undefined ? amount - : Math.min(amount, calculateCpmmAmount(cpmmState, limit, outcome)) + : Math.min(amount, calculateCpmmAmountToProb(cpmmState, limit, outcome)) const { shares, newPool, newP, fees } = calculateCpmmPurchase( cpmmState,