Skip to content

Commit

Permalink
toFixedDecimals should handle scientific notation (#2612)
Browse files Browse the repository at this point in the history
  • Loading branch information
kev1n-peters authored Sep 16, 2024
1 parent 59e1f32 commit e459ad5
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions wormhole-connect/src/utils/balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ export function toFixedDecimals(number: string, numDecimals: number) {
return '0';
}

const index = number.indexOf('.');
if (index === -1) {
if (!number.includes('.')) {
return number;
}

const end = index + (numDecimals || 18) + 1;
return `${Number.parseFloat(number.slice(0, end))}`;
return parseFloat(number).toFixed(numDecimals);
}

// Cache that stores calls to the coingecko API
Expand Down

0 comments on commit e459ad5

Please sign in to comment.