diff --git a/packages/ui/src/components/common/TransactionModal/steps/SwapSuccessStep.tsx b/packages/ui/src/components/common/TransactionModal/steps/SwapSuccessStep.tsx index d7a13e780..e1037e675 100644 --- a/packages/ui/src/components/common/TransactionModal/steps/SwapSuccessStep.tsx +++ b/packages/ui/src/components/common/TransactionModal/steps/SwapSuccessStep.tsx @@ -20,7 +20,7 @@ import { useRelayClient } from '../../../../hooks/index.js' import { faClockFour } from '@fortawesome/free-solid-svg-icons/faClockFour' import type { Execute } from '@reservoir0x/relay-sdk' import { bitcoin } from '../../../../utils/bitcoin.js' -import { formatBN, formatToSignificantDigits } from '../../../../utils/numbers.js' +import { formatBN } from '../../../../utils/numbers.js' import { TransactionsByChain } from './TransactionsByChain.js' import { faArrowRight } from '@fortawesome/free-solid-svg-icons' @@ -62,13 +62,10 @@ export const SwapSuccessStep: FC = ({ const isUnwrap = details?.operation === 'unwrap' const _fromAmountFormatted = transaction?.data?.metadata?.currencyIn?.amount - ? formatToSignificantDigits( - formatBN( - transaction?.data?.metadata?.currencyIn?.amount, - 20, - transaction?.data?.metadata?.currencyIn?.currency?.decimals ?? 18, - false - ) + ? formatBN( + transaction?.data?.metadata?.currencyIn?.amount, + 5, + transaction?.data?.metadata?.currencyIn?.currency?.decimals ?? 18 ) : fromAmountFormatted const _fromToken = @@ -77,13 +74,10 @@ export const SwapSuccessStep: FC = ({ transaction?.data?.metadata?.currencyIn?.currency?.metadata?.logoURI ?? fromToken?.logoURI const _toAmountFormatted = transaction?.data?.metadata?.currencyOut?.amount - ? formatToSignificantDigits( - formatBN( - transaction?.data?.metadata?.currencyOut?.amount, - 20, - transaction?.data?.metadata?.currencyOut?.currency?.decimals ?? 18, - false - ) + ? formatBN( + transaction?.data?.metadata?.currencyOut?.amount, + 5, + transaction?.data?.metadata?.currencyOut?.currency?.decimals ?? 18 ) : toAmountFormatted const _toToken = transaction?.data?.metadata?.currencyOut?.currency ?? toToken @@ -118,13 +112,10 @@ export const SwapSuccessStep: FC = ({ transaction?.data?.metadata?.currencyGasTopup?.currency const formattedGasTopUpAmount = transaction?.data?.metadata?.currencyGasTopup ?.amount - ? formatToSignificantDigits( - formatBN( - BigInt(transaction?.data?.metadata?.currencyGasTopup?.amount), - 20, - gasTopUpAmountCurrency?.decimals ?? 18, - false - ) + ? formatBN( + BigInt(transaction?.data?.metadata?.currencyGasTopup?.amount), + 5, + gasTopUpAmountCurrency?.decimals ?? 18 ) : undefined diff --git a/packages/ui/src/utils/numbers.ts b/packages/ui/src/utils/numbers.ts index b7a1ce99d..f8b117fba 100644 --- a/packages/ui/src/utils/numbers.ts +++ b/packages/ui/src/utils/numbers.ts @@ -240,29 +240,10 @@ function formatFixedLength(amount: string, maxLength: number) { return result } -/** - * Formats a number to show a specified number of significant digits - * @param amount The number to format (string, number, or bigint) - * @param significantDigits The number of significant digits to show (defaults to 6) - * @returns A string representation with the specified significant digits - */ -function formatToSignificantDigits(amount: string | number | bigint, significantDigits: number = 6): string { - if (amount === null || amount === undefined) return '-' - - const num = typeof amount === 'string' ? parseFloat(amount) : Number(amount) - - if (num === 0 || isNaN(num)) return '0' - - const formatted = num.toPrecision(significantDigits) - - return formatted.replace(/\.?0+$/, '').replace(/\.?0+e/, 'e') -} - export { formatDollar, formatBN, formatFixedLength, formatNumber, - formatToSignificantDigits, truncateBalance }