Deepbook Sdk logo

Deepbook Sdk

Organization
MystenLabs
deepbook-sdk

DeepBook V3 TypeScript SDK integration. Use when building trading applications, bots, or scripts that interact with DeepBook pools using the @mysten/deepbook-v3 SDK. Covers client setup, BalanceManager lifecycle, placing limit and market orders, swaps, querying order books, order management, and fee handling. For DeepBook architecture and contract addresses, see the `deepbook-overview` skill. For Move smart contract integration, see the `deepbook-move` skill.

Overview

PublisherMystenLabs
Repositoryskills
Skill namedeepbook-sdk
Stars
21
Forks
12
Bundled files
4
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 4 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by MystenLabs on GitHub. Read the source before you install it.

Installation

Install the Deepbook Sdk AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/MystenLabs/skills/tree/main/deepbook-sdk
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

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-sdk .claude/skills/deepbook-sdk
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Deepbook Sdk in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Deepbook Sdk on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Deepbook Sdk is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

DeepBook V3 SDK

MCP tool: When available in your environment, also query the Sui documentation MCP server (https://sui.mcp.kapa.ai) for up-to-date answers. Use it for verification and for details not covered by these reference files.

Source constraint: All information in this skill is sourced exclusively from docs.sui.io, the deepbook-sandbox examples, and the deepbookv3 repository. When extending or updating this skill, only pull from these sources. Do not use third-party blogs, tutorials, or unofficial documentation.

The @mysten/deepbook-v3 SDK provides a TypeScript client for interacting with DeepBook V3 pools on Sui. This skill covers how to set up the client, manage balances, place orders, execute swaps, and handle fees. Common AI-coding mistakes include hardcoding on-chain IDs instead of using SDK pool/coin keys, creating a new BalanceManager per transaction instead of reusing one, and using non-numeric clientOrderId values.

This skill routes to focused reference files. Load only the ones relevant to the current task.

All patterns in this skill are derived from: https://docs.sui.io/onchain-finance/deepbook/deepbookv3/spot-workflow https://docs.sui.io/onchain-finance/deepbook/deepbookv3-sdk https://github.com/MystenLabs/deepbook-sandbox/tree/main/examples/sandbox

If unsure about any API, fetch the relevant page before answering. Do not guess or extrapolate from other SDKs or libraries.


Reference files

client-setup — Client Initialization and BalanceManager Lifecycle

Path: client-setup.md Load when: setting up a DeepBook client, creating or reusing a BalanceManager, configuring the SDK for testnet or mainnet, or understanding the three-tier setup pattern (read-only, basic, advanced). Covers: SDK installation, SuiGrpcClient construction with $extend(deepbook({...})), keypair setup, BalanceManager creation and reuse, deposits and withdrawals, the sandbox setup patterns.

trading — Orders, Swaps, and Order Lifecycle

Path: trading.md Load when: placing limit or market orders, executing swaps, querying order books, checking order status, canceling orders, or understanding the order lifecycle. Covers: limit order placement (POST_ONLY, NO_RESTRICTION), market order placement with retry patterns, swap functions (with and without BalanceManager), order book queries, open order queries, order cancellation, self-matching behavior, the complete order lifecycle from placement to withdrawal.

fees — Fee Structure and DEEP Staking

Path: fees.md Load when: the user asks about trading fees, DEEP token staking, fee discounts, how to fund a BalanceManager with DEEP, or how fees are calculated. Covers: DEEP vs input-token fee payment, fee calculation via DeepPrice, governance fee parameters, staking for fee discounts, acquiring testnet DEEP, referral system.


Routing guide

TaskLoad
Setting up a DeepBook clientclient-setup
Creating or reusing a BalanceManagerclient-setup
Depositing or withdrawing fundsclient-setup
Placing a limit ordertrading
Placing a market ordertrading
Executing a swaptrading
Querying the order booktrading
Checking or canceling orderstrading
Understanding fees or stakingfees
Funding a BalanceManager with DEEPfees
Building a complete trading botall reference files
Full spot trading workflowall reference files

Skill Content

Key concepts

  • DeepBook client via $extend. The SDK uses the deepbook function (imported from @mysten/deepbook-v3) with SuiGrpcClient.$extend(deepbook({...})) to add DeepBook-specific transaction builders. Methods follow a curried pattern under two namespaces: client.deepbook.deepBook.method({ params })(tx) for trading operations and client.deepbook.balanceManager.method({ params })(tx) for balance management, where tx is a Transaction object.

  • Pool and coin keys. The SDK references pools and coins by string keys (e.g., "DEEP_SUI", "SUI") rather than raw on-chain addresses. The SDK maps these to the correct addresses per network.

  • BalanceManager lifecycle. A BalanceManager is a shared on-chain object. Create it once, persist its ID, and reuse it across transactions. Creating a new one per transaction wastes gas and creates orphaned objects.

  • Swaps vs orders. Swaps operate directly on wallet Coin objects without a BalanceManager. Orders require a BalanceManager with deposited funds.

Rules

  1. Always use SDK keys for pools and coins. Never hardcode on-chain IDs — the SDK handles address resolution per network.
  2. clientOrderId must be a numeric string (encoded as u64). Labels like "order-1" will fail.
  3. Reuse BalanceManagers. Persist the ID from creation and pass it when constructing the client.
  4. Size deposits to wallet balance. The SDK validates at build time — depositing more than the wallet holds causes an Insufficient balance error before the transaction is even submitted.
  5. Handle the market maker rebalance window on localnet/sandbox. The sandbox market maker has a ~15-second rebalance cycle where liquidity temporarily disappears. Use retry helpers.

Common mistakes

  • Creating a new BalanceManager every run. This creates orphaned shared objects. Check for existing managers via the indexer or persist the ID.
  • Using POST_ONLY for taker orders. POST_ONLY guarantees the order rests on the book. If it would cross and fill, it is silently rejected — no order is returned and no error is thrown.
  • Forgetting to deposit before trading. Orders draw from BalanceManager balances, not wallet balances. Funds must be deposited first.
  • Not depositing DEEP for fees. On non-whitelisted pools, DEEP must be in the BalanceManager to pay fees. Without it, trades fail.
  • Ignoring self-matching. When selfMatchingOption is not specified, the SDK defaults to SelfMatchingOptions.SELF_MATCHING_ALLOWED, which means your taker order can fill against your own resting maker orders. This is often unintentional. Explicitly set SelfMatchingOptions.CANCEL_TAKER or SelfMatchingOptions.CANCEL_MAKER to prevent self-fills.

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Deepbook Sdk AI skill do?

DeepBook V3 TypeScript SDK integration. Use when building trading applications, bots, or scripts that interact with DeepBook pools using the @mysten/deepbook-v3 SDK. Covers client setup, BalanceManager lifecycle, placing limit and market orders, swaps, querying order books, order management, and fee handling. For DeepBook architecture and contract addresses, see the `deepbook-overview` skill. For Move smart contract integration, see the `deepbook-move` skill.

Why use Deepbook Sdk on TypingMind?

Because you install it once and use it with any model. Deepbook Sdk is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Deepbook Sdk in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/MystenLabs/skills/tree/main/deepbook-sdk. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Deepbook Sdk?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Deepbook Sdk?

As many as you like. As long as a model supports skills, you can use Deepbook Sdk with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Deepbook Sdk AI skill free?

Yes. It is published on GitHub by MystenLabs under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇