fix: deal ticket fees value formatting (#2014)
* fix: #2002 use asset dp for estimate order * Update libs/deal-ticket/src/hooks/use-fee-deal-ticket-details.tsx * fix: fix linting issue for format value with market dp
This commit is contained in:
parent
25699b6283
commit
e0b2fb9bf3
@ -96,21 +96,35 @@ export const getFeeDetailsValues = ({
|
|||||||
estCloseOut,
|
estCloseOut,
|
||||||
market,
|
market,
|
||||||
}: FeeDetails) => {
|
}: FeeDetails) => {
|
||||||
const formatValue = (value: string | number | null | undefined): string => {
|
const formatValueWithMarketDp = (
|
||||||
|
value: string | number | null | undefined
|
||||||
|
): string => {
|
||||||
return value && !isNaN(Number(value))
|
return value && !isNaN(Number(value))
|
||||||
? normalizeFormatNumber(value, market.decimalPlaces)
|
? normalizeFormatNumber(value, market.decimalPlaces)
|
||||||
: '-';
|
: '-';
|
||||||
};
|
};
|
||||||
|
const formatValueWithAssetDp = (
|
||||||
|
value: string | number | null | undefined
|
||||||
|
): string => {
|
||||||
|
return value && !isNaN(Number(value))
|
||||||
|
? normalizeFormatNumber(
|
||||||
|
value,
|
||||||
|
market.tradableInstrument.instrument.product.settlementAsset.decimals
|
||||||
|
)
|
||||||
|
: '-';
|
||||||
|
};
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
label: t('Notional'),
|
label: t('Notional'),
|
||||||
value: formatValue(notionalSize),
|
value: formatValueWithMarketDp(notionalSize),
|
||||||
quoteName,
|
quoteName,
|
||||||
labelDescription: NOTIONAL_SIZE_TOOLTIP_TEXT,
|
labelDescription: NOTIONAL_SIZE_TOOLTIP_TEXT,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('Fees'),
|
label: t('Fees'),
|
||||||
value: estMargin?.totalFees && `~${formatValue(estMargin?.totalFees)}`,
|
value:
|
||||||
|
estMargin?.totalFees &&
|
||||||
|
`~${formatValueWithAssetDp(estMargin?.totalFees)}`,
|
||||||
labelDescription: (
|
labelDescription: (
|
||||||
<>
|
<>
|
||||||
<span>
|
<span>
|
||||||
@ -129,13 +143,14 @@ export const getFeeDetailsValues = ({
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('Margin'),
|
label: t('Margin'),
|
||||||
value: estMargin?.margin && `~${formatValue(estMargin?.margin)}`,
|
value:
|
||||||
|
estMargin?.margin && `~${formatValueWithAssetDp(estMargin?.margin)}`,
|
||||||
quoteName,
|
quoteName,
|
||||||
labelDescription: EST_MARGIN_TOOLTIP_TEXT,
|
labelDescription: EST_MARGIN_TOOLTIP_TEXT,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('Liquidation'),
|
label: t('Liquidation'),
|
||||||
value: estCloseOut && `~${formatValue(estCloseOut)}`,
|
value: estCloseOut && `~${formatValueWithMarketDp(estCloseOut)}`,
|
||||||
quoteName,
|
quoteName,
|
||||||
labelDescription: EST_CLOSEOUT_TOOLTIP_TEXT,
|
labelDescription: EST_CLOSEOUT_TOOLTIP_TEXT,
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user