From e0b2fb9bf3b50836055c11b669e3b102fc96bdbb Mon Sep 17 00:00:00 2001 From: "m.ray" <16125548+MadalinaRaicu@users.noreply.github.com> Date: Thu, 10 Nov 2022 20:09:32 +0000 Subject: [PATCH] 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 --- .../src/hooks/use-fee-deal-ticket-details.tsx | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/libs/deal-ticket/src/hooks/use-fee-deal-ticket-details.tsx b/libs/deal-ticket/src/hooks/use-fee-deal-ticket-details.tsx index 3b6b8d759..9d38831d7 100644 --- a/libs/deal-ticket/src/hooks/use-fee-deal-ticket-details.tsx +++ b/libs/deal-ticket/src/hooks/use-fee-deal-ticket-details.tsx @@ -96,21 +96,35 @@ export const getFeeDetailsValues = ({ estCloseOut, market, }: FeeDetails) => { - const formatValue = (value: string | number | null | undefined): string => { + const formatValueWithMarketDp = ( + value: string | number | null | undefined + ): string => { return value && !isNaN(Number(value)) ? 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 [ { label: t('Notional'), - value: formatValue(notionalSize), + value: formatValueWithMarketDp(notionalSize), quoteName, labelDescription: NOTIONAL_SIZE_TOOLTIP_TEXT, }, { label: t('Fees'), - value: estMargin?.totalFees && `~${formatValue(estMargin?.totalFees)}`, + value: + estMargin?.totalFees && + `~${formatValueWithAssetDp(estMargin?.totalFees)}`, labelDescription: ( <> @@ -129,13 +143,14 @@ export const getFeeDetailsValues = ({ }, { label: t('Margin'), - value: estMargin?.margin && `~${formatValue(estMargin?.margin)}`, + value: + estMargin?.margin && `~${formatValueWithAssetDp(estMargin?.margin)}`, quoteName, labelDescription: EST_MARGIN_TOOLTIP_TEXT, }, { label: t('Liquidation'), - value: estCloseOut && `~${formatValue(estCloseOut)}`, + value: estCloseOut && `~${formatValueWithMarketDp(estCloseOut)}`, quoteName, labelDescription: EST_CLOSEOUT_TOOLTIP_TEXT, },