9d5490cf9a
* initial commit * antes * rename path, compute to contractPath, contractMetrics * merge * Include antes as bets; more calculations * fees on estimated winnings * mkt payout calculation * contract: remove startPool, add phantomShares * Merge branch 'main' into new-dpm * dpm migration script * my service account
49 lines
1.0 KiB
TypeScript
49 lines
1.0 KiB
TypeScript
import { calcStartPool } from './antes'
|
|
|
|
import { Contract } from './contract'
|
|
import { User } from './user'
|
|
|
|
export function getNewContract(
|
|
id: string,
|
|
slug: string,
|
|
creator: User,
|
|
question: string,
|
|
description: string,
|
|
initialProb: number,
|
|
ante?: number,
|
|
closeTime?: number
|
|
) {
|
|
const { sharesYes, sharesNo, poolYes, poolNo, phantomYes, phantomNo } =
|
|
calcStartPool(initialProb, ante)
|
|
|
|
const contract: Contract = {
|
|
id,
|
|
slug,
|
|
outcomeType: 'BINARY',
|
|
|
|
creatorId: creator.id,
|
|
creatorName: creator.name,
|
|
creatorUsername: creator.username,
|
|
|
|
question: question.trim(),
|
|
description: description.trim(),
|
|
|
|
mechanism: 'dpm-2',
|
|
phantomShares: { YES: phantomYes, NO: phantomNo },
|
|
pool: { YES: poolYes, NO: poolNo },
|
|
totalShares: { YES: sharesYes, NO: sharesNo },
|
|
totalBets: { YES: poolYes, NO: poolNo },
|
|
isResolved: false,
|
|
|
|
createdTime: Date.now(),
|
|
lastUpdatedTime: Date.now(),
|
|
|
|
volume24Hours: 0,
|
|
volume7Days: 0,
|
|
}
|
|
|
|
if (closeTime) contract.closeTime = closeTime
|
|
|
|
return contract
|
|
}
|