2022-01-10 23:52:03 +00:00
|
|
|
import { calcStartPool } from './antes'
|
|
|
|
import { Contract } from './contract'
|
|
|
|
import { User } from './user'
|
2022-01-10 22:49:04 +00:00
|
|
|
|
|
|
|
export function getNewContract(
|
|
|
|
id: string,
|
|
|
|
slug: string,
|
|
|
|
creator: User,
|
|
|
|
question: string,
|
|
|
|
description: string,
|
|
|
|
initialProb: number,
|
|
|
|
ante?: number,
|
|
|
|
closeTime?: number
|
|
|
|
) {
|
|
|
|
const { startYes, startNo, poolYes, poolNo } = calcStartPool(
|
|
|
|
initialProb,
|
|
|
|
ante
|
2022-01-10 23:52:03 +00:00
|
|
|
)
|
2022-01-10 22:49:04 +00:00
|
|
|
|
|
|
|
const contract: Contract = {
|
|
|
|
id,
|
|
|
|
slug,
|
2022-01-10 23:52:03 +00:00
|
|
|
outcomeType: 'BINARY',
|
2022-01-10 22:49:04 +00:00
|
|
|
|
|
|
|
creatorId: creator.id,
|
|
|
|
creatorName: creator.name,
|
|
|
|
creatorUsername: creator.username,
|
|
|
|
|
|
|
|
question: question.trim(),
|
|
|
|
description: description.trim(),
|
|
|
|
|
|
|
|
startPool: { YES: startYes, NO: startNo },
|
|
|
|
pool: { YES: poolYes, NO: poolNo },
|
|
|
|
totalShares: { YES: 0, NO: 0 },
|
|
|
|
totalBets: { YES: 0, NO: 0 },
|
|
|
|
isResolved: false,
|
|
|
|
|
|
|
|
createdTime: Date.now(),
|
|
|
|
lastUpdatedTime: Date.now(),
|
|
|
|
|
|
|
|
volume24Hours: 0,
|
|
|
|
volume7Days: 0,
|
2022-01-10 23:52:03 +00:00
|
|
|
}
|
2022-01-10 22:49:04 +00:00
|
|
|
|
2022-01-10 23:52:03 +00:00
|
|
|
if (closeTime) contract.closeTime = closeTime
|
2022-01-10 22:49:04 +00:00
|
|
|
|
2022-01-10 23:52:03 +00:00
|
|
|
return contract
|
2022-01-10 22:49:04 +00:00
|
|
|
}
|