From 48df0ac7ce6ac5a4b4df102ee881503fe296bdbb Mon Sep 17 00:00:00 2001 From: mantikoros Date: Thu, 10 Mar 2022 16:05:39 -0600 Subject: [PATCH] calculateCpmmPurchase: deduct creator fee --- common/calculate-cpmm.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/calculate-cpmm.ts b/common/calculate-cpmm.ts index 74218a42..217258bc 100644 --- a/common/calculate-cpmm.ts +++ b/common/calculate-cpmm.ts @@ -76,10 +76,12 @@ export function calculateCpmmPurchase( const shares = calculateCpmmShares(pool, remainingBet, outcome) const { YES: y, NO: n } = pool + const { liquidityFee: fee } = fees + const [newY, newN] = outcome === 'YES' - ? [y - shares + bet, n + bet] - : [y + bet, n - shares + bet] + ? [y - shares + remainingBet + fee, n + remainingBet + fee] + : [y + remainingBet + fee, n - shares + remainingBet + fee] const newPool = { YES: newY, NO: newN }