Show decimals on 98%+
This commit is contained in:
parent
434c7b6b97
commit
d6a751d9a2
|
@ -19,8 +19,8 @@ export function formatWithCommas(amount: number) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatPercent(zeroToOne: number) {
|
export function formatPercent(zeroToOne: number) {
|
||||||
// Show 1 decimal place if <2% or >99%
|
// Show 1 decimal place if <2% or >98%, giving more resolution on the tails
|
||||||
const decimalPlaces = zeroToOne < 0.02 || zeroToOne > 0.99 ? 1 : 0
|
const decimalPlaces = zeroToOne < 0.02 || zeroToOne > 0.98 ? 1 : 0
|
||||||
return (zeroToOne * 100).toFixed(decimalPlaces) + '%'
|
return (zeroToOne * 100).toFixed(decimalPlaces) + '%'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ export function AnswerBetPanel(props: {
|
||||||
: 0
|
: 0
|
||||||
|
|
||||||
const currentReturn = betAmount ? (currentPayout - betAmount) / betAmount : 0
|
const currentReturn = betAmount ? (currentPayout - betAmount) / betAmount : 0
|
||||||
const currentReturnPercent = (currentReturn * 100).toFixed() + '%'
|
const currentReturnPercent = formatPercent(currentReturn)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Col className={clsx('px-2 pb-2 pt-4 sm:pt-0', className)}>
|
<Col className={clsx('px-2 pb-2 pt-4 sm:pt-0', className)}>
|
||||||
|
|
|
@ -112,7 +112,7 @@ export function BetPanel(props: {
|
||||||
: 0
|
: 0
|
||||||
|
|
||||||
const currentReturn = betAmount ? (currentPayout - betAmount) / betAmount : 0
|
const currentReturn = betAmount ? (currentPayout - betAmount) / betAmount : 0
|
||||||
const currentReturnPercent = (currentReturn * 100).toFixed() + '%'
|
const currentReturnPercent = formatPercent(currentReturn)
|
||||||
|
|
||||||
const panelTitle = title ?? 'Place a trade'
|
const panelTitle = title ?? 'Place a trade'
|
||||||
if (title) {
|
if (title) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user