use geometric mean probability to calculate fees for cfmm (a lot easier than solving the integral)

This commit is contained in:
mantikoros 2022-05-17 17:03:18 -04:00
parent 85a182b7f2
commit a1c3a5e569

View File

@ -63,8 +63,10 @@ export function getCpmmLiquidityFee(
bet: number,
outcome: string
) {
const prob = getCpmmProbabilityAfterBetBeforeFees(contract, outcome, bet)
const betP = outcome === 'YES' ? 1 - prob : prob
const probBefore = getCpmmProbability(contract.pool, contract.p)
const probAfter = getCpmmProbabilityAfterBetBeforeFees(contract, outcome, bet)
const probMid = Math.sqrt(probBefore * probAfter)
const betP = outcome === 'YES' ? 1 - probMid : probMid
const liquidityFee = LIQUIDITY_FEE * betP * bet
const platformFee = PLATFORM_FEE * betP * bet