Sort most traded by volume instead of pool size

This commit is contained in:
James Grugett 2022-03-23 00:27:22 -05:00
parent 364c6ad8e5
commit a967f7459d
2 changed files with 3 additions and 9 deletions

View File

@ -7,7 +7,6 @@ import {
contractMetrics, contractMetrics,
Contract, Contract,
listContracts, listContracts,
getBinaryProbPercent,
getBinaryProb, getBinaryProb,
} from '../lib/firebase/contracts' } from '../lib/firebase/contracts'
import { User } from '../lib/firebase/users' import { User } from '../lib/firebase/users'
@ -16,7 +15,6 @@ import { SiteLink } from './site-link'
import { ContractCard } from './contract-card' import { ContractCard } from './contract-card'
import { Sort, useQueryAndSortParams } from '../hooks/use-sort-and-query-params' import { Sort, useQueryAndSortParams } from '../hooks/use-sort-and-query-params'
import { Answer } from '../../common/answer' import { Answer } from '../../common/answer'
import { getProbability } from '../../common/calculate'
export function ContractsGrid(props: { export function ContractsGrid(props: {
contracts: Contract[] contracts: Contract[]
@ -249,9 +247,7 @@ export function SearchableGrid(props: {
({ closeTime }) => closeTime && closeTime > Date.now() !== hideClosed ({ closeTime }) => closeTime && closeTime > Date.now() !== hideClosed
) )
} else if (sort === 'most-traded') { } else if (sort === 'most-traded') {
matches.sort( matches.sort((a, b) => b.volume - a.volume)
(a, b) => contractMetrics(b).truePool - contractMetrics(a).truePool
)
} else if (sort === '24-hour-vol') { } else if (sort === '24-hour-vol') {
// Use lodash for stable sort, so previous sort breaks all ties. // Use lodash for stable sort, so previous sort breaks all ties.
matches = _.sortBy(matches, ({ volume7Days }) => -1 * volume7Days) matches = _.sortBy(matches, ({ volume7Days }) => -1 * volume7Days)

View File

@ -29,9 +29,7 @@ export function contractPath(contract: Contract) {
} }
export function contractMetrics(contract: Contract) { export function contractMetrics(contract: Contract) {
const { pool, createdTime, resolutionTime, isResolved } = contract const { createdTime, resolutionTime, isResolved } = contract
const truePool = _.sum(Object.values(pool))
const createdDate = dayjs(createdTime).format('MMM D') const createdDate = dayjs(createdTime).format('MMM D')
@ -41,7 +39,7 @@ export function contractMetrics(contract: Contract) {
const volumeLabel = `${formatMoney(contract.volume)} volume` const volumeLabel = `${formatMoney(contract.volume)} volume`
return { truePool, volumeLabel, createdDate, resolvedDate } return { volumeLabel, createdDate, resolvedDate }
} }
export function getBinaryProb(contract: FullContract<any, Binary>) { export function getBinaryProb(contract: FullContract<any, Binary>) {