2022-02-17 23:00:19 +00:00
|
|
|
import { Answer } from './answer'
|
2022-03-15 22:27:51 +00:00
|
|
|
import { Fees } from './fees'
|
2022-02-17 23:00:19 +00:00
|
|
|
|
2022-03-15 22:27:51 +00:00
|
|
|
export type FullContract<
|
|
|
|
M extends DPM | CPMM,
|
|
|
|
T extends Binary | Multi | FreeResponse
|
|
|
|
> = {
|
2022-01-10 23:52:03 +00:00
|
|
|
id: string
|
|
|
|
slug: string // auto-generated; must be unique
|
2022-01-10 21:07:57 +00:00
|
|
|
|
2022-01-10 23:52:03 +00:00
|
|
|
creatorId: string
|
|
|
|
creatorName: string
|
|
|
|
creatorUsername: string
|
2022-05-04 18:07:22 +00:00
|
|
|
creatorAvatarUrl: string
|
2022-01-10 21:07:57 +00:00
|
|
|
|
2022-01-10 23:52:03 +00:00
|
|
|
question: string
|
|
|
|
description: string // More info about what the contract is about
|
2022-01-21 23:21:46 +00:00
|
|
|
tags: string[]
|
2022-01-24 22:33:02 +00:00
|
|
|
lowercaseTags: string[]
|
2022-01-13 01:53:50 +00:00
|
|
|
visibility: 'public' | 'unlisted'
|
2022-01-10 21:07:57 +00:00
|
|
|
|
2022-01-10 23:52:03 +00:00
|
|
|
createdTime: number // Milliseconds since epoch
|
2022-05-01 16:36:54 +00:00
|
|
|
lastUpdatedTime?: number // Updated on new bet or comment
|
|
|
|
lastBetTime?: number
|
|
|
|
lastCommentTime?: number
|
2022-01-10 23:52:03 +00:00
|
|
|
closeTime?: number // When no more trading is allowed
|
2022-01-10 21:07:57 +00:00
|
|
|
|
2022-01-10 23:52:03 +00:00
|
|
|
isResolved: boolean
|
|
|
|
resolutionTime?: number // When the contract creator resolved the market
|
2022-02-17 23:00:19 +00:00
|
|
|
resolution?: string
|
2022-03-15 22:27:51 +00:00
|
|
|
|
2022-02-17 18:18:02 +00:00
|
|
|
closeEmailsSent?: number
|
2022-01-10 21:07:57 +00:00
|
|
|
|
2022-03-23 05:09:47 +00:00
|
|
|
volume: number
|
2022-01-10 23:52:03 +00:00
|
|
|
volume24Hours: number
|
|
|
|
volume7Days: number
|
2022-03-15 22:27:51 +00:00
|
|
|
|
|
|
|
collectedFees: Fees
|
|
|
|
} & M &
|
|
|
|
T
|
|
|
|
|
|
|
|
export type Contract = FullContract<DPM | CPMM, Binary | Multi | FreeResponse>
|
2022-04-18 23:02:40 +00:00
|
|
|
export type BinaryContract = FullContract<DPM | CPMM, Binary>
|
|
|
|
export type FreeResponseContract = FullContract<DPM | CPMM, FreeResponse>
|
2022-03-15 22:27:51 +00:00
|
|
|
|
|
|
|
export type DPM = {
|
|
|
|
mechanism: 'dpm-2'
|
|
|
|
|
|
|
|
pool: { [outcome: string]: number }
|
|
|
|
phantomShares?: { [outcome: string]: number }
|
|
|
|
totalShares: { [outcome: string]: number }
|
|
|
|
totalBets: { [outcome: string]: number }
|
|
|
|
}
|
|
|
|
|
|
|
|
export type CPMM = {
|
|
|
|
mechanism: 'cpmm-1'
|
|
|
|
pool: { [outcome: string]: number }
|
|
|
|
p: number // probability constant in y^p * n^(1-p) = k
|
|
|
|
totalLiquidity: number // in M$
|
|
|
|
}
|
|
|
|
|
|
|
|
export type FixedPayouts = CPMM
|
|
|
|
|
|
|
|
export type Binary = {
|
|
|
|
outcomeType: 'BINARY'
|
|
|
|
initialProbability: number
|
|
|
|
resolutionProbability?: number // Used for BINARY markets resolved to MKT
|
2022-04-18 23:02:40 +00:00
|
|
|
resolution?: 'YES' | 'NO' | 'MKT' | 'CANCEL'
|
2022-03-15 22:27:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export type Multi = {
|
|
|
|
outcomeType: 'MULTI'
|
|
|
|
multiOutcomes: string[] // Used for outcomeType 'MULTI'.
|
2022-04-18 23:02:40 +00:00
|
|
|
resolutions?: { [outcome: string]: number } // Used for MKT resolution.
|
2022-03-15 22:27:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export type FreeResponse = {
|
|
|
|
outcomeType: 'FREE_RESPONSE'
|
|
|
|
answers: Answer[] // Used for outcomeType 'FREE_RESPONSE'.
|
2022-04-18 23:02:40 +00:00
|
|
|
resolution?: string | 'MKT' | 'CANCEL'
|
|
|
|
resolutions?: { [outcome: string]: number } // Used for MKT resolution.
|
2022-01-10 23:52:03 +00:00
|
|
|
}
|
2022-01-22 23:59:50 +00:00
|
|
|
|
2022-02-17 23:00:19 +00:00
|
|
|
export type outcomeType = 'BINARY' | 'MULTI' | 'FREE_RESPONSE'
|
2022-03-09 17:08:57 +00:00
|
|
|
|
|
|
|
export const MAX_QUESTION_LENGTH = 480
|
|
|
|
export const MAX_DESCRIPTION_LENGTH = 10000
|
|
|
|
export const MAX_TAG_LENGTH = 60
|