Display liquidity "pool" instead of "bet" volume

This commit is contained in:
Austin Chen 2022-05-24 16:57:34 -07:00
parent 8715ff2740
commit d5a362502a
3 changed files with 25 additions and 20 deletions

View File

@ -14,6 +14,7 @@ import { UserLink } from '../user-page'
import { import {
Contract, Contract,
contractMetrics, contractMetrics,
contractPool,
updateContract, updateContract,
} from 'web/lib/firebase/contracts' } from 'web/lib/firebase/contracts'
import { Col } from '../layout/col' import { Col } from '../layout/col'
@ -43,10 +44,6 @@ export function MiscDetails(props: {
return ( return (
<Row className="items-center gap-3 text-sm text-gray-400"> <Row className="items-center gap-3 text-sm text-gray-400">
{categories.length > 0 && (
<TagsList className="text-gray-400" tags={categories} noLabel />
)}
{showHotVolume ? ( {showHotVolume ? (
<Row className="gap-0.5"> <Row className="gap-0.5">
<TrendingUpIcon className="h-5 w-5" /> {formatMoney(volume24Hours)} <TrendingUpIcon className="h-5 w-5" /> {formatMoney(volume24Hours)}
@ -58,10 +55,14 @@ export function MiscDetails(props: {
{fromNow(closeTime || 0)} {fromNow(closeTime || 0)}
</Row> </Row>
) : volume > 0 ? ( ) : volume > 0 ? (
<Row>{volumeLabel}</Row> <Row>{contractPool(contract)} pool</Row>
) : ( ) : (
<NewContractBadge /> <NewContractBadge />
)} )}
{categories.length > 0 && (
<TagsList className="text-gray-400" tags={categories} noLabel />
)}
</Row> </Row>
) )
} }

View File

@ -7,7 +7,12 @@ import { Bet } from 'common/bet'
import { Contract } from 'common/contract' import { Contract } from 'common/contract'
import { formatMoney } from 'common/util/format' 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 { AddLiquidityPanel } from '../add-liquidity-panel'
import { CopyLinkButton } from '../copy-link-button' import { CopyLinkButton } from '../copy-link-button'
import { Col } from '../layout/col' import { Col } from '../layout/col'
@ -98,19 +103,10 @@ export function ContractInfoDialog(props: { contract: Contract; bets: Bet[] }) {
<td>{tradersCount}</td> <td>{tradersCount}</td>
</tr> </tr>
{contract.mechanism === 'cpmm-1' && (
<tr>
<td>Liquidity</td>
<td>{formatMoney(contract.totalLiquidity)}</td>
</tr>
)}
{contract.mechanism === 'dpm-2' && (
<tr> <tr>
<td>Pool</td> <td>Pool</td>
<td>{formatMoney(sum(Object.values(contract.pool)))}</td> <td>{contractPool(contract)}</td>
</tr> </tr>
)}
</tbody> </tbody>
</table> </table>

View File

@ -13,7 +13,7 @@ import {
updateDoc, updateDoc,
limit, limit,
} from 'firebase/firestore' } from 'firebase/firestore'
import { range, sortBy } from 'lodash' import { range, sortBy, sum } from 'lodash'
import { app } from './init' import { app } from './init'
import { getValues, listenForValue, listenForValues } from './utils' import { getValues, listenForValue, listenForValues } from './utils'
@ -55,6 +55,14 @@ export function contractMetrics(contract: Contract) {
return { volumeLabel, createdDate, resolvedDate } 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<any, Binary>) { export function getBinaryProb(contract: FullContract<any, Binary>) {
const { totalShares, pool, p, resolutionProbability, mechanism } = contract const { totalShares, pool, p, resolutionProbability, mechanism } = contract