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
|
||||
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
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue
Block a user