diff --git a/web/components/bets-list.tsx b/web/components/bets-list.tsx index c7f8cc86..58d9aaf9 100644 --- a/web/components/bets-list.tsx +++ b/web/components/bets-list.tsx @@ -18,13 +18,12 @@ import { UserLink } from './user-page' import { calculatePayout, calculateSaleAmount, - currentValue, resolvedPayout, } from '../lib/calculate' import clsx from 'clsx' import { cloudFunction } from '../lib/firebase/api-call' import { ConfirmationButton } from './confirmation-button' -import { OutcomeLabel, YesLabel, NoLabel } from './outcome-label' +import { OutcomeLabel, YesLabel, NoLabel, MarketLabel } from './outcome-label' export function BetsList(props: { user: User }) { const { user } = props @@ -84,7 +83,7 @@ export function BetsList(props: { user: User }) { const currentBetsValue = _.sumBy(unresolved, (contract) => _.sumBy(contractBets[contract.id], (bet) => { if (bet.isSold || bet.sale) return 0 - return currentValue(contract, bet) + return calculatePayout(contract, bet, 'MKT') }) ) @@ -183,9 +182,10 @@ function MyContractBets(props: { contract: Contract; bets: Bet[] }) { export function MyBetsSummary(props: { contract: Contract bets: Bet[] + showMKT?: boolean className?: string }) { - const { bets, contract, className } = props + const { bets, contract, showMKT, className } = props const { resolution } = contract const excludeSales = bets.filter((b) => !b.isSold && !b.sale) @@ -202,21 +202,29 @@ export function MyBetsSummary(props: { calculatePayout(contract, bet, 'NO') ) + const marketWinnings = _.sumBy(excludeSales, (bet) => + calculatePayout(contract, bet, 'MKT') + ) + return ( - +
Invested
{formatMoney(betsTotal)}
{resolution ? ( - <> - -
Payout
-
{formatMoney(betsPayout)}
- - + +
Payout
+
{formatMoney(betsPayout)}
+ ) : ( - <> +
Payout if @@ -229,7 +237,17 @@ export function MyBetsSummary(props: {
{formatMoney(noWinnings)}
- + {showMKT && ( + +
+ Payout if +
+
+ {formatMoney(marketWinnings)} +
+ + )} +
)}
) diff --git a/web/pages/[username]/[contractSlug].tsx b/web/pages/[username]/[contractSlug].tsx index 8b824c44..f467578a 100644 --- a/web/pages/[username]/[contractSlug].tsx +++ b/web/pages/[username]/[contractSlug].tsx @@ -110,7 +110,7 @@ function BetsSection(props: { contract: Contract; user: User | null }) { return (
- <MyBetsSummary contract={contract} bets={userBets} /> + <MyBetsSummary contract={contract} bets={userBets} showMKT /> <Spacer h={6} /> <ContractBetsTable contract={contract} bets={userBets} /> <Spacer h={12} />