/install deepbook-cli
DeepBook CLI Skill
Use this skill when the user wants to use deepbook end to end: market data, wallet/config setup, and on-chain execution (spot, swap, manager, margin).
Installation
Check if deepbook is installed:
deepbook --version
If not, install it:
npm install -g deepbook-cli
Setup
- Work from the
deepbook-cliproject directory. - Ensure
~/.deepbook/config.jsonexists (auto-created on first run). - Configure global defaults in
~/.deepbook(works from any path). - Optional one-off overrides can still be provided via global flags.
mainnet/testnet are aliases used consistently for both provider-side reads/streams and on-chain RPC.
Global flags
--json--provider \x3Cname>--base-url \x3Curl>--stream-base-url \x3Curl>--network \x3Cmainnet|testnet>--rpc-url \x3Curl>--private-key \x3Csuiprivkey>--address \x3Caddress>--manager \x3Cid>--trade-cap \x3Cid>
Available commands
-
Top-level:
deepbook providersdeepbook poolsdeepbook orderbook \x3Cpool>(alias:deepbook book \x3Cpool>)deepbook trades \x3Cpool>deepbook ohlcv \x3Cpool>deepbook stream ...deepbook spot ...deepbook swap ...deepbook margin ...deepbook manager ...deepbook config ...deepbook account ...
-
deepbook config:showset-network \x3Cnetwork>set-provider \x3Cprovider>set-rpc-url \x3Cnetwork> \x3Curl>set-address \x3Caddress>set-trade-cap \x3Cid>set-read-key [apiKey]set-stream-key \x3Cpool> [apiKey]set-provider-base-url \x3Cnetwork> \x3Curl>set-provider-stream-base-url \x3Cnetwork> \x3Curl>import-key [privateKey]
-
deepbook account:detailslistbalanceimport \x3Calias> [privateKey]use \x3Calias>
-
deepbook stream:trades \x3Cpool>
-
deepbook spot:poolsbuy \x3Cpool>sell \x3Cpool>limit \x3Cpool>
-
deepbook swap:base-for-quote \x3Cpool>quote-for-base \x3Cpool>
-
deepbook margin:poolsmanagersdeposit \x3Cpool>market \x3Cpool>limit \x3Cpool>position \x3Cpool>close \x3Cpool>
-
deepbook manager:lscreatedepositwithdrawbalance
Command cheat sheet (required args/options)
-
deepbook providers -
deepbook pools -
deepbook orderbook \x3Cpool> -
deepbook trades \x3Cpool> -
deepbook ohlcv \x3Cpool> -
deepbook stream trades \x3Cpool> -
deepbook spot pools -
deepbook spot buy \x3Cpool> --quantity \x3Cvalue> [--price \x3Cvalue>] [--manager \x3Cid>] -
deepbook spot sell \x3Cpool> --quantity \x3Cvalue> [--price \x3Cvalue>] [--manager \x3Cid>] -
deepbook spot limit \x3Cpool> --side \x3Cbuy|sell> --price \x3Cvalue> --quantity \x3Cvalue> [--manager \x3Cid>] -
deepbook spot limit \x3Cpool> --cancel \x3Cid> [--manager \x3Cid>] -
deepbook config show -
deepbook config set-network \x3Cmainnet|testnet> -
deepbook config set-provider \x3Csurflux> -
deepbook config set-rpc-url \x3Cmainnet|testnet> \x3Curl> -
deepbook config set-address \x3Caddress> -
deepbook config set-trade-cap \x3CobjectId> -
deepbook config set-read-key [apiKey](or--stdin) -
deepbook config set-stream-key \x3Cpool> [apiKey](or--stdin) -
deepbook config set-provider-base-url \x3Cmainnet|testnet> \x3Curl> -
deepbook config set-provider-stream-base-url \x3Cmainnet|testnet> \x3Curl> -
deepbook config import-key [privateKey](or--stdin, optional--alias) -
deepbook account details -
deepbook account list -
deepbook account balance [--coin \x3CSUI|USDC|DEEP|coinType>] -
deepbook account import \x3Calias> [privateKey](or--stdin) -
deepbook account use \x3Calias> -
deepbook swap base-for-quote \x3Cpool> --amount \x3Cvalue> -
deepbook swap quote-for-base \x3Cpool> --amount \x3Cvalue> -
deepbook margin pools -
deepbook margin managers -
deepbook margin deposit \x3Cpool> --coin \x3CBASE|QUOTE|DEEP|coinKey> --amount \x3Cvalue> [--margin-manager \x3Cid>] -
deepbook margin market \x3Cpool> --side \x3Cbuy|sell> --quantity \x3Cvalue> [--margin-manager \x3Cid>] -
deepbook margin limit \x3Cpool> --side \x3Cbuy|sell> --price \x3Cvalue> --quantity \x3Cvalue> [--margin-manager \x3Cid>] -
deepbook margin position \x3Cpool> [--margin-manager \x3Cid>] -
deepbook margin close \x3Cpool> [--margin-manager \x3Cid>]+ either:--full- OR
--side \x3Cbuy|sell> --quantity \x3Cvalue>
-
deepbook manager ls -
deepbook manager create -
deepbook manager deposit --coin \x3Ckey> --amount \x3Cvalue> [--manager \x3Cid>] -
deepbook manager withdraw --coin \x3Ckey> --amount \x3Cvalue> [--manager \x3Cid>] -
deepbook manager balance --coin \x3Ckey> [--manager \x3Cid>]
Key margin close flags
deepbook margin close \x3Cpool> --full --withdrawdeepbook margin close \x3Cpool> --full --non-reduce-onlydeepbook margin close \x3Cpool> --side \x3Cbuy|sell> --quantity \x3Cq> --reduce-only --no-repay
Swap vs spot market buy
- Swap (
deepbook swap quote-for-base) is a direct pool swap with exact-input semantics. - Spot market buy (
deepbook spot buy \x3Cpool> --quantity ...) is an orderbook market order and uses a balance manager. - CLI output now includes
execution.kindandexecution.type/directionso the mode is explicit.
Safety defaults
- Prefer
--dry-runfirst for all state-changing commands. - Validate pool key and manager object ID before placing/canceling orders.
- SUI-involved deposit/collateral paths split from gas coin inside the transaction automatically.
- Never print or log private keys.
- Margin manager type safety:
- Margin managers are generic typed objects:
MarginManager\x3CBase, Quote>. - The margin manager type must match the exact pool pair being traded.
- Example:
MarginManager\x3CDEEP,USDC>works withDEEP_USDC, notDEEP_SUI.
- Margin managers are generic typed objects:
- Margin manager resolution behavior:
- If
--margin-manageris omitted, CLI auto-selects a compatible manager for that pool, or creates one in-transaction if none exists. - If
--margin-manageris provided, CLI treats it as explicit and strict: it must match signer + pool; no fallback or auto-create is performed.
- If
- Internal margin fee buffer behavior:
- Margin market/limit orders auto-deposit a fee buffer before placing the order.
- With
--no-pay-with-deep, buffer is deposited in trade asset collateral (base for sell, quote for buy). - Without
--no-pay-with-deep, buffer is deposited as DEEP into the margin manager.
- Full-close quantity normalization:
deepbook margin close \x3Cpool> --fullnow auto-normalizes inferred quantity to pool lot-size/min-size.- If reduce-only full close cannot satisfy lot-size exactly, CLI auto-switches to non-reduce-only and rounds up, then repays debt in the same transaction.
- If user explicitly passes
--reduce-only, CLI keeps reduce-only semantics and errors when full close cannot be represented as a valid lot-size quantity.
End-to-end spot trading flow (fund -> buy -> withdraw)
Use this when executing a real spot trade through a balance manager.
- Discover balance managers:
deepbook manager ls
- If none exist, create one:
deepbook manager create
- Deposit quote coin to manager (for
DEEP_SUIbuy, fundSUI):deepbook manager deposit --coin SUI --amount 1 --manager \x3Cid>
- Optional balance check:
deepbook manager balance --coin SUI --manager \x3Cid>
- Simulate buy first:
deepbook spot buy DEEP_SUI --quantity 38 --manager \x3Cid> --no-pay-with-deep --dry-run
- Execute live buy:
deepbook spot buy DEEP_SUI --quantity 38 --manager \x3Cid> --no-pay-with-deep
- Withdraw purchased asset to signer address (or explicit recipient):
deepbook manager withdraw --coin DEEP --amount 38 --manager \x3Cid>- optional recipient:
--recipient \x3Caddress>
- Verify manager balance:
deepbook manager balance --coin DEEP --manager \x3Cid>
Spot trade troubleshooting
MoveAbort ... balance_manager::withdraw_with_proof code=3means manager available balance is too low.- This includes fees/reserved amounts, not just raw deposited balance.
- For spot buys, ensure quote coin is funded in manager (for
DEEP_SUI, quote isSUI). - If fees are attempted in DEEP and manager lacks DEEP, either deposit DEEP or pass
--no-pay-with-deep. - When manager is omitted, CLI resolves dynamically:
- one manager found -> uses it
- none found -> error
- multiple found -> require
--manager \x3Cid>
Typical workflow
- Inspect pools/orderbook (
deepbook spot pools,deepbook margin pools,deepbook orderbook ...). - Confirm manager ID (
deepbook manager ls). - Simulate order (
deepbook spot buy ... --dry-run). - Execute live order (same command without
--dry-run). - Monitor with
deepbook orderbook --watchanddeepbook stream trades ....
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install deepbook-cli - After installation, invoke the skill by name or use
/deepbook-cli - Provide required inputs per the skill's parameter spec and get structured output
What is DeepBook CLI. Watch, Make & Take the Sui Market?
Operate the deepbook CLI for DeepBook reads (REST/SSE), global ~/.deepbook config/account management, on-chain spot trading, top-level swap execution, balance-manager ops, and margin trading. It is an AI Agent Skill for Claude Code / OpenClaw, with 1497 downloads so far.
How do I install DeepBook CLI. Watch, Make & Take the Sui Market?
Run "/install deepbook-cli" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is DeepBook CLI. Watch, Make & Take the Sui Market free?
Yes, DeepBook CLI. Watch, Make & Take the Sui Market is completely free (open-source). You can download, install and use it at no cost.
Which platforms does DeepBook CLI. Watch, Make & Take the Sui Market support?
DeepBook CLI. Watch, Make & Take the Sui Market is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created DeepBook CLI. Watch, Make & Take the Sui Market?
It is built and maintained by astinz (@astinz); the current version is v0.0.1.