Skip to content

Commit

Permalink
fix: small numbers as string
Browse files Browse the repository at this point in the history
  • Loading branch information
Majorfi committed Oct 12, 2023
1 parent 580ea7b commit 2578f27
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/utils/format.bigNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@ export function bigNumberAsAmount(
}${symbolWithPrefix}`);
}

export const toNormalizedValue = (v: bigint, d?: number): number => {
export const toNormalizedValue = (v: bigint, d?: number): number => {
return Number(formatUnits(v, d ?? 18));
};

export const toNormalizedAmount = (v: bigint, d?: number): string => {
export const toNormalizedAmount = (v: bigint, d?: number): string => {
return formatAmount(toNormalizedValue(v, d ?? 18), 6, 6);
};

export const toNormalizedBN = (value: TNumberish, decimals?: number): TNormalizedBN => ({
export const toNormalizedBN = (value: TNumberish, decimals?: number): TNormalizedBN => ({
raw: toBigInt(value),
normalized: toNormalizedValue(toBigInt(value), decimals ?? 18)
normalized: formatUnits(toBigInt(value), decimals ?? 18)
});

export function parseUnits(value: TNumberish, decimals = 18): bigint {
Expand Down

0 comments on commit 2578f27

Please sign in to comment.