contract type
This commit is contained in:
parent
b05d8b3d3c
commit
d91abf4faf
|
@ -4,7 +4,7 @@ import { useEffect, useRef, useState } from 'react'
|
|||
import { XIcon } from '@heroicons/react/solid'
|
||||
|
||||
import { Answer } from '../../../common/answer'
|
||||
import { Contract } from '../../../common/contract'
|
||||
import { DPM, FreeResponse, FullContract } from '../../../common/contract'
|
||||
import { AmountInput } from '../amount-input'
|
||||
import { Col } from '../layout/col'
|
||||
import { placeBet } from '../../lib/firebase/api-call'
|
||||
|
@ -28,7 +28,7 @@ import { Bet } from '../../../common/bet'
|
|||
|
||||
export function AnswerBetPanel(props: {
|
||||
answer: Answer
|
||||
contract: Contract
|
||||
contract: FullContract<DPM, FreeResponse>
|
||||
closePanel: () => void
|
||||
className?: string
|
||||
}) {
|
||||
|
|
|
@ -3,7 +3,7 @@ import _ from 'lodash'
|
|||
import { useState } from 'react'
|
||||
|
||||
import { Answer } from '../../../common/answer'
|
||||
import { Contract } from '../../../common/contract'
|
||||
import { DPM, FreeResponse, FullContract } from '../../../common/contract'
|
||||
import { Col } from '../layout/col'
|
||||
import { Row } from '../layout/row'
|
||||
import { Avatar } from '../avatar'
|
||||
|
@ -18,7 +18,7 @@ import { Linkify } from '../linkify'
|
|||
|
||||
export function AnswerItem(props: {
|
||||
answer: Answer
|
||||
contract: Contract
|
||||
contract: FullContract<DPM, FreeResponse>
|
||||
showChoice: 'radio' | 'checkbox' | undefined
|
||||
chosenProb: number | undefined
|
||||
totalChosenProb?: number
|
||||
|
|
|
@ -2,7 +2,7 @@ import clsx from 'clsx'
|
|||
import _ from 'lodash'
|
||||
import { useState } from 'react'
|
||||
|
||||
import { Contract } from '../../../common/contract'
|
||||
import { DPM, FreeResponse, FullContract } from '../../../common/contract'
|
||||
import { Col } from '../layout/col'
|
||||
import { resolveMarket } from '../../lib/firebase/api-call'
|
||||
import { Row } from '../layout/row'
|
||||
|
@ -11,7 +11,7 @@ import { ResolveConfirmationButton } from '../confirmation-button'
|
|||
import { removeUndefinedProps } from '../../../common/util/object'
|
||||
|
||||
export function AnswerResolvePanel(props: {
|
||||
contract: Contract
|
||||
contract: FullContract<DPM, FreeResponse>
|
||||
resolveOption: 'CHOOSE' | 'CHOOSE_MULTIPLE' | 'CANCEL' | undefined
|
||||
setResolveOption: (
|
||||
option: 'CHOOSE' | 'CHOOSE_MULTIPLE' | 'CANCEL' | undefined
|
||||
|
|
|
@ -2,7 +2,7 @@ import _ from 'lodash'
|
|||
import { useLayoutEffect, useState } from 'react'
|
||||
|
||||
import { Answer } from '../../../common/answer'
|
||||
import { Contract } from '../../../common/contract'
|
||||
import { DPM, FreeResponse, FullContract } from '../../../common/contract'
|
||||
import { Col } from '../layout/col'
|
||||
import { formatPercent } from '../../../common/util/format'
|
||||
import { useUser } from '../../hooks/use-user'
|
||||
|
@ -13,7 +13,10 @@ import { AnswerItem } from './answer-item'
|
|||
import { CreateAnswerPanel } from './create-answer-panel'
|
||||
import { AnswerResolvePanel } from './answer-resolve-panel'
|
||||
|
||||
export function AnswersPanel(props: { contract: Contract; answers: Answer[] }) {
|
||||
export function AnswersPanel(props: {
|
||||
contract: FullContract<DPM, FreeResponse>
|
||||
answers: Answer[]
|
||||
}) {
|
||||
const { contract } = props
|
||||
const { creatorId, resolution, resolutions, totalBets } = contract
|
||||
|
||||
|
|
|
@ -3,7 +3,12 @@ import _ from 'lodash'
|
|||
import { useState } from 'react'
|
||||
import Textarea from 'react-expanding-textarea'
|
||||
|
||||
import { Contract } from '../../../common/contract'
|
||||
import {
|
||||
Contract,
|
||||
DPM,
|
||||
FreeResponse,
|
||||
FullContract,
|
||||
} from '../../../common/contract'
|
||||
import { AmountInput } from '../amount-input'
|
||||
import { Col } from '../layout/col'
|
||||
import { createAnswer } from '../../lib/firebase/api-call'
|
||||
|
@ -23,7 +28,9 @@ import {
|
|||
import { firebaseLogin } from '../../lib/firebase/users'
|
||||
import { Bet } from '../../../common/bet'
|
||||
|
||||
export function CreateAnswerPanel(props: { contract: Contract }) {
|
||||
export function CreateAnswerPanel(props: {
|
||||
contract: FullContract<DPM, FreeResponse>
|
||||
}) {
|
||||
const { contract } = props
|
||||
const user = useUser()
|
||||
const [text, setText] = useState('')
|
||||
|
|
|
@ -42,6 +42,7 @@ import BetRow from './bet-row'
|
|||
import { parseTags } from '../../common/util/parse'
|
||||
import { Avatar } from './avatar'
|
||||
import { useAdmin } from '../hooks/use-admin'
|
||||
import { FreeResponse, FullContract } from '../../common/contract'
|
||||
|
||||
function FeedComment(props: {
|
||||
activityItem: any
|
||||
|
@ -384,7 +385,10 @@ function FeedDescription(props: { contract: Contract }) {
|
|||
)
|
||||
}
|
||||
|
||||
function FeedAnswer(props: { contract: Contract; outcome: string }) {
|
||||
function FeedAnswer(props: {
|
||||
contract: FullContract<any, FreeResponse>
|
||||
outcome: string
|
||||
}) {
|
||||
const { contract, outcome } = props
|
||||
const answer = contract?.answers?.[Number(outcome) - 1]
|
||||
if (!answer) return null
|
||||
|
|
|
@ -17,9 +17,10 @@ import _ from 'lodash'
|
|||
|
||||
import { app } from './init'
|
||||
import { getValues, listenForValue, listenForValues } from './utils'
|
||||
import { Contract } from '../../../common/contract'
|
||||
import { Binary, Contract, FullContract } from '../../../common/contract'
|
||||
import { getProbability } from '../../../common/calculate'
|
||||
import { createRNG, shuffle } from '../../../common/util/random'
|
||||
import { getCpmmProbability } from '../../../common/calculate-cpmm'
|
||||
export type { Contract }
|
||||
|
||||
export function contractPath(contract: Contract) {
|
||||
|
@ -40,12 +41,15 @@ export function contractMetrics(contract: Contract) {
|
|||
return { truePool, createdDate, resolvedDate }
|
||||
}
|
||||
|
||||
export function getBinaryProbPercent(contract: Contract) {
|
||||
const { totalShares, resolutionProbability } = contract
|
||||
export function getBinaryProbPercent(contract: FullContract<any, Binary>) {
|
||||
const { totalShares, pool, resolutionProbability, mechanism } = contract
|
||||
|
||||
const prob =
|
||||
resolutionProbability ?? mechanism === 'cpmm-1'
|
||||
? getCpmmProbability(pool)
|
||||
: getProbability(totalShares)
|
||||
|
||||
const prob = resolutionProbability ?? getProbability(totalShares)
|
||||
const probPercent = Math.round(prob * 100) + '%'
|
||||
|
||||
return probPercent
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user