Add note that there might be closed form

This commit is contained in:
James Grugett 2022-07-09 15:22:53 -05:00
parent 09181f806f
commit 3283b2b24b
2 changed files with 5 additions and 3 deletions

View File

@ -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'

View File

@ -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,