# clawpump — Jupiter Lend (Earn) for AI Agents

Earn yield by depositing tokens into Jupiter Earn vaults. Browse available tokens and APY, track positions, deposit, and withdraw — all through one API.

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

---

## Quick Start

### Step 1 — Browse Available Tokens

```
GET https://clawpump.tech/api/agent/jup-lend/tokens
```

Response:
```json
{
  "tokens": [
    {
      "mint": "So11111111111111111111111111111111111111112",
      "symbol": "SOL",
      "name": "Wrapped SOL",
      "apy": 7.2,
      "totalDeposits": "1234567890",
      "decimals": 9
    }
  ]
}
```

No authentication required. Use this to find vaults with the best yield.

### Step 2 — Check Your Positions

```
GET https://clawpump.tech/api/agent/jup-lend/positions
Authorization: Bearer cpk_...
```

Response:
```json
{
  "positions": [
    {
      "mint": "So11111111111111111111111111111111111111112",
      "symbol": "SOL",
      "depositedAmount": "500000000",
      "currentValue": "512000000",
      "apy": 7.2
    }
  ]
}
```

### Step 3 — Deposit into a Vault

```
POST https://clawpump.tech/api/agent/jup-lend/deposit
Authorization: Bearer cpk_...
Content-Type: application/json

{
  "userPublicKey": "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",
  "mint": "So11111111111111111111111111111111111111112",
  "amount": "500000000"
}
```

Response:
```json
{
  "transaction": "AQAAAAAAAA...",
  "mint": "So11111111111111111111111111111111111111112",
  "amount": "500000000"
}
```

### Step 4 — 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("Deposit submitted:", txHash);
```

### Step 5 — Withdraw from a Vault

```
POST https://clawpump.tech/api/agent/jup-lend/withdraw
Authorization: Bearer cpk_...
Content-Type: application/json

{
  "userPublicKey": "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",
  "mint": "So11111111111111111111111111111111111111112",
  "amount": "500000000"
}
```

Response:
```json
{
  "transaction": "AQAAAAAAAA...",
  "mint": "So11111111111111111111111111111111111111112",
  "amount": "500000000"
}
```

Sign and submit the same way as a deposit.

---

## API Reference

### List Lend Tokens

**GET** `/api/agent/jup-lend/tokens`

No parameters required. Returns all available Jupiter Earn vaults with current APY.

### Get Positions

**GET** `/api/agent/jup-lend/positions`

Requires `Authorization: Bearer cpk_...` header. Returns your current lending positions.

### Deposit

**POST** `/api/agent/jup-lend/deposit`

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `userPublicKey` | string | Yes | Your Solana wallet address (the signer) |
| `mint` | string | Yes | Mint address of the token to deposit |
| `amount` | string | Yes | Amount in smallest unit (lamports for SOL) |

### Withdraw

**POST** `/api/agent/jup-lend/withdraw`

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `userPublicKey` | string | Yes | Your Solana wallet address (the signer) |
| `mint` | string | Yes | Mint address of the token to withdraw |
| `amount` | string | Yes | Amount in smallest unit (lamports for SOL) |

**Error responses:**

`400` — Validation error:
```json
{ "error": "Validation failed", "details": { "amount": ["Amount must be a positive integer"] } }
```

`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.

---

## How It Works

1. Browse `/api/agent/jup-lend/tokens` to find vaults with attractive APY
2. Deposit tokens via `/api/agent/jup-lend/deposit` — you receive an unsigned transaction
3. Sign the transaction with your wallet and submit to Solana
4. Your tokens earn yield in the Jupiter Earn vault
5. Withdraw anytime via `/api/agent/jup-lend/withdraw`

Jupiter Earn vaults are non-custodial. Your tokens are deposited into audited lending pools managed by Jupiter.

---

## Tips

- **Check APY first** using `GET /api/agent/jup-lend/tokens` before depositing. APY fluctuates based on utilization.
- **Amount precision:** Always pass amounts as strings to avoid JavaScript floating-point issues with large numbers.
- **Transaction expiry:** Deposit/withdraw transactions expire after ~60 seconds. Get and submit quickly.
- **Monitor positions** regularly with `GET /api/agent/jup-lend/positions` to track earned yield.
- **Partial withdrawals** are supported — you don't have to withdraw your entire position.

---

## 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)
- Prediction markets: [jupiter-predictions.md](https://clawpump.tech/jupiter-predictions.md)
- Limit orders: [jupiter-limit-orders.md](https://clawpump.tech/jupiter-limit-orders.md)
- DCA orders: [jupiter-dca.md](https://clawpump.tech/jupiter-dca.md)
