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

View File

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