bet labeling
This commit is contained in:
parent
dffc61ebe4
commit
716588eb57
|
|
@ -8,6 +8,7 @@ import { useUserBets } from 'web/hooks/use-user-bets'
|
||||||
import { Bet } from 'web/lib/firebase/bets'
|
import { Bet } from 'web/lib/firebase/bets'
|
||||||
import { User } from 'web/lib/firebase/users'
|
import { User } from 'web/lib/firebase/users'
|
||||||
import {
|
import {
|
||||||
|
formatLargeNumber,
|
||||||
formatMoney,
|
formatMoney,
|
||||||
formatPercent,
|
formatPercent,
|
||||||
formatWithCommas,
|
formatWithCommas,
|
||||||
|
|
@ -24,13 +25,7 @@ import { Row } from './layout/row'
|
||||||
import { UserLink } from './user-page'
|
import { UserLink } from './user-page'
|
||||||
import { sellBet } from 'web/lib/firebase/api-call'
|
import { sellBet } from 'web/lib/firebase/api-call'
|
||||||
import { ConfirmationButton } from './confirmation-button'
|
import { ConfirmationButton } from './confirmation-button'
|
||||||
import {
|
import { OutcomeLabel, YesLabel, NoLabel } from './outcome-label'
|
||||||
OutcomeLabel,
|
|
||||||
YesLabel,
|
|
||||||
NoLabel,
|
|
||||||
HigherLabel,
|
|
||||||
LowerLabel,
|
|
||||||
} from './outcome-label'
|
|
||||||
import { filterDefined } from 'common/util/array'
|
import { filterDefined } from 'common/util/array'
|
||||||
import { LoadingIndicator } from './loading-indicator'
|
import { LoadingIndicator } from './loading-indicator'
|
||||||
import { SiteLink } from './site-link'
|
import { SiteLink } from './site-link'
|
||||||
|
|
@ -46,6 +41,7 @@ import {
|
||||||
import { useTimeSinceFirstRender } from 'web/hooks/use-time-since-first-render'
|
import { useTimeSinceFirstRender } from 'web/hooks/use-time-since-first-render'
|
||||||
import { trackLatency } from 'web/lib/firebase/tracking'
|
import { trackLatency } from 'web/lib/firebase/tracking'
|
||||||
import { NumericContract } from 'common/contract'
|
import { NumericContract } from 'common/contract'
|
||||||
|
import { formatNumericProbability } from 'common/pseudo-numeric'
|
||||||
import { useUser } from 'web/hooks/use-user'
|
import { useUser } from 'web/hooks/use-user'
|
||||||
import { SellSharesModal } from './sell-modal'
|
import { SellSharesModal } from './sell-modal'
|
||||||
|
|
||||||
|
|
@ -438,7 +434,7 @@ export function BetsSummary(props: {
|
||||||
<>
|
<>
|
||||||
<Col>
|
<Col>
|
||||||
<div className="whitespace-nowrap text-sm text-gray-500">
|
<div className="whitespace-nowrap text-sm text-gray-500">
|
||||||
Payout if <HigherLabel />
|
Payout if {'>='} {formatLargeNumber(contract.max)}
|
||||||
</div>
|
</div>
|
||||||
<div className="whitespace-nowrap">
|
<div className="whitespace-nowrap">
|
||||||
{formatMoney(yesWinnings)}
|
{formatMoney(yesWinnings)}
|
||||||
|
|
@ -446,7 +442,7 @@ export function BetsSummary(props: {
|
||||||
</Col>
|
</Col>
|
||||||
<Col>
|
<Col>
|
||||||
<div className="whitespace-nowrap text-sm text-gray-500">
|
<div className="whitespace-nowrap text-sm text-gray-500">
|
||||||
Payout if <LowerLabel />
|
Payout if {'<='} {formatLargeNumber(contract.min)}
|
||||||
</div>
|
</div>
|
||||||
<div className="whitespace-nowrap">
|
<div className="whitespace-nowrap">
|
||||||
{formatMoney(noWinnings)}
|
{formatMoney(noWinnings)}
|
||||||
|
|
@ -533,13 +529,15 @@ export function ContractBetsTable(props: {
|
||||||
const { isResolved, mechanism, outcomeType } = contract
|
const { isResolved, mechanism, outcomeType } = contract
|
||||||
const isCPMM = mechanism === 'cpmm-1'
|
const isCPMM = mechanism === 'cpmm-1'
|
||||||
const isNumeric = outcomeType === 'NUMERIC'
|
const isNumeric = outcomeType === 'NUMERIC'
|
||||||
|
const isPseudoNumeric = outcomeType === 'PSEUDO_NUMERIC'
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={clsx('overflow-x-auto', className)}>
|
<div className={clsx('overflow-x-auto', className)}>
|
||||||
{amountRedeemed > 0 && (
|
{amountRedeemed > 0 && (
|
||||||
<>
|
<>
|
||||||
<div className="pl-2 text-sm text-gray-500">
|
<div className="pl-2 text-sm text-gray-500">
|
||||||
{amountRedeemed} YES shares and {amountRedeemed} NO shares
|
{amountRedeemed} {isPseudoNumeric ? 'HIGHER' : 'YES'} shares and{' '}
|
||||||
|
{amountRedeemed} {isPseudoNumeric ? 'LOWER' : 'NO'} shares
|
||||||
automatically redeemed for {formatMoney(amountRedeemed)}.
|
automatically redeemed for {formatMoney(amountRedeemed)}.
|
||||||
</div>
|
</div>
|
||||||
<Spacer h={4} />
|
<Spacer h={4} />
|
||||||
|
|
@ -567,7 +565,7 @@ export function ContractBetsTable(props: {
|
||||||
)}
|
)}
|
||||||
{!isCPMM && !isResolved && <th>Payout if chosen</th>}
|
{!isCPMM && !isResolved && <th>Payout if chosen</th>}
|
||||||
<th>Shares</th>
|
<th>Shares</th>
|
||||||
<th>Probability</th>
|
{!isPseudoNumeric && <th>Probability</th>}
|
||||||
<th>Date</th>
|
<th>Date</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
@ -611,6 +609,7 @@ function BetRow(props: {
|
||||||
|
|
||||||
const isCPMM = mechanism === 'cpmm-1'
|
const isCPMM = mechanism === 'cpmm-1'
|
||||||
const isNumeric = outcomeType === 'NUMERIC'
|
const isNumeric = outcomeType === 'NUMERIC'
|
||||||
|
const isPseudoNumeric = outcomeType === 'PSEUDO_NUMERIC'
|
||||||
|
|
||||||
const saleAmount = saleBet?.sale?.amount
|
const saleAmount = saleBet?.sale?.amount
|
||||||
|
|
||||||
|
|
@ -654,14 +653,17 @@ function BetRow(props: {
|
||||||
truncate="short"
|
truncate="short"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{isPseudoNumeric && ' than ' +formatNumericProbability(bet.probAfter, contract)}
|
||||||
</td>
|
</td>
|
||||||
<td>{formatMoney(Math.abs(amount))}</td>
|
<td>{formatMoney(Math.abs(amount))}</td>
|
||||||
{!isCPMM && !isNumeric && <td>{saleDisplay}</td>}
|
{!isCPMM && !isNumeric && <td>{saleDisplay}</td>}
|
||||||
{!isCPMM && !isResolved && <td>{payoutIfChosenDisplay}</td>}
|
{!isCPMM && !isResolved && <td>{payoutIfChosenDisplay}</td>}
|
||||||
<td>{formatWithCommas(Math.abs(shares))}</td>
|
<td>{formatWithCommas(Math.abs(shares))}</td>
|
||||||
<td>
|
{!isPseudoNumeric && (
|
||||||
{formatPercent(probBefore)} → {formatPercent(probAfter)}
|
<td>
|
||||||
</td>
|
{formatPercent(probBefore)} → {formatPercent(probAfter)}
|
||||||
|
</td>
|
||||||
|
)}
|
||||||
<td>{dayjs(createdTime).format('MMM D, h:mma')}</td>
|
<td>{dayjs(createdTime).format('MMM D, h:mma')}</td>
|
||||||
</tr>
|
</tr>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,14 @@ import { Row } from 'web/components/layout/row'
|
||||||
import { Avatar, EmptyAvatar } from 'web/components/avatar'
|
import { Avatar, EmptyAvatar } from 'web/components/avatar'
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import { UsersIcon } from '@heroicons/react/solid'
|
import { UsersIcon } from '@heroicons/react/solid'
|
||||||
import { formatMoney } from 'common/util/format'
|
import { formatMoney, formatPercent } from 'common/util/format'
|
||||||
import { OutcomeLabel } from 'web/components/outcome-label'
|
import { OutcomeLabel } from 'web/components/outcome-label'
|
||||||
import { RelativeTimestamp } from 'web/components/relative-timestamp'
|
import { RelativeTimestamp } from 'web/components/relative-timestamp'
|
||||||
import React, { Fragment } from 'react'
|
import React, { Fragment } from 'react'
|
||||||
import { uniqBy, partition, sumBy, groupBy } from 'lodash'
|
import { uniqBy, partition, sumBy, groupBy } from 'lodash'
|
||||||
import { JoinSpans } from 'web/components/join-spans'
|
import { JoinSpans } from 'web/components/join-spans'
|
||||||
import { UserLink } from '../user-page'
|
import { UserLink } from '../user-page'
|
||||||
|
import { formatNumericProbability } from 'common/pseudo-numeric'
|
||||||
|
|
||||||
export function FeedBet(props: {
|
export function FeedBet(props: {
|
||||||
contract: Contract
|
contract: Contract
|
||||||
|
|
@ -75,6 +76,8 @@ export function BetStatusText(props: {
|
||||||
hideOutcome?: boolean
|
hideOutcome?: boolean
|
||||||
}) {
|
}) {
|
||||||
const { bet, contract, bettor, isSelf, hideOutcome } = props
|
const { bet, contract, bettor, isSelf, hideOutcome } = props
|
||||||
|
const { outcomeType } = contract
|
||||||
|
const isPseudoNumeric = outcomeType === 'PSEUDO_NUMERIC'
|
||||||
const { amount, outcome, createdTime } = bet
|
const { amount, outcome, createdTime } = bet
|
||||||
|
|
||||||
const bought = amount >= 0 ? 'bought' : 'sold'
|
const bought = amount >= 0 ? 'bought' : 'sold'
|
||||||
|
|
@ -97,7 +100,10 @@ export function BetStatusText(props: {
|
||||||
value={(bet as any).value}
|
value={(bet as any).value}
|
||||||
contract={contract}
|
contract={contract}
|
||||||
truncate="short"
|
truncate="short"
|
||||||
/>
|
/>{' '}
|
||||||
|
{isPseudoNumeric
|
||||||
|
? ' than ' + formatNumericProbability(bet.probAfter, contract)
|
||||||
|
: ' at ' + formatPercent(bet.probAfter)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<RelativeTimestamp time={createdTime} />
|
<RelativeTimestamp time={createdTime} />
|
||||||
|
|
|
||||||
|
|
@ -112,11 +112,11 @@ export function YesLabel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function HigherLabel() {
|
export function HigherLabel() {
|
||||||
return <span className="text-primary">HIGH</span>
|
return <span className="text-primary">HIGHER</span>
|
||||||
}
|
}
|
||||||
|
|
||||||
export function LowerLabel() {
|
export function LowerLabel() {
|
||||||
return <span className="text-red-400">LOW</span>
|
return <span className="text-red-400">LOWER</span>
|
||||||
}
|
}
|
||||||
|
|
||||||
export function NoLabel() {
|
export function NoLabel() {
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ export function YesNoSelector(props: {
|
||||||
)}
|
)}
|
||||||
onClick={() => onSelect('YES')}
|
onClick={() => onSelect('YES')}
|
||||||
>
|
>
|
||||||
{isPseudoNumeric ? 'Higher' : 'Bet YES'}
|
{isPseudoNumeric ? 'HIGHER' : 'Bet YES'}
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
{replaceNoButton ? (
|
{replaceNoButton ? (
|
||||||
|
|
@ -60,7 +60,7 @@ export function YesNoSelector(props: {
|
||||||
)}
|
)}
|
||||||
onClick={() => onSelect('NO')}
|
onClick={() => onSelect('NO')}
|
||||||
>
|
>
|
||||||
{isPseudoNumeric ? 'Lower' : 'Bet NO'}
|
{isPseudoNumeric ? 'LOWER' : 'Bet NO'}
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
</Row>
|
</Row>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user