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 11bddd2 commit 97e92f3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/components/UI/Stake/hooks/useBalance.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('useBalance', () => {
expect(result.current.balanceFiatNumber).toBe(39506172511.6); // Fiat number balance
expect(result.current.stakedBalanceWei).toBe('5791332670714232000'); // No staked assets
expect(result.current.formattedStakedBalanceETH).toBe('5.79133 ETH'); // Formatted ETH balance
expect(result.current.stakedBalanceFiatNumber).toBe(18532.26454); // Staked balance in fiat number
expect(result.current.stakedBalanceFiatNumber).toBe(18532.26455); // Staked balance in fiat number
expect(result.current.formattedStakedBalanceFiat).toBe('$18532.26'); //
});

Expand Down
2 changes: 1 addition & 1 deletion app/util/number/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ export function weiToFiatNumber(wei, conversionRate, decimalsToShow = 5) {
return undefined;
}
const eth = new BigNumber(fromWei(wei), 10);
const value = parseFloat(eth.multipliedBy(new BigNumber(conversionRate, 10)).toPrecision(decimalsToShow));
const value = parseFloat(eth.multipliedBy(new BigNumber(conversionRate, 10)).decimalPlaces(decimalsToShow).toString());
return value;
}

Expand Down

0 comments on commit 97e92f3

Please sign in to comment.