diff --git a/web/components/bets-list.tsx b/web/components/bets-list.tsx index e55cd22e..9dae42fc 100644 --- a/web/components/bets-list.tsx +++ b/web/components/bets-list.tsx @@ -127,18 +127,20 @@ export function BetsList(props: { user: User }) { const totalReturn = (pnl > 0 ? '+' : '') + ((pnl / user.totalDeposits) * 100).toFixed() + '%' + const color = pnl === 0 ? '' : pnl > 0 ? 'text-green-500' : 'text-red-500' + return ( -
Total portfolio
+
Portfolio value
{formatMoney(totalPortfolio)}
Total profits & losses
- {formatMoney(pnl)} ({totalReturn}) + {formatMoney(pnl)} ({totalReturn})
@@ -226,6 +228,7 @@ function MyContractBets(props: { contract: Contract; bets: Bet[] }) { className="mr-5 flex-1 justify-end sm:mr-8" contract={contract} bets={bets} + onlyMKT />
@@ -235,6 +238,14 @@ function MyContractBets(props: { contract: Contract; bets: Bet[] }) { > + + + + @@ -244,10 +255,10 @@ function MyContractBets(props: { contract: Contract; bets: Bet[] }) { export function MyBetsSummary(props: { contract: Contract bets: Bet[] - showMKT?: boolean + onlyMKT?: boolean className?: string }) { - const { bets, contract, showMKT, className } = props + const { bets, contract, onlyMKT, className } = props const { resolution } = contract calculateCancelPayout @@ -269,49 +280,86 @@ export function MyBetsSummary(props: { calculatePayout(contract, bet, 'MKT') ) + const currentValue = resolution ? betsPayout : marketWinnings + const pnl = currentValue - betsTotal + const totalReturn = + betsTotal === 0 + ? '0%' + : (pnl > 0 ? '+' : '') + ((pnl / betsTotal) * 100).toFixed() + '%' + + const color = pnl === 0 ? '' : pnl > 0 ? 'text-green-500' : 'text-red-500' + + const mktCol = ( + +
+ Market value +
+
+ {formatMoney(marketWinnings)} ( + {totalReturn}) +
+ + ) + + const payoutCol = ( + +
Payout
+
+ {formatMoney(betsPayout)} ({totalReturn}) +
+ + ) + return ( - -
Invested
-
{formatMoney(betsTotal)}
- - {resolution ? ( - -
Payout
-
{formatMoney(betsPayout)}
- + {onlyMKT ? ( + {resolution ? payoutCol : mktCol} ) : (
- Payout if + Invested
-
{formatMoney(yesWinnings)}
+
{formatMoney(betsTotal)}
- -
- Payout if -
-
{formatMoney(noWinnings)}
- - {showMKT && ( - -
- Payout at{' '} - - {formatPercent(getProbability(contract.totalShares))} - -
-
- {formatMoney(marketWinnings)} -
- + {resolution ? ( + payoutCol + ) : ( + <> + +
+ Payout if +
+
+ {formatMoney(yesWinnings)} +
+ + +
+ Payout if +
+
+ {formatMoney(noWinnings)} +
+ + +
+ Payout at{' '} + + {formatPercent(getProbability(contract.totalShares))} + +
+
+ {formatMoney(marketWinnings)} +
+ + )}
)} diff --git a/web/pages/[username]/[contractSlug].tsx b/web/pages/[username]/[contractSlug].tsx index 7beaef44..c4f80e9c 100644 --- a/web/pages/[username]/[contractSlug].tsx +++ b/web/pages/[username]/[contractSlug].tsx @@ -156,12 +156,7 @@ function BetsSection(props: { contract: Contract; user: User | null }) { return (
- <MyBetsSummary - className="px-2" - contract={contract} - bets={userBets} - showMKT - /> + <MyBetsSummary className="px-2" contract={contract} bets={userBets} /> <Spacer h={6} /> <ContractBetsTable contract={contract} bets={userBets} /> <Spacer h={12} />