# Class: DCA

## DCA(options)

Service class to handle interacting with the Cask DCA system

## Constructor

#### new DCA(options)

Create an instance of the DCA service.

##### Parameters:

Name | Type | Description
--- | --- | ---
`options` |  | See CaskSDK configuration.

See:
  - CaskSDK

### Methods

#### (async) assetDefinition() → {Promise.<DCA.DCAAssetDefinition>}

Get the specified asset definition from the asset manifest

##### Returns:

Type
  Promise.<DCA.DCAAssetDefinition>

#### (async) assetPrice() → {Promise.<BigNumber>}

Get the current price of a DCA asset denominated in the vault base asset

##### Returns:

Type
  Promise.<BigNumber>

#### (async) cancel(dcaId) → {Promise.<{tx: *}>}

Cancel a DCA.

##### Parameters:

Name | Type | Description
--- | --- | ---
`dcaId` | string | DCA ID

##### Returns:

Type
  Promise.<{tx: *}>

#### (async) create(args) → {DCA.CreateDCAResult}

Create a new DCA.

##### Parameters:

Name | Type | Description
--- | --- | ---
`args` | Object | Function arguments ###### Properties
Name | Type | Description
--- | --- | ---
`asset` | string | Address of asset to DCA

##### Returns:

Type
  DCA.CreateDCAResult

#### (async) estimatedCommitment(address, periodopt)

Get the estimated spend for a DCA for a specific period

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`address` | string |  |  | User address
`period` | number | <optional> | 1 month | Commitment period

#### (async) get(dcaId) → {Promise.<DCA.DCADetail>}

Get the details of a specific DCA.

##### Parameters:

Name | Type | Description
--- | --- | ---
`dcaId` |  |

See:
  - The SDK guide for more details on unit formatting at https://docs.cask.fi/developer-docs/javascript-sdk

##### Returns:

Type
  Promise.<DCA.DCADetail>

#### (async) history(dcaId, queryoptsopt) → {Promise.<*>}

Get history for a DCA flow

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`dcaId` | string |  | DCA ID
`queryopts` |  | <optional> | Optional query options ###### Properties
Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`limit` |  | <optional> | 10 | Limit
`offset` |  | <optional> | 0 | Offset
`orderBy` |  | <optional> | timestamp | Order by
`orderDirection` |  | <optional> | desc | Order direction, one of asc or desc
`options` |  | <optional> | asc | Optional options to pass to apollo for graphQL

##### Returns:

Type
  Promise.<*>

#### (async) init(args)

Initialize the DCA service.

##### Parameters:

Name | Type | Description
--- | --- | ---
`args` | Object | Function arguments ###### Properties
Name | Type | Attributes | Description
--- | --- | --- | ---
`ethersConnection` | EthersConnection | <optional> | EthersConnection instance

#### (async) loadDCAManifest() → {Promise.<Object>}

Load the DCA asset manifest.

##### Returns:

Type
  Promise.<Object>

#### (async) pause(dcaId) → {Promise.<{tx: *}>}

Pause an active DCA

##### Parameters:

Name | Type | Description
--- | --- | ---
`dcaId` | string | DCA ID

##### Returns:

Type
  Promise.<{tx: *}>

#### (async) resume(dcaId) → {Promise.<{tx: *}>}

Resume a paused DCA.

##### Parameters:

Name | Type | Description
--- | --- | ---
`dcaId` | string | DCA ID

##### Returns:

Type
  Promise.<{tx: *}>

### Type Definitions

#### CreateDCAResult

##### Properties:

Name | Type | Description
--- | --- | ---
`tx` | Object | Create Transaction
`chainId` | number | Chain ID that the transaction took place on
`dcaId` | string | ID of newly created DCA

#### DCAAssetDefinition

##### Properties:

Name | Type | Description
--- | --- | ---
`outputAssetSymbol` | string | Outut asset symbol

#### DCADetail

##### Properties:

Name | Type | Description
--- | --- | ---
`dcaId` | string | DCA ID
`status` | number | DCA status
`createdAt` | number | Unix timestamp of DCA creation time