Skip to content

Commit

Permalink
fix: fix rounding for 1 eth
Browse files Browse the repository at this point in the history
  • Loading branch information
DiRaiks committed May 12, 2023
1 parent f9a41b4 commit 499c0b3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/http/nft/nft.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { MAX_AMOUNT_IN_ETH, MIN_AMOUNT_IN_WEI } from './nft.constants';
export const convertFromWei = (amountInWei: string, prefix?: string): string => {
const convertedInWei = parseFloat(formatUnits(amountInWei.toString(), 'wei'));
const amountInGwei = Math.floor(Number(formatUnits(amountInWei.toString(), 'gwei')) * 10000) / 10000;
const amountInEth = Math.floor(Number(formatUnits(amountInWei.toString(), 'ether')) * 10000) / 10000;
const amountInEth = Math.floor(Number(formatUnits(amountInWei.toString(), 'ether').slice(0, 16)) * 10000) / 10000;

if (amountInEth > 0.00009) {
return `${parseFloat(String(amountInEth))} ${prefix ? prefix : ''}ETH`;
Expand Down

0 comments on commit 499c0b3

Please sign in to comment.