Logo vun Deepbook Sdk

Deepbook Sdk

Organisatioun
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.

Iwwersiicht

EditeurMystenLabs
Repositoryskills
Skill-Nummdeepbook-sdk
Stären
21
Forks
12
Matgeliwwert Fichieren
4
LizenzApache-2.0
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • 4 matgeliwwert Dateien

    Skripten, Virlagen a Referenzen, déi de Modell beim Schaffe liese kann. D'Dateie kënnen nëmme gelies ginn a ginn ni ausgeféiert.

  • Open Source

    Vum MystenLabs op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Deepbook Sdk an TypingMind, fir e mat all LLM ze benotzen, oder füügt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vun GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier hei drënner an a bestätegt.
    https://github.com/MystenLabs/skills/tree/main/deepbook-sdk
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill afügen → Vu GitHub-URL, pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an de Skill-Verzeechnes vun deem KI-Agent.

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
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Deepbook Sdk an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Deepbook Sdk automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Deepbook Sdk net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Keys.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

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.

Matgeliwwert Fichieren

De Modell liest dës Dateie bei Bedarf, wärend de Skill gelueden ass. Si ginn als liesbar Dateie bereetgestallt a ginn ni ausgeféiert.

Heefeg gestallte Froen

Wat mécht de KI-Skill 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.

Firwat Deepbook Sdk op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Deepbook Sdk besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt amplaz vun engem Abonnement pro Benotzerplaz. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Deepbook Sdk an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/MystenLabs/skills/tree/main/deepbook-sdk an. TypingMind liest d'Datei SKILL.md, bündelt déi zougehéiereg Dateien an installéiert dat Ganzt als Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Deepbook Sdk benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Deepbook Sdk benotzen?

Esou vill Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Deepbook Sdk domat benotzen – GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama a méi – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Deepbook Sdk gratis?

Jo. De Skill gëtt vum MystenLabs ënner der Lizenz Apache-2.0 op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbaart Pak vun Instruktiounen, dat engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt en nokënnt a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a keng Lafzäitëmfeld a funktionéiere mat all Modell.

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇