fix(trading): fix percentage formatter rounding in liquidity table (#5250)
This commit is contained in:
parent
f780013846
commit
22703d937e
@ -2,7 +2,6 @@ import { useMemo } from 'react';
|
|||||||
import {
|
import {
|
||||||
addDecimalsFormatNumber,
|
addDecimalsFormatNumber,
|
||||||
addDecimalsFormatNumberQuantum,
|
addDecimalsFormatNumberQuantum,
|
||||||
formatNumberPercentage,
|
|
||||||
getDateTimeFormat,
|
getDateTimeFormat,
|
||||||
} from '@vegaprotocol/utils';
|
} from '@vegaprotocol/utils';
|
||||||
import { t } from '@vegaprotocol/i18n';
|
import { t } from '@vegaprotocol/i18n';
|
||||||
@ -29,6 +28,12 @@ import { LiquidityProvisionStatus } from '@vegaprotocol/types';
|
|||||||
import { LiquidityProvisionStatusMapping } from '@vegaprotocol/types';
|
import { LiquidityProvisionStatusMapping } from '@vegaprotocol/types';
|
||||||
import type { LiquidityProvisionData } from './liquidity-data-provider';
|
import type { LiquidityProvisionData } from './liquidity-data-provider';
|
||||||
|
|
||||||
|
const formatNumberPercentage = (value: BigNumber, decimals?: number) => {
|
||||||
|
const decimalPlaces =
|
||||||
|
typeof decimals === 'undefined' ? value.dp() || 0 : decimals;
|
||||||
|
return `${value.toFixed(decimalPlaces, 1)}%`;
|
||||||
|
};
|
||||||
|
|
||||||
const percentageFormatter = ({ value }: ValueFormatterParams) => {
|
const percentageFormatter = ({ value }: ValueFormatterParams) => {
|
||||||
if (!value) return '-';
|
if (!value) return '-';
|
||||||
return formatNumberPercentage(new BigNumber(value).times(100), 2) || '-';
|
return formatNumberPercentage(new BigNumber(value).times(100), 2) || '-';
|
||||||
@ -126,11 +131,11 @@ export const LiquidityTable = ({
|
|||||||
new BigNumber(data.sla.currentEpochFractionOfTimeOnBook).times(
|
new BigNumber(data.sla.currentEpochFractionOfTimeOnBook).times(
|
||||||
100
|
100
|
||||||
),
|
),
|
||||||
2
|
4
|
||||||
),
|
),
|
||||||
formatNumberPercentage(
|
formatNumberPercentage(
|
||||||
new BigNumber(data.commitmentMinTimeFraction).times(100),
|
new BigNumber(data.commitmentMinTimeFraction).times(100),
|
||||||
2
|
4
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
@ -143,7 +148,7 @@ export const LiquidityTable = ({
|
|||||||
new BigNumber(data.sla.currentEpochFractionOfTimeOnBook).times(
|
new BigNumber(data.sla.currentEpochFractionOfTimeOnBook).times(
|
||||||
100
|
100
|
||||||
),
|
),
|
||||||
2
|
4
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user