Logo Deepbook Move

Deepbook Move

Tổ chức
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.

Tổng quan

Nhà phát hànhMystenLabs
Kho mãskills
Tên kỹ năngdeepbook-move
Sao
21
Bản fork
12
Tệp đi kèm
4
Giấy phépApache-2.0
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 4 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được MystenLabs công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Deepbook Move trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/MystenLabs/skills/tree/main/deepbook-move
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân 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
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Deepbook Move trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Deepbook Move ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Deepbook Move với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

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.

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Deepbook Move làm được gì?

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.

Vì sao nên dùng Deepbook Move trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Deepbook Move là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Deepbook Move trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/MystenLabs/skills/tree/main/deepbook-move. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Deepbook Move?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Deepbook Move với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Deepbook Move với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Deepbook Move có miễn phí không?

Có. Kỹ năng này được MystenLabs phát hành trên GitHub theo giấy phép Apache-2.0. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇