Skip to content

Commit

Permalink
Merge pull request #56 from lidofinance/fix/fix_convert_amount
Browse files Browse the repository at this point in the history
fix: fix rounding for 1 eth
  • Loading branch information
DiRaiks authored May 12, 2023
2 parents 295f39e + 499c0b3 commit a6fb500
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 a6fb500

Please sign in to comment.