use all bets for getFixedCancelPayouts

This commit is contained in:
mantikoros 2022-03-08 11:32:03 -06:00
parent b05c4da0f2
commit 4a0db10b20
2 changed files with 6 additions and 4 deletions

View File

@ -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)
}
}

View File

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