From b0ed080020a560fb4665d8bdb59cebd3258792d4 Mon Sep 17 00:00:00 2001 From: mantikoros Date: Wed, 18 May 2022 11:52:58 -0400 Subject: [PATCH] use correct amount for numeric dpm payouts --- common/calculate-dpm.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/common/calculate-dpm.ts b/common/calculate-dpm.ts index efd0268d..0bd14193 100644 --- a/common/calculate-dpm.ts +++ b/common/calculate-dpm.ts @@ -255,7 +255,7 @@ export function calculateStandardDpmPayout( bet: Bet, outcome: string ) { - const { amount, outcome: betOutcome } = bet + const { outcome: betOutcome } = bet const isNumeric = contract.outcomeType === 'NUMERIC' if (!isNumeric && betOutcome !== outcome) return 0 @@ -274,8 +274,13 @@ export function calculateStandardDpmPayout( totalShares[outcome] - (phantomShares ? phantomShares[outcome] : 0) const winnings = (shares / total) * poolTotal - // profit can be negative if using phantom shares - return amount + (1 - DPM_FEES) * Math.max(0, winnings - amount) + + const amount = isNumeric + ? (bet as NumericBet).allBetAmounts[outcome] + : bet.amount + + const payout = amount + (1 - DPM_FEES) * Math.max(0, winnings - amount) + return payout } export function calculateDpmPayoutAfterCorrectBet(