ante for free FR market now come from house
This commit is contained in:
parent
99c41b6112
commit
e9fee04761
|
@ -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,
|
||||||
|
|
|
@ -141,72 +141,68 @@ 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') {
|
|
||||||
const yesBetDoc = firestore
|
|
||||||
.collection(`contracts/${contract.id}/bets`)
|
|
||||||
.doc()
|
|
||||||
|
|
||||||
const noBetDoc = firestore
|
if (outcomeType === 'BINARY' && contract.mechanism === 'dpm-2') {
|
||||||
.collection(`contracts/${contract.id}/bets`)
|
const yesBetDoc = firestore
|
||||||
.doc()
|
.collection(`contracts/${contract.id}/bets`)
|
||||||
|
.doc()
|
||||||
|
|
||||||
const { yesBet, noBet } = getAnteBets(
|
const noBetDoc = firestore.collection(`contracts/${contract.id}/bets`).doc()
|
||||||
creator,
|
|
||||||
contract as FullContract<DPM, Binary>,
|
|
||||||
yesBetDoc.id,
|
|
||||||
noBetDoc.id
|
|
||||||
)
|
|
||||||
|
|
||||||
await yesBetDoc.set(yesBet)
|
const { yesBet, noBet } = getAnteBets(
|
||||||
await noBetDoc.set(noBet)
|
creator,
|
||||||
} else if (outcomeType === 'BINARY') {
|
contract as FullContract<DPM, Binary>,
|
||||||
const liquidityDoc = firestore
|
yesBetDoc.id,
|
||||||
.collection(`contracts/${contract.id}/liquidity`)
|
noBetDoc.id
|
||||||
.doc()
|
)
|
||||||
|
|
||||||
const providerId = isFree ? HOUSE_LIQUIDITY_PROVIDER_ID : creator.id
|
await yesBetDoc.set(yesBet)
|
||||||
|
await noBetDoc.set(noBet)
|
||||||
|
} else if (outcomeType === 'BINARY') {
|
||||||
|
const liquidityDoc = firestore
|
||||||
|
.collection(`contracts/${contract.id}/liquidity`)
|
||||||
|
.doc()
|
||||||
|
|
||||||
const lp = getCpmmInitialLiquidity(
|
const lp = getCpmmInitialLiquidity(
|
||||||
providerId,
|
providerId,
|
||||||
contract as FullContract<CPMM, Binary>,
|
contract as FullContract<CPMM, Binary>,
|
||||||
liquidityDoc.id,
|
liquidityDoc.id,
|
||||||
ante
|
ante
|
||||||
)
|
)
|
||||||
|
|
||||||
await liquidityDoc.set(lp)
|
await liquidityDoc.set(lp)
|
||||||
} else if (outcomeType === 'FREE_RESPONSE') {
|
} else if (outcomeType === 'FREE_RESPONSE') {
|
||||||
const noneAnswerDoc = firestore
|
const noneAnswerDoc = firestore
|
||||||
.collection(`contracts/${contract.id}/answers`)
|
.collection(`contracts/${contract.id}/answers`)
|
||||||
.doc('0')
|
.doc('0')
|
||||||
|
|
||||||
const noneAnswer = getNoneAnswer(contract.id, creator)
|
const noneAnswer = getNoneAnswer(contract.id, creator)
|
||||||
await noneAnswerDoc.set(noneAnswer)
|
await noneAnswerDoc.set(noneAnswer)
|
||||||
|
|
||||||
const anteBetDoc = firestore
|
const anteBetDoc = firestore
|
||||||
.collection(`contracts/${contract.id}/bets`)
|
.collection(`contracts/${contract.id}/bets`)
|
||||||
.doc()
|
.doc()
|
||||||
|
|
||||||
const anteBet = getFreeAnswerAnte(
|
const anteBet = getFreeAnswerAnte(
|
||||||
creator,
|
providerId,
|
||||||
contract as FullContract<DPM, FreeResponse>,
|
contract as FullContract<DPM, FreeResponse>,
|
||||||
anteBetDoc.id
|
anteBetDoc.id
|
||||||
)
|
)
|
||||||
await anteBetDoc.set(anteBet)
|
await anteBetDoc.set(anteBet)
|
||||||
} else if (outcomeType === 'NUMERIC') {
|
} else if (outcomeType === 'NUMERIC') {
|
||||||
const anteBetDoc = firestore
|
const anteBetDoc = firestore
|
||||||
.collection(`contracts/${contract.id}/bets`)
|
.collection(`contracts/${contract.id}/bets`)
|
||||||
.doc()
|
.doc()
|
||||||
|
|
||||||
const anteBet = getNumericAnte(
|
const anteBet = getNumericAnte(
|
||||||
creator,
|
creator,
|
||||||
contract as FullContract<DPM, Numeric>,
|
contract as FullContract<DPM, Numeric>,
|
||||||
ante,
|
ante,
|
||||||
anteBetDoc.id
|
anteBetDoc.id
|
||||||
)
|
)
|
||||||
|
|
||||||
await anteBetDoc.set(anteBet)
|
await anteBetDoc.set(anteBet)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return { contract: contract }
|
return { contract: contract }
|
||||||
|
|
Loading…
Reference in New Issue
Block a user