Skip to content

Commit

Permalink
fix weiToFiatNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
legobeat committed Oct 28, 2024
1 parent 714774e commit 11bddd2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/util/number/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,9 +564,12 @@ export function addCurrencySymbol(
* @returns {Number} - The converted balance
*/
export function weiToFiatNumber(wei, conversionRate, decimalsToShow = 5) {
if (!conversionRate) {
return undefined;
}
const eth = new BigNumber(fromWei(wei), 10);
const value = parseFloat(eth.multipliedBy(new BigNumber(conversionRate, 10)).toPrecision(decimalsToShow));
return isNaN(value) ? '0.0' : value;
return value;
}

/**
Expand Down

0 comments on commit 11bddd2

Please sign in to comment.