small fixes

This commit is contained in:
mantikoros 2022-03-10 15:15:52 -06:00
parent 82b66a8d53
commit b515ca8bd0
2 changed files with 13 additions and 12 deletions

View File

@ -5,6 +5,7 @@ import { Bet } from '../../common/bet'
import { getProbability } from '../../common/calculate' import { getProbability } from '../../common/calculate'
import { Binary, CPMM, FullContract } from '../../common/contract' import { Binary, CPMM, FullContract } from '../../common/contract'
import { noFees } from '../../common/fees'
import { User } from '../../common/user' import { User } from '../../common/user'
export const redeemShares = async (userId: string, contractId: string) => { export const redeemShares = async (userId: string, contractId: string) => {
@ -46,6 +47,7 @@ export const redeemShares = async (userId: string, contractId: string) => {
probAfter: p, probAfter: p,
createdTime, createdTime,
isRedemption: true, isRedemption: true,
fees: noFees,
} }
const noDoc = firestore.collection(`contracts/${contract.id}/bets`).doc() const noDoc = firestore.collection(`contracts/${contract.id}/bets`).doc()
@ -60,6 +62,7 @@ export const redeemShares = async (userId: string, contractId: string) => {
probAfter: p, probAfter: p,
createdTime, createdTime,
isRedemption: true, isRedemption: true,
fees: noFees,
} }
const userDoc = firestore.doc(`users/${userId}`) const userDoc = firestore.doc(`users/${userId}`)

View File

@ -6,13 +6,8 @@ initAdmin('james')
import { Bet } from '../../../common/bet' import { Bet } from '../../../common/bet'
import { Contract } from '../../../common/contract' import { Contract } from '../../../common/contract'
import { import { getLoanPayouts, getPayouts } from '../../../common/payouts'
getLoanPayouts,
getPayouts,
getPayoutsMultiOutcome,
} from '../../../common/payouts'
import { filterDefined } from '../../../common/util/array' import { filterDefined } from '../../../common/util/array'
import { payUser } from '../utils'
type DocRef = admin.firestore.DocumentReference type DocRef = admin.firestore.DocumentReference
@ -28,12 +23,15 @@ async function checkIfPayOutAgain(contractRef: DocRef, contract: Contract) {
const loanedBets = openBets.filter((bet) => bet.loanAmount) const loanedBets = openBets.filter((bet) => bet.loanAmount)
if (loanedBets.length && contract.resolution) { if (loanedBets.length && contract.resolution) {
const { resolution, outcomeType, resolutions, resolutionProbability } = const { resolution, resolutions, resolutionProbability } = contract as any
contract const [payouts] = getPayouts(
const payouts = resolution,
outcomeType === 'FREE_RESPONSE' && resolutions resolutions,
? getPayoutsMultiOutcome(resolutions, contract, openBets) contract,
: getPayouts(resolution, contract, openBets, resolutionProbability) openBets,
[],
resolutionProbability
)
const loanPayouts = getLoanPayouts(openBets) const loanPayouts = getLoanPayouts(openBets)
const groups = _.groupBy( const groups = _.groupBy(