8 lines
277 B
TypeScript
8 lines
277 B
TypeScript
|
import type { BigNumber } from './bignumber';
|
||
|
|
||
|
export const formatNumber = (value: BigNumber, decimals?: number) => {
|
||
|
const decimalPlaces =
|
||
|
typeof decimals === 'undefined' ? Math.max(value.dp(), 2) : decimals;
|
||
|
return value.dp(decimalPlaces).toFormat(decimalPlaces);
|
||
|
};
|