otterscan/src/components/formatter.ts

11 lines
316 B
TypeScript

import { ethers, BigNumber } from "ethers";
export const formatValue = (value: BigNumber, decimals: number): string => {
const formatted = ethers.utils.commify(
ethers.utils.formatUnits(value, decimals)
);
return formatted.endsWith(".0")
? formatted.slice(0, formatted.length - 2)
: formatted;
};