diff --git a/src/utils.ts b/src/utils.ts index 82c66dd..e575013 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 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, 3) === '000' + + return new Intl.NumberFormat('en-US', { + style: 'currency', + currency: 'USD', + maximumFractionDigits: isMemeCoin ? 10 : 2 + }).format(price) } export const formatFileName = (coinName: string, fileExt: string): string => {