Skip to main content
DeepBook is a decentralized central limit order book (CLOB) built natively on Sui. It provides efficient on-chain trading with minimal MEV and high throughput.

Overview

DeepBook enables:
  • Order Book Trading: Limit and market orders
  • Atomic Matching: Instant order matching in a single transaction
  • Low Latency: Leveraging Sui’s parallel execution
  • Deep Liquidity: Aggregated order book for all trading pairs
  • MEV Protection: Fair order execution

Core Modules

clob_v2.move

The main CLOB implementation (v2 is the current version). Key Types:
Key Functions:

custodian_v2.move

Manages user accounts and balances within DeepBook. Key Types:
Key Functions:

order_query.move

Provides read-only functions for querying order book state. Key Functions:

Usage Examples

Create a Trading Pool

Place Limit Order

Place Market Order

Cancel Order

Query Order Book

Account Management

Create Account

Deposit Funds

Withdraw Funds

Price Levels and Matching

DeepBook uses:
  • Tick Size: Minimum price increment
  • Lot Size: Minimum quantity increment
  • Price-Time Priority: Orders matched by price, then timestamp
  • Post-Only Orders: Optional for market makers
  • Fill-or-Kill: Optional for immediate execution

Best Practices

  1. Use AccountCap: Always use account capabilities for custody
  2. Handle Partial Fills: Market orders may be partially filled
  3. Check Slippage: Monitor price impact for large orders
  4. Cancel Stale Orders: Clean up unfilled orders
  5. Query Before Trading: Check order book depth and spread

Integration Example

Resources