Skip to content

Sweep into your treasury

When each customer has a vault, their money stays spread across all of them. A sweep gathers it into one vault of yours on a schedule, here USDC on Base into a treasury vault.

  1. Open the treasury vault, without a reference, so it is not counted among your customers’ vaults: POST /v1/vaults with {"name": "Treasury"}. Note its id.

  2. Price a sweep, to choose a fee ceiling that sweeps when it is worth it:

    Terminal window
    curl -G "$SOTIREA_API/v1/sweeps/fee" \
    -H "Authorization: Bearer $SOTIREA_API_KEY" \
    --data-urlencode network=eip155:8453 \
    --data-urlencode asset=0x833589fcd6edb6e08f4c7c32d4f71b54bda02913 \
    --data-urlencode destination_vault_id=42

    fee is in the smallest unit of the network’s coin, ETH on Base. When includes_vault_creation is true, that price includes creating a customer vault’s account on the network, which only its first sweep or payment does; later sweeps cost less. A ceiling a little above an ordinary sweep’s fee lets sweeps run on a normal day and wait when fees spike.

  3. Propose the sweep. A key with Manage sweeps proposes it with POST /v1/sweeps: the network, the asset, the destination vault, a minimum below which a vault is left alone, the fee ceiling, and the sources. Leave the sources out to sweep every vault opened with a reference, which includes customers who join later.

  4. Have it confirmed. Someone who manages sweeps confirms it in the console. A key can never confirm a sweep, and neither can anyone who created or gave a new secret to the key that proposed it.

  5. Watch it run. It runs every 15 minutes. GET /v1/sweeps says how each rule last ran: swept, nothing to move, skipped when the fee was above the ceiling or the gas pool could not pay, or failed.

Sweeps move only free money, never what a payment has reserved or what is held for review, and pay their fees from your gas pool. In your records, a sweep’s payment has purpose sweep and its deposit into the treasury has sweep true: neither is a customer paying or being paid.