Deepbook Moveのロゴ

Deepbook Move

組織
MystenLabs
deepbook-move

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.

概要

公開者MystenLabs
リポジトリskills
スキル名deepbook-move
スター
21
フォーク
12
同梱ファイル
4
ライセンスApache-2.0
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 4個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    MystenLabsがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Deepbook Move」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/MystenLabs/skills/tree/main/deepbook-move
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/MystenLabs/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/deepbook-move .claude/skills/deepbook-move
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでDeepbook Moveを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にDeepbook Moveを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Deepbook Moveは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

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>(
    self: &Pool<BaseAsset, QuoteAsset>,
    base_quantity: u64,
    quote_quantity: u64,
    clock: &Clock,
): (u64, u64, u64) // (base_out, quote_out, deep_required)

Exactly one of base_quantity or quote_quantity must be non-zero; passing both or neither is invalid.

Flash loans

move
public fun borrow_flashloan_base<BaseAsset, QuoteAsset>(
    self: &mut Pool<BaseAsset, QuoteAsset>, base_amount: u64, ctx: &mut TxContext,
): (Coin<BaseAsset>, FlashLoan)

public fun borrow_flashloan_quote<BaseAsset, QuoteAsset>(
    self: &mut Pool<BaseAsset, QuoteAsset>, quote_amount: u64, ctx: &mut TxContext,
): (Coin<QuoteAsset>, FlashLoan)

public fun return_flashloan_base<BaseAsset, QuoteAsset>(
    self: &mut Pool<BaseAsset, QuoteAsset>, coin: Coin<BaseAsset>, flash_loan: FlashLoan,
)

public fun return_flashloan_quote<BaseAsset, QuoteAsset>(
    self: &mut Pool<BaseAsset, QuoteAsset>, coin: Coin<QuoteAsset>, flash_loan: FlashLoan,
)

FlashLoan has no abilities — it cannot be stored, copied, or dropped, so it must be consumed by the matching return_flashloan_* call in the same transaction. If it is not repaid the whole transaction reverts and no state change persists. The maximum borrowable amount is the pool's current holdings of that asset. There is no borrow fee; repay the exact borrowed amount.

BalanceManager and delegation

A BalanceManager is a shared object that holds a user's balances and is reused across all pools — deposit once, trade everywhere. Two-tier authorization:

  • Owner — full control: deposit, withdraw, mint and revoke caps, generate_proof_as_owner.
  • Cap holders — TradeCap can only trade (generate_proof_as_trader); it cannot deposit or withdraw. DepositCap can only deposit, WithdrawCap can only withdraw.
move
public fun new(ctx: &mut TxContext): BalanceManager
public fun mint_trade_cap(bm: &mut BalanceManager, ctx: &mut TxContext): TradeCap
public fun deposit<T>(bm: &mut BalanceManager, coin: Coin<T>, ctx: &mut TxContext)
public fun withdraw<T>(bm: &mut BalanceManager, amount: u64, ctx: &mut TxContext): Coin<T>

Limit: 1,000 total capabilities per BalanceManager across TradeCap, DepositCap, and WithdrawCap combined. Beyond that, shard across multiple BalanceManagers.

Rules and common mistakes

  1. Type parameter order. <USDC, SUI> against a Pool<SUI, USDC> is a type mismatch; match the pool's base/quote order.
  2. Return the hot potato. Forgetting return_flashloan_* compiles but aborts at runtime.
  3. Do not borrow from a pool and trade in that same pool in one transaction. Borrowed funds are unavailable for settlement and the combined operations can fail; use a different pool or venue for the trade leg.
  4. generate_proof_as_owner only works from the owner address. Delegated traders must call generate_proof_as_trader with a valid TradeCap.
  5. generate_proof_as_trader takes ctx — (bm, trade_cap, ctx: &TxContext); omitting it is a compile error.
  6. Use _v2 variants where they exist (e.g. new_with_custom_owner_caps_v2). The unsuffixed originals are stubs that abort 1337.
  7. Plan around the 1,000-cap limit before building a system with many delegated trading accounts.

Reference files

  • pool-api.md — pool creation, order placement and cancellation, pool state queries, governance, constants.
  • balance-manager-api.md — BalanceManager creation, cap minting and revocation, deposits/withdrawals, TradeProofs, events.
  • flash-loans.md — borrow/return details, constraints, worked example.

Related skills: deepbook-overview (architecture, package addresses, pool IDs), deepbook-sdk (TypeScript), sui-move (Move fundamentals), ptbs (PTB composition).

If a signature is not above, read the reference file or https://docs.sui.io/onchain-finance/deepbook/deepbookv3/contract-information and the deepbookv3 sources. Do not extrapolate from other protocols.

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Deepbook Move」では何ができますか?

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.

TypingMindでDeepbook Moveを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Deepbook Moveはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにDeepbook Moveをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/MystenLabs/skills/tree/main/deepbook-moveを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Deepbook Moveを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Deepbook Moveで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもDeepbook Moveを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Deepbook Move」は無料ですか?

はい。MystenLabsがApache-2.0ライセンスのもとでGitHubに公開しています。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇