type BI = bigint
type BIish = BI | string | number
function toDecimals(amount: BIish, decimals: number): string {}
Convert BIish
to string by provided decimals
function fromDecimals(
amount: string,
decimals: number,
options?: Partial<BIParseOption>,
): BI {}
Convert string to BIish
by provided decimals
Parse options
type BIParseOption = {
isDecimalsCountOverflowPossible: boolean // throw error or ignore if string has more symbols than provided decimals
}
Default options
type BIParseOption = {
isDecimalsCountOverflowPossible: true
}
function fromBIish(amount: BIish): BI {}
Convert BIish
to strict BI
function fromBP(percentInBP: BI, percentDecimals = 2): number {}
Convert BigPercent to number, by default percent decimals equal 2
function formattedNumber(
value: number,
formatOptions?: Intl.NumberFormatOptions,
): string {}
Format number by formatOptions
. By default:
const defaultOptions = {
style: 'decimal',
minimumFractionDigits: 0,
maximumFractionDigits: 2,
}
function formattedDecimals(
amountTKN: BIish,
decimals: number,
formatOptions?: Intl.NumberFormatOptions,
): string {}
Format BI
by decimals
and formatOptions
. By default:
const defaultOptions = {
style: 'decimal',
minimumFractionDigits: 0,
maximumFractionDigits: 2,
}
BIMath.min(...values: BI[]): BI
Return min of provided values
BIMath.max(...values: BI[]): BI
Return max of provided values