Show 1 decimal point on probability tails
This commit is contained in:
parent
224a8214b4
commit
7d5d945a20
|
@ -19,7 +19,9 @@ export function formatWithCommas(amount: number) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatPercent(zeroToOne: number) {
|
export function formatPercent(zeroToOne: number) {
|
||||||
return Math.round(zeroToOne * 100) + '%'
|
// Show 1 decimal place if <2% or >99%
|
||||||
|
const decimalPlaces = zeroToOne < 0.02 || zeroToOne > 0.99 ? 1 : 0
|
||||||
|
return (zeroToOne * 100).toFixed(decimalPlaces) + '%'
|
||||||
}
|
}
|
||||||
|
|
||||||
export function toCamelCase(words: string) {
|
export function toCamelCase(words: string) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ import { Binary, Contract, FullContract } from '../../../common/contract'
|
||||||
import { getDpmProbability } from '../../../common/calculate-dpm'
|
import { getDpmProbability } from '../../../common/calculate-dpm'
|
||||||
import { createRNG, shuffle } from '../../../common/util/random'
|
import { createRNG, shuffle } from '../../../common/util/random'
|
||||||
import { getCpmmProbability } from '../../../common/calculate-cpmm'
|
import { getCpmmProbability } from '../../../common/calculate-cpmm'
|
||||||
import { formatMoney } from '../../../common/util/format'
|
import { formatMoney, formatPercent } from '../../../common/util/format'
|
||||||
import { getCpmmLiquidity } from '../../../common/calculate-cpmm'
|
import { getCpmmLiquidity } from '../../../common/calculate-cpmm'
|
||||||
export type { Contract }
|
export type { Contract }
|
||||||
|
|
||||||
|
@ -58,8 +58,7 @@ export function getBinaryProbPercent(contract: FullContract<any, Binary>) {
|
||||||
? getCpmmProbability(pool, p)
|
? getCpmmProbability(pool, p)
|
||||||
: getDpmProbability(totalShares)
|
: getDpmProbability(totalShares)
|
||||||
|
|
||||||
const probPercent = Math.round(prob * 100) + '%'
|
return formatPercent(prob)
|
||||||
return probPercent
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function tradingAllowed(contract: Contract) {
|
export function tradingAllowed(contract: Contract) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user