diff --git a/web/components/bet-panel.tsx b/web/components/bet-panel.tsx index 6fcfc899..90db558d 100644 --- a/web/components/bet-panel.tsx +++ b/web/components/bet-panel.tsx @@ -838,6 +838,11 @@ export function SellPanel(props: { const sellQuantity = isSellingAllShares ? shares : amount + const loanAmount = sumBy(userBets, (bet) => bet.loanAmount ?? 0) + const soldShares = Math.min(sellQuantity ?? 0, shares) + const saleFrac = soldShares / shares + const loanPaid = saleFrac * loanAmount + async function submitSell() { if (!user || !amount) return @@ -882,6 +887,7 @@ export function SellPanel(props: { sharesOutcome, unfilledBets ) + const netProceeds = saleValue - loanPaid const resultProb = getCpmmProbability(cpmmState.pool, cpmmState.p) const getValue = getMappedValue(contract) @@ -941,9 +947,21 @@ export function SellPanel(props: {