From 4a0db10b2091fc7fffa373db315a526eb7a9661a Mon Sep 17 00:00:00 2001 From: mantikoros Date: Tue, 8 Mar 2022 11:32:03 -0600 Subject: [PATCH] use all bets for getFixedCancelPayouts --- common/payouts.ts | 6 ++++-- functions/src/resolve-market.ts | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/common/payouts.ts b/common/payouts.ts index 9cf95a9d..77a88e80 100644 --- a/common/payouts.ts +++ b/common/payouts.ts @@ -22,10 +22,12 @@ export const getPayouts = ( [outcome: string]: number }, contract: Contract, - bets: Bet[], + allBets: Bet[], liquidities: LiquidityProvision[], resolutionProbability?: number ) => { + const bets = allBets.filter((b) => !b.isSold && !b.sale) + if (contract.mechanism === 'cpmm-1' && contract.outcomeType === 'BINARY') { switch (outcome) { case 'YES': @@ -39,7 +41,7 @@ export const getPayouts = ( resolutionProbability ) case 'CANCEL': - return getFixedCancelPayouts(contract, bets, liquidities) + return getFixedCancelPayouts(contract, allBets, liquidities) } } diff --git a/functions/src/resolve-market.ts b/functions/src/resolve-market.ts index b256b1b8..b13aff3e 100644 --- a/functions/src/resolve-market.ts +++ b/functions/src/resolve-market.ts @@ -93,7 +93,6 @@ export const resolveMarket = functions .get() const bets = betsSnap.docs.map((doc) => doc.data() as Bet) - const openBets = bets.filter((b) => !b.isSold && !b.sale) const liquiditiesSnap = await firestore .collection(`contracts/${contractId}/liquidity`) @@ -106,11 +105,12 @@ export const resolveMarket = functions const payouts = getPayouts( resolutions ?? outcome, contract, - openBets, + bets, liquidities, resolutionProbability ) + const openBets = bets.filter((b) => !b.isSold && !b.sale) const loanPayouts = getLoanPayouts(openBets) console.log('payouts:', payouts)