diff --git a/web/components/contract/contract-card.tsx b/web/components/contract/contract-card.tsx index 9386b8c6..2bf30f23 100644 --- a/web/components/contract/contract-card.tsx +++ b/web/components/contract/contract-card.tsx @@ -52,7 +52,7 @@ export function ContractCard(props: { className )} > - +
0) { + return getOutcomeProbabilityAfterBet( + contract, + quickOutcome(contract, 'UP') || '', + amount + ) + } + if (amount < 0) { + return ( + 1 - + getOutcomeProbabilityAfterBet( + contract, + quickOutcome(contract, 'DOWN') || '', + -amount + ) + ) + } + } catch (e) { + return getProb(contract) + } +} + +function quickOutcome(contract: Contract, direction: 'UP' | 'DOWN') { + if (contract.outcomeType === 'BINARY') { + return direction === 'UP' ? 'YES' : 'NO' + } + if (contract.outcomeType === 'FREE_RESPONSE') { + // TODO: Implement shorting of free response answers + if (direction === 'DOWN') { + throw new Error("Can't short free response answers") + } + return getTopAnswer(contract)?.id + } + if (contract.outcomeType === 'NUMERIC') { + // TODO: Ideally an 'UP' bet would be a uniform bet between [current, max] + throw new Error("Can't quick bet on numeric markets") + } +} + export function QuickBet(props: { contract: Contract }) { const { contract } = props @@ -88,30 +132,12 @@ export function QuickBet(props: { contract: Contract }) { }) } - function quickOutcome(contract: Contract, direction: 'UP' | 'DOWN') { - if (contract.outcomeType === 'BINARY') { - return direction === 'UP' ? 'YES' : 'NO' - } - if (contract.outcomeType === 'FREE_RESPONSE') { - // TODO: Implement shorting of free response answers - if (direction === 'DOWN') { - throw new Error("Can't short free response answers") - } - return getTopAnswer(contract)?.id - } - if (contract.outcomeType === 'NUMERIC') { - // TODO: Ideally an 'UP' bet would be a uniform bet between [current, max] - throw new Error("Can't quick bet on numeric markets") - } - } - return ( {/* Up bet triangle */} @@ -174,14 +200,14 @@ export function ProbBar(props: { contract: Contract; previewProb?: number }) { <>
+ {/* Gray background */} + {/*
*/} + {/* indigo-200 liquidity range for 100 */} + + {/* indigo-400 liquidity range for 10 */} +
+ + {/* indigo-400 liquidity range for 10 */} +
+ + {/* Try a tailwind gradient for 100 */} + {/*
*/} + + {/*
*/} + + ) +} + function QuickOutcomeView(props: { contract: Contract previewProb?: number @@ -225,6 +319,7 @@ function QuickOutcomeView(props: { {override ?? display} {caption &&
{caption}
} + ) }