Skip to content

Commit

Permalink
fix: prevent decimals removal if no tokens are selected
Browse files Browse the repository at this point in the history
  • Loading branch information
chybisov committed May 25, 2023
1 parent 9f17adb commit b78066e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/widget/src/utils/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const formatSlippage = (

export const formatInputAmount = (
amount: string,
decimals: number = 0,
decimals: number | null = null,
returnInitial: boolean = false,
) => {
if (!amount) {
Expand All @@ -82,7 +82,7 @@ export const formatInputAmount = (
return formattedAmount;
}
let [integer, fraction = ''] = formattedAmount.split('.');
if (fraction.length > decimals) {
if (decimals !== null && fraction.length > decimals) {
fraction = fraction.slice(0, decimals);
}
integer = integer.replace(/^0+|-/, '');
Expand Down

0 comments on commit b78066e

Please sign in to comment.