update api to include cfmm props
This commit is contained in:
		
							parent
							
								
									e39f6d4125
								
							
						
					
					
						commit
						927a5137a2
					
				|  | @ -1,7 +1,8 @@ | ||||||
| import { Bet } from '../../../../common/bet' | import { Bet } from '../../../../common/bet' | ||||||
| import { getDpmProbability } from '../../../../common/calculate-dpm' | import { getProbability } from '../../../../common/calculate' | ||||||
| import { Comment } from '../../../../common/comment' | import { Comment } from '../../../../common/comment' | ||||||
| import { DPM, FullContract } from '../../../../common/contract' | import { Contract } from '../../../../common/contract' | ||||||
|  | import { removeUndefinedProps } from '../../../../common/util/object' | ||||||
| 
 | 
 | ||||||
| export type LiteMarket = { | export type LiteMarket = { | ||||||
|   // Unique identifer for this market
 |   // Unique identifer for this market
 | ||||||
|  | @ -19,11 +20,16 @@ export type LiteMarket = { | ||||||
|   description: string |   description: string | ||||||
|   tags: string[] |   tags: string[] | ||||||
|   url: string |   url: string | ||||||
|  |   mechanism: string | ||||||
| 
 | 
 | ||||||
|   pool: number |   pool: number | ||||||
|   probability: number |   probability?: number | ||||||
|  |   p?: number | ||||||
|  |   totalLiquidity?: number | ||||||
|  | 
 | ||||||
|   volume7Days: number |   volume7Days: number | ||||||
|   volume24Hours: number |   volume24Hours: number | ||||||
|  | 
 | ||||||
|   isResolved: boolean |   isResolved: boolean | ||||||
|   resolution?: string |   resolution?: string | ||||||
|   resolutionTime?: number |   resolutionTime?: number | ||||||
|  | @ -38,26 +44,33 @@ export type ApiError = { | ||||||
|   error: string |   error: string | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export function toLiteMarket({ | export function toLiteMarket(contract: Contract): LiteMarket { | ||||||
|   id, |   const { | ||||||
|   creatorUsername, |     id, | ||||||
|   creatorName, |     creatorUsername, | ||||||
|   createdTime, |     creatorName, | ||||||
|   creatorAvatarUrl, |     createdTime, | ||||||
|   closeTime, |     creatorAvatarUrl, | ||||||
|   question, |     closeTime, | ||||||
|   description, |     question, | ||||||
|   tags, |     description, | ||||||
|   slug, |     tags, | ||||||
|   pool, |     slug, | ||||||
|   totalShares, |     pool, | ||||||
|   volume7Days, |     mechanism, | ||||||
|   volume24Hours, |     volume7Days, | ||||||
|   isResolved, |     volume24Hours, | ||||||
|   resolution, |     isResolved, | ||||||
|   resolutionTime, |     resolution, | ||||||
| }: FullContract<DPM, any>): LiteMarket { |     resolutionTime, | ||||||
|   return { |   } = contract | ||||||
|  | 
 | ||||||
|  |   const { p, totalLiquidity } = contract as any | ||||||
|  | 
 | ||||||
|  |   const probability = | ||||||
|  |     contract.outcomeType === 'BINARY' ? getProbability(contract) : undefined | ||||||
|  | 
 | ||||||
|  |   return removeUndefinedProps({ | ||||||
|     id, |     id, | ||||||
|     creatorUsername, |     creatorUsername, | ||||||
|     creatorName, |     creatorName, | ||||||
|  | @ -72,11 +85,14 @@ export function toLiteMarket({ | ||||||
|     tags, |     tags, | ||||||
|     url: `https://manifold.markets/${creatorUsername}/${slug}`, |     url: `https://manifold.markets/${creatorUsername}/${slug}`, | ||||||
|     pool: pool.YES + pool.NO, |     pool: pool.YES + pool.NO, | ||||||
|     probability: getDpmProbability(totalShares), |     probability, | ||||||
|  |     p, | ||||||
|  |     totalLiquidity, | ||||||
|  |     mechanism, | ||||||
|     volume7Days, |     volume7Days, | ||||||
|     volume24Hours, |     volume24Hours, | ||||||
|     isResolved, |     isResolved, | ||||||
|     resolution, |     resolution, | ||||||
|     resolutionTime, |     resolutionTime, | ||||||
|   } |   }) | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user