76f27d1a93
* Numeric contract type * Create market numeric type * Add numeric graph (coded without testing) * Outline of numeric bet panel * Update bet panel logic * create numeric contracts * remove batching for antes for numeric markets * Remove focus * numeric market range [1, 100] * Zoom graph * Hide bet panels * getNumericBets * Add numeric resolution panel * Use getNumericBets in bet panel calc * Switch bucket count to 100 * Parallelize ante creation * placeBet for numeric markets * halve std of numeric bets * Update resolveMarket with numeric type * Set min and max for contract * lower std for numeric bets * calculateNumericDpmShares: use sorted order * Use min and max to map the input * Fix probability calc * normpdf variance mislabeled * range input * merge * change numeric graph color * fix getNewContract params * bet panel labels * validation * number input * fix bucketing * bucket input, numeric resolution panel * outcome label * merge * numeric bet panel on mobile * Make text underneath filled green answer bar selectable * Default to 'all' feed category when loading page. * fix numeric resolution panel * fix numeric bet panel calculations * display numeric resolution * don't render NumericBetPanel for non numeric markets * numeric bets: store shares, bet amounts across buckets in each bet object * restore your bets for numeric markets * numeric pnl calculations * remove hasUserHitManaLimit * contrain contract type * handle undefined allOutcomeShares * numeric ante bet amount * use correct amount for numeric dpm payouts * change numeric graph/outcome color * numeric constants * hack to show correct numeric payout in calculateDpmPayoutAfterCorrectBet * remove comment * fix ante display in bet list * halve bucket count * cast to NumericContract * fix merge imports * OUTCOME_TYPES * typo * lower bucket count to 200 * store raw numeric value with bet * store raw numeric resolution value * number input max length * create page: min, max to undefined if not numeric market * numeric resolution formatting * expected value for numeric markets * expected value for numeric markets * rearrange lines for readability * move normalpdf to util/math * show bets tab * check if outcomeMode is undefined * remove extraneous auto-merge cruft * hide comment status for numeric markets * import Co-authored-by: mantikoros <sgrugett@gmail.com>
106 lines
2.8 KiB
TypeScript
106 lines
2.8 KiB
TypeScript
import * as _ from 'lodash'
|
|
import { Answer } from './answer'
|
|
import { Fees } from './fees'
|
|
|
|
export type FullContract<
|
|
M extends DPM | CPMM,
|
|
T extends Binary | Multi | FreeResponse | Numeric
|
|
> = {
|
|
id: string
|
|
slug: string // auto-generated; must be unique
|
|
|
|
creatorId: string
|
|
creatorName: string
|
|
creatorUsername: string
|
|
creatorAvatarUrl?: string
|
|
|
|
question: string
|
|
description: string // More info about what the contract is about
|
|
tags: string[]
|
|
lowercaseTags: string[]
|
|
visibility: 'public' | 'unlisted'
|
|
|
|
createdTime: number // Milliseconds since epoch
|
|
lastUpdatedTime?: number // Updated on new bet or comment
|
|
lastBetTime?: number
|
|
lastCommentTime?: number
|
|
closeTime?: number // When no more trading is allowed
|
|
|
|
isResolved: boolean
|
|
resolutionTime?: number // When the contract creator resolved the market
|
|
resolution?: string
|
|
|
|
closeEmailsSent?: number
|
|
|
|
manaLimitPerUser?: number
|
|
|
|
volume: number
|
|
volume24Hours: number
|
|
volume7Days: number
|
|
|
|
collectedFees: Fees
|
|
} & M &
|
|
T
|
|
|
|
export type Contract = FullContract<
|
|
DPM | CPMM,
|
|
Binary | Multi | FreeResponse | Numeric
|
|
>
|
|
export type BinaryContract = FullContract<DPM | CPMM, Binary>
|
|
export type FreeResponseContract = FullContract<DPM | CPMM, FreeResponse>
|
|
export type NumericContract = FullContract<DPM, Numeric>
|
|
|
|
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
|
|
resolution?: 'YES' | 'NO' | 'MKT' | 'CANCEL'
|
|
}
|
|
|
|
export type Multi = {
|
|
outcomeType: 'MULTI'
|
|
multiOutcomes: string[] // Used for outcomeType 'MULTI'.
|
|
resolutions?: { [outcome: string]: number } // Used for MKT resolution.
|
|
}
|
|
|
|
export type FreeResponse = {
|
|
outcomeType: 'FREE_RESPONSE'
|
|
answers: Answer[] // Used for outcomeType 'FREE_RESPONSE'.
|
|
resolution?: string | 'MKT' | 'CANCEL'
|
|
resolutions?: { [outcome: string]: number } // Used for MKT resolution.
|
|
}
|
|
|
|
export type Numeric = {
|
|
outcomeType: 'NUMERIC'
|
|
bucketCount: number
|
|
min: number
|
|
max: number
|
|
resolutions?: { [outcome: string]: number } // Used for MKT resolution.
|
|
resolutionValue?: number
|
|
}
|
|
|
|
export type outcomeType = 'BINARY' | 'MULTI' | 'FREE_RESPONSE' | 'NUMERIC'
|
|
export const OUTCOME_TYPES = ['BINARY', 'MULTI', 'FREE_RESPONSE', 'NUMERIC']
|
|
|
|
export const MAX_QUESTION_LENGTH = 480
|
|
export const MAX_DESCRIPTION_LENGTH = 10000
|
|
export const MAX_TAG_LENGTH = 60
|