From b08cdd495f34a669d65ce2fc85276cbb88b3e75f Mon Sep 17 00:00:00 2001 From: mantikoros Date: Tue, 14 Jun 2022 12:06:22 -0500 Subject: [PATCH] Revert "Refinement of LiteMarket (#479)" This reverts commit 99457388110119801cc3d1298e988a8b39a15143. --- docs/docs/api.md | 10 ++-------- web/lib/firebase/contracts.ts | 12 +++--------- web/pages/api/v0/_types.ts | 12 ++++++------ 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/docs/docs/api.md b/docs/docs/api.md index 133cbb6b..f7217045 100644 --- a/docs/docs/api.md +++ b/docs/docs/api.md @@ -95,20 +95,14 @@ Requires no authorization. description: string tags: string[] url: string - outcomeType: string - mechanism: string pool: number - probability?: number - p?: number - - volume: number + probability: number volume7Days: number volume24Hours: number - isResolved: boolean - resolution?: string resolutionTime?: number + resolution?: string } ``` diff --git a/web/lib/firebase/contracts.ts b/web/lib/firebase/contracts.ts index a3976339..0e0ad57e 100644 --- a/web/lib/firebase/contracts.ts +++ b/web/lib/firebase/contracts.ts @@ -57,17 +57,11 @@ 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' - ? contract.totalLiquidity + ? formatMoney(contract.totalLiquidity) : contract.mechanism === 'dpm-2' - ? sum(Object.values(contract.pool)) - : 0 + ? formatMoney(sum(Object.values(contract.pool))) + : 'Empty pool' } export function getBinaryProb(contract: BinaryContract) { diff --git a/web/pages/api/v0/_types.ts b/web/pages/api/v0/_types.ts index 38f1aa7a..78fe3708 100644 --- a/web/pages/api/v0/_types.ts +++ b/web/pages/api/v0/_types.ts @@ -1,10 +1,8 @@ import { Bet } from 'common/bet' import { getProbability } from 'common/calculate' import { Comment } from 'common/comment' -import { Contract, DPM } from 'common/contract' +import { Contract } 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 @@ -28,7 +26,7 @@ export type LiteMarket = { pool: number probability?: number p?: number - totalShares?: number + totalLiquidity?: number volume: number volume7Days: number @@ -60,6 +58,7 @@ export function toLiteMarket(contract: Contract): LiteMarket { description, tags, slug, + pool, outcomeType, mechanism, volume, @@ -70,7 +69,7 @@ export function toLiteMarket(contract: Contract): LiteMarket { resolutionTime, } = contract - const { p } = contract as any + const { p, totalLiquidity } = contract as any const probability = contract.outcomeType === 'BINARY' ? getProbability(contract) : undefined @@ -89,9 +88,10 @@ export function toLiteMarket(contract: Contract): LiteMarket { description, tags, url: `https://manifold.markets/${creatorUsername}/${slug}`, - pool: getPoolValue(contract), + pool: pool.YES + pool.NO, probability, p, + totalLiquidity, outcomeType, mechanism, volume,