# Dollar-Cost Averaging (DCA)

The goal of this function is to periodically buy a fixed amount of a token using slippage-protected swaps.

For example, suppose the inputs are:

* Token In: USDC
* Token Out: WETH

And the cron trigger schedule is `30 19 * * 0`, meaning:

* `30` -> minute
* `19` -> hour UTC
* `*` -> every day of the month
* `*` -> every month
* `0` -> 0 = Sunday, 1 = Monday, etc

Then the function will buy 100 USDC worth of WETH every Sunday at 7:30 PM UTC.

### Function

{% @github-files/github-code-block url="<https://github.com/mimic-protocol/examples/blob/main/examples/12-dollar-cost-averaging/src/function.ts>" visible="false" %}

[Github link](https://github.com/mimic-protocol/examples/blob/main/examples/12-dollar-cost-averaging/src/function.ts)

### Manifest

{% @github-files/github-code-block url="<https://github.com/mimic-protocol/examples/blob/main/examples/12-dollar-cost-averaging/manifest.yaml>" visible="false" %}

[Github link](https://github.com/mimic-protocol/examples/blob/main/examples/12-dollar-cost-averaging/manifest.yaml)
