ante for free FR market now come from house

This commit is contained in:
mantikoros 2022-05-19 22:06:50 -04:00
parent 99c41b6112
commit e9fee04761
2 changed files with 53 additions and 57 deletions

View File

@ -88,7 +88,7 @@ export function getAnteBets(
} }
export function getFreeAnswerAnte( export function getFreeAnswerAnte(
creator: User, anteBettorId: string,
contract: FullContract<DPM, FreeResponse>, contract: FullContract<DPM, FreeResponse>,
anteBetId: string anteBetId: string
) { ) {
@ -100,7 +100,7 @@ export function getFreeAnswerAnte(
const anteBet: Bet = { const anteBet: Bet = {
id: anteBetId, id: anteBetId,
userId: creator.id, userId: anteBettorId,
contractId: contract.id, contractId: contract.id,
amount, amount,
shares, shares,

View File

@ -141,15 +141,14 @@ export const createContract = newEndpoint(['POST'], async (req, _res) => {
await contractRef.create(contract) await contractRef.create(contract)
if (ante) { const providerId = isFree ? HOUSE_LIQUIDITY_PROVIDER_ID : creator.id
if (outcomeType === 'BINARY' && contract.mechanism === 'dpm-2') { if (outcomeType === 'BINARY' && contract.mechanism === 'dpm-2') {
const yesBetDoc = firestore const yesBetDoc = firestore
.collection(`contracts/${contract.id}/bets`) .collection(`contracts/${contract.id}/bets`)
.doc() .doc()
const noBetDoc = firestore const noBetDoc = firestore.collection(`contracts/${contract.id}/bets`).doc()
.collection(`contracts/${contract.id}/bets`)
.doc()
const { yesBet, noBet } = getAnteBets( const { yesBet, noBet } = getAnteBets(
creator, creator,
@ -165,8 +164,6 @@ export const createContract = newEndpoint(['POST'], async (req, _res) => {
.collection(`contracts/${contract.id}/liquidity`) .collection(`contracts/${contract.id}/liquidity`)
.doc() .doc()
const providerId = isFree ? HOUSE_LIQUIDITY_PROVIDER_ID : creator.id
const lp = getCpmmInitialLiquidity( const lp = getCpmmInitialLiquidity(
providerId, providerId,
contract as FullContract<CPMM, Binary>, contract as FullContract<CPMM, Binary>,
@ -188,7 +185,7 @@ export const createContract = newEndpoint(['POST'], async (req, _res) => {
.doc() .doc()
const anteBet = getFreeAnswerAnte( const anteBet = getFreeAnswerAnte(
creator, providerId,
contract as FullContract<DPM, FreeResponse>, contract as FullContract<DPM, FreeResponse>,
anteBetDoc.id anteBetDoc.id
) )
@ -207,7 +204,6 @@ export const createContract = newEndpoint(['POST'], async (req, _res) => {
await anteBetDoc.set(anteBet) await anteBetDoc.set(anteBet)
} }
}
return { contract: contract } return { contract: contract }
}) })