diff --git a/web/components/bet-panel.tsx b/web/components/bet-panel.tsx index 90db558d..040a0406 100644 --- a/web/components/bet-panel.tsx +++ b/web/components/bet-panel.tsx @@ -25,7 +25,7 @@ import { NoLabel, YesLabel, } from './outcome-label' -import { getProbability } from 'common/calculate' +import { getContractBetMetrics, getProbability } from 'common/calculate' import { useFocus } from 'web/hooks/use-focus' import { useUserContractBets } from 'web/hooks/use-user-bets' import { calculateCpmmSale, getCpmmProbability } from 'common/calculate-cpmm' @@ -843,6 +843,9 @@ export function SellPanel(props: { const saleFrac = soldShares / shares const loanPaid = saleFrac * loanAmount + const { invested } = getContractBetMetrics(contract, userBets) + const costBasis = invested * saleFrac + async function submitSell() { if (!user || !amount) return @@ -888,6 +891,7 @@ export function SellPanel(props: { unfilledBets ) const netProceeds = saleValue - loanPaid + const profit = saleValue - costBasis const resultProb = getCpmmProbability(cpmmState.pool, cpmmState.p) const getValue = getMappedValue(contract) @@ -950,18 +954,10 @@ export function SellPanel(props: { Sale amount {formatMoney(saleValue)} - {loanPaid !== 0 && ( - <> - - Loan repaid - {formatMoney(-loanPaid)} - - - Net proceeds - {formatMoney(netProceeds)} - - - )} + + Profit + {formatMoney(profit)} +
{isPseudoNumeric ? 'Estimated value' : 'Probability'} @@ -972,20 +968,32 @@ export function SellPanel(props: { {format(resultProb)}
+ {loanPaid !== 0 && ( + <> + + Loan repaid + {formatMoney(-loanPaid)} + + + Net proceeds + {formatMoney(netProceeds)} + + + )} {wasSubmitted &&
Sell submitted!
}