diff --git a/web/components/bet-panel.tsx b/web/components/bet-panel.tsx index d1351595..50fcbf8d 100644 --- a/web/components/bet-panel.tsx +++ b/web/components/bet-panel.tsx @@ -45,7 +45,7 @@ import { ProbabilityInput } from './probability-input' import { track } from 'web/lib/service/analytics' import { removeUndefinedProps } from 'common/util/object' import { useUnfilledBets } from 'web/hooks/use-bets' -import { OpenBets } from './open-bets' +import { LimitBets } from './limit-bets' export function BetPanel(props: { contract: CPMMBinaryContract | PseudoNumericContract @@ -101,7 +101,7 @@ export function BetPanel(props: { {yourUnfilledBets.length > 0 && ( - + )} ) @@ -320,11 +320,13 @@ function BuyPanel(props: { betChoice ?? 'YES' ) + const limitProbFrac = (limitProb ?? 0) / 100 + const { newPool, newP, newBet } = getBinaryCpmmBetInfo( betChoice ?? 'YES', betAmount ?? 0, contract, - isLimitOrder ? limitProb : undefined, + isLimitOrder ? limitProbFrac : undefined, unfilledBets as LimitBet[] ) @@ -339,14 +341,26 @@ function BuyPanel(props: { const resultProb = getCpmmProbability(newPool, newP) const matchedAmount = sumBy(newBet.fills, (fill) => fill.amount) + const filledShares = sumBy(newBet.fills, (fill) => fill.shares) + const overallShares = + filledShares + + ((betAmount ?? 0) - matchedAmount) / + (betChoice === 'YES' ? limitProbFrac : 1 - limitProbFrac) - const currentPayout = matchedAmount - ? calculatePayoutAfterCorrectBet(contract, { - outcome: betChoice, - amount: matchedAmount, - shares: newBet.shares, - } as Bet) - : 0 + console.log( + 'overallShares', + overallShares, + 'filledShares', + filledShares, + 'amount', + betAmount, + 'matchedAmount', + matchedAmount, + 'limitProb', + limitProb + ) + + const currentPayout = overallShares const currentReturn = betAmount ? (currentPayout - betAmount) / betAmount : 0 const currentReturnPercent = formatPercent(currentReturn) @@ -381,7 +395,7 @@ function BuyPanel(props: { {isLimitOrder && ( <>
- {betChoice === 'YES' ? 'Max' : 'Min'} probability + {betChoice === 'NO' ? 'Min' : 'Max'} probability
bet.createdTime).reverse() return ( -
Open bets
+
Limit bets
{recentBets.map((bet) => ( diff --git a/web/pages/[username]/[contractSlug].tsx b/web/pages/[username]/[contractSlug].tsx index 31e3ba73..4e0327b4 100644 --- a/web/pages/[username]/[contractSlug].tsx +++ b/web/pages/[username]/[contractSlug].tsx @@ -45,7 +45,7 @@ import { useTracking } from 'web/hooks/use-tracking' import { CommentTipMap, useTipTxns } from 'web/hooks/use-tip-txns' import { useRouter } from 'next/router' import { useLiquidity } from 'web/hooks/use-liquidity' -import { OpenBets } from 'web/components/open-bets' +import { LimitBets } from 'web/components/limit-bets' export const getStaticProps = fromPropz(getStaticPropz) export async function getStaticPropz(props: { @@ -222,7 +222,7 @@ export function ContractPageContent( {yourUnfilledBets.length > 0 && ( - + )} {isNumeric && (