diff --git a/ui/pages/swaps/swaps.util.test.js b/ui/pages/swaps/swaps.util.test.js index 05f06f7d1..642879484 100644 --- a/ui/pages/swaps/swaps.util.test.js +++ b/ui/pages/swaps/swaps.util.test.js @@ -401,6 +401,12 @@ describe('Swaps Util', () => { '39.6493201125', ); }); + + it('gets swaps value for display when the value contains three dots', () => { + expect(formatSwapsValueForDisplay('33680099000000000000...')).toBe( + '33680099000000000000...', + ); + }); }); describe('getSwapsTokensReceivedFromTxMeta', () => { diff --git a/ui/pages/swaps/swaps.util.ts b/ui/pages/swaps/swaps.util.ts index 566faa93f..7782f0df8 100644 --- a/ui/pages/swaps/swaps.util.ts +++ b/ui/pages/swaps/swaps.util.ts @@ -545,8 +545,18 @@ export function quotesToRenderableData({ }); } -export function formatSwapsValueForDisplay(destinationAmount: string): string { - let amountToDisplay = toPrecisionWithoutTrailingZeros(destinationAmount, 12); +export function formatSwapsValueForDisplay( + destinationAmount: string | BigNumber, +): string { + let amountToDisplay; + if ( + typeof destinationAmount === 'string' && + destinationAmount.includes('...') + ) { + amountToDisplay = destinationAmount; + } else { + amountToDisplay = toPrecisionWithoutTrailingZeros(destinationAmount, 12); + } if (amountToDisplay.match(/e[+-]/u)) { amountToDisplay = new BigNumber(amountToDisplay).toFixed(); }