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 [outcome: string]: number
}, },
contract: Contract, contract: Contract,
bets: Bet[], allBets: Bet[],
liquidities: LiquidityProvision[], liquidities: LiquidityProvision[],
resolutionProbability?: number resolutionProbability?: number
) => { ) => {
const bets = allBets.filter((b) => !b.isSold && !b.sale)
if (contract.mechanism === 'cpmm-1' && contract.outcomeType === 'BINARY') { if (contract.mechanism === 'cpmm-1' && contract.outcomeType === 'BINARY') {
switch (outcome) { switch (outcome) {
case 'YES': case 'YES':
@ -39,7 +41,7 @@ export const getPayouts = (
resolutionProbability resolutionProbability
) )
case 'CANCEL': case 'CANCEL':
return getFixedCancelPayouts(contract, bets, liquidities) return getFixedCancelPayouts(contract, allBets, liquidities)
} }
} }

View File

@ -93,7 +93,6 @@ export const resolveMarket = functions
.get() .get()
const bets = betsSnap.docs.map((doc) => doc.data() as Bet) const bets = betsSnap.docs.map((doc) => doc.data() as Bet)
const openBets = bets.filter((b) => !b.isSold && !b.sale)
const liquiditiesSnap = await firestore const liquiditiesSnap = await firestore
.collection(`contracts/${contractId}/liquidity`) .collection(`contracts/${contractId}/liquidity`)
@ -106,11 +105,12 @@ export const resolveMarket = functions
const payouts = getPayouts( const payouts = getPayouts(
resolutions ?? outcome, resolutions ?? outcome,
contract, contract,
openBets, bets,
liquidities, liquidities,
resolutionProbability resolutionProbability
) )
const openBets = bets.filter((b) => !b.isSold && !b.sale)
const loanPayouts = getLoanPayouts(openBets) const loanPayouts = getLoanPayouts(openBets)
console.log('payouts:', payouts) console.log('payouts:', payouts)