diff --git a/web/components/bet-panel.tsx b/web/components/bet-panel.tsx index beb7168a..6fcfc899 100644 --- a/web/components/bet-panel.tsx +++ b/web/components/bet-panel.tsx @@ -831,7 +831,7 @@ export function SellPanel(props: { const unfilledBets = useUnfilledBets(contract.id) ?? [] - const betDisabled = isSubmitting || !amount || error + const betDisabled = isSubmitting || !amount || error !== undefined // Sell all shares if remaining shares would be < 1 const isSellingAllShares = amount === Math.floor(shares) @@ -884,6 +884,19 @@ export function SellPanel(props: { ) const resultProb = getCpmmProbability(cpmmState.pool, cpmmState.p) + const getValue = getMappedValue(contract) + const rawDifference = Math.abs(getValue(resultProb) - getValue(initialProb)) + const displayedDifference = + contract.outcomeType === 'PSEUDO_NUMERIC' + ? formatLargeNumber(rawDifference) + : formatPercent(rawDifference) + const probChange = Math.abs(resultProb - initialProb) + + const warning = + probChange >= 0.3 + ? `Are you sure you want to move the market by ${displayedDifference}?` + : undefined + const openUserBets = userBets.filter((bet) => !bet.isSold && !bet.sale) const [yesBets, noBets] = partition( openUserBets, @@ -923,7 +936,7 @@ export function SellPanel(props: { label="Qty" error={error} disabled={isSubmitting} - inputClassName="w-full" + inputClassName="w-full ml-1" /> @@ -945,20 +958,17 @@ export function SellPanel(props: { - + {wasSubmitted &&
Sell submitted!
} diff --git a/web/components/warning-confirmation-button.tsx b/web/components/warning-confirmation-button.tsx index 71553663..7bf26165 100644 --- a/web/components/warning-confirmation-button.tsx +++ b/web/components/warning-confirmation-button.tsx @@ -6,17 +6,19 @@ import { ConfirmationButton } from './confirmation-button' import { ExclamationIcon } from '@heroicons/react/solid' import { formatMoney } from 'common/util/format' import { Button, ColorType, SizeType } from './button' +import { capitalize } from 'lodash' export function WarningConfirmationButton(props: { amount: number | undefined marketType: 'freeResponse' | 'binary' warning?: string - onSubmit: () => void + onSubmit?: () => void disabled: boolean isSubmitting: boolean openModalButtonClass?: string color: ColorType size: SizeType + actionLabel?: string }) { const { amount, @@ -27,8 +29,16 @@ export function WarningConfirmationButton(props: { openModalButtonClass, size, color, + actionLabel, } = props + const label = capitalize(actionLabel) ?? 'Wager' + const buttonText = isSubmitting + ? 'Submitting...' + : amount + ? `${label} ${formatMoney(amount)}` + : label + if (!warning) { return ( ) } @@ -50,10 +56,10 @@ export function WarningConfirmationButton(props: { return (