From 3ce0b7eae8a8efdccf1bb6bca9da5e948428d25a Mon Sep 17 00:00:00 2001 From: Zidious Date: Fri, 28 Mar 2025 01:43:30 +0000 Subject: [PATCH 1/2] fix: adjust price formatting to account for meme coins --- src/utils.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 82c66dd..b2d11ba 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -3,11 +3,6 @@ import chalk from 'chalk' const ERROR = chalk.bold.red const SUCCESS = chalk.bold.green -const formatter = new Intl.NumberFormat('en-US', { - style: 'currency', - currency: 'USD' -}) - export const logError = (message: string) => { console.error(ERROR(message)) process.exit(1) @@ -18,7 +13,16 @@ export const logSuccess = (message: string) => { } export const format = (price: number) => { - return formatter.format(price) + const decimalPart = price.toString().split('.')[1] + // If the decimal part starts with 0000, it's likely a meme coin + // and we want to show more decimal places to avoid showing 0.00 + const isMemeCoin = decimalPart && decimalPart.slice(0, 4) === '0000' + + return new Intl.NumberFormat('en-US', { + style: 'currency', + currency: 'USD', + maximumFractionDigits: isMemeCoin ? 10 : 2 + }).format(price) } export const formatFileName = (coinName: string, fileExt: string): string => { From 6ade1a25b20206cfcbb9f5209e92fedc23231db7 Mon Sep 17 00:00:00 2001 From: Zidious Date: Fri, 28 Mar 2025 01:44:49 +0000 Subject: [PATCH 2/2] fix: adjust price formatting to account for meme coins --- src/utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index b2d11ba..e575013 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -14,9 +14,9 @@ export const logSuccess = (message: string) => { export const format = (price: number) => { const decimalPart = price.toString().split('.')[1] - // If the decimal part starts with 0000, it's likely a meme coin + // If the decimal part starts with 000, it's likely a meme coin // and we want to show more decimal places to avoid showing 0.00 - const isMemeCoin = decimalPart && decimalPart.slice(0, 4) === '0000' + const isMemeCoin = decimalPart && decimalPart.slice(0, 3) === '000' return new Intl.NumberFormat('en-US', { style: 'currency',