diff --git a/docs/docs/api.md b/docs/docs/api.md index f7217045..133cbb6b 100644 --- a/docs/docs/api.md +++ b/docs/docs/api.md @@ -95,14 +95,20 @@ Requires no authorization. description: string tags: string[] url: string + outcomeType: string + mechanism: string pool: number - probability: number + probability?: number + p?: number + + volume: number volume7Days: number volume24Hours: number + isResolved: boolean - resolutionTime?: number resolution?: string + resolutionTime?: number } ``` diff --git a/web/lib/firebase/contracts.ts b/web/lib/firebase/contracts.ts index 0e0ad57e..a3976339 100644 --- a/web/lib/firebase/contracts.ts +++ b/web/lib/firebase/contracts.ts @@ -57,11 +57,17 @@ export function contractMetrics(contract: Contract) { } export function contractPool(contract: Contract) { + return getPoolValue(contract) === 0 + ? 'Empty Pool' + : formatMoney(getPoolValue(contract)) +} + +export function getPoolValue(contract: Contract) { return contract.mechanism === 'cpmm-1' - ? formatMoney(contract.totalLiquidity) + ? contract.totalLiquidity : contract.mechanism === 'dpm-2' - ? formatMoney(sum(Object.values(contract.pool))) - : 'Empty pool' + ? sum(Object.values(contract.pool)) + : 0 } export function getBinaryProb(contract: BinaryContract) { diff --git a/web/pages/api/v0/_types.ts b/web/pages/api/v0/_types.ts index 78fe3708..38f1aa7a 100644 --- a/web/pages/api/v0/_types.ts +++ b/web/pages/api/v0/_types.ts @@ -1,8 +1,10 @@ import { Bet } from 'common/bet' import { getProbability } from 'common/calculate' import { Comment } from 'common/comment' -import { Contract } from 'common/contract' +import { Contract, DPM } from 'common/contract' import { removeUndefinedProps } from 'common/util/object' +import { sum } from 'lodash' +import { getPoolValue } from 'web/lib/firebase/contracts' export type LiteMarket = { // Unique identifer for this market @@ -26,7 +28,7 @@ export type LiteMarket = { pool: number probability?: number p?: number - totalLiquidity?: number + totalShares?: number volume: number volume7Days: number @@ -58,7 +60,6 @@ export function toLiteMarket(contract: Contract): LiteMarket { description, tags, slug, - pool, outcomeType, mechanism, volume, @@ -69,7 +70,7 @@ export function toLiteMarket(contract: Contract): LiteMarket { resolutionTime, } = contract - const { p, totalLiquidity } = contract as any + const { p } = contract as any const probability = contract.outcomeType === 'BINARY' ? getProbability(contract) : undefined @@ -88,10 +89,9 @@ export function toLiteMarket(contract: Contract): LiteMarket { description, tags, url: `https://manifold.markets/${creatorUsername}/${slug}`, - pool: pool.YES + pool.NO, + pool: getPoolValue(contract), probability, p, - totalLiquidity, outcomeType, mechanism, volume,