# Namespace: units

## CaskSDK.units

Units helpers and utilities

### Members

#### (static, constant) BASE_ASSET_DECIMALS :number

Asset decimals used by Cask base asset

##### Type:

- number

### Methods

#### (static) formatFeedUnits(args) → {string|number|*}

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:
  - The SDK guide for more details on unit formatting at https://docs.cask.fi/developer-docs/javascript-sdk

##### Returns:

Type
  string | number | *

#### (static) formatUnits(args) → {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:
  - The SDK guide for more details on unit formatting at https://docs.cask.fi/developer-docs/javascript-sdk

##### 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