diff --git a/web/pages/challenges/[username]/[contractSlug]/[challengeSlug].tsx b/web/pages/challenges/[username]/[contractSlug]/[challengeSlug].tsx
index 85c0d2f8..d1f25e86 100644
--- a/web/pages/challenges/[username]/[contractSlug]/[challengeSlug].tsx
+++ b/web/pages/challenges/[username]/[contractSlug]/[challengeSlug].tsx
@@ -131,19 +131,30 @@ function ClosedChallengeContent(props: {
}) {
const { contract, challenge, creator, bets } = props
const { resolution } = contract
- const user = useUserById(challenge.acceptances[0].userId)
+ const {
+ acceptances,
+ amount,
+ creatorsOutcome,
+ creatorsOutcomeProb,
+ yourOutcome,
+ } = challenge
+
+ const user = useUserById(acceptances[0].userId)
const [showConfetti, setShowConfetti] = useState(false)
const { width, height } = useWindowSize()
useEffect(() => {
- if (challenge.acceptances.length === 0) return
- if (challenge.acceptances[0].createdTime > Date.now() - 1000 * 60)
+ if (acceptances.length === 0) return
+ if (acceptances[0].createdTime > Date.now() - 1000 * 60)
setShowConfetti(true)
- }, [challenge.acceptances])
- const creatorWon = resolution === challenge.creatorsOutcome
+ }, [acceptances])
+ const creatorWon = resolution === creatorsOutcome
+ const yourShares = (1 / (1 - creatorsOutcomeProb)) * amount
+ const creatorShares = (1 / creatorsOutcomeProb) * amount
+ const winningShares = creatorWon ? creatorShares : yourShares
if (!user) return
- const userWonCol = (user: User) => (
+ const userWonCol = (user: User, amount: number) => (
🥇
@@ -157,10 +168,7 @@ function ClosedChallengeContent(props: {
- WON{' '}
-
- {formatMoney(challenge.amount)}
-
+ WON {formatMoney(amount)}
@@ -171,10 +179,7 @@ function ClosedChallengeContent(props: {
{userRow(challenger)}
- LOST{' '}
-
- {formatMoney(challenge.amount)}
-
+ LOST {formatMoney(amount)}
@@ -191,17 +196,14 @@ function ClosedChallengeContent(props: {
{!lost ? (
- is betting {formatMoney(challenge.amount)}
+ is betting {formatMoney(amount)}
{' on '}
at{' '}
{Math.round(prob * 100)}%
) : (
- LOST{' '}
-
- {formatMoney(challenge.amount)}
-
+ LOST {formatMoney(amount)}
)}
@@ -243,7 +245,7 @@ function ClosedChallengeContent(props: {
}
>
- {userWonCol(creatorWon ? creator : user)}
+ {userWonCol(creatorWon ? creator : user, winningShares)}
{userLostCol(creatorWon ? user : creator)}
@@ -255,17 +257,9 @@ function ClosedChallengeContent(props: {
'h-full w-full content-between justify-between gap-1 py-10 sm:flex-row'
}
>
- {userCol(
- creator,
- challenge.creatorsOutcome,
- challenge.creatorsOutcomeProb
- )}
+ {userCol(creator, creatorsOutcome, creatorsOutcomeProb)}
VS
- {userCol(
- user,
- challenge.yourOutcome,
- 1 - challenge.creatorsOutcomeProb
- )}
+ {userCol(user, yourOutcome, 1 - creatorsOutcomeProb)}
)}
@@ -310,6 +304,14 @@ function OpenChallengeContent(props: {
}) {
const { contract, challenge, creator, user, bets } = props
const { question } = contract
+ const {
+ amount,
+ creatorId,
+ creatorsOutcome,
+ creatorsOutcomeProb,
+ yourOutcome,
+ } = challenge
+
const [creatorPortfolioHistory, setUsersCreatorPortfolioHistory] = useState<
PortfolioMetrics[]
>([])
@@ -340,9 +342,9 @@ function OpenChallengeContent(props: {
) => {
const lastPortfolioMetrics = last(portfolioHistory)
const prob =
- (outcome === challenge.creatorsOutcome
- ? challenge.creatorsOutcomeProb
- : 1 - challenge.creatorsOutcomeProb) * 100
+ (outcome === creatorsOutcome
+ ? creatorsOutcomeProb
+ : 1 - creatorsOutcomeProb) * 100
return (
@@ -356,7 +358,7 @@ function OpenChallengeContent(props: {
)}
- is betting {formatMoney(challenge.amount)}
+ is betting {formatMoney(amount)}
{' on '}
at{' '}
{Math.round(prob)}%
@@ -409,16 +411,12 @@ function OpenChallengeContent(props: {
'h-full max-h-[50vh] w-full content-between justify-between gap-1 py-10 sm:flex-row'
}
>
- {userColumn(
- creator,
- creatorPortfolioHistory,
- challenge.creatorsOutcome
- )}
+ {userColumn(creator, creatorPortfolioHistory, creatorsOutcome)}
VS
{userColumn(
- user?.id === challenge.creatorId ? undefined : user,
+ user?.id === creatorId ? undefined : user,
portfolioHistory,
- challenge.yourOutcome
+ yourOutcome
)}