К основному содержанию
скилл CX Codex

dca-bot — скилл для Claude Code: регулярная покупка токенов

Покупает фиксированную сумму токена по расписанию, при желании только при выполнении условия по цене. Пригодится, если нужен DCA без ручных сделок.

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add Uniswap/uniswap-ai --skill dca-bot -a claude-code
Открыть на GitHub

Что делает dca-bot

Скилл задаёт ритм покупок, следит за идемпотентностью и не даёт потратить лишнего. Исполнение он не делает сам: каждый свап, котировка и подпись уходят в swap-integration, а счета, клиенты и трансляция транзакций — в viem-integration. Поэтому оба плагина должны стоять заранее, иначе скиллу нечем работать.

Планировщика внутри нет. Скилл просыпается по расписанию хоста — записи cron или механизму пробуждения рантайма — и каждый запуск читает свой JSON-файл состояния, решает, покупать ли, и записывает результат. Если за текущий период покупка уже прошла, повторное пробуждение просто завершается: двойных сделок не будет. Неудачный запуск оставляет период незакрытым, и следующее пробуждение может повторить попытку.

Порог цены вроде «покупать, только когда ETH ниже X» работает сразу: цена берётся из /quote Trading API Uniswap. А вот условие на рыночные данные, которых этот API не отдаёт, скилл выполнить не сможет — внешние источники он не подключает. Перед тратой проверяются лимит на запуск и на период, список разрешённых токенов и стоп-кран. Если лимиты не заданы, автономный режим не включается, остаётся подтверждение каждой транзакции. Кошелёк должен покрывать сумму покупки и газ, иначе сделка пропускается.

Какие задачи решает

  • настроить ежедневную покупку токена на фиксированную сумму
  • покупать только когда цена актива опустилась ниже порога
  • не допустить двойной покупки при повторном запуске по расписанию
  • ограничить траты на один запуск и на период
  • проверить баланс кошелька перед сделкой и пропустить её при нехватке

Примеры запросов агенту

  • Настрой DCA: покупай ETH на 50 USDC каждый день, но только если цена ниже 3000 USDC
  • Задай лимит трат на день и покажи, что записалось в файл состояния
  • Проверь, прошла ли покупка за сегодня, и не повторяй её

Как установить dca-bot

1Через Skills CLI (Vercel)

npx skills add Uniswap/uniswap-ai --skill dca-bot -a claude-code

2Вручную: положить файлы

~/.claude/skills/dca-bot/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/dca-bot/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Вопросы о dca-bot

Как установить dca-bot в Claude Code?

Выполните npx skills add Uniswap/uniswap-ai --skill dca-bot -a claude-code. Файл скилла появится по пути ~/.claude/skills/dca-bot/SKILL.md.

Что делает dca-bot?

Покупает фиксированную сумму токена по расписанию, при желании с условием по цене. Сами свапы выполняет swap-integration через Trading API Uniswap, а скилл отвечает за ритм, проверки и запись состояния.

Что нужно для работы dca-bot?

Установленные плагины swap-integration и viem-integration, настроенные лимиты трат и кошелёк с нужным токеном и газом. Без лимитов автономный режим недоступен.

Исходный текст

SKILL.md · MIT
---
name: dca-bot
description: This skill should be used when the user wants to "dca into" a token, "buy X every day", set up a "recurring buy", "dollar cost average" into an asset, "schedule a buy", or "auto-buy on a dip". Buys a fixed amount into a token on a schedule, optionally only when a condition holds (for example only when ETH is below a price threshold). The host agent's scheduler wakes the skill on a cadence; each wake is one self-contained run.
allowed-tools: Read, Write, Edit, Glob, Grep, Bash(npm:*), Bash(npx:*), Bash(curl:*), WebFetch, AskUserQuestion
model: sonnet
license: MIT
metadata:
  author: uniswap
  version: '0.2.0'
prerequisites:
  - swap-integration
  - viem-integration
---

# DCA Bot

Dollar-cost-average a fixed amount into a token on a schedule on the operator's target chain, optionally gated on a price condition such as "only buy when ETH is below a threshold".

> **Runtime Compatibility:** This skill uses `AskUserQuestion` for interactive prompts (mode selection, per-transaction confirmation). If `AskUserQuestion` is not available in your runtime, collect the same parameters and confirmations through natural language conversation instead.

## Overview

This is a thin strategy layer. It owns cadence, idempotency, the optional condition check, and guardrails. It does NOT own execution. Every quote, approval, swap, and signature is delegated to `swap-integration` and `viem-integration`. The skill never builds quote, approval, swap, or signing logic itself.

The skill does not run a scheduler. The host agent's scheduler (a cron entry or the runtime's wake mechanism) invokes the skill on a cadence. Each invocation is a single, self-contained run that reads state, decides whether to act, optionally acts, and writes state.

## Prerequisites

- **swap-integration** (uniswap-trading): the only execution path. All swaps go through its Trading API flow (`check_approval` then `quote` then `swap`, then sign and broadcast). Do not reimplement any of it.
- **viem-integration** (uniswap-viem): accounts, clients, signing, transaction broadcast, and receipt waiting.

Read these plugin references before acting and treat them as ground truth:

- selected target-chain template: chainId, chain name, contract addresses, tradable token source, funding constraints, market-data availability, and template-specific caveats. For the reference Robinhood Chain template, see `../../references/robinhood-chain.md`.
- `../../references/execution-model.md`: the Trading API requirement, execution modes, restrictions, and disclaimer rules.
- `../../references/strategy-state.md`: the shared state file and scheduler pattern.

## Template inputs

The selected target-chain template must provide:

- chain id, chain name, native gas token, and RPC / read path.
- deployed Uniswap router, Permit2, and quoter / state-reader addresses needed by delegated execution.
- tradable token resolution rules, including any token list or allowlist source.
- funding constraints and market-data availability.
- transfer-restriction caveats and market-hours guidance.

## Workflow

### Step 1: Read state

Read the bot's JSON state file (see [State](#state)). If it does not exist, treat this as the first run.

### Step 2: Check cadence and idempotency

Compute the current period from the configured cadence (for example the UTC day for a daily DCA). If the state file shows a successful buy already recorded for the current period, skip and exit. This makes repeated wakes within one period safe (no double buys).

### Step 3: Resolve token and amount

Resolve the target token to an address by reading the selected target-chain template and its token source. Resolve the fixed buy amount from config. Validate both before use (see [Input validation](#input-validation)). Do not maintain a local token registry; reuse the template-provided token list or resolver.

### Step 4: Collect guardrails

Read the configured guardrails. If the per-run spend cap or per-period spend cap is missing, ask the operator for those caps using `AskUserQuestion` (or natural language if unavailable); include the funding token or denomination used for comparison. If either cap remains unset, do not enter `autonomous` mode. In `confirm` mode, proceed only with the per-transaction confirmation gate and report that autonomous mode remains unavailable.

### Step 5: Optional condition check

If a condition is configured (for example "only when the last daily candle is red"), evaluate it before buying:

- Fetch the price needed for the condition from Uniswap: the Trading API `/quote` (via `swap-integration`). Do not use venue-specific APIs or non-Uniswap price feeds for execution data; see `../../references/execution-model.md` (Data and pricing). If the condition needs market data Uniswap does not expose, treat that data source as unavailable rather than adding an external dependency.
- Evaluate the predicate (for example `price < 3000 USDC`).
- If the condition is not met, record the evaluation, skip the buy, and exit. Skipping for an unmet condition is a normal outcome, not an error.

Be honest about what is satisfiable today. A price-threshold condition (for example "only buy when ETH is below X") works out of the box, because the current price comes from the Trading API `/quote`.

### Step 6: Guardrails

Before any spend, enforce the guardrails for the active execution mode (see [Execution mode](#execution-mode)): spend cap per run and per period, token allowlist, and the kill switch. If any guardrail blocks the buy, stop and report why.

Also check the wallet can cover the buy: it must hold enough of the funding token (`tokenIn`) for the buy amount and enough native gas to broadcast. If either is short, skip the buy and report it. Follow the selected template's funding constraints; the skill does not auto-fund, bridge, or top up unless that behavior is explicitly provided outside the skill.

### Step 7: Delegate the swap

Hand execution to the `swap-integration` Trading API flow. Pass the target chain id and that chain's router / token addresses from the selected template. The skill MUST NOT build quote, approval, swap, or signing logic of its own; it only supplies parameters (swapper, tokenIn, tokenOut, amount, chain id) and reads back the result.

If the selected template has RPC or raw-transaction constraints, treat them as template caveats. Skills always execute through the Trading API / router path regardless of chain, so router-compatible constraints should not block them.

### Step 8: Update state

On a successful broadcast, write the current period, timestamp, and the resulting transaction hash to the state file so the next wake is idempotent. On failure, record the error and leave the period unmarked so a later wake can retry.

## Execution mode

The operator who runs the agent chooses an execution mode. See `../../references/execution-model.md` for the full model.

| Mode                | Behavior                                                                                                                                                                   |
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `confirm` (default) | Ask the user to approve the transaction before broadcast via `AskUserQuestion`, showing token, amount, chain, and estimated gas. Reuses the `swap-integration` spend gate. |
| `autonomous`        | Execute without per-transaction prompts, only within guardrails.                                                                                                           |

Default to `confirm`. `autonomous` mode requires all of: a spend cap (per run and per period), a token allowlist, a dry-run first, and a kill switch. Without all four, fall back to `confirm`.

## State

Follow the shared pattern in `../../references/strategy-state.md`. The dca-bot keeps a small JSON state file so a run knows what previous runs did. Suggested shape:

- `lastBuyPeriod` is the idempotency key: a run buys at most once per period. Compare the current period against `lastBuyPeriod` before acting, and update it only after a confirmed broadcast.
- `lastAction` is the last action taken: a swap, or a skip due to a guardrail or condition. Record the action type, transaction hash, and amount.

## Restrictions and Disclaimers

RWA gating is template-specific and may be enforced at the token level (transfer-restricted ERC-20s), so a swap can revert at transfer time even when the router accepts it. See `../../references/execution-model.md`. The skill must:

1. Handle transfer-restriction reverts gracefully, record them, and report them rather than retrying blindly.
2. Respect the selected template's equity market-hours guidance; some RWAs may have off-hours liquidity limits, so a buy may be skipped or deferred outside hours.
3. Surface the financial disclaimers in the repo root `DISCLAIMER.md` to the operator.

## Input validation

Before interpolating ANY user-provided or config value into a command, API call, or generated code:

- **Token / wallet addresses**: MUST match `^0x[a-fA-F0-9]{40}$`; reject otherwise.
- **Amounts**: MUST be non-negative numeric values matching `^[0-9]+\.?[0-9]*$`.
- **Chain id**: MUST be the operator-configured target chain id, read from the selected template rather than hardcoded.
- **API keys**: MUST come from environment variables, never hardcoded.
- **REJECT** any input containing shell metacharacters: `;`, `|`, `&`, `$`, `` ` ``, `(`, `)`, `>`, `<`, `\`, `'`, `"`, or newlines.

© uniswap · MIT · Uniswap/uniswap-ai

Похожие скиллы

Все скиллы по теме «Настройка агента: память, контекст, субагенты» →
setup-matt-pocock-skills Matt Pocock Скилл настраивает репозиторий для инженерных скиллов Matt Pocock: задаёт трекер задач, метки триажа и расположение доменной документации. Запустите его перед первым использованием остальных скиллов. 1 052 851установок ask-matt Matt Pocock Помогает выбрать подходящий скилл или рабочий поток из набора Matt Pocock. Пригодится, когда непонятно, с чего начать задачу: от идеи до разбора бага. 766 587установок to-tickets Matt Pocock Разбивает план, спецификацию или переписку на небольшие сквозные задачи и отмечает, какие из них блокируют остальные. Пригодится, когда нужно согласовать порядок работы до публикации задач в трекере. 711 230установок writing-plans Jesse Vincent Скилл превращает требования к многошаговой задаче в подробный план реализации до начала работы с кодом. Пригодится, когда исполнителю нужно зафиксировать файлы, интерфейсы и проверки. CX Codex 282 859установок caveman-review JuliusBrussee Пишет замечания к коду одной строкой: место, проблема, исправление. Пригодится, когда ревью диффа или PR надо пройти быстро и без воды. CX Codex +1 411 800установок caveman-compress JuliusBrussee Сжимает CLAUDE.md, списки задач и другие текстовые файлы в краткий формат, сохраняя читаемую резервную копию. CX Codex +1 411 500установок

Из того же набора15

deployer Разворачивает смарт-контракты аукционов Continuous Clearing Auction (CCA) через фабрику CREATE2 и проверяет параметры перед отправкой транзакций. CX Codex +1 1 100установок pay-with-any-token Оплачивает ответы HTTP 402 и вызовы machine payment protocol через Tempo CLI. Пополняет кошелёк обменом токенов из других EVM-сетей через Uniswap Trading API. CX Codex +1 815установок v4-sdk-integration Скилл ведёт агента по Uniswap v4 SDK: сборка свапов через Universal Router, котировки, чтение состояния пула и работа с LP-позициями. CX Codex +1 729установок v4-hook-generator Скилл собирает контракты хуков Uniswap v4 через MCP-инструмент OpenZeppelin Contracts Wizard: выбор типа хука, права, библиотеки, готовый Solidity. CX Codex +1 686установок pay-with-app Закрывает HTTP 402 от мерчантов OKX на X Layer: проверяет баланс, при нехватке добирает токены через Uniswap Trading API и подписывает платёж. CX Codex +1 524установок lp-integration Учит агента работать с Uniswap LP REST API: собирать транзакции для создания позиций ликвидности, добавления и снятия ликвидности, сбора комиссий. CX Codex +1 440установок copy-trade Отслеживает транзакции выбранного кошелька и зеркалит его свопы на Uniswap с учётом ограничений. Запускается по расписанию для автоматического повторения сделок. CX Codex +1 406установок index-bot Формирует портфель токенов по текстовому запросу, покупает активы в один проход через Uniswap Trading API и следит за ребалансировкой при отклонении весов. CX Codex +1 403установок

Спонсоры проекта

Компании, которые помогают держать аналитику открытой