cpmm ContractBetsTable display
This commit is contained in:
parent
3145966a3c
commit
b81742cd02
|
@ -412,28 +412,46 @@ export function ContractBetsTable(props: {
|
||||||
const { contract, bets, className } = props
|
const { contract, bets, className } = props
|
||||||
|
|
||||||
const [sales, buys] = _.partition(bets, (bet) => bet.sale)
|
const [sales, buys] = _.partition(bets, (bet) => bet.sale)
|
||||||
|
|
||||||
const salesDict = _.fromPairs(
|
const salesDict = _.fromPairs(
|
||||||
sales.map((sale) => [sale.sale?.betId ?? '', sale])
|
sales.map((sale) => [sale.sale?.betId ?? '', sale])
|
||||||
)
|
)
|
||||||
|
|
||||||
const { isResolved } = contract
|
const [redemptions, normalBets] = _.partition(buys, (b) => b.isRedemption)
|
||||||
|
const amountRedeemed = Math.floor(
|
||||||
|
-0.5 * _.sumBy(redemptions, (b) => b.shares)
|
||||||
|
)
|
||||||
|
|
||||||
|
const { isResolved, mechanism } = contract
|
||||||
|
const isCPMM = mechanism === 'cpmm-1'
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={clsx('overflow-x-auto', className)}>
|
<div className={clsx('overflow-x-auto', className)}>
|
||||||
|
{amountRedeemed > 0 && (
|
||||||
|
<>
|
||||||
|
<div className="text-gray-500 text-sm pl-2">
|
||||||
|
{amountRedeemed} YES shares and {amountRedeemed} NO shares
|
||||||
|
automatically redeemed for {formatMoney(amountRedeemed)}.
|
||||||
|
</div>
|
||||||
|
<Spacer h={4} />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
<table className="table-zebra table-compact table w-full text-gray-500">
|
<table className="table-zebra table-compact table w-full text-gray-500">
|
||||||
<thead>
|
<thead>
|
||||||
<tr className="p-2">
|
<tr className="p-2">
|
||||||
<th></th>
|
<th></th>
|
||||||
<th>Outcome</th>
|
<th>Outcome</th>
|
||||||
<th>Amount</th>
|
<th>Amount</th>
|
||||||
<th>{isResolved ? <>Payout</> : <>Sale price</>}</th>
|
{!isCPMM && <th>{isResolved ? <>Payout</> : <>Sale price</>}</th>}
|
||||||
{!isResolved && <th>Payout if chosen</th>}
|
{!isCPMM && !isResolved && <th>Payout if chosen</th>}
|
||||||
<th>Probability</th>
|
|
||||||
<th>Shares</th>
|
<th>Shares</th>
|
||||||
|
<th>Probability</th>
|
||||||
<th>Date</th>
|
<th>Date</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{buys.map((bet) => (
|
{normalBets.map((bet) => (
|
||||||
<BetRow
|
<BetRow
|
||||||
key={bet.id}
|
key={bet.id}
|
||||||
bet={bet}
|
bet={bet}
|
||||||
|
@ -458,12 +476,17 @@ function BetRow(props: { bet: Bet; contract: Contract; saleBet?: Bet }) {
|
||||||
shares,
|
shares,
|
||||||
isSold,
|
isSold,
|
||||||
isAnte,
|
isAnte,
|
||||||
|
isLiquidityProvision,
|
||||||
|
isRedemption,
|
||||||
loanAmount,
|
loanAmount,
|
||||||
} = bet
|
} = bet
|
||||||
|
|
||||||
const { isResolved, closeTime } = contract
|
const { isResolved, closeTime, mechanism } = contract
|
||||||
|
|
||||||
const isClosed = closeTime && Date.now() > closeTime
|
const isClosed = closeTime && Date.now() > closeTime
|
||||||
|
|
||||||
|
const isCPMM = mechanism === 'cpmm-1'
|
||||||
|
|
||||||
const saleAmount = saleBet?.sale?.amount
|
const saleAmount = saleBet?.sale?.amount
|
||||||
|
|
||||||
const saleDisplay = isAnte ? (
|
const saleDisplay = isAnte ? (
|
||||||
|
@ -486,9 +509,12 @@ function BetRow(props: { bet: Bet; contract: Contract; saleBet?: Bet }) {
|
||||||
return (
|
return (
|
||||||
<tr>
|
<tr>
|
||||||
<td className="text-neutral">
|
<td className="text-neutral">
|
||||||
{!isResolved && !isClosed && !isSold && !isAnte && (
|
{!isCPMM && !isResolved && !isClosed && !isSold && !isAnte && (
|
||||||
<SellButton contract={contract} bet={bet} />
|
<SellButton contract={contract} bet={bet} />
|
||||||
)}
|
)}
|
||||||
|
{/* {isAnte && 'ANTE'}
|
||||||
|
{isLiquidityProvision && !isAnte && 'LIQD'}
|
||||||
|
{isRedemption && 'REDEEM'} */}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<OutcomeLabel outcome={outcome} />
|
<OutcomeLabel outcome={outcome} />
|
||||||
|
@ -497,12 +523,12 @@ function BetRow(props: { bet: Bet; contract: Contract; saleBet?: Bet }) {
|
||||||
{formatMoney(amount)}
|
{formatMoney(amount)}
|
||||||
{loanAmount ? ` (${formatMoney(loanAmount ?? 0)} loan)` : ''}
|
{loanAmount ? ` (${formatMoney(loanAmount ?? 0)} loan)` : ''}
|
||||||
</td>
|
</td>
|
||||||
<td>{saleDisplay}</td>
|
{!isCPMM && <td>{saleDisplay}</td>}
|
||||||
{!isResolved && <td>{payoutIfChosenDisplay}</td>}
|
{!isCPMM && !isResolved && <td>{payoutIfChosenDisplay}</td>}
|
||||||
|
<td>{formatWithCommas(shares)}</td>
|
||||||
<td>
|
<td>
|
||||||
{formatPercent(probBefore)} → {formatPercent(probAfter)}
|
{formatPercent(probBefore)} → {formatPercent(probAfter)}
|
||||||
</td>
|
</td>
|
||||||
<td>{formatWithCommas(shares)}</td>
|
|
||||||
<td>{dayjs(createdTime).format('MMM D, h:mma')}</td>
|
<td>{dayjs(createdTime).format('MMM D, h:mma')}</td>
|
||||||
</tr>
|
</tr>
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user