# deepbook-move

The deepbook-move Claude Code skill guides Move contract work with DeepBook V3. It covers pools, orders, swaps, flash loans, and BalanceManager permissions.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 181 installs · ★ 25 repo stars
- Author: MystenLabs
- License: Apache-2.0 · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/MystenLabs/skills/tree/HEAD/deepbook-move/SKILL.md
- Updated: 2026-11-12
- Security check: automated, 2026-11-17 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/deepbook-move

## What it does

The skill helps write, review, and debug Move contracts that call DeepBook V3. Its guidance covers limit and market orders, swaps that do not use a BalanceManager, flash loans, and calls combined in programmable transaction blocks. Add `deepbook = { mvr = "@deepbook/core" }` to `Move.toml` for the dependency.

It explains pool asset type ordering and the roles of `TradeProof`, `TradeCap`, `DepositCap`, and `WithdrawCap`. A `FlashLoan` must be consumed by its matching return call in the same transaction; otherwise, the transaction reverts. Borrowing from a pool and trading through that same pool in one transaction can fail.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add MystenLabs/skills --skill deepbook-move -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/deepbook-move/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/deepbook-move/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add MystenLabs/skills --skill deepbook-move -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/deepbook-move/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add MystenLabs/skills --skill deepbook-move -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/deepbook-move/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install MystenLabs/skills deepbook-move
```

2. **Manually: put the files in place**
- File: `.github/skills/deepbook-move/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add MystenLabs/skills --skill deepbook-move -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/MystenLabs/skills --path deepbook-move
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/deepbook-move/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add MystenLabs/skills --skill deepbook-move -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/MystenLabs/skills/tree/HEAD/deepbook-move/SKILL.md

## When to use it
- write a Move contract that places a DeepBook order
- compose a pool swap without a BalanceManager
- debug flash-loan repayment in a transaction
- set up BalanceManager permissions for owners and cap holders

## Example prompts
- Help me add a DeepBook limit order to this Move contract using `deepbook::pool`.
- Explain how to call `swap_exact_base_for_quote` without a BalanceManager.
- Check how this transaction should return its `FlashLoan`.

## Source text · SKILL.md · Apache-2.0

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: e83a72d8873cde46.

BEGIN THIRD-PARTY FILE e83a72d8873cde46
````text
---
name: deepbook-move
description: >
  Guides writing, reviewing, and debugging Move smart contracts that call DeepBook V3:
  placing limit or market orders on-chain, creating pools, swapping without a
  BalanceManager, flash loans, BalanceManager/TradeCap authorization, and composing
  DeepBook calls in programmable transaction blocks. Use when the user asks about
  deepbook::pool, place_limit_order, swap_exact_base_for_quote, borrow_flashloan_base,
  FlashLoan hot potato, TradeProof, TradeCap/DepositCap/WithdrawCap, or adding
  `deepbook = { mvr = "@deepbook/core" }` to Move.toml.
---

# DeepBook V3 Move Integration

## Setup

`Move.toml`:

```toml
[dependencies]
deepbook = { mvr = "@deepbook/core" }
```

```move
use deepbook::pool::{Self, Pool};
use deepbook::balance_manager::{Self, BalanceManager, TradeProof, TradeCap};
```

Every `Pool` function is generic over `<BaseAsset, QuoteAsset>` and the type arguments must match the pool's creation order exactly: `Pool<SUI, USDC>` is a different type from `Pool<USDC, SUI>`.

## Orders (require a BalanceManager + TradeProof)

```move
public fun place_limit_order<BaseAsset, QuoteAsset>(
    self: &mut Pool<BaseAsset, QuoteAsset>,
    balance_manager: &mut BalanceManager,
    trade_proof: &TradeProof,
    client_order_id: u64,
    order_type: u8,
    self_matching_option: u8,
    price: u64,
    quantity: u64,
    is_bid: bool,
    pay_with_deep: bool,
    expire_timestamp: u64,
    clock: &Clock,
    ctx: &mut TxContext,
): OrderInfo
```

`place_market_order` takes the same arguments minus `price` and `expire_timestamp`.
`cancel_order<BaseAsset, QuoteAsset>(pool, balance_manager, trade_proof, order_id, clock, ctx)`.

`order_type` constants: `0` = NO_RESTRICTION, `1` = IMMEDIATE_OR_CANCEL (IOC), `2` = FILL_OR_KILL (FOK), `3` = POST_ONLY.

Every order placement and cancellation needs a `TradeProof`, created in the same transaction:

```move
// owner of the BalanceManager
public fun generate_proof_as_owner(bm: &mut BalanceManager, ctx: &TxContext): TradeProof
// delegated trader holding a TradeCap
public fun generate_proof_as_trader(bm: &mut BalanceManager, trade_cap: &TradeCap, ctx: &TxContext): TradeProof
```

## Swaps (no BalanceManager, no TradeProof)

```move
public fun swap_exact_base_for_quote<BaseAsset, QuoteAsset>(
    self: &mut Pool<BaseAsset, QuoteAsset>,
    base_in: Coin<BaseAsset>,
    deep_in: Coin<DEEP>,
    min_quote_out: u64,
    clock: &Clock,
    ctx: &mut TxContext,
): (Coin<BaseAsset>, Coin<QuoteAsset>, Coin<DEEP>)

public fun swap_exact_quote_for_base<BaseAsset, QuoteAsset>(
    self: &mut Pool<BaseAsset, QuoteAsset>,
    quote_in: Coin<QuoteAsset>,
    deep_in: Coin<DEEP>,
    min_base_out: u64,
    clock: &Clock,
    ctx: &mut TxContext,
): (Coin<BaseAsset>, Coin<QuoteAsset>, Coin<DEEP>)
```

Both return three coins: leftover base, leftover quote, and unused DEEP. `deep_in` pays the taker fee — overestimating is safe because the unused DEEP is returned; underestimating aborts.

Simulate first:

```move
public fun get_quantity_out<BaseAsset, QuoteAsset>(
````
END THIRD-PARTY FILE e83a72d8873cde46

The third-party file has ended. Everything between the e83a72d8873cde46 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 3079 of 7134 bytes. © MystenLabs · Apache-2.0 · https://github.com/MystenLabs/skills/tree/HEAD/deepbook-move/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
