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

# Sweep your balance on-chain automatically

> Set a destination, balance threshold, and fee tier for automatic sweeps in BTCPay Server, then sweep now, edit or turn off sweeps, track them, and resume them.

Automatic sweeps move your store's Ark balance to an on-chain wallet, each time enough of it reaches your fee tier. They stay off until you set them up.

> [!NOTE]
>
> Automatic sweeps need plugin 0.14.0 or later. If **Bark** > **Settings** has no **Automatic sweep** section, [update the plugin](https://second.tech/docs/btcpay/uninstall.md#update-the-plugin). Setting them up requires permission to modify the store's settings, which BTCPay's Owner role has.

## Choose your sweep rules

A sweep is an [on-chain payment](https://second.tech/docs/learn/payments-on-chain.md) from your Ark balance. The Ark server's fee for it falls as your VTXOs get closer to expiry. Four rules control your sweeps:

* **Balance threshold:** The plugin sweeps once this much of your balance, above the reserve, reaches your fee tier.
* **Fee tier:** The highest percentage fee the Ark server charges on a sweep. The server's base fee, if it has one, and the on-chain fee come on top. Bitcoin you receive waits in Ark until the VTXOs holding it reach this tier. Cheaper tiers mean longer waits.
* **Total fee limit:** The most a sweep can cost, Ark server fee and on-chain fee together, as a share of the amount swept.
* **Reserve:** An amount the plugin leaves in Ark after every sweep. With the default of 0 sats, a sweep can empty your Ark balance. Set a reserve if your store sends Lightning payments.

The plugin checks your balance every minute. Each sweep spends the VTXOs that have reached your fee tier, up to the number of VTXOs the Ark server accepts in one on-chain payment. If your reserve cuts into a VTXO, the sweep sends only the part above the reserve. VTXOs left over wait for a later sweep, unless Bark refreshes them first.

Bark can get close to [refreshing](https://second.tech/docs/btcpay/settings.md#auto-refresh-threshold) VTXOs in your fee tier while their total is below the balance threshold. If your whole balance above the reserve has reached the balance threshold, the plugin then sweeps the VTXOs in your tier instead of refreshing them into a more expensive tier. If that balance is below the balance threshold, or the sweep costs more than your total fee limit, Bark refreshes them as usual.

## Set up automatic sweeps

> [!WARNING]
>
> For an extended public key, compare the three addresses in the dialog with the addresses in your wallet before you turn on sweeps. If they differ, your wallet doesn't show the bitcoin that sweeps send. Enter the wallet's output descriptor instead.

**1. Open the setup dialog**

Go to **Bark** > **Settings**, then select **Set up automatic sweeps** in the **Automatic sweep** section.

**2. Select a destination**

Select one of two destinations:

* **BTCPay Server wallet:** Your store's on-chain wallet. This option needs an on-chain wallet set up for the store in BTCPay Server. The dialog shows the wallet's label and master fingerprint, when it has them, and its next unused address. A sweep reserves its address when it runs. If an invoice takes the address in the dialog first, the sweep uses the next free one.
* **Extended public key:** Any wallet, through its extended public key or output descriptor. Enter the key or descriptor, then set **First address index** to the first index your wallet hasn't used. The dialog lists the next three addresses.

For an output descriptor, the plugin accepts `pkh()`, `sh(wpkh())`, `wpkh()`, and `tr()` with a single key, with or without a key origin. The path after the key ends in `/*`, such as `/0/*` or `/7/*`, with no hardened step. A multisig descriptor needs a key origin and `/0/*` or `/<0;1>/*` on every key. The plugin refuses a descriptor with a wrong checksum.

Each sweep goes to a new address of the destination wallet. Select **Next**.

**3. Set the balance threshold**

Enter the **Balance threshold** in sats, or select a preset from **100K** to **10M**.

**4. Select a fee tier**

The dialog selects the **Recommended** tier, the cheapest one that a VTXO stays in for at least a day, or the cheapest one offered if none does. Select another tier for shorter waits or lower fees. Each tier shows its fee and its **Max wait**, the longest that bitcoin you receive waits in Ark before the VTXOs holding it reach the tier. The most expensive tier shows **No wait**. See [Second's pricing](https://second.tech/pricing) for the tiers on Second's Ark server.

With a wider auto-refresh threshold, the plugin refreshes VTXOs earlier, before they reach the cheapest tiers. The dialog can then offer fewer tiers.

**5. Check the fee and the advanced settings**

The **Estimated total fee** table shows what a sweep of your balance threshold costs at your fee tier, with the Ark server's current on-chain feerate. Under **Advanced settings**, you can change the **Total fee limit** (1% by default, from 0.1% to 20%) and the **Reserve** (0 sats by default).

Set the **Total fee limit** above your fee tier. Otherwise a sweep runs only when your balance reaches a cheaper tier, which rarely happens on the cheapest tier. Select **Next**.

<video autoPlay src="https://mintcdn.com/second-0659a37d/whkW7_bYJZxDX7wf/videos/btcpay/set-sweep-rules.mp4?fit=max&auto=format&n=whkW7_bYJZxDX7wf&q=85&s=f8c97b7b70b28ef74e13e2a81f4b0186" aria-label="Screen recording of the Rules step of the Automatic sweep dialog. Advanced settings opens the Total fee limit field, set to 1%. The 100K preset then fills the Balance threshold field with 100000 and brings up an Estimated total fee table." />

A preset fills the balance threshold and the fee estimate, with the total fee limit under Advanced settings

**6. Review and turn on sweeps**

Check the destination and your rules in the **Review** step. For an extended public key, select **I control this destination and have checked it against my wallet.** Then select **Turn on automatic sweeps**.

![Screenshot of the Review step of the Automatic sweep dialog, with the BTCPay Server wallet as destination and its next address. It lists a balance threshold of 100,000 sats, the 0.2% fee tier, an estimated total fee of 227 sats, and a 1% total fee limit. The Turn on automatic sweeps button sits at the bottom.](https://mintcdn.com/second-0659a37d/whkW7_bYJZxDX7wf/images/btcpay/sweep-review.png?fit=max\&auto=format\&n=whkW7_bYJZxDX7wf\&q=85\&s=365e9d57accc0143ad139766569eebce)

The Review step lists the destination, its next address, and your rules before you turn sweeps on

The **Automatic sweep** section then shows how much of your balance is ready to sweep against your balance threshold, along with your rules. After the first sweep, it also shows your last sweep.

## Sweep now, edit, or turn sweeps off

The **Automatic sweep** section saves its own changes. The **Save** button at the top of the Settings page doesn't apply to it. The section has three controls:

* **Sweep now:** Sweep your whole spendable Ark balance above the reserve right away, up to the Ark server's limit for one on-chain payment. The dialog shows the exact fee and the amount you receive before you confirm. **Sweep now** ignores your fee tier and total fee limit. It also works while automatic sweeps are off.
* **Edit:** Change the destination or the rules. When you save your changes, the plugin clears any pause. A sweep that is already pending still completes to its earlier destination.
* **On/Off toggle:** Turn automatic sweeps off or back on. Your settings stay saved while sweeps are off.

<video autoPlay src="https://mintcdn.com/second-0659a37d/whkW7_bYJZxDX7wf/videos/btcpay/sweep-now.mp4?fit=max&auto=format&n=whkW7_bYJZxDX7wf&q=85&s=80b18e636d9ebf9f11a8a82b727624f4" aria-label="Screen recording of the Automatic sweep section. Sweep now opens a dialog that confirms a sweep of 30,000 sats to the BTCPay Server wallet, with a fee of 85 sats (0.28%) and 29,915 sats received. A note says that Sweep now ignores your fee tier and total fee limit." />

Sweep now quotes the exact fee and the amount the destination receives before you confirm

## Track your sweeps

Select **Activity** at the bottom of the **Automatic sweep** section to list its 20 most recent events, such as sweeps, delays, failures, pauses, and changes to your settings.

![Screenshot of the Automatic sweep section with Activity open and a last sweep of 30,000 sats. The table lists two events: a Sweep now sweep of 30,000 sats to the BTCPay Server wallet with an 85-sat fee, and Turned on. Each event shows the email of the user who acted.](https://mintcdn.com/second-0659a37d/whkW7_bYJZxDX7wf/images/btcpay/sweep-activity.png?fit=max\&auto=format\&n=whkW7_bYJZxDX7wf\&q=85\&s=45adfa728d7bbe5519f8aacb19c5fa2d)

Activity lists each sweep with its fee and each settings change with the user who made it

On the Bark wallet page, the plugin adds the **Auto-sweep** label to every sweep in the [transactions list](https://second.tech/docs/btcpay/dashboard.md#transactions), including **Sweep now** sweeps.

![Screenshot of two rows of the Bark wallet transactions list. The first row is an Ark receive of 30,000 sats. The second is a sweep of 30,000 sats with the Auto-sweep label, the Successful status, and the On-chain payment type.](https://mintcdn.com/second-0659a37d/whkW7_bYJZxDX7wf/images/btcpay/sweep-label.png?fit=max\&auto=format\&n=whkW7_bYJZxDX7wf\&q=85\&s=f1a27236dd4f14817c8300f8e8bd4cf4)

A sweep shows in the transactions list with the Auto-sweep label

BTCPay notifies the store users who can modify the store's settings in six cases:

* After each sweep
* On the first failure of a series
* When sweeps pause
* When someone changes the destination
* When someone turns sweeps on or off
* When the Ark server changes its on-chain payment fees while sweeps are on

## Resume sweeps that wait, pause, or need a review

* **Fee above your limit:** The sweep waits for lower on-chain fees. The plugin requests a new fee quote every minute. It sends the sweep once the fee fits under your total fee limit, unless Bark refreshes the VTXOs first. The wait doesn't count as a failure. If the sweep keeps waiting, raise your balance threshold or your total fee limit with **Edit**.
* **Failed attempts:** The plugin tries again after five minutes, 15 minutes, one hour, then four hours. After five failures in a row, sweeps pause. Select **Resume** to try again.
* **Destination changed or invalid:** Sweeps pause when someone removes or replaces the store's BTCPay Server wallet, or when the extended public key no longer derives your confirmed addresses. They also pause when a descriptor you saved before plugin 0.15.0 has a wrong checksum. Select **Review destination**, check the destination, correct it if needed, confirm that you control it, and select **Save changes**.
* **Fee tier out of reach:** Sweeps pause when Bark refreshes VTXOs before they reach your fee tier, after a wider auto-refresh threshold or a change on the Ark server. Select **Change fee tier** to select another tier, or narrow the [auto-refresh threshold](https://second.tech/docs/btcpay/settings.md#auto-refresh-threshold) if you widened it. Sweeps resume on their own once the tier is within reach again.
* **Ark server fees changed:** Sweeps continue with your rules while your fee tier stays within reach. The section asks you to review your fee tier. While sweeps are off, you can't turn them back on until you review your rules with **Edit** and save them.

![Screenshot of the Automatic sweep section with a Paused badge, a Review destination button, and an alert that says the destination changed or is no longer valid.](https://mintcdn.com/second-0659a37d/whkW7_bYJZxDX7wf/images/btcpay/sweep-paused.png?fit=max\&auto=format\&n=whkW7_bYJZxDX7wf\&q=85\&s=88a4629bd4abdca7f32a4b33e810861e)

A paused sweep names its cause, next to the button that fixes it


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