Units helpers and utilities
Methods
Format an amount from a price feed. If no units are supplied. uses the globally configured default units from the SDK
initialization.
Parameters:
Name |
Type |
Description |
args |
Object
|
Function arguments
Properties
Name |
Type |
Attributes |
Default |
Description |
amount |
BigNumber
|
number
|
string
|
|
|
Amount to format |
asset |
Asset
|
<optional>
|
|
Asset being formatted |
decimals |
number
|
<optional>
|
|
Number of decimals for asset formatting. If not supplied, uses priceFeedDecimals from the specified asset. |
units |
string
|
<optional>
|
|
Units of output |
unitOptions |
Object
|
<optional>
|
{}
|
Options passed to unit formatter. |
|
- See:
-
Returns:
-
Type
-
string
|
number
|
*
Format an amount of an asset. If no units are supplied. uses the globally configured default units from the SDK
initialization.
Parameters:
Name |
Type |
Description |
args |
Object
|
Function arguments
Properties
Name |
Type |
Attributes |
Default |
Description |
amount |
BigNumber
|
number
|
string
|
|
|
Amount to format |
asset |
Asset
|
<optional>
|
|
Asset being formatted |
decimals |
number
|
<optional>
|
|
Number of decimals for asset formatting. If not supplied, uses assetDecimals from the specified asset. |
units |
string
|
<optional>
|
|
Units of output |
unitOptions |
Object
|
<optional>
|
{}
|
Options passed to unit formatter. |
|
- See:
-
Returns:
-
Type
-
string
|
number
|
*
(static) humanizePeriod(seconds) → {string}
Return human-friendly wording for a given period specified in seconds
Parameters:
Name |
Type |
Description |
seconds |
number
|
Period in seconds |
Returns:
-
Type
-
string
(static) roundDown(amount, digits) → {number}
Drop all but the specified digits from a floating point value.
Parameters:
Name |
Type |
Default |
Description |
amount |
|
|
Amount |
digits |
|
2
|
Number of decimals to keep |
Returns:
-
Type
-
number
(static) scalePrice(amount, amountDecimals, toDecimals) → {BigNumber}
Scale an amount between two different decimal formats
Parameters:
Name |
Type |
Description |
amount |
|
Amount to scale |
amountDecimals |
|
Number of decimals to scale from |
toDecimals |
|
Number of decimals to scale to |
Returns:
-
Type
-
BigNumber