Skip to content

Commit

Permalink
feat: 🔥 fixed decimal
Browse files Browse the repository at this point in the history
  • Loading branch information
sadiabbasi committed Jan 21, 2025
1 parent 0386749 commit fa39d0f
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/utils/numbers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ export function formatTokenValue(amount: Decimal, maxDecimals = 4): string {
let formattedAmount: string;
const decimalPart = amount.toFixed().split('.')[1] || '';

console.log('amount', amount);

if (amount.equals(amount.floor())) {
formattedAmount = amount.toFixed(1);
formattedAmount = amount.toFixed(2);
} else if (decimalPart.length > maxDecimals) {
// If the decimal part exceeds maxDecimals, display only maxDecimals decimal places
formattedAmount = amount.toFixed(maxDecimals, Decimal.ROUND_DOWN);
Expand All @@ -38,7 +36,5 @@ export function formatTokenValue(amount: Decimal, maxDecimals = 4): string {
formattedAmount = amount.toString();
}

console.log('formattedAmount', formattedAmount);

return formattedAmount;
}

0 comments on commit fa39d0f

Please sign in to comment.