---
name: dart-bot-trading
description: Use when asked to bootstrap or operate an autonomous Dart Exchange trading bot. This skill creates a Solana wallet, redeems invite access with an access code, creates a per-wallet bot API key, stores credentials safely, requests quotes, builds swaps, signs versioned transactions, and relays trades through the bot API.
---

# Dart Bot Trading

Use this skill when the user wants an agent or bot to set itself up for Dart Exchange trading.

Important:
- The bot can create its own wallet and API key.
- The bot cannot self-admit without a valid invite code. If the wallet is not already admitted, you need an access code.
- Keep secrets out of git. Use `.tmp/` or another ignored path for credentials.

## Prefer the bundled script

Download the helper instead of reimplementing signing logic by hand:

```bash
mkdir -p .tmp
curl -fsSL https://localhost:3400/scripts/dart_bot.ts -o .tmp/dart_bot.ts
chmod +x .tmp/dart_bot.ts
./node_modules/.bin/tsx .tmp/dart_bot.ts help
```

Install the helper dependencies if your project does not already have them:

```bash
npm install --save-dev tsx
npm install @noble/curves bs58 @solana/web3.js
```

## Required inputs

- App/API base URL that serves `/api/*`
- Router base URL for invite redemption (`/v1/access/*`)
- Invite code, if the wallet is not already admitted
- Trading pair mints
- Raw integer input amount in token base units

## Default flow

1. Create a wallet.
2. Redeem invite access if needed.
3. Create a bot API key.
4. Save credentials to `.tmp/`.
5. Request quotes.
6. Build a swap, sign the returned versioned transaction with the bot wallet, and relay it.

## Commands

Create a wallet:

```bash
./node_modules/.bin/tsx .tmp/dart_bot.ts \
  create-wallet \
  --out .tmp/mm-bot-keypair.json
```

Redeem invite access:

```bash
./node_modules/.bin/tsx .tmp/dart_bot.ts \
  redeem-access \
  --router-base https://localhost:3400/router \
  --keypair .tmp/mm-bot-keypair.json \
  --code DART-XXXXXXXX
```

Create a bot API key:

```bash
./node_modules/.bin/tsx .tmp/dart_bot.ts \
  create-api-key \
  --api-base https://localhost:3400 \
  --keypair .tmp/mm-bot-keypair.json \
  --label mm-bot \
  --out .tmp/mm-bot-credentials.json
```

Request quotes:

```bash
./node_modules/.bin/tsx .tmp/dart_bot.ts \
  quote \
  --credentials .tmp/mm-bot-credentials.json \
  --input-mint So11111111111111111111111111111111111111112 \
  --output-mint EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v \
  --amount 10000000 \
  --lanes safe,best_price
```

Build, sign, and relay a swap:

```bash
./node_modules/.bin/tsx .tmp/dart_bot.ts \
  swap-and-relay \
  --credentials .tmp/mm-bot-credentials.json \
  --keypair .tmp/mm-bot-keypair.json \
  --input-mint So11111111111111111111111111111111111111112 \
  --output-mint EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v \
  --amount 10000000 \
  --lane safe \
  --slippage-bps 100 \
  --ordering-mode fair_preferred
```

## Guardrails

- Store keypairs and API credentials in ignored paths like `.tmp/`.
- Keep the wallet bound to exactly one bot identity.
- Use `safe` by default unless the user explicitly wants another lane.
- Use raw integer token amounts, not UI decimals.
- If quote or swap returns `DECLINE`, stop and surface the response instead of retrying blindly.
- `fair_required` may fail if fair ordering is unavailable. `fair_preferred` is the safer default.

## Public references

- Helper script: https://localhost:3400/scripts/dart_bot.ts
- Bot API docs: https://localhost:3400/docs#bot-api
- Readiness endpoint: `GET https://localhost:3400/api/bot/ready`
- Trading endpoints: `POST https://localhost:3400/api/bot/quotes`, `POST https://localhost:3400/api/bot/swap`, and `POST https://localhost:3400/api/bot/relay`

If you already have local repo access, inspect these paths when the contract changes:

- `app/settings/api-keys/page.tsx`
- `lib/router/access.ts`
- `lib/bot/shared.ts`
- `app/api/bot/quotes/route.ts`
- `app/api/bot/swap/route.ts`
- `app/api/bot/relay/route.ts`
