diff --git a/web/components/contract/contract-details.tsx b/web/components/contract/contract-details.tsx index 0ec082d8..801609c1 100644 --- a/web/components/contract/contract-details.tsx +++ b/web/components/contract/contract-details.tsx @@ -14,6 +14,7 @@ import { UserLink } from '../user-page' import { Contract, contractMetrics, + contractPool, updateContract, } from 'web/lib/firebase/contracts' import { Col } from '../layout/col' @@ -43,10 +44,6 @@ export function MiscDetails(props: { return ( - {categories.length > 0 && ( - - )} - {showHotVolume ? ( {formatMoney(volume24Hours)} @@ -58,10 +55,14 @@ export function MiscDetails(props: { {fromNow(closeTime || 0)} ) : volume > 0 ? ( - {volumeLabel} + {contractPool(contract)} pool ) : ( )} + + {categories.length > 0 && ( + + )} ) } diff --git a/web/components/contract/contract-info-dialog.tsx b/web/components/contract/contract-info-dialog.tsx index f15eed2e..8a238727 100644 --- a/web/components/contract/contract-info-dialog.tsx +++ b/web/components/contract/contract-info-dialog.tsx @@ -7,7 +7,12 @@ import { Bet } from 'common/bet' import { Contract } from 'common/contract' import { formatMoney } from 'common/util/format' -import { contractPath, getBinaryProbPercent } from 'web/lib/firebase/contracts' +import { + contractMetrics, + contractPath, + contractPool, + getBinaryProbPercent, +} from 'web/lib/firebase/contracts' import { AddLiquidityPanel } from '../add-liquidity-panel' import { CopyLinkButton } from '../copy-link-button' import { Col } from '../layout/col' @@ -98,19 +103,10 @@ export function ContractInfoDialog(props: { contract: Contract; bets: Bet[] }) { {tradersCount} - {contract.mechanism === 'cpmm-1' && ( - - Liquidity - {formatMoney(contract.totalLiquidity)} - - )} - - {contract.mechanism === 'dpm-2' && ( - - Pool - {formatMoney(sum(Object.values(contract.pool)))} - - )} + + Pool + {contractPool(contract)} + diff --git a/web/lib/firebase/contracts.ts b/web/lib/firebase/contracts.ts index 4fcfb6da..3ea413ce 100644 --- a/web/lib/firebase/contracts.ts +++ b/web/lib/firebase/contracts.ts @@ -13,7 +13,7 @@ import { updateDoc, limit, } from 'firebase/firestore' -import { range, sortBy } from 'lodash' +import { range, sortBy, sum } from 'lodash' import { app } from './init' import { getValues, listenForValue, listenForValues } from './utils' @@ -55,6 +55,14 @@ export function contractMetrics(contract: Contract) { return { volumeLabel, createdDate, resolvedDate } } +export function contractPool(contract: Contract) { + return contract.mechanism === 'cpmm-1' + ? formatMoney(contract.totalLiquidity) + : contract.mechanism === 'dpm-2' + ? formatMoney(sum(Object.values(contract.pool))) + : 'Empty pool' +} + export function getBinaryProb(contract: FullContract) { const { totalShares, pool, p, resolutionProbability, mechanism } = contract