MULTI contracts are not a thing (#381)
This commit is contained in:
parent
dec286583a
commit
35c373f6ce
|
@ -2,11 +2,11 @@ import { Answer } from './answer'
|
||||||
import { Fees } from './fees'
|
import { Fees } from './fees'
|
||||||
|
|
||||||
export type AnyMechanism = DPM | CPMM
|
export type AnyMechanism = DPM | CPMM
|
||||||
export type AnyOutcomeType = Binary | Multi | FreeResponse | Numeric
|
export type AnyOutcomeType = Binary | FreeResponse | Numeric
|
||||||
export type AnyContractType =
|
export type AnyContractType =
|
||||||
| (CPMM & Binary)
|
| (CPMM & Binary)
|
||||||
| (DPM & Binary)
|
| (DPM & Binary)
|
||||||
| (DPM & (Multi | FreeResponse))
|
| (DPM & FreeResponse)
|
||||||
| (DPM & Numeric)
|
| (DPM & Numeric)
|
||||||
|
|
||||||
export type Contract<T extends AnyContractType = AnyContractType> = {
|
export type Contract<T extends AnyContractType = AnyContractType> = {
|
||||||
|
@ -74,12 +74,6 @@ export type Binary = {
|
||||||
resolution?: 'YES' | 'NO' | 'MKT' | 'CANCEL'
|
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 = {
|
export type FreeResponse = {
|
||||||
outcomeType: 'FREE_RESPONSE'
|
outcomeType: 'FREE_RESPONSE'
|
||||||
answers: Answer[] // Used for outcomeType 'FREE_RESPONSE'.
|
answers: Answer[] // Used for outcomeType 'FREE_RESPONSE'.
|
||||||
|
@ -97,12 +91,7 @@ export type Numeric = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export type outcomeType = AnyOutcomeType['outcomeType']
|
export type outcomeType = AnyOutcomeType['outcomeType']
|
||||||
export const OUTCOME_TYPES = [
|
export const OUTCOME_TYPES = ['BINARY', 'FREE_RESPONSE', 'NUMERIC'] as const
|
||||||
'BINARY',
|
|
||||||
'MULTI',
|
|
||||||
'FREE_RESPONSE',
|
|
||||||
'NUMERIC',
|
|
||||||
] as const
|
|
||||||
export const MAX_QUESTION_LENGTH = 480
|
export const MAX_QUESTION_LENGTH = 480
|
||||||
export const MAX_DESCRIPTION_LENGTH = 10000
|
export const MAX_DESCRIPTION_LENGTH = 10000
|
||||||
export const MAX_TAG_LENGTH = 60
|
export const MAX_TAG_LENGTH = 60
|
||||||
|
|
|
@ -110,9 +110,7 @@ const toDisplayResolution = (
|
||||||
getValueFromBucket(resolution, contract).toString()
|
getValueFromBucket(resolution, contract).toString()
|
||||||
)
|
)
|
||||||
|
|
||||||
const answer = (contract as FreeResponseContract).answers?.find(
|
const answer = contract.answers.find((a) => a.id === resolution)
|
||||||
(a) => a.id === resolution
|
|
||||||
)
|
|
||||||
if (answer) return answer.text
|
if (answer) return answer.text
|
||||||
return `#${resolution}`
|
return `#${resolution}`
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { ReactNode } from 'react'
|
||||||
import { Answer } from 'common/answer'
|
import { Answer } from 'common/answer'
|
||||||
import { getProbability } from 'common/calculate'
|
import { getProbability } from 'common/calculate'
|
||||||
import { getValueFromBucket } from 'common/calculate-dpm'
|
import { getValueFromBucket } from 'common/calculate-dpm'
|
||||||
import { BinaryContract, Contract, NumericContract } from 'common/contract'
|
import { BinaryContract, Contract, FreeResponseContract } from 'common/contract'
|
||||||
import { formatPercent } from 'common/util/format'
|
import { formatPercent } from 'common/util/format'
|
||||||
import { ClientRender } from './client-render'
|
import { ClientRender } from './client-render'
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ export function OutcomeLabel(props: {
|
||||||
if (contract.outcomeType === 'NUMERIC')
|
if (contract.outcomeType === 'NUMERIC')
|
||||||
return (
|
return (
|
||||||
<span className="text-blue-500">
|
<span className="text-blue-500">
|
||||||
{value ?? getValueFromBucket(outcome, contract as NumericContract)}
|
{value ?? getValueFromBucket(outcome, contract)}
|
||||||
</span>
|
</span>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ export function BinaryContractOutcomeLabel(props: {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function FreeResponseOutcomeLabel(props: {
|
export function FreeResponseOutcomeLabel(props: {
|
||||||
contract: Contract
|
contract: FreeResponseContract
|
||||||
resolution: string | 'CANCEL' | 'MKT'
|
resolution: string | 'CANCEL' | 'MKT'
|
||||||
truncate: 'short' | 'long' | 'none'
|
truncate: 'short' | 'long' | 'none'
|
||||||
answerClassName?: string
|
answerClassName?: string
|
||||||
|
@ -71,9 +71,7 @@ export function FreeResponseOutcomeLabel(props: {
|
||||||
if (resolution === 'CANCEL') return <CancelLabel />
|
if (resolution === 'CANCEL') return <CancelLabel />
|
||||||
if (resolution === 'MKT') return <MultiLabel />
|
if (resolution === 'MKT') return <MultiLabel />
|
||||||
|
|
||||||
const answers =
|
const chosen = contract.answers.find((answer) => answer.id === resolution)
|
||||||
contract.outcomeType === 'FREE_RESPONSE' ? contract.answers : []
|
|
||||||
const chosen = answers.find((answer) => answer.id === resolution)
|
|
||||||
if (!chosen) return <AnswerNumberLabel number={resolution} />
|
if (!chosen) return <AnswerNumberLabel number={resolution} />
|
||||||
return (
|
return (
|
||||||
<FreeResponseAnswerToolTip text={chosen.text}>
|
<FreeResponseAnswerToolTip text={chosen.text}>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user