# clawpump — Jupiter DCA for AI Agents

Dollar-cost average into any Solana token with recurring buys. Set your frequency, amount per cycle, and total cycles — Jupiter handles execution automatically.

Base URL: `https://clawpump.tech`

---

## Quick Start

### Step 1 — Create a DCA Order

```
POST https://clawpump.tech/api/agent/dca/create
Authorization: Bearer cpk_...
Content-Type: application/json

{
  "userPublicKey": "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",
  "inputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
  "outputMint": "So11111111111111111111111111111111111111112",
  "amount": "10000000",
  "frequency": 86400,
  "totalCycles": 30
}
```

Response:
```json
{
  "transaction": "AQAAAAAAAA...",
  "orderId": "dca_abc123",
  "inputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
  "outputMint": "So11111111111111111111111111111111111111112",
  "amount": "10000000",
  "frequency": 86400,
  "totalCycles": 30
}
```

This creates a DCA order that buys 10 USDC worth of SOL every day for 30 days.

### Step 2 — Sign and Submit

The `transaction` is a base64-encoded Solana `VersionedTransaction`. Deserialize it, sign with your wallet, and submit:

```js
import { VersionedTransaction, Connection } from "@solana/web3.js";

const txBuffer = Buffer.from(transaction, "base64");
const tx = VersionedTransaction.deserialize(txBuffer);

tx.sign([wallet]);

const connection = new Connection("https://api.mainnet-beta.solana.com", "confirmed");
const txHash = await connection.sendTransaction(tx, {
  skipPreflight: false,
  maxRetries: 3,
});

console.log("DCA order created:", txHash);
```

### Step 3 — View Your Orders

```
GET https://clawpump.tech/api/agent/dca/orders
Authorization: Bearer cpk_...
```

Response:
```json
{
  "orders": [
    {
      "orderId": "dca_abc123",
      "inputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
      "outputMint": "So11111111111111111111111111111111111111112",
      "amount": "10000000",
      "frequency": 86400,
      "totalCycles": 30,
      "completedCycles": 5,
      "status": "active",
      "nextExecution": "2026-04-01T12:00:00Z"
    }
  ]
}
```

### Step 4 — Cancel a DCA Order

```
POST https://clawpump.tech/api/agent/dca/cancel
Authorization: Bearer cpk_...
Content-Type: application/json

{
  "userPublicKey": "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",
  "orderId": "dca_abc123"
}
```

Response:
```json
{
  "transaction": "AQAAAAAAAA...",
  "orderId": "dca_abc123"
}
```

Sign and submit the cancellation transaction the same way.

---

## API Reference

### Create DCA Order

**POST** `/api/agent/dca/create`

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `userPublicKey` | string | Yes | Your Solana wallet address (the signer) |
| `inputMint` | string | Yes | Mint address of the token you're spending |
| `outputMint` | string | Yes | Mint address of the token you're buying |
| `amount` | string | Yes | Amount per cycle in smallest unit |
| `frequency` | number | Yes | Seconds between buys (minimum 60) |
| `totalCycles` | number | No | Total number of buy cycles (2 to 1,000) |
| `startTime` | number | No | Unix timestamp for the first buy (optional, defaults to now) |

### View Orders

**GET** `/api/agent/dca/orders`

Requires `Authorization: Bearer cpk_...` header. Returns all your DCA orders with status and progress.

### Cancel Order

**POST** `/api/agent/dca/cancel`

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `userPublicKey` | string | Yes | Your Solana wallet address (the signer) |
| `orderId` | string | Yes | ID of the DCA order to cancel |

**Error responses:**

`400` — Validation error:
```json
{ "error": "Validation failed", "details": { "frequency": ["Minimum frequency is 60 seconds"] } }
```

`401` — Unauthorized:
```json
{ "error": "Missing or invalid API key" }
```

---

## Common Token Mints

| Token | Mint Address |
|-------|-------------|
| SOL (Wrapped) | `So11111111111111111111111111111111111111112` |
| USDC | `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v` |
| USDT | `Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB` |

**Amount units:** Always use the smallest unit. For SOL, 1 SOL = `1000000000` lamports. For USDC, 1 USDC = `1000000` micro-units.

---

## Common Frequencies

| Interval | Seconds |
|----------|---------|
| Every minute | `60` |
| Hourly | `3600` |
| Daily | `86400` |
| Weekly | `604800` |

---

## How It Works

1. Create a DCA order with your desired token pair, amount, and frequency
2. Sign the returned transaction and submit to Solana — your input tokens are deposited into a DCA vault
3. Jupiter's keeper network automatically executes buys at each interval
4. Monitor progress via `/api/agent/dca/orders`
5. Cancel anytime via `/api/agent/dca/cancel` — remaining tokens are returned to your wallet

DCA orders are non-custodial. Your tokens sit in a Jupiter DCA vault that only you can cancel.

---

## Tips

- **Daily buys are most common.** Set `frequency: 86400` for standard DCA into volatile tokens.
- **Budget your total spend.** `amount` is per cycle, so total spend = `amount * totalCycles`. Make sure your wallet has enough input tokens.
- **Use `startTime`** to schedule DCA orders for the future. Pass a Unix timestamp.
- **Cancel early** if market conditions change. Remaining input tokens are returned to your wallet.
- **Amount precision:** Always pass amounts as strings to avoid JavaScript floating-point issues.
- **Transaction expiry:** Transactions expire after ~60 seconds. Get and submit quickly.
- **Minimum 2 cycles** when specifying `totalCycles`. If omitted, the DCA runs indefinitely until cancelled.

---

## Example: DCA $100 USDC into SOL over 10 days

```
POST https://clawpump.tech/api/agent/dca/create
Authorization: Bearer cpk_...
Content-Type: application/json

{
  "userPublicKey": "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",
  "inputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
  "outputMint": "So11111111111111111111111111111111111111112",
  "amount": "10000000",
  "frequency": 86400,
  "totalCycles": 10
}
```

This buys 10 USDC of SOL every 24 hours, 10 times = $100 total spend.

---

## Other Skills

- Swap tokens: [swap.md](https://clawpump.tech/swap.md)
- Launch tokens: [skill.md](https://clawpump.tech/skill.md)
- Arbitrage: [arbitrage.md](https://clawpump.tech/arbitrage.md)
- Jupiter Lend: [jupiter-lend.md](https://clawpump.tech/jupiter-lend.md)
- Prediction markets: [jupiter-predictions.md](https://clawpump.tech/jupiter-predictions.md)
- Limit orders: [jupiter-limit-orders.md](https://clawpump.tech/jupiter-limit-orders.md)
