diff --git a/web/components/bet-panel.tsx b/web/components/bet-panel.tsx
index 05af4aee..e8bd6f20 100644
--- a/web/components/bet-panel.tsx
+++ b/web/components/bet-panel.tsx
@@ -8,6 +8,7 @@ import { Col } from './layout/col'
import { Row } from './layout/row'
import { Spacer } from './layout/spacer'
import { YesNoSelector } from './yes-no-selector'
+import { formatMoney } from '../lib/util/format'
export function BetPanel(props: { contract: Contract; className?: string }) {
const { contract, className } = props
@@ -23,6 +24,8 @@ export function BetPanel(props: { contract: Contract; className?: string }) {
function onBetChange(str: string) {
const amount = parseInt(str)
setBetAmount(isNaN(amount) ? undefined : amount)
+
+ setWasSubmitted(false)
}
async function submitBet() {
@@ -48,10 +51,20 @@ export function BetPanel(props: { contract: Contract; className?: string }) {
const betDisabled = isSubmitting || wasSubmitted
+ const initialProb = getProbability(contract.pot, betChoice)
+ const resultProb = getProbability(contract.pot, betChoice, betAmount)
+ const dpmWeight = getDpmWeight(contract.pot, betAmount ?? 0, betChoice)
+
+ const estimatedWinnings = Math.floor((betAmount ?? 0) + dpmWeight)
+ const estimatedReturn = betAmount
+ ? (estimatedWinnings - betAmount) / betAmount
+ : 0
+ const estimatedReturnPercent = (estimatedReturn * 100).toFixed() + '%'
+
return (
@@ -60,69 +73,73 @@ export function BetPanel(props: { contract: Contract; className?: string }) {
className="p-2"
selected={betChoice}
onSelect={setBetChoice}
- yesLabel="Yes 57"
- noLabel="No 43"
/>
Bet amount
-
+
+
+ M$
+
onBetChange(e.target.value)}
/>
- points
- {!!betAmount && (
- <>
+
+
+ Implied probability
+
+
+ {Math.floor(initialProb * 1000) / 10 + '%'}
+
+ →
+
+ {Math.floor(resultProb * 1000) / 10 + '%'}
+
+
+
+
+
+ Estimated winnings
+
+ {formatMoney(estimatedWinnings)} (+{estimatedReturnPercent})
+
+
+
+
+
+
+ {wasSubmitted && (
+
- Average price
- {betChoice === 'YES' ? 0.57 : 0.43} points
+ Bet submitted!
-
+
- Estimated winnings
-
- {Math.floor(betAmount / (betChoice === 'YES' ? 0.57 : 0.43))} points
-
-
-
-
-