Refinement of LiteMarket (#479)
* split into two function to access the pool value as number * rename function * changes to the exported object * removal of totalLiquidity: this value was only set for binary markets and it's value is identical to getPoolvalue(contract) * pool: set in the same way as in the "Market Overview" from contract-info-dialog.tsx now * totalShares: total shares of the contract. It's value is equal to the old "pool" value in case of binary markets * update docs * removal of totalShares
This commit is contained in:
parent
da2c6ae037
commit
9945738811
|
@ -95,14 +95,20 @@ Requires no authorization.
|
||||||
description: string
|
description: string
|
||||||
tags: string[]
|
tags: string[]
|
||||||
url: string
|
url: string
|
||||||
|
outcomeType: string
|
||||||
|
mechanism: string
|
||||||
|
|
||||||
pool: number
|
pool: number
|
||||||
probability: number
|
probability?: number
|
||||||
|
p?: number
|
||||||
|
|
||||||
|
volume: number
|
||||||
volume7Days: number
|
volume7Days: number
|
||||||
volume24Hours: number
|
volume24Hours: number
|
||||||
|
|
||||||
isResolved: boolean
|
isResolved: boolean
|
||||||
resolutionTime?: number
|
|
||||||
resolution?: string
|
resolution?: string
|
||||||
|
resolutionTime?: number
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -57,11 +57,17 @@ export function contractMetrics(contract: Contract) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function contractPool(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'
|
return contract.mechanism === 'cpmm-1'
|
||||||
? formatMoney(contract.totalLiquidity)
|
? contract.totalLiquidity
|
||||||
: contract.mechanism === 'dpm-2'
|
: contract.mechanism === 'dpm-2'
|
||||||
? formatMoney(sum(Object.values(contract.pool)))
|
? sum(Object.values(contract.pool))
|
||||||
: 'Empty pool'
|
: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getBinaryProb(contract: BinaryContract) {
|
export function getBinaryProb(contract: BinaryContract) {
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
import { Bet } from 'common/bet'
|
import { Bet } from 'common/bet'
|
||||||
import { getProbability } from 'common/calculate'
|
import { getProbability } from 'common/calculate'
|
||||||
import { Comment } from 'common/comment'
|
import { Comment } from 'common/comment'
|
||||||
import { Contract } from 'common/contract'
|
import { Contract, DPM } from 'common/contract'
|
||||||
import { removeUndefinedProps } from 'common/util/object'
|
import { removeUndefinedProps } from 'common/util/object'
|
||||||
|
import { sum } from 'lodash'
|
||||||
|
import { getPoolValue } from 'web/lib/firebase/contracts'
|
||||||
|
|
||||||
export type LiteMarket = {
|
export type LiteMarket = {
|
||||||
// Unique identifer for this market
|
// Unique identifer for this market
|
||||||
|
@ -26,7 +28,7 @@ export type LiteMarket = {
|
||||||
pool: number
|
pool: number
|
||||||
probability?: number
|
probability?: number
|
||||||
p?: number
|
p?: number
|
||||||
totalLiquidity?: number
|
totalShares?: number
|
||||||
|
|
||||||
volume: number
|
volume: number
|
||||||
volume7Days: number
|
volume7Days: number
|
||||||
|
@ -58,7 +60,6 @@ export function toLiteMarket(contract: Contract): LiteMarket {
|
||||||
description,
|
description,
|
||||||
tags,
|
tags,
|
||||||
slug,
|
slug,
|
||||||
pool,
|
|
||||||
outcomeType,
|
outcomeType,
|
||||||
mechanism,
|
mechanism,
|
||||||
volume,
|
volume,
|
||||||
|
@ -69,7 +70,7 @@ export function toLiteMarket(contract: Contract): LiteMarket {
|
||||||
resolutionTime,
|
resolutionTime,
|
||||||
} = contract
|
} = contract
|
||||||
|
|
||||||
const { p, totalLiquidity } = contract as any
|
const { p } = contract as any
|
||||||
|
|
||||||
const probability =
|
const probability =
|
||||||
contract.outcomeType === 'BINARY' ? getProbability(contract) : undefined
|
contract.outcomeType === 'BINARY' ? getProbability(contract) : undefined
|
||||||
|
@ -88,10 +89,9 @@ export function toLiteMarket(contract: Contract): LiteMarket {
|
||||||
description,
|
description,
|
||||||
tags,
|
tags,
|
||||||
url: `https://manifold.markets/${creatorUsername}/${slug}`,
|
url: `https://manifold.markets/${creatorUsername}/${slug}`,
|
||||||
pool: pool.YES + pool.NO,
|
pool: getPoolValue(contract),
|
||||||
probability,
|
probability,
|
||||||
p,
|
p,
|
||||||
totalLiquidity,
|
|
||||||
outcomeType,
|
outcomeType,
|
||||||
mechanism,
|
mechanism,
|
||||||
volume,
|
volume,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user