Skip to content

Commit

Permalink
trim decimal zeros from points number
Browse files Browse the repository at this point in the history
  • Loading branch information
p6te committed Dec 31, 2024
1 parent 5dd95a8 commit e069d16
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ export const printBN = (amount: BN, decimals: number): string => {
}

export const formatNumberWithCommas = (number: string) => {
return number.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
const trimmedNumber = number.replace(/(\.\d*?[1-9])0+$/, '$1').replace(/\.0+$/, '')

return trimmedNumber.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
}

export const trimZeros = (numStr: string): string => {
Expand Down Expand Up @@ -1092,7 +1094,11 @@ export const handleSimulate = async (

okChanges += 1
} else if (
byAmountIn ? allFailedData.amountOut.lt(result) : allFailedData.amountOut.eq(MAX_U64) ? result : allFailedData.amountOut.lt(result)
byAmountIn
? allFailedData.amountOut.lt(result)
: allFailedData.amountOut.eq(MAX_U64)
? result
: allFailedData.amountOut.lt(result)
) {
allFailedData = {
amountOut: result,
Expand Down

0 comments on commit e069d16

Please sign in to comment.