Constructors

  • Parameters

    • suiClient: SuiClient = ...

      connection to fullnode

    • accountCap: undefined | string = undefined

      (optional) only required for wrting operations

    • currentAddress: string = DUMMY_ADDRESS

      (optional) address of the current user (default: DUMMY_ADDRESS)

    • clientOrderId: number = 0

    Returns DeepBookClient

Properties

accountCap: undefined | string = undefined

(optional) only required for wrting operations

currentAddress: string = DUMMY_ADDRESS

(optional) address of the current user (default: DUMMY_ADDRESS)

suiClient: SuiClient = ...

connection to fullnode

Methods

  • @description: batch cancel order

    Parameters

    • poolId: string

      Object id of pool, created after invoking createPool, eg: "0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4"

    • orderIds: string[]

      array of order ids you want to cancel, you can find your open orders by query.list_open_orders eg: ["0", "1", "2"]

    Returns Promise<Transaction>

  • @description: Cancel all limit orders under a certain account capacity

    Parameters

    • poolId: string

      Object id of pool, created after invoking createPool, eg: "0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4"

    Returns Promise<Transaction>

  • @description: cancel an order

    Parameters

    • poolId: string

      Object id of pool, created after invoking createPool, eg: "0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4"

    • orderId: string

      orderId of a limit order, you can find them through function query.list_open_orders eg: "0"

    Returns Promise<Transaction>

  • Parameters

    • poolId: string

      Object id of pool, created after invoking createPool, eg: "0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4"

    • orderIds: string[]

      array of expired order ids to clean, eg: ["0", "1", "2"]

    • orderOwners: string[]

      array of Order owners, should be the owner addresses from the account capacities which placed the orders

    Returns Promise<Transaction>

  • @description: Create and Transfer custodian account to user

    Parameters

    • currentAddress: string = ...

      current address of the user

    • tx: Transaction = ...

    Returns Transaction

  • @description: Create Account Cap

    Parameters

    Returns {
        $kind: "NestedResult";
        NestedResult: [number, number];
    }

    • $kind: "NestedResult"
    • NestedResult: [number, number]
  • @description: Create and Transfer custodian account to user

    Parameters

    • currentAddress: string = ...
    • accountCap: undefined | string = ...

    Returns Transaction

  • @description: Create pool for trading pair

    Parameters

    • baseAssetType: string

      Full coin type of the base asset, eg: "0x3d0d0ce17dcd3b40c2d839d96ce66871ffb40e1154a8dd99af72292b3d10d7fc::wbtc::WBTC"

    • quoteAssetType: string

      Full coin type of quote asset, eg: "0x3d0d0ce17dcd3b40c2d839d96ce66871ffb40e1154a8dd99af72292b3d10d7fc::usdt::USDT"

    • tickSize: bigint

      Minimal Price Change Accuracy of this pool, eg: 10000000. The number must be an interger float scaled by FLOAT_SCALING_FACTOR.

    • lotSize: bigint

      Minimal Lot Change Accuracy of this pool, eg: 10000.

    • takerFeeRate: bigint

      Customized taker fee rate, float scaled by FLOAT_SCALING_FACTOR, Taker_fee_rate of 0.25% should be 2_500_000 for example

    • makerRebateRate: bigint

      Customized maker rebate rate, float scaled by FLOAT_SCALING_FACTOR, should be less than or equal to the taker_rebate_rate

    Returns Transaction

  • @description: Create pool for trading pair

    Parameters

    • baseAssetType: string

      Full coin type of the base asset, eg: "0x3d0d0ce17dcd3b40c2d839d96ce66871ffb40e1154a8dd99af72292b3d10d7fc::wbtc::WBTC"

    • quoteAssetType: string

      Full coin type of quote asset, eg: "0x3d0d0ce17dcd3b40c2d839d96ce66871ffb40e1154a8dd99af72292b3d10d7fc::usdt::USDT"

    • tickSize: bigint

      Minimal Price Change Accuracy of this pool, eg: 10000000. The number must be an integer float scaled by FLOAT_SCALING_FACTOR.

    • lotSize: bigint

      Minimal Lot Change Accuracy of this pool, eg: 10000.

    Returns Transaction

  • Parameters

    • poolId: string

      the pool id for the deposit

    • coinId: undefined | string = undefined

      the coin used for the deposit. You can omit this argument if you are depositing SUI, in which case gas coin will be used

    • quantity: undefined | bigint = undefined

    Returns Promise<Transaction>

    construct transaction for depositing asset into a pool.

  • Parameters

    Returns Promise<PaginatedPoolSummary>

    returns paginated list of pools created in DeepBook by querying for the PoolCreated event. Warning: this method can return incomplete results if the upstream data source is pruned.

  • Parameters

    • coinId: string

    Returns Promise<null | string>

  • Parameters

    • poolId: string

      the pool id, eg: 0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4

    • lowerPrice: bigint

      lower price you want to query in the level2 book, eg: 18000000000. The number must be an integer float scaled by FLOAT_SCALING_FACTOR.

    • higherPrice: bigint

      higher price you want to query in the level2 book, eg: 20000000000. The number must be an integer float scaled by FLOAT_SCALING_FACTOR.

    • side: "bid" | "ask" | "both"

      { 'bid' | 'ask' | 'both' } bid or ask or both sides.

    Returns Promise<Level2BookStatusPoint[] | Level2BookStatusPoint[][]>

    get level2 book status

  • Parameters

    • poolId: string

      the pool id, eg: 0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4

    Returns Promise<MarketPrice>

    get the market price {bestBidPrice, bestAskPrice}

  • Parameters

    • poolId: string
    • orderId: string

      the order id, eg: "1"

    • accountCap: undefined | string = ...

    Returns Promise<undefined | Order>

    get the order status

  • Parameters

    • poolId: string

      object id of the pool

    Returns Promise<PoolSummary>

    Metadata for the Pool

    Fetch metadata for a pool

  • Parameters

    • poolId: string

    Returns Promise<string[]>

  • @description: get the base and quote token in custodian account

    Parameters

    • poolId: string

      the pool id, eg: 0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4

    • accountCap: undefined | string = undefined

      your accountCap, eg: 0x6f699fef193723277559c8f499ca3706121a65ac96d273151b8e52deb29135d3. If not provided, this.accountCap will be used.

    Returns Promise<UserPosition>

  • Parameters

    • poolId: string

      the pool id, eg: 0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4

    • accountCap: undefined | string = undefined

      your accountCap, eg: 0x6f699fef193723277559c8f499ca3706121a65ac96d273151b8e52deb29135d3. If not provided, this.accountCap will be used.

    Returns Promise<Order[]>

    get the open orders of the current user

  • @description: place a limit order

    Parameters

    • poolId: string

      Object id of pool, created after invoking createPool, eg: "0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4"

    • price: bigint
    • quantity: bigint
    • orderType: "bid" | "ask"
    • expirationTimestamp: number = ...
    • restriction: LimitOrderType = LimitOrderType.NO_RESTRICTION

      restrictions on limit orders, explain in doc for more details, eg: 0

    • clientOrderId: undefined | string = undefined

      a client side defined order number for bookkeeping purpose, e.g., "1", "2", etc. If omitted, the sdk will assign a increasing number starting from 0. But this number might be duplicated if you are using multiple sdk instances

    • selfMatchingPrevention: SelfMatchingPreventionStyle = SelfMatchingPreventionStyle.CANCEL_OLDEST

    Returns Promise<Transaction>

  • @description: place a market order

    Parameters

    • accountCap: string | {
          $kind: "NestedResult";
          NestedResult: [number, number];
      }
    • poolId: string

      Object id of pool, created after invoking createPool, eg: "0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4"

    • quantity: bigint

      Amount of quote asset to swap in base asset

    • orderType: "bid" | "ask"

      bid for buying base with quote, ask for selling base for quote

    • baseCoin: undefined | string | TransactionResult = undefined

      the objectId or the coin object of the base coin

    • quoteCoin: undefined | string | TransactionResult = undefined

      the objectId or the coin object of the quote coin

    • clientOrderId: undefined | string = undefined

      a client side defined order id for bookkeeping purpose. eg: "1" , "2", ... If omitted, the sdk will assign an increasing number starting from 0. But this number might be duplicated if you are using multiple sdk instances

    • recipientAddress: undefined | string = ...

      the address to receive the swapped asset. If omitted, this.currentAddress will be used. The function

    • tx: Transaction = ...

    Returns Promise<Transaction>

  • Parameters

    • cap: string

      set the account cap for interacting with DeepBook

    Returns Promise<void>

  • Parameters

    • poolId: string

      Object id of pool, created after invoking createPool, eg: "0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4"

    • tokenObjectIn: string

      Object id of the token to swap: eg: "0x6e566fec4c388eeb78a7dab832c9f0212eb2ac7e8699500e203def5b41b9c70d"

    • amountIn: bigint

      amount of token to buy or sell, eg: 10000000

    • currentAddress: string

      current user address, eg: "0xbddc9d4961b46a130c2e1f38585bbc6fa8077ce54bcb206b26874ac08d607966"

    • clientOrderId: undefined | string = undefined

      a client side defined order number for bookkeeping purpose. eg: "1" , "2", ...

    Returns Promise<Transaction>

    swap exact base for quote

  • @description: swap exact quote for base

    Parameters

    • poolId: string

      Object id of pool, created after invoking createPool, eg: "0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4"

    • tokenObjectIn: TransactionObjectInput

      Object id of the token to swap: eg: "0x6e566fec4c388eeb78a7dab832c9f0212eb2ac7e8699500e203def5b41b9c70d"

    • amountIn: bigint

      amount of token to buy or sell, eg: 10000000.

    • currentAddress: string

      current user address, eg: "0xbddc9d4961b46a130c2e1f38585bbc6fa8077ce54bcb206b26874ac08d607966"

    • OptionalclientOrderId: string

      a client side defined order id for bookkeeping purpose, eg: "1" , "2", ... If omitted, the sdk will assign an increasing number starting from 0. But this number might be duplicated if you are using multiple sdk instances

    • tx: Transaction = ...

    Returns Promise<Transaction>

  • Parameters

    • poolId: string

      the pool id for the withdraw

    • quantity: bigint
    • assetType: "base" | "quote"

      Base or Quote

    • recipientAddress: string = ...

      the address to receive the withdrawn asset. If omitted, this.currentAddress will be used. The function will throw if the recipientAddress === DUMMY_ADDRESS

    Returns Promise<Transaction>

    construct transaction for withdrawing asset from a pool.