outcome label
This commit is contained in:
parent
39b745b25a
commit
17fca14084
|
@ -74,6 +74,17 @@ export const getMappedBucket = (value: number, contract: NumericContract) => {
|
|||
return `${bucket}`
|
||||
}
|
||||
|
||||
export const getValueFromBucket = (
|
||||
bucket: string,
|
||||
contract: NumericContract
|
||||
) => {
|
||||
const { bucketCount, min, max } = contract
|
||||
const index = parseInt(bucket)
|
||||
const value = min + (index / bucketCount) * (max - min)
|
||||
const rounded = Math.round(value * 1e4) / 1e4
|
||||
return rounded
|
||||
}
|
||||
|
||||
export function getDpmOutcomeProbabilityAfterBet(
|
||||
totalShares: {
|
||||
[outcome: string]: number
|
||||
|
|
|
@ -48,7 +48,7 @@ export type Contract = FullContract<
|
|||
>
|
||||
export type BinaryContract = FullContract<DPM | CPMM, Binary>
|
||||
export type FreeResponseContract = FullContract<DPM | CPMM, FreeResponse>
|
||||
export type NumericContract = FullContract<DPM, Numeric>
|
||||
export type NumericContract = FullContract<any, Numeric>
|
||||
|
||||
export type DPM = {
|
||||
mechanism: 'dpm-2'
|
||||
|
|
|
@ -4,6 +4,7 @@ import { DOMAIN, PROJECT_ID } from 'common/envs/constants'
|
|||
import { Answer } from 'common/answer'
|
||||
import { Bet } from 'common/bet'
|
||||
import { getProbability } from 'common/calculate'
|
||||
import { getValueFromBucket } from 'common/calculate-dpm'
|
||||
import { Comment } from 'common/comment'
|
||||
import { Contract, FreeResponseContract } from 'common/contract'
|
||||
import { DPM_CREATOR_FEE } from 'common/fees'
|
||||
|
@ -105,6 +106,9 @@ const toDisplayResolution = (
|
|||
if (resolution === 'MKT' && resolutions) return 'MULTI'
|
||||
if (resolution === 'CANCEL') return 'N/A'
|
||||
|
||||
if (contract.outcomeType === 'NUMERIC')
|
||||
return getValueFromBucket(resolution, contract).toString()
|
||||
|
||||
const answer = (contract as FreeResponseContract).answers?.find(
|
||||
(a) => a.id === resolution
|
||||
)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import clsx from 'clsx'
|
||||
import { Answer } from 'common/answer'
|
||||
import { getProbability } from 'common/calculate'
|
||||
import { getValueFromBucket } from 'common/calculate-dpm'
|
||||
import {
|
||||
Binary,
|
||||
Contract,
|
||||
|
@ -23,6 +24,13 @@ export function OutcomeLabel(props: {
|
|||
if (contract.outcomeType === 'BINARY')
|
||||
return <BinaryOutcomeLabel outcome={outcome as any} />
|
||||
|
||||
if (contract.outcomeType === 'NUMERIC')
|
||||
return (
|
||||
<span className="text-indigo-500">
|
||||
{getValueFromBucket(outcome, contract)}
|
||||
</span>
|
||||
)
|
||||
|
||||
return (
|
||||
<FreeResponseOutcomeLabel
|
||||
contract={contract as FullContract<DPM, FreeResponse>}
|
||||
|
|
Loading…
Reference in New Issue
Block a user