deepbook-sdk
Skill20 starsChanged 15 days agoApache-2.0View on GitHub
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.
In this repository30 other files it gives its agents.
- accessing-dataSkill
- composable-move-functionsSkill
- deepbook-marginSkill
- deepbook-moveSkill
- deepbook-overviewSkill
- deepbook-predictSkill
- frontend-appsSkill
- generate-sui-agent-configSkill
- kioskSkill
- modern-move-syntaxSkill
- move-securitySkill
- move-unit-testingSkill
- naming-conventionsSkill
- sui-object-modelSkill
- onchain-randomnessSkill
- ptbsSkill
- sui-bridgeSkill
- sui-buildSkill
- sui-clientSkill
- sui-for-ethereumSkill
- sui-installSkill
- sui-move-projectSkill
- sui-moveSkill
- sui-networks-gasSkill
- sui-overviewSkill
- sui-publishSkill
- sui-sdksSkill
- sui-ts-sdk-backendSkill
- walrus-sitesSkill
- zkloginSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 23
All patterns in this skill are derived from: https://docs.sui.io/onchain-finance/deepbook/deepbookv3/spot-workflow …
- Distinctive: line 28
If unsure about any API, fetch the relevant page before answering.
- Distinctive: line 29
Do not guess or extrapolate from other SDKs or libraries.
- Distinctive: line 85
Always use SDK keys for pools and coins: Never hardcode on-chain IDs — the SDK handles address resolution per network.
- Very specific: line 97
Ignoring self-matching: When selfMatchingOption is not specified, the SDK defaults to SelfMatchingOptions.SELF_MATCHING_ALLOWED, which …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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
| Task | Load |
| Setting up a DeepBook client | client-setup |
| Creating or reusing a BalanceManager | client-setup |
| Depositing or withdrawing funds | client-setup |
| Placing a limit order | trading |
| Placing a market order | trading |
| Executing a swap | trading |
| Querying the order book | trading |
| Checking or canceling orders | trading |
| Understanding fees or staking | fees |
| Funding a BalanceManager with DEEP | fees |
| Building a complete trading bot | all reference files |
| Full spot trading workflow | all reference files |
Skill Content
Key concepts
- DeepBook client via
$extend. The SDK uses thedeepbookfunction (imported from@mysten/deepbook-v3) withSuiGrpcClient.$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 andclient.deepbook.balanceManager.method({ params })(tx)for balance management, wheretxis aTransactionobject. - 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
Coinobjects without a BalanceManager. Orders require a BalanceManager with deposited funds.
Rules
- Always use SDK keys for pools and coins. Never hardcode on-chain IDs — the SDK handles address resolution per network.
clientOrderIdmust be a numeric string (encoded asu64). Labels like"order-1"will fail.- Reuse BalanceManagers. Persist the ID from creation and pass it when constructing the client.
- Size deposits to wallet balance. The SDK validates at build time — depositing more than the wallet holds causes an
Insufficient balanceerror before the transaction is even submitted. - 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_ONLYfor taker orders.POST_ONLYguarantees 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
selfMatchingOptionis not specified, the SDK defaults toSelfMatchingOptions.SELF_MATCHING_ALLOWED, which means your taker order can fill against your own resting maker orders. This is often unintentional. Explicitly setSelfMatchingOptions.CANCEL_TAKERorSelfMatchingOptions.CANCEL_MAKERto prevent self-fills.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

