FormatTokenAmountOptions
Defined in: core/src/utils/token-amount.ts:96
Options for formatTokenAmount.
Properties
Section titled “Properties”maxFractionDigits?
Section titled “maxFractionDigits?”
optionalmaxFractionDigits?:number
Defined in: core/src/utils/token-amount.ts:102
The most fraction digits to show. Digits past it are dropped as
roundingMode says. Defaults to the token’s decimals, which shows the
amount exactly, or to minFractionDigits when that is more.
minFractionDigits?
Section titled “minFractionDigits?”
optionalminFractionDigits?:number
Defined in: core/src/utils/token-amount.ts:107
The fewest fraction digits to show, padded with zeros: 2 shows one ICP
as "1.00". Defaults to 0.
trimTrailingZeros?
Section titled “trimTrailingZeros?”
optionaltrimTrailingZeros?:boolean
Defined in: core/src/utils/token-amount.ts:113
Drop zeros at the end of the fraction, down to minFractionDigits.
Defaults to true, so one ICP shows as "1". With false the fraction
is padded to maxFractionDigits: "1.00000000".
roundingMode?
Section titled “roundingMode?”
optionalroundingMode?:"trunc"|"halfExpand"
Defined in: core/src/utils/token-amount.ts:120
How digits past maxFractionDigits are dropped. "trunc" (the default)
cuts them, so a balance of 0.99999999 shown to two digits is "0.99",
never more than is held. "halfExpand" rounds half away from zero, as
Intl.NumberFormat does: "1".
locale?
Section titled “locale?”
optionallocale?:string| readonlystring[]
Defined in: core/src/utils/token-amount.ts:127
A BCP 47 locale, such as "de-DE", whose decimal separator, grouping and
digits to use, through Intl.NumberFormat. Without one the text is plain:
-, the digits 0-9 and ., the form parseTokenAmount reads back,
and the same on the server and in every browser.
useGrouping?
Section titled “useGrouping?”
optionaluseGrouping?:boolean
Defined in: core/src/utils/token-amount.ts:133
Group the whole part into thousands. Without a locale this writes ,
every three digits and defaults to false; with one it follows the
locale, as Intl.NumberFormat does.