> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cashmere.exchange/llms.txt
> Use this file to discover all available pages before exploring further.

# Automation

> Auto-compound, auto-range and auto-exit: what each does, what you allow, what it costs and how to stop it.

<Frame>
  <img src="https://mintcdn.com/cashmerelabs/VaU9JZozZKsaMUY5/images/goat-lp/cover-automation.png?fit=max&auto=format&n=VaU9JZozZKsaMUY5&q=85&s=523eccd14fb8a34aa53a46ff2bb30914" alt="Automation cover: auto-compound, auto-range and auto-exit cards with only auto-compound switched on (one automation per position), and the pixel goat keeper holding a wrench." noZoom width="1600" height="640" data-path="images/goat-lp/cover-automation.png" />
</Frame>

<Callout type="warning">
  Goat LP is experimental. Use small amounts.
</Callout>

Let a keeper do routine work on your positions. You stay the owner, you can still deposit, withdraw and
collect, and you can stop at any time. Automation is live on Uniswap v3 and v4.

## The three automations

| | What it does | Goat LP fee | Gas |
| - | - | - | - |
| **Auto-compound** | Adds the fees your position collects back into it, when that is worth the gas | 10% of the fees added back | Paid by us |
| **Auto-range** | When the price leaves your range by the distance you set, moves the position to a new range around the price | 0.15% per move | Paid by us |
| **Auto-exit** | Closes the position when the price reaches a level you set, above, below or both. Runs once, then turns itself off | 0.15% once, when it closes | Paid by us |

On Uniswap v4, auto-compound can also **send the fees to your wallet** instead of adding them back: 10% of
the fees collected, gas paid by us. The exact base of each fee is on [Fees](/goat-lp/fees).

A position runs **one automation at a time**. Stop one before you start another.

<Frame>
  <video autoPlay muted loop playsInline className="w-full rounded-xl" src="https://mintcdn.com/cashmerelabs/VaU9JZozZKsaMUY5/images/goat-lp/loop-auto-range.mp4?fit=max&auto=format&n=VaU9JZozZKsaMUY5&q=85&s=da518fd11309297120f7aac12fea6256" poster="/images/goat-lp/loop-auto-range.gif" aria-label="Auto-range loop: the price leaves your range, a price check passes, the range moves to centre on the current price and the new position NFT goes to your wallet; 0.15% of the amount moved, gas paid by us." data-path="images/goat-lp/loop-auto-range.mp4">
    <img src="https://mintcdn.com/cashmerelabs/VaU9JZozZKsaMUY5/images/goat-lp/loop-auto-range.gif?s=5d5fe99ca7f3c5d3bee907aa0febad23" alt="Auto-range loop: the price leaves your range, a price check passes, the range moves to centre on the current price and the new position NFT goes to your wallet; 0.15% of the amount moved, gas paid by us." width="1200" height="630" data-path="images/goat-lp/loop-auto-range.gif" />
  </video>
</Frame>

## How a run works

<Tabs>
  <Tab title="Price check">
    <img className="block dark:hidden" src="https://mintcdn.com/cashmerelabs/VaU9JZozZKsaMUY5/images/goat-lp/diagram-price-protection-light.png?fit=max&auto=format&n=VaU9JZozZKsaMUY5&q=85&s=e36eb159b82f1aff8dff885c91efed20" alt="Price protection: every automatic swap (in a compound, a range move or a swap exit) first checks a Chainlink price, or the time-weighted average of a deep reference pool; pairs with neither get no automation. If the prices agree it acts; if the check is not ready or the prices do not agree, it waits." width="2400" height="940" data-path="images/goat-lp/diagram-price-protection-light.png" />

    <img className="hidden dark:block" src="https://mintcdn.com/cashmerelabs/VaU9JZozZKsaMUY5/images/goat-lp/diagram-price-protection-dark.png?fit=max&auto=format&n=VaU9JZozZKsaMUY5&q=85&s=4ea26b81468a8f74592b3d3f6c79d42b" alt="Price protection: every automatic swap (in a compound, a range move or a swap exit) first checks a Chainlink price, or the time-weighted average of a deep reference pool; pairs with neither get no automation. If the prices agree it acts; if the check is not ready or the prices do not agree, it waits." width="2400" height="940" data-path="images/goat-lp/diagram-price-protection-dark.png" />
  </Tab>

  <Tab title="Auto-compound">
    <img className="block dark:hidden" src="https://mintcdn.com/cashmerelabs/VaU9JZozZKsaMUY5/images/goat-lp/diagram-auto-compound-light.png?fit=max&auto=format&n=VaU9JZozZKsaMUY5&q=85&s=10c110f60e38d060f8a33da346128e9b" alt="Auto-compound: a Goat keeper starts each run and the gas is paid by us; of the collected fees, 10% of the fees added back goes to the Cashmere fee address and the rest is added back into your position. On Uniswap v4, Send fees to my wallet sends the fees to your wallet instead, for 10% of the fees collected." width="2400" height="1200" data-path="images/goat-lp/diagram-auto-compound-light.png" />

    <img className="hidden dark:block" src="https://mintcdn.com/cashmerelabs/VaU9JZozZKsaMUY5/images/goat-lp/diagram-auto-compound-dark.png?fit=max&auto=format&n=VaU9JZozZKsaMUY5&q=85&s=fc6cc2f6f8b7573236228c4d02af3164" alt="Auto-compound: a Goat keeper starts each run and the gas is paid by us; of the collected fees, 10% of the fees added back goes to the Cashmere fee address and the rest is added back into your position. On Uniswap v4, Send fees to my wallet sends the fees to your wallet instead, for 10% of the fees collected." width="2400" height="1200" data-path="images/goat-lp/diagram-auto-compound-dark.png" />
  </Tab>

  <Tab title="Auto-range">
    <img className="block dark:hidden" src="https://mintcdn.com/cashmerelabs/VaU9JZozZKsaMUY5/images/goat-lp/diagram-auto-range-light.png?fit=max&auto=format&n=VaU9JZozZKsaMUY5&q=85&s=d0270ea680b75056bad7f93667eaf3b6" alt="Auto-range: when the price leaves your range, a price check runs, then a new range centred on the current price is opened and the new position NFT goes to your wallet; 0.15% of the amount moved per move." width="2400" height="1000" data-path="images/goat-lp/diagram-auto-range-light.png" />

    <img className="hidden dark:block" src="https://mintcdn.com/cashmerelabs/VaU9JZozZKsaMUY5/images/goat-lp/diagram-auto-range-dark.png?fit=max&auto=format&n=VaU9JZozZKsaMUY5&q=85&s=b6a2c19bcb4858f02fd417684becaffa" alt="Auto-range: when the price leaves your range, a price check runs, then a new range centred on the current price is opened and the new position NFT goes to your wallet; 0.15% of the amount moved per move." width="2400" height="1000" data-path="images/goat-lp/diagram-auto-range-dark.png" />
  </Tab>

  <Tab title="Auto-exit">
    <img className="block dark:hidden" src="https://mintcdn.com/cashmerelabs/VaU9JZozZKsaMUY5/images/goat-lp/diagram-auto-exit-light.png?fit=max&auto=format&n=VaU9JZozZKsaMUY5&q=85&s=aee7d276a23394118798f7d5df536b39" alt="Auto-exit: when the price hits your level the position closes once, either keeping both tokens (withdraw at once) or withdrawing and then swapping into one token after a price check; then the rule turns itself off; 0.15% once. Swap exits may wait and try again." width="2400" height="1184" data-path="images/goat-lp/diagram-auto-exit-light.png" />

    <img className="hidden dark:block" src="https://mintcdn.com/cashmerelabs/VaU9JZozZKsaMUY5/images/goat-lp/diagram-auto-exit-dark.png?fit=max&auto=format&n=VaU9JZozZKsaMUY5&q=85&s=62bb60c360d9412963992a75f129e942" alt="Auto-exit: when the price hits your level the position closes once, either keeping both tokens (withdraw at once) or withdrawing and then swapping into one token after a price check; then the rule turns itself off; 0.15% once. Swap exits may wait and try again." width="2400" height="1184" data-path="images/goat-lp/diagram-auto-exit-dark.png" />
  </Tab>
</Tabs>

* The keeper only triggers the run. The contract decides what happens and where the money goes.
* Before any swap, the contract compares the pool price with an outside price, so one big trade in the pool
  cannot set off a run or push its price.
* Every output goes to the position's owner. The keeper receives nothing.

## Turn it on

<Steps>
  <Step title="Open the setup sheet">
    Press **Automate** on the position page and pick **Auto-compound**, **Auto-range** or **Auto-exit**. The
    sheet says straight away if the automation cannot run on this position, and why.
  </Step>

  <Step title="Pick your settings">
    Every field starts with a default. The picture shows your range and the prices where we act. The cost
    line shows Goat's fee and that the gas is paid by us.
  </Step>

  <Step title="Review, then two wallet steps">
    **Allow this position**, then **Turn on**. Changing a rule later is one step, **Save changes**, and the
    permission stays. Nothing is sent until you confirm in your wallet.
  </Step>
</Steps>

## What you allow

Every automation works through a permission for **one position**. The one exception is auto-range: you can
give one permission for all your positions of one Uniswap version, see
[Allow for all positions](/goat-lp/allow-for-all-positions).

<img className="block dark:hidden" src="https://mintcdn.com/cashmerelabs/VaU9JZozZKsaMUY5/images/goat-lp/diagram-per-position-permission-light.png?fit=max&auto=format&n=VaU9JZozZKsaMUY5&q=85&s=0a2830dc770477245b193513c10ad9f0" alt="Per-position permission: the automation contract gets permission for one position only (here Position C, with auto-range on); every position NFT stays in your wallet, and an automation never blocks collect or withdraw." width="2400" height="1120" data-path="images/goat-lp/diagram-per-position-permission-light.png" />

<img className="hidden dark:block" src="https://mintcdn.com/cashmerelabs/VaU9JZozZKsaMUY5/images/goat-lp/diagram-per-position-permission-dark.png?fit=max&auto=format&n=VaU9JZozZKsaMUY5&q=85&s=928b04a2f7b0367c3cd7c7dc09dfa858" alt="Per-position permission: the automation contract gets permission for one position only (here Position C, with auto-range on); every position NFT stays in your wallet, and an automation never blocks collect or withdraw." width="2400" height="1120" data-path="images/goat-lp/diagram-per-position-permission-dark.png" />

| Automation | Uniswap v3 | Uniswap v4 |
| - | - | - |
| Auto-compound | One position, to the auto-compound contract. Your NFT never moves | One position, used up by each compound: the app asks you to allow it again after every run |
| Auto-range | One position, to the auto-range contract | One position, to the Goat automation engine |
| Auto-exit | One position, to the auto-exit contract | One position, to the Goat automation engine |

**After each auto-range move** the new position has a new number and needs your OK before it can move
again: **Allow #new**, one tap, a network fee under a cent, no Goat LP fee. Your settings move with it.
You can skip this tap with [Allow for all positions](/goat-lp/allow-for-all-positions).

**On Uniswap v3, a manual compound, or a withdraw or collect to one token,** moves the NFT through a
contract and back, which removes the permission you gave that position. If an automation is on, the app
says so before your wallet opens and adds **Allow again** to the same transaction (a second wallet step if
your wallet cannot batch calls).

<Callout type="info">
  On Uniswap v3 and v4, a permission on a position lets the allowed contract manage that position. What
  limits it is the contract's code: each Goat contract only runs the rule you set and sends every output to
  the owner. The contract addresses are on [Contracts](/goat-lp/contracts).
</Callout>

## Settings

<AccordionGroup>
  <Accordion title="Auto-compound">
    * **At most once every:** 1 hour (default), 6 hours, 12 hours, 1 day or 7 days.
    * **Price protection:** the most the swap may lose against the outside price (default 1%).
    * **Uniswap v4 mode:** **Add fees back** (default) or **Send fees to my wallet**.
    * **Uniswap v3:** **Swap to match the range**. Off: only the matching part is added; the rest comes back
      to you without a fee.
  </Accordion>

  <Accordion title="Auto-range">
    * **How far past the edge before we move:** at least the pair's minimum, shown in the sheet.
    * **Width of each new range:** on v3, same as now or custom; on v4, the same width as now.
    * **Price protection per move:** default 0.50%.
    * **Uniswap v4 only:** wait between moves (1 hour to 30 days, default 6 hours), the highest swap fee in a
      move (default 1%, at most 10%) and 20 moves before you save the rule again.
    * **Uniswap v3:** no wait between moves.
  </Accordion>

  <Accordion title="Auto-exit">
    * A level below your range, above it, or both. The sheet suggests 5% beyond each edge.
    * **Keep** (withdraw only) acts as soon as the pool price reaches your level.
    * **Swap all to** one token also checks the outside price first, so in a fast move it can wait.
    * In a sudden jump the price can pass your level before we act, so you may get less than shown.
  </Accordion>
</AccordionGroup>

## Where it can run

* **Listed pairs with an outside price:** a Chainlink price, or a deep pool Goat checks against. Pairs
  without one are not offered.
* **Uniswap v4 hooks:** pools without a hook, or with a hook Goat reviewed. Other hook pools get
  withdraw-only exits at most.
* **Withdraw-only exits** also work on a listed pair's pools that have no price check of their own.
* **Size:** there is no per-position cap. Positions under about \$50 are not offered auto-range, because a
  move's fee would not cover its gas. On pairs without a Chainlink price, an hourly swap limit is shared by
  everyone on the pair; auto-range is not offered for a position too large for it. Auto-exit still works.
* **Stock-token pairs** run swaps only while their outside price is updating, so a move or a swap exit can
  wait a day or more.

The **Agents** light on the Pools list shows green (available), red (not offered, with the reason) or grey.

## Status and stopping

| Status | Meaning |
| - | - |
| **On** | Set and waiting. The line says when it would act |
| **Ran / Moved / Exited** | It did its job, with a link to the transaction |
| **Needs you** | One step from you, such as **Allow #new** or **Allow again** |
| **Waiting for fees** | The run would not yet pay for its gas |
| **Paused** | A price, capacity or timing check does not pass right now. The line says what it waits for; the keeper tries again later |
| **On hold** | The keeper stopped trying after failed runs and says when it tries again |
| **Closed** | The rule is saved but cannot run, for example its moves are used up |

**Stop** turns the rule off (the keeper stops right away), then removes the permission. The sheet then
checks the chain and says "Checked on chain: the rule is off and no permission is left." Your funds stay
in the position. Automation also stops when the position changes owner.

On a v4 auto-range rule whose trigger is reached, you can press **Move now** yourself: one transaction, you
pay the network fee, the 0.15% fee applies as usual.

## Keepers

<img className="block dark:hidden" src="https://mintcdn.com/cashmerelabs/VaU9JZozZKsaMUY5/images/goat-lp/illus-goat-keeper-light.png?fit=max&auto=format&n=VaU9JZozZKsaMUY5&q=85&s=d28747791c36324c5c0081c22c3833f5" alt="Pixel goat with a large wrench and a gear: a Goat keeper starts the automation runs." width="240" data-path="images/goat-lp/illus-goat-keeper-light.png" />

<img className="hidden dark:block" src="https://mintcdn.com/cashmerelabs/VaU9JZozZKsaMUY5/images/goat-lp/illus-goat-keeper-dark.png?fit=max&auto=format&n=VaU9JZozZKsaMUY5&q=85&s=e520819c0a0ff6d9c41f48cc219094ac" alt="Pixel goat with a large wrench and a gear: a Goat keeper starts the automation runs." width="240" data-path="images/goat-lp/illus-goat-keeper-dark.png" />

* Keepers are Goat-run bots. They pay the gas. They never hold or receive your tokens.
* A compound or a move runs only when Goat's fee from it is at least 1.25 times the gas it costs, so a
  small position may run rarely.
* Exits run even when the fee does not cover the gas, within Goat's daily gas limits.
* If a keeper is late or down, nothing happens to your position. Do not rely on automation as your only
  safety net. In the first days after the opening, keepers are switched on in stages.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.