diff --git a/web/components/bet-panel.tsx b/web/components/bet-panel.tsx index 47130441..e965ec3d 100644 --- a/web/components/bet-panel.tsx +++ b/web/components/bet-panel.tsx @@ -33,7 +33,10 @@ import { getCpmmLiquidityFee, calculateCpmmAmount, } from 'common/calculate-cpmm' -import { getFormattedMappedValue } from 'common/pseudo-numeric' +import { + getFormattedMappedValue, + getPseudoProbability, +} from 'common/pseudo-numeric' import { SellRow } from './sell-row' import { useSaveShares } from './use-save-shares' import { SignUpPrompt } from './sign-up-prompt' @@ -43,6 +46,7 @@ import { track } from 'web/lib/service/analytics' import { removeUndefinedProps } from 'common/util/object' import { useUnfilledBets } from 'web/hooks/use-bets' import { LimitBets } from './limit-bets' +import { BucketInput } from './bucket-input' export function BetPanel(props: { contract: CPMMBinaryContract | PseudoNumericContract @@ -98,7 +102,11 @@ export function BetPanel(props: { {yourUnfilledBets.length > 0 && ( - + )} ) @@ -407,16 +415,37 @@ function BuyPanel(props: { {isLimitOrder && ( <>
- {betChoice === 'NO' ? 'Min' : 'Max'} probability + {betChoice === 'NO' ? 'Min' : 'Max'}{' '} + {isPseudoNumeric ? 'value' : 'probability'}
- + {isPseudoNumeric ? ( + + setLimitProb( + value === undefined + ? undefined + : 100 * + getPseudoProbability( + value, + contract.min, + contract.max, + contract.isLogScale + ) + ) + } + isSubmitting={isSubmitting} + /> + ) : ( + + )} )} diff --git a/web/components/bucket-input.tsx b/web/components/bucket-input.tsx index 86456bff..195032dc 100644 --- a/web/components/bucket-input.tsx +++ b/web/components/bucket-input.tsx @@ -1,12 +1,12 @@ import { useState } from 'react' -import { NumericContract } from 'common/contract' +import { NumericContract, PseudoNumericContract } from 'common/contract' import { getMappedBucket } from 'common/calculate-dpm' import { NumberInput } from './number-input' export function BucketInput(props: { - contract: NumericContract + contract: NumericContract | PseudoNumericContract isSubmitting?: boolean onBucketChange: (value?: number, bucket?: string) => void }) { @@ -24,7 +24,10 @@ export function BucketInput(props: { return } - const bucket = getMappedBucket(value, contract) + const bucket = + contract.outcomeType === 'PSEUDO_NUMERIC' + ? '' + : getMappedBucket(value, contract) onBucketChange(value, bucket) } diff --git a/web/components/limit-bets.tsx b/web/components/limit-bets.tsx index 3538cc4d..4dd70819 100644 --- a/web/components/limit-bets.tsx +++ b/web/components/limit-bets.tsx @@ -1,15 +1,21 @@ import clsx from 'clsx' import { LimitBet } from 'common/bet' +import { CPMMBinaryContract, PseudoNumericContract } from 'common/contract' +import { getFormattedMappedValue } from 'common/pseudo-numeric' import { formatMoney, formatPercent } from 'common/util/format' -import { sortBy, sumBy } from 'lodash' +import { sortBy } from 'lodash' import { useState } from 'react' import { cancelBet } from 'web/lib/firebase/api-call' import { Col } from './layout/col' import { LoadingIndicator } from './loading-indicator' -import { BinaryOutcomeLabel } from './outcome-label' +import { BinaryOutcomeLabel, PseudoNumericOutcomeLabel } from './outcome-label' -export function LimitBets(props: { bets: LimitBet[]; className?: string }) { - const { bets, className } = props +export function LimitBets(props: { + contract: CPMMBinaryContract | PseudoNumericContract + bets: LimitBet[] + className?: string +}) { + const { contract, bets, className } = props const recentBets = sortBy(bets, (bet) => bet.createdTime).reverse() return ( @@ -18,7 +24,7 @@ export function LimitBets(props: { bets: LimitBet[]; className?: string }) { {recentBets.map((bet) => ( - + ))}
@@ -26,9 +32,14 @@ export function LimitBets(props: { bets: LimitBet[]; className?: string }) { ) } -function LimitBet(props: { bet: LimitBet }) { - const { bet } = props +function LimitBet(props: { + contract: CPMMBinaryContract | PseudoNumericContract + bet: LimitBet +}) { + const { contract, bet } = props const { orderAmount, amount, limitProb, outcome } = bet + const isPseudoNumeric = contract.outcomeType === 'PSEUDO_NUMERIC' + const [isCancelling, setIsCancelling] = useState(false) const onCancel = () => { @@ -40,11 +51,19 @@ function LimitBet(props: { bet: LimitBet }) {
- + {isPseudoNumeric ? ( + + ) : ( + + )}
{formatMoney(orderAmount - amount)} - {formatPercent(limitProb)} + + {isPseudoNumeric + ? getFormattedMappedValue(contract)(limitProb) + : formatPercent(limitProb)} + {isCancelling ? ( diff --git a/web/components/numeric-resolution-panel.tsx b/web/components/numeric-resolution-panel.tsx index cf111281..98a2aabc 100644 --- a/web/components/numeric-resolution-panel.tsx +++ b/web/components/numeric-resolution-panel.tsx @@ -96,7 +96,7 @@ export function NumericResolutionPanel(props: { {outcomeMode === 'NUMBER' && ( (setValue(v), setOutcome(o))} /> diff --git a/web/pages/[username]/[contractSlug].tsx b/web/pages/[username]/[contractSlug].tsx index 4e0327b4..95a95948 100644 --- a/web/pages/[username]/[contractSlug].tsx +++ b/web/pages/[username]/[contractSlug].tsx @@ -39,7 +39,7 @@ import { FeedBet } from 'web/components/feed/feed-bets' import { useIsIframe } from 'web/hooks/use-is-iframe' import ContractEmbedPage from '../embed/[username]/[contractSlug]' import { useBets, useUnfilledBets } from 'web/hooks/use-bets' -import { CPMMBinaryContract } from 'common/contract' +import { CPMMBinaryContract, PseudoNumericContract } from 'common/contract' import { AlertBox } from 'web/components/alert-box' import { useTracking } from 'web/hooks/use-tracking' import { CommentTipMap, useTipTxns } from 'web/hooks/use-tip-txns' @@ -222,7 +222,11 @@ export function ContractPageContent( {yourUnfilledBets.length > 0 && ( - + )} {isNumeric && (