11 lines
316 B
TypeScript
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;
|
||
|
};
|