@haneullabs/deepbook 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG.md +974 -0
  2. package/README.md +11 -0
  3. package/dist/cjs/client.d.ts +198 -0
  4. package/dist/cjs/client.js +630 -0
  5. package/dist/cjs/client.js.map +7 -0
  6. package/dist/cjs/index.d.ts +1 -0
  7. package/dist/cjs/index.js +19 -0
  8. package/dist/cjs/index.js.map +7 -0
  9. package/dist/cjs/package.json +4 -0
  10. package/dist/cjs/types/bcs.d.ts +11 -0
  11. package/dist/cjs/types/bcs.js +36 -0
  12. package/dist/cjs/types/bcs.js.map +7 -0
  13. package/dist/cjs/types/index.d.ts +51 -0
  14. package/dist/cjs/types/index.js +38 -0
  15. package/dist/cjs/types/index.js.map +7 -0
  16. package/dist/cjs/utils/constants.d.ts +7 -0
  17. package/dist/cjs/utils/constants.js +38 -0
  18. package/dist/cjs/utils/constants.js.map +7 -0
  19. package/dist/cjs/utils/index.d.ts +1 -0
  20. package/dist/cjs/utils/index.js +19 -0
  21. package/dist/cjs/utils/index.js.map +7 -0
  22. package/dist/esm/client.d.ts +198 -0
  23. package/dist/esm/client.js +623 -0
  24. package/dist/esm/client.js.map +7 -0
  25. package/dist/esm/index.d.ts +1 -0
  26. package/dist/esm/index.js +2 -0
  27. package/dist/esm/index.js.map +7 -0
  28. package/dist/esm/package.json +4 -0
  29. package/dist/esm/types/bcs.d.ts +11 -0
  30. package/dist/esm/types/bcs.js +16 -0
  31. package/dist/esm/types/bcs.js.map +7 -0
  32. package/dist/esm/types/index.d.ts +51 -0
  33. package/dist/esm/types/index.js +17 -0
  34. package/dist/esm/types/index.js.map +7 -0
  35. package/dist/esm/utils/constants.d.ts +7 -0
  36. package/dist/esm/utils/constants.js +18 -0
  37. package/dist/esm/utils/constants.js.map +7 -0
  38. package/dist/esm/utils/index.d.ts +1 -0
  39. package/dist/esm/utils/index.js +2 -0
  40. package/dist/esm/utils/index.js.map +7 -0
  41. package/dist/tsconfig.esm.tsbuildinfo +1 -0
  42. package/dist/tsconfig.tsbuildinfo +1 -0
  43. package/package.json +56 -0
  44. package/src/client.ts +786 -0
  45. package/src/index.ts +4 -0
  46. package/src/types/bcs.ts +16 -0
  47. package/src/types/index.ts +71 -0
  48. package/src/utils/constants.ts +18 -0
  49. package/src/utils/index.ts +4 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/client.ts"],
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '@haneullabs/haneul/bcs';\nimport type { OrderArguments, PaginatedEvents, PaginationArguments } from '@haneullabs/haneul/client';\nimport { getFullnodeUrl, HaneulClient } from '@haneullabs/haneul/client';\nimport type { Argument, TransactionObjectInput, TransactionResult } from '@haneullabs/haneul/transactions';\nimport { Transaction } from '@haneullabs/haneul/transactions';\nimport {\n\tnormalizeStructTag,\n\tnormalizeHaneulAddress,\n\tnormalizeHaneulObjectId,\n\tparseStructTag,\n\tHANEUL_CLOCK_OBJECT_ID,\n} from '@haneullabs/haneul/utils';\n\nimport { BcsOrder } from './types/bcs.js';\nimport type {\n\tLevel2BookStatusPoint,\n\tMarketPrice,\n\tOrder,\n\tPaginatedPoolSummary,\n\tPoolSummary,\n\tUserPosition,\n} from './types/index.js';\nimport { LimitOrderType, SelfMatchingPreventionStyle } from './types/index.js';\nimport {\n\tCREATION_FEE,\n\tMODULE_CLOB,\n\tMODULE_CUSTODIAN,\n\tNORMALIZED_HANEUL_COIN_TYPE,\n\tORDER_DEFAULT_EXPIRATION_IN_MS,\n\tPACKAGE_ID,\n} from './utils/index.js';\n\nconst DUMMY_ADDRESS = normalizeHaneulAddress('0x0');\n\nexport class DeepBookClient {\n\t#poolTypeArgsCache: Map<string, string[]> = new Map();\n\t/**\n\t *\n\t * @param haneulClient connection to fullnode\n\t * @param accountCap (optional) only required for wrting operations\n\t * @param currentAddress (optional) address of the current user (default: DUMMY_ADDRESS)\n\t */\n\tconstructor(\n\t\tpublic haneulClient: HaneulClient = new HaneulClient({ url: getFullnodeUrl('testnet') }),\n\t\tpublic accountCap: string | undefined = undefined,\n\t\tpublic currentAddress: string = DUMMY_ADDRESS,\n\t\tprivate clientOrderId: number = 0,\n\t) {}\n\n\t/**\n\t * @param cap set the account cap for interacting with DeepBook\n\t */\n\tasync setAccountCap(cap: string) {\n\t\tthis.accountCap = cap;\n\t}\n\n\t/**\n\t * @description Create pool for trading pair\n\t * @param baseAssetType Full coin type of the base asset, eg: \"0x3d0d0ce17dcd3b40c2d839d96ce66871ffb40e1154a8dd99af72292b3d10d7fc::wbtc::WBTC\"\n\t * @param quoteAssetType Full coin type of quote asset, eg: \"0x3d0d0ce17dcd3b40c2d839d96ce66871ffb40e1154a8dd99af72292b3d10d7fc::usdt::USDT\"\n\t * @param tickSize Minimal Price Change Accuracy of this pool, eg: 10000000. The number must be an integer float scaled by `FLOAT_SCALING_FACTOR`.\n\t * @param lotSize Minimal Lot Change Accuracy of this pool, eg: 10000.\n\t */\n\tcreatePool(\n\t\tbaseAssetType: string,\n\t\tquoteAssetType: string,\n\t\ttickSize: bigint,\n\t\tlotSize: bigint,\n\t): Transaction {\n\t\tconst tx = new Transaction();\n\t\t// create a pool with CREATION_FEE\n\t\tconst [coin] = tx.splitCoins(tx.gas, [CREATION_FEE]);\n\t\ttx.moveCall({\n\t\t\ttypeArguments: [baseAssetType, quoteAssetType],\n\t\t\ttarget: `${PACKAGE_ID}::${MODULE_CLOB}::create_pool`,\n\t\t\targuments: [tx.pure.u64(tickSize), tx.pure.u64(lotSize), coin],\n\t\t});\n\t\treturn tx;\n\t}\n\n\t/**\n\t * @description Create pool for trading pair\n\t * @param baseAssetType Full coin type of the base asset, eg: \"0x3d0d0ce17dcd3b40c2d839d96ce66871ffb40e1154a8dd99af72292b3d10d7fc::wbtc::WBTC\"\n\t * @param quoteAssetType Full coin type of quote asset, eg: \"0x3d0d0ce17dcd3b40c2d839d96ce66871ffb40e1154a8dd99af72292b3d10d7fc::usdt::USDT\"\n\t * @param tickSize Minimal Price Change Accuracy of this pool, eg: 10000000. The number must be an interger float scaled by `FLOAT_SCALING_FACTOR`.\n\t * @param lotSize Minimal Lot Change Accuracy of this pool, eg: 10000.\n\t * @param takerFeeRate Customized taker fee rate, float scaled by `FLOAT_SCALING_FACTOR`, Taker_fee_rate of 0.25% should be 2_500_000 for example\n\t * @param makerRebateRate Customized maker rebate rate, float scaled by `FLOAT_SCALING_FACTOR`, should be less than or equal to the taker_rebate_rate\n\t */\n\tcreateCustomizedPool(\n\t\tbaseAssetType: string,\n\t\tquoteAssetType: string,\n\t\ttickSize: bigint,\n\t\tlotSize: bigint,\n\t\ttakerFeeRate: bigint,\n\t\tmakerRebateRate: bigint,\n\t): Transaction {\n\t\tconst tx = new Transaction();\n\t\t// create a pool with CREATION_FEE\n\t\tconst [coin] = tx.splitCoins(tx.gas, [CREATION_FEE]);\n\t\ttx.moveCall({\n\t\t\ttypeArguments: [baseAssetType, quoteAssetType],\n\t\t\ttarget: `${PACKAGE_ID}::${MODULE_CLOB}::create_customized_pool`,\n\t\t\targuments: [\n\t\t\t\ttx.pure.u64(tickSize),\n\t\t\t\ttx.pure.u64(lotSize),\n\t\t\t\ttx.pure.u64(takerFeeRate),\n\t\t\t\ttx.pure.u64(makerRebateRate),\n\t\t\t\tcoin,\n\t\t\t],\n\t\t});\n\t\treturn tx;\n\t}\n\n\t/**\n\t * @description Create Account Cap\n\t * @param tx\n\t */\n\tcreateAccountCap(tx: Transaction) {\n\t\tconst [cap] = tx.moveCall({\n\t\t\ttypeArguments: [],\n\t\t\ttarget: `${PACKAGE_ID}::${MODULE_CLOB}::create_account`,\n\t\t\targuments: [],\n\t\t});\n\t\treturn cap;\n\t}\n\n\t/**\n\t * @description Create and Transfer custodian account to user\n\t * @param currentAddress current address of the user\n\t * @param tx\n\t */\n\tcreateAccount(\n\t\tcurrentAddress: string = this.currentAddress,\n\t\ttx: Transaction = new Transaction(),\n\t): Transaction {\n\t\tconst cap = this.createAccountCap(tx);\n\t\ttx.transferObjects([cap], this.#checkAddress(currentAddress));\n\t\treturn tx;\n\t}\n\n\t/**\n\t * @description Create and Transfer custodian account to user\n\t * @param currentAddress: current user address, eg: \"0xbddc9d4961b46a130c2e1f38585bbc6fa8077ce54bcb206b26874ac08d607966\"\n\t * @param accountCap: Object id of Account Capacity under user address, created after invoking createAccount, eg: \"0x6f699fef193723277559c8f499ca3706121a65ac96d273151b8e52deb29135d3\"\n\t */\n\tcreateChildAccountCap(\n\t\tcurrentAddress: string = this.currentAddress,\n\t\taccountCap: string | undefined = this.accountCap,\n\t): Transaction {\n\t\tconst tx = new Transaction();\n\t\tconst [childCap] = tx.moveCall({\n\t\t\ttypeArguments: [],\n\t\t\ttarget: `${PACKAGE_ID}::${MODULE_CUSTODIAN}::create_child_account_cap`,\n\t\t\targuments: [tx.object(this.#checkAccountCap(accountCap))],\n\t\t});\n\t\ttx.transferObjects([childCap], this.#checkAddress(currentAddress));\n\t\treturn tx;\n\t}\n\n\t/**\n\t * @description construct transaction for depositing asset into a pool.\n\t * @param poolId the pool id for the deposit\n\t * @param coinId the coin used for the deposit. You can omit this argument if you are depositing SUI, in which case\n\t * gas coin will be used\n\t * @param amount the amount of coin to deposit. If omitted, the entire balance of the coin will be deposited\n\t */\n\tasync deposit(\n\t\tpoolId: string,\n\t\tcoinId: string | undefined = undefined,\n\t\tquantity: bigint | undefined = undefined,\n\t): Promise<Transaction> {\n\t\tconst tx = new Transaction();\n\n\t\tconst [baseAsset, quoteAsset] = await this.getPoolTypeArgs(poolId);\n\t\tconst hasSui =\n\t\t\tbaseAsset === NORMALIZED_HANEUL_COIN_TYPE || quoteAsset === NORMALIZED_HANEUL_COIN_TYPE;\n\n\t\tif (coinId === undefined && !hasSui) {\n\t\t\tthrow new Error('coinId must be specified if neither baseAsset nor quoteAsset is SUI');\n\t\t}\n\n\t\tconst inputCoin = coinId ? tx.object(coinId) : tx.gas;\n\n\t\tconst [coin] = quantity ? tx.splitCoins(inputCoin, [quantity]) : [inputCoin];\n\n\t\tconst coinType = coinId ? await this.getCoinType(coinId) : NORMALIZED_HANEUL_COIN_TYPE;\n\t\tif (coinType !== baseAsset && coinType !== quoteAsset) {\n\t\t\tthrow new Error(\n\t\t\t\t`coin ${coinId} of ${coinType} type is not a valid asset for pool ${poolId}, which supports ${baseAsset} and ${quoteAsset}`,\n\t\t\t);\n\t\t}\n\t\tconst functionName = coinType === baseAsset ? 'deposit_base' : 'deposit_quote';\n\n\t\ttx.moveCall({\n\t\t\ttypeArguments: [baseAsset, quoteAsset],\n\t\t\ttarget: `${PACKAGE_ID}::${MODULE_CLOB}::${functionName}`,\n\t\t\targuments: [tx.object(poolId), coin, tx.object(this.#checkAccountCap())],\n\t\t});\n\t\treturn tx;\n\t}\n\n\t/**\n\t * @description construct transaction for withdrawing asset from a pool.\n\t * @param poolId the pool id for the withdraw\n\t * @param amount the amount of coin to withdraw\n\t * @param assetType Base or Quote\n\t * @param recipientAddress the address to receive the withdrawn asset. If omitted, `this.currentAddress` will be used. The function\n\t * will throw if the `recipientAddress === DUMMY_ADDRESS`\n\t */\n\tasync withdraw(\n\t\tpoolId: string,\n\t\t// TODO: implement withdraw all\n\t\tquantity: bigint,\n\t\tassetType: 'base' | 'quote',\n\t\trecipientAddress: string = this.currentAddress,\n\t): Promise<Transaction> {\n\t\tconst tx = new Transaction();\n\t\tconst functionName = assetType === 'base' ? 'withdraw_base' : 'withdraw_quote';\n\t\tconst [withdraw] = tx.moveCall({\n\t\t\ttypeArguments: await this.getPoolTypeArgs(poolId),\n\t\t\ttarget: `${PACKAGE_ID}::${MODULE_CLOB}::${functionName}`,\n\t\t\targuments: [tx.object(poolId), tx.pure.u64(quantity), tx.object(this.#checkAccountCap())],\n\t\t});\n\t\ttx.transferObjects([withdraw], this.#checkAddress(recipientAddress));\n\t\treturn tx;\n\t}\n\n\t/**\n\t * @description place a limit order\n\t * @param poolId Object id of pool, created after invoking createPool, eg: \"0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4\"\n\t * @param price: price of the limit order. The number must be an interger float scaled by `FLOAT_SCALING_FACTOR`.\n\t * @param quantity: quantity of the limit order in BASE ASSET, eg: 100000000.\n\t * @param orderType: bid for buying base with quote, ask for selling base for quote\n\t * @param expirationTimestamp: expiration timestamp of the limit order in ms, eg: 1620000000000. If omitted, the order will expire in 1 day\n\t * from the time this function is called(not the time the transaction is executed)\n\t * @param restriction restrictions on limit orders, explain in doc for more details, eg: 0\n\t * @param clientOrderId a client side defined order number for bookkeeping purpose, e.g., \"1\", \"2\", etc. If omitted, the sdk will\n\t * assign a increasing number starting from 0. But this number might be duplicated if you are using multiple sdk instances\n\t * @param selfMatchingPrevention: Options for self-match prevention. Right now only support `CANCEL_OLDEST`\n\t */\n\tasync placeLimitOrder(\n\t\tpoolId: string,\n\t\tprice: bigint,\n\t\tquantity: bigint,\n\t\torderType: 'bid' | 'ask',\n\t\texpirationTimestamp: number = Date.now() + ORDER_DEFAULT_EXPIRATION_IN_MS,\n\t\trestriction: LimitOrderType = LimitOrderType.NO_RESTRICTION,\n\t\tclientOrderId: string | undefined = undefined,\n\t\tselfMatchingPrevention: SelfMatchingPreventionStyle = SelfMatchingPreventionStyle.CANCEL_OLDEST,\n\t): Promise<Transaction> {\n\t\tconst tx = new Transaction();\n\t\tconst args = [\n\t\t\ttx.object(poolId),\n\t\t\ttx.pure.u64(clientOrderId ?? this.#nextClientOrderId()),\n\t\t\ttx.pure.u64(price),\n\t\t\ttx.pure.u64(quantity),\n\t\t\ttx.pure.u8(selfMatchingPrevention),\n\t\t\ttx.pure.bool(orderType === 'bid'),\n\t\t\ttx.pure.u64(expirationTimestamp),\n\t\t\ttx.pure.u8(restriction),\n\t\t\ttx.object(HANEUL_CLOCK_OBJECT_ID),\n\t\t\ttx.object(this.#checkAccountCap()),\n\t\t];\n\t\ttx.moveCall({\n\t\t\ttypeArguments: await this.getPoolTypeArgs(poolId),\n\t\t\ttarget: `${PACKAGE_ID}::${MODULE_CLOB}::place_limit_order`,\n\t\t\targuments: args,\n\t\t});\n\t\treturn tx;\n\t}\n\n\t/**\n\t * @description place a market order\n\t * @param poolId Object id of pool, created after invoking createPool, eg: \"0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4\"\n\t * @param quantity Amount of quote asset to swap in base asset\n\t * @param orderType bid for buying base with quote, ask for selling base for quote\n\t * @param baseCoin the objectId or the coin object of the base coin\n\t * @param quoteCoin the objectId or the coin object of the quote coin\n\t * @param clientOrderId a client side defined order id for bookkeeping purpose. eg: \"1\" , \"2\", ... If omitted, the sdk will\n\t * assign an increasing number starting from 0. But this number might be duplicated if you are using multiple sdk instances\n\t * @param accountCap\n\t * @param recipientAddress the address to receive the swapped asset. If omitted, `this.currentAddress` will be used. The function\n\t * @param tx\n\t */\n\tasync placeMarketOrder(\n\t\taccountCap: string | Extract<Argument, { $kind: 'NestedResult' }>,\n\t\tpoolId: string,\n\t\tquantity: bigint,\n\t\torderType: 'bid' | 'ask',\n\t\tbaseCoin: TransactionResult | string | undefined = undefined,\n\t\tquoteCoin: TransactionResult | string | undefined = undefined,\n\t\tclientOrderId: string | undefined = undefined,\n\t\trecipientAddress: string | undefined = this.currentAddress,\n\t\ttx: Transaction = new Transaction(),\n\t): Promise<Transaction> {\n\t\tconst [baseAssetType, quoteAssetType] = await this.getPoolTypeArgs(poolId);\n\t\tif (!baseCoin && orderType === 'ask') {\n\t\t\tthrow new Error('Must specify a valid base coin for an ask order');\n\t\t} else if (!quoteCoin && orderType === 'bid') {\n\t\t\tthrow new Error('Must specify a valid quote coin for a bid order');\n\t\t}\n\t\tconst emptyCoin = tx.moveCall({\n\t\t\ttypeArguments: [baseCoin ? quoteAssetType : baseAssetType],\n\t\t\ttarget: `0x2::coin::zero`,\n\t\t\targuments: [],\n\t\t});\n\n\t\tconst [base_coin_ret, quote_coin_ret] = tx.moveCall({\n\t\t\ttypeArguments: [baseAssetType, quoteAssetType],\n\t\t\ttarget: `${PACKAGE_ID}::${MODULE_CLOB}::place_market_order`,\n\t\t\targuments: [\n\t\t\t\ttx.object(poolId),\n\t\t\t\ttypeof accountCap === 'string' ? tx.object(this.#checkAccountCap(accountCap)) : accountCap,\n\t\t\t\ttx.pure.u64(clientOrderId ?? this.#nextClientOrderId()),\n\t\t\t\ttx.pure.u64(quantity),\n\t\t\t\ttx.pure.bool(orderType === 'bid'),\n\t\t\t\tbaseCoin ? tx.object(baseCoin) : emptyCoin,\n\t\t\t\tquoteCoin ? tx.object(quoteCoin) : emptyCoin,\n\t\t\t\ttx.object(HANEUL_CLOCK_OBJECT_ID),\n\t\t\t],\n\t\t});\n\t\tconst recipient = this.#checkAddress(recipientAddress);\n\t\ttx.transferObjects([base_coin_ret], recipient);\n\t\ttx.transferObjects([quote_coin_ret], recipient);\n\n\t\treturn tx;\n\t}\n\n\t/**\n\t * @description swap exact quote for base\n\t * @param poolId Object id of pool, created after invoking createPool, eg: \"0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4\"\n\t * @param tokenObjectIn Object id of the token to swap: eg: \"0x6e566fec4c388eeb78a7dab832c9f0212eb2ac7e8699500e203def5b41b9c70d\"\n\t * @param amountIn amount of token to buy or sell, eg: 10000000.\n\t * @param currentAddress current user address, eg: \"0xbddc9d4961b46a130c2e1f38585bbc6fa8077ce54bcb206b26874ac08d607966\"\n\t * @param clientOrderId a client side defined order id for bookkeeping purpose, eg: \"1\" , \"2\", ... If omitted, the sdk will\n\t * assign an increasing number starting from 0. But this number might be duplicated if you are using multiple sdk instances\n\t * @param tx\n\t */\n\tasync swapExactQuoteForBase(\n\t\tpoolId: string,\n\t\ttokenObjectIn: TransactionObjectInput,\n\t\tamountIn: bigint, // quantity of USDC\n\t\tcurrentAddress: string,\n\t\tclientOrderId?: string,\n\t\ttx: Transaction = new Transaction(),\n\t): Promise<Transaction> {\n\t\t// in this case, we assume that the tokenIn--tokenOut always exists.\n\t\tconst [base_coin_ret, quote_coin_ret, _amount] = tx.moveCall({\n\t\t\ttypeArguments: await this.getPoolTypeArgs(poolId),\n\t\t\ttarget: `${PACKAGE_ID}::${MODULE_CLOB}::swap_exact_quote_for_base`,\n\t\t\targuments: [\n\t\t\t\ttx.object(poolId),\n\t\t\t\ttx.pure.u64(clientOrderId ?? this.#nextClientOrderId()),\n\t\t\t\ttx.object(this.#checkAccountCap()),\n\t\t\t\ttx.pure.u64(String(amountIn)),\n\t\t\t\ttx.object(HANEUL_CLOCK_OBJECT_ID),\n\t\t\t\ttx.object(tokenObjectIn),\n\t\t\t],\n\t\t});\n\t\ttx.transferObjects([base_coin_ret], currentAddress);\n\t\ttx.transferObjects([quote_coin_ret], currentAddress);\n\t\treturn tx;\n\t}\n\n\t/**\n\t * @description swap exact base for quote\n\t * @param poolId Object id of pool, created after invoking createPool, eg: \"0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4\"\n\t * @param tokenObjectIn Object id of the token to swap: eg: \"0x6e566fec4c388eeb78a7dab832c9f0212eb2ac7e8699500e203def5b41b9c70d\"\n\t * @param amountIn amount of token to buy or sell, eg: 10000000\n\t * @param currentAddress current user address, eg: \"0xbddc9d4961b46a130c2e1f38585bbc6fa8077ce54bcb206b26874ac08d607966\"\n\t * @param clientOrderId a client side defined order number for bookkeeping purpose. eg: \"1\" , \"2\", ...\n\t */\n\tasync swapExactBaseForQuote(\n\t\tpoolId: string,\n\t\ttokenObjectIn: string,\n\t\tamountIn: bigint,\n\t\tcurrentAddress: string,\n\t\tclientOrderId: string | undefined = undefined,\n\t): Promise<Transaction> {\n\t\tconst tx = new Transaction();\n\t\tconst [baseAsset, quoteAsset] = await this.getPoolTypeArgs(poolId);\n\t\t// in this case, we assume that the tokenIn--tokenOut always exists.\n\t\tconst [base_coin_ret, quote_coin_ret, _amount] = tx.moveCall({\n\t\t\ttypeArguments: [baseAsset, quoteAsset],\n\t\t\ttarget: `${PACKAGE_ID}::${MODULE_CLOB}::swap_exact_base_for_quote`,\n\t\t\targuments: [\n\t\t\t\ttx.object(poolId),\n\t\t\t\ttx.pure.u64(clientOrderId ?? this.#nextClientOrderId()),\n\t\t\t\ttx.object(this.#checkAccountCap()),\n\t\t\t\ttx.object(String(amountIn)),\n\t\t\t\ttx.object(tokenObjectIn),\n\t\t\t\ttx.moveCall({\n\t\t\t\t\ttypeArguments: [quoteAsset],\n\t\t\t\t\ttarget: `0x2::coin::zero`,\n\t\t\t\t\targuments: [],\n\t\t\t\t}),\n\t\t\t\ttx.object(HANEUL_CLOCK_OBJECT_ID),\n\t\t\t],\n\t\t});\n\t\ttx.transferObjects([base_coin_ret], currentAddress);\n\t\ttx.transferObjects([quote_coin_ret], currentAddress);\n\t\treturn tx;\n\t}\n\n\t/**\n\t * @description cancel an order\n\t * @param poolId Object id of pool, created after invoking createPool, eg: \"0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4\"\n\t * @param orderId orderId of a limit order, you can find them through function query.list_open_orders eg: \"0\"\n\t */\n\tasync cancelOrder(poolId: string, orderId: string): Promise<Transaction> {\n\t\tconst tx = new Transaction();\n\t\ttx.moveCall({\n\t\t\ttypeArguments: await this.getPoolTypeArgs(poolId),\n\t\t\ttarget: `${PACKAGE_ID}::${MODULE_CLOB}::cancel_order`,\n\t\t\targuments: [tx.object(poolId), tx.pure.u64(orderId), tx.object(this.#checkAccountCap())],\n\t\t});\n\t\treturn tx;\n\t}\n\n\t/**\n\t * @description Cancel all limit orders under a certain account capacity\n\t * @param poolId Object id of pool, created after invoking createPool, eg: \"0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4\"\n\t */\n\tasync cancelAllOrders(poolId: string): Promise<Transaction> {\n\t\tconst tx = new Transaction();\n\t\ttx.moveCall({\n\t\t\ttypeArguments: await this.getPoolTypeArgs(poolId),\n\t\t\ttarget: `${PACKAGE_ID}::${MODULE_CLOB}::cancel_all_orders`,\n\t\t\targuments: [tx.object(poolId), tx.object(this.#checkAccountCap())],\n\t\t});\n\t\treturn tx;\n\t}\n\n\t/**\n\t * @description batch cancel order\n\t * @param poolId Object id of pool, created after invoking createPool, eg: \"0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4\"\n\t * @param orderIds array of order ids you want to cancel, you can find your open orders by query.list_open_orders eg: [\"0\", \"1\", \"2\"]\n\t */\n\tasync batchCancelOrder(poolId: string, orderIds: string[]): Promise<Transaction> {\n\t\tconst tx = new Transaction();\n\t\ttx.moveCall({\n\t\t\ttypeArguments: await this.getPoolTypeArgs(poolId),\n\t\t\ttarget: `${PACKAGE_ID}::${MODULE_CLOB}::batch_cancel_order`,\n\t\t\targuments: [\n\t\t\t\ttx.object(poolId),\n\t\t\t\tbcs.vector(bcs.U64).serialize(orderIds),\n\t\t\t\ttx.object(this.#checkAccountCap()),\n\t\t\t],\n\t\t});\n\t\treturn tx;\n\t}\n\n\t/**\n\t * @param poolId Object id of pool, created after invoking createPool, eg: \"0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4\"\n\t * @param orderIds array of expired order ids to clean, eg: [\"0\", \"1\", \"2\"]\n\t * @param orderOwners array of Order owners, should be the owner addresses from the account capacities which placed the orders\n\t */\n\tasync cleanUpExpiredOrders(\n\t\tpoolId: string,\n\t\torderIds: string[],\n\t\torderOwners: string[],\n\t): Promise<Transaction> {\n\t\tconst tx = new Transaction();\n\t\ttx.moveCall({\n\t\t\ttypeArguments: await this.getPoolTypeArgs(poolId),\n\t\t\ttarget: `${PACKAGE_ID}::${MODULE_CLOB}::clean_up_expired_orders`,\n\t\t\targuments: [\n\t\t\t\ttx.object(poolId),\n\t\t\t\ttx.object(HANEUL_CLOCK_OBJECT_ID),\n\t\t\t\tbcs.vector(bcs.U64).serialize(orderIds),\n\t\t\t\tbcs.vector(bcs.Address).serialize(orderOwners),\n\t\t\t],\n\t\t});\n\t\treturn tx;\n\t}\n\n\t/**\n\t * @description returns paginated list of pools created in DeepBook by querying for the\n\t * `PoolCreated` event. Warning: this method can return incomplete results if the upstream data source\n\t * is pruned.\n\t */\n\tasync getAllPools(\n\t\tinput: PaginationArguments<PaginatedEvents['nextCursor']> & OrderArguments,\n\t): Promise<PaginatedPoolSummary> {\n\t\tconst resp = await this.haneulClient.queryEvents({\n\t\t\tquery: { MoveEventType: `${PACKAGE_ID}::${MODULE_CLOB}::PoolCreated` },\n\t\t\t...input,\n\t\t});\n\t\tconst pools = resp.data.map((event) => {\n\t\t\tconst rawEvent = event.parsedJson as any;\n\t\t\treturn {\n\t\t\t\tpoolId: rawEvent.pool_id as string,\n\t\t\t\tbaseAsset: normalizeStructTag(rawEvent.base_asset.name),\n\t\t\t\tquoteAsset: normalizeStructTag(rawEvent.quote_asset.name),\n\t\t\t};\n\t\t});\n\t\treturn {\n\t\t\tdata: pools,\n\t\t\tnextCursor: resp.nextCursor,\n\t\t\thasNextPage: resp.hasNextPage,\n\t\t};\n\t}\n\n\t/**\n\t * @description Fetch metadata for a pool\n\t * @param poolId object id of the pool\n\t * @returns Metadata for the Pool\n\t */\n\tasync getPoolInfo(poolId: string): Promise<PoolSummary> {\n\t\tconst resp = await this.haneulClient.getObject({\n\t\t\tid: poolId,\n\t\t\toptions: { showContent: true },\n\t\t});\n\t\tif (resp?.data?.content?.dataType !== 'moveObject') {\n\t\t\tthrow new Error(`pool ${poolId} does not exist`);\n\t\t}\n\n\t\tconst [baseAsset, quoteAsset] = parseStructTag(resp!.data!.content!.type).typeParams.map((t) =>\n\t\t\tnormalizeStructTag(t),\n\t\t);\n\n\t\treturn {\n\t\t\tpoolId,\n\t\t\tbaseAsset,\n\t\t\tquoteAsset,\n\t\t};\n\t}\n\n\tasync getPoolTypeArgs(poolId: string): Promise<string[]> {\n\t\tif (!this.#poolTypeArgsCache.has(poolId)) {\n\t\t\tconst { baseAsset, quoteAsset } = await this.getPoolInfo(poolId);\n\t\t\tconst typeArgs = [baseAsset, quoteAsset];\n\t\t\tthis.#poolTypeArgsCache.set(poolId, typeArgs);\n\t\t}\n\n\t\treturn this.#poolTypeArgsCache.get(poolId)!;\n\t}\n\n\t/**\n\t * @description get the order status\n\t * @param poolId: the pool id, eg: 0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4\n\t * @param orderId the order id, eg: \"1\"\n\t */\n\tasync getOrderStatus(\n\t\tpoolId: string,\n\t\torderId: string,\n\t\taccountCap: string | undefined = this.accountCap,\n\t): Promise<Order | undefined> {\n\t\tconst tx = new Transaction();\n\t\tconst cap = this.#checkAccountCap(accountCap);\n\t\ttx.moveCall({\n\t\t\ttypeArguments: await this.getPoolTypeArgs(poolId),\n\t\t\ttarget: `${PACKAGE_ID}::${MODULE_CLOB}::get_order_status`,\n\t\t\targuments: [tx.object(poolId), tx.pure.u64(orderId), tx.object(cap)],\n\t\t});\n\t\tconst results = (\n\t\t\tawait this.haneulClient.devInspectTransactionBlock({\n\t\t\t\ttransactionBlock: tx,\n\t\t\t\tsender: this.currentAddress,\n\t\t\t})\n\t\t).results;\n\n\t\tif (!results) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn BcsOrder.parse(Uint8Array.from(results![0].returnValues![0][0]));\n\t}\n\n\t/**\n\t * @description get the base and quote token in custodian account\n\t * @param poolId the pool id, eg: 0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4\n\t * @param accountCap your accountCap, eg: 0x6f699fef193723277559c8f499ca3706121a65ac96d273151b8e52deb29135d3. If not provided, `this.accountCap` will be used.\n\t */\n\tasync getUserPosition(\n\t\tpoolId: string,\n\t\taccountCap: string | undefined = undefined,\n\t): Promise<UserPosition> {\n\t\tconst tx = new Transaction();\n\t\tconst cap = this.#checkAccountCap(accountCap);\n\n\t\ttx.moveCall({\n\t\t\ttypeArguments: await this.getPoolTypeArgs(poolId),\n\t\t\ttarget: `${PACKAGE_ID}::${MODULE_CLOB}::account_balance`,\n\t\t\targuments: [tx.object(normalizeHaneulObjectId(poolId)), tx.object(cap)],\n\t\t});\n\t\tconst [availableBaseAmount, lockedBaseAmount, availableQuoteAmount, lockedQuoteAmount] = (\n\t\t\tawait this.haneulClient.devInspectTransactionBlock({\n\t\t\t\ttransactionBlock: tx,\n\t\t\t\tsender: this.currentAddress,\n\t\t\t})\n\t\t).results![0].returnValues!.map(([bytes, _]) => BigInt(bcs.U64.parse(Uint8Array.from(bytes))));\n\t\treturn {\n\t\t\tavailableBaseAmount,\n\t\t\tlockedBaseAmount,\n\t\t\tavailableQuoteAmount,\n\t\t\tlockedQuoteAmount,\n\t\t};\n\t}\n\n\t/**\n\t * @description get the open orders of the current user\n\t * @param poolId the pool id, eg: 0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4\n\t * @param accountCap your accountCap, eg: 0x6f699fef193723277559c8f499ca3706121a65ac96d273151b8e52deb29135d3. If not provided, `this.accountCap` will be used.\n\t */\n\tasync listOpenOrders(\n\t\tpoolId: string,\n\t\taccountCap: string | undefined = undefined,\n\t): Promise<Order[]> {\n\t\tconst tx = new Transaction();\n\t\tconst cap = this.#checkAccountCap(accountCap);\n\n\t\ttx.moveCall({\n\t\t\ttypeArguments: await this.getPoolTypeArgs(poolId),\n\t\t\ttarget: `${PACKAGE_ID}::${MODULE_CLOB}::list_open_orders`,\n\t\t\targuments: [tx.object(poolId), tx.object(cap)],\n\t\t});\n\n\t\tconst results = (\n\t\t\tawait this.haneulClient.devInspectTransactionBlock({\n\t\t\t\ttransactionBlock: tx,\n\t\t\t\tsender: this.currentAddress,\n\t\t\t})\n\t\t).results;\n\n\t\tif (!results) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn bcs.vector(BcsOrder).parse(Uint8Array.from(results![0].returnValues![0][0]));\n\t}\n\n\t/**\n\t * @description get the market price {bestBidPrice, bestAskPrice}\n\t * @param poolId the pool id, eg: 0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4\n\t */\n\tasync getMarketPrice(poolId: string): Promise<MarketPrice> {\n\t\tconst tx = new Transaction();\n\t\ttx.moveCall({\n\t\t\ttypeArguments: await this.getPoolTypeArgs(poolId),\n\t\t\ttarget: `${PACKAGE_ID}::${MODULE_CLOB}::get_market_price`,\n\t\t\targuments: [tx.object(poolId)],\n\t\t});\n\t\tconst resp = (\n\t\t\tawait this.haneulClient.devInspectTransactionBlock({\n\t\t\t\ttransactionBlock: tx,\n\t\t\t\tsender: this.currentAddress,\n\t\t\t})\n\t\t).results![0].returnValues!.map(([bytes, _]) => {\n\t\t\tconst opt = bcs.option(bcs.U64).parse(Uint8Array.from(bytes));\n\t\t\treturn opt == null ? undefined : BigInt(opt);\n\t\t});\n\n\t\treturn { bestBidPrice: resp[0], bestAskPrice: resp[1] };\n\t}\n\n\t/**\n\t * @description get level2 book status\n\t * @param poolId the pool id, eg: 0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4\n\t * @param lowerPrice lower price you want to query in the level2 book, eg: 18000000000. The number must be an integer float scaled by `FLOAT_SCALING_FACTOR`.\n\t * @param higherPrice higher price you want to query in the level2 book, eg: 20000000000. The number must be an integer float scaled by `FLOAT_SCALING_FACTOR`.\n\t * @param side { 'bid' | 'ask' | 'both' } bid or ask or both sides.\n\t */\n\tasync getLevel2BookStatus(\n\t\tpoolId: string,\n\t\tlowerPrice: bigint,\n\t\thigherPrice: bigint,\n\t\tside: 'bid' | 'ask' | 'both',\n\t): Promise<Level2BookStatusPoint[] | Level2BookStatusPoint[][]> {\n\t\tconst tx = new Transaction();\n\t\tif (side === 'both') {\n\t\t\ttx.moveCall({\n\t\t\t\ttypeArguments: await this.getPoolTypeArgs(poolId),\n\t\t\t\ttarget: `${PACKAGE_ID}::${MODULE_CLOB}::get_level2_book_status_bid_side`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(poolId),\n\t\t\t\t\ttx.pure.u64(lowerPrice),\n\t\t\t\t\ttx.pure.u64(higherPrice),\n\t\t\t\t\ttx.object(HANEUL_CLOCK_OBJECT_ID),\n\t\t\t\t],\n\t\t\t});\n\t\t\ttx.moveCall({\n\t\t\t\ttypeArguments: await this.getPoolTypeArgs(poolId),\n\t\t\t\ttarget: `${PACKAGE_ID}::${MODULE_CLOB}::get_level2_book_status_ask_side`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(poolId),\n\t\t\t\t\ttx.pure.u64(lowerPrice),\n\t\t\t\t\ttx.pure.u64(higherPrice),\n\t\t\t\t\ttx.object(HANEUL_CLOCK_OBJECT_ID),\n\t\t\t\t],\n\t\t\t});\n\t\t} else {\n\t\t\ttx.moveCall({\n\t\t\t\ttypeArguments: await this.getPoolTypeArgs(poolId),\n\t\t\t\ttarget: `${PACKAGE_ID}::${MODULE_CLOB}::get_level2_book_status_${side}_side`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(poolId),\n\t\t\t\t\ttx.pure.u64(lowerPrice),\n\t\t\t\t\ttx.pure.u64(higherPrice),\n\t\t\t\t\ttx.object(HANEUL_CLOCK_OBJECT_ID),\n\t\t\t\t],\n\t\t\t});\n\t\t}\n\n\t\tconst results = await this.haneulClient.devInspectTransactionBlock({\n\t\t\ttransactionBlock: tx,\n\t\t\tsender: this.currentAddress,\n\t\t});\n\n\t\tif (side === 'both') {\n\t\t\tconst bidSide = results.results![0].returnValues!.map(([bytes, _]) =>\n\t\t\t\tbcs\n\t\t\t\t\t.vector(bcs.U64)\n\t\t\t\t\t.parse(Uint8Array.from(bytes))\n\t\t\t\t\t.map((s: string) => BigInt(s)),\n\t\t\t);\n\t\t\tconst askSide = results.results![1].returnValues!.map(([bytes, _]) =>\n\t\t\t\tbcs\n\t\t\t\t\t.vector(bcs.U64)\n\t\t\t\t\t.parse(Uint8Array.from(bytes))\n\t\t\t\t\t.map((s: string) => BigInt(s)),\n\t\t\t);\n\t\t\treturn [\n\t\t\t\tbidSide[0].map((price: bigint, i: number) => ({ price, depth: bidSide[1][i] })),\n\t\t\t\taskSide[0].map((price: bigint, i: number) => ({ price, depth: askSide[1][i] })),\n\t\t\t];\n\t\t} else {\n\t\t\tconst result = results.results![0].returnValues!.map(([bytes, _]) =>\n\t\t\t\tbcs\n\t\t\t\t\t.vector(bcs.U64)\n\t\t\t\t\t.parse(Uint8Array.from(bytes))\n\t\t\t\t\t.map((s) => BigInt(s)),\n\t\t\t);\n\t\t\treturn result[0].map((price: bigint, i: number) => ({ price, depth: result[1][i] }));\n\t\t}\n\t}\n\n\t#checkAccountCap(accountCap: string | undefined = undefined): string {\n\t\tconst cap = accountCap ?? this.accountCap;\n\t\tif (cap === undefined) {\n\t\t\tthrow new Error('accountCap is undefined, please call setAccountCap() first');\n\t\t}\n\t\treturn normalizeHaneulObjectId(cap);\n\t}\n\n\t#checkAddress(recipientAddress: string): string {\n\t\tif (recipientAddress === DUMMY_ADDRESS) {\n\t\t\tthrow new Error('Current address cannot be DUMMY_ADDRESS');\n\t\t}\n\t\treturn normalizeHaneulAddress(recipientAddress);\n\t}\n\n\tpublic async getCoinType(coinId: string) {\n\t\tconst resp = await this.haneulClient.getObject({\n\t\t\tid: coinId,\n\t\t\toptions: { showType: true },\n\t\t});\n\n\t\tconst parsed = resp.data?.type != null ? parseStructTag(resp.data.type) : null;\n\n\t\t// Modification handle case like 0x2::coin::Coin<0xf398b9ecb31aed96c345538fb59ca5a1a2c247c5e60087411ead6c637129f1c4::fish::FISH>\n\t\tif (\n\t\t\tparsed?.address === NORMALIZED_HANEUL_COIN_TYPE.split('::')[0] &&\n\t\t\tparsed.module === 'coin' &&\n\t\t\tparsed.name === 'Coin' &&\n\t\t\tparsed.typeParams.length > 0\n\t\t) {\n\t\t\tconst firstTypeParam = parsed.typeParams[0];\n\t\t\treturn typeof firstTypeParam === 'object'\n\t\t\t\t? firstTypeParam.address + '::' + firstTypeParam.module + '::' + firstTypeParam.name\n\t\t\t\t: null;\n\t\t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AAa,SAAC,kBAAkC;AAC/C,MAAI,qBAAqB,eAAe;AACvC,UAAM,IAAI,MAAM,yCAAyC;AAAA,EAC1D;AACA,aAAO,qCAAuB,gBAAgB;AAC/C;AA0BA,uBAAkB,WAAG;AACpB,QAAM,KAAK,KAAK;AAChB,OAAK,iBAAiB;AACtB,SAAO;AACR;",
6
+ "names": ["import_bcs", "import_utils"]
7
+ }
@@ -0,0 +1 @@
1
+ export * from './client.js';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var index_exports = {};
17
+ module.exports = __toCommonJS(index_exports);
18
+ __reExport(index_exports, require("./client.js"), module.exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport * from './client.js';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAGA,0BAAc,wBAHd;",
6
+ "names": []
7
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "private": true,
3
+ "type": "commonjs"
4
+ }
@@ -0,0 +1,11 @@
1
+ export declare const BcsOrder: import("@haneullabs/haneul/bcs").BcsStruct<{
2
+ orderId: import("@haneullabs/haneul/bcs").BcsType<string, string | number | bigint, "u64">;
3
+ clientOrderId: import("@haneullabs/haneul/bcs").BcsType<string, string | number | bigint, "u64">;
4
+ price: import("@haneullabs/haneul/bcs").BcsType<string, string | number | bigint, "u64">;
5
+ originalQuantity: import("@haneullabs/haneul/bcs").BcsType<string, string | number | bigint, "u64">;
6
+ quantity: import("@haneullabs/haneul/bcs").BcsType<string, string | number | bigint, "u64">;
7
+ isBid: import("@haneullabs/haneul/bcs").BcsType<boolean, boolean, "bool">;
8
+ owner: import("@haneullabs/haneul/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
9
+ expireTimestamp: import("@haneullabs/haneul/bcs").BcsType<string, string | number | bigint, "u64">;
10
+ selfMatchingPrevention: import("@haneullabs/haneul/bcs").BcsType<number, number, "u8">;
11
+ }, string>;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var bcs_exports = {};
20
+ __export(bcs_exports, {
21
+ BcsOrder: () => BcsOrder
22
+ });
23
+ module.exports = __toCommonJS(bcs_exports);
24
+ var import_bcs = require("@haneullabs/haneul/bcs");
25
+ const BcsOrder = import_bcs.bcs.struct("Order", {
26
+ orderId: import_bcs.bcs.u64(),
27
+ clientOrderId: import_bcs.bcs.u64(),
28
+ price: import_bcs.bcs.u64(),
29
+ originalQuantity: import_bcs.bcs.u64(),
30
+ quantity: import_bcs.bcs.u64(),
31
+ isBid: import_bcs.bcs.bool(),
32
+ owner: import_bcs.bcs.Address,
33
+ expireTimestamp: import_bcs.bcs.u64(),
34
+ selfMatchingPrevention: import_bcs.bcs.u8()
35
+ });
36
+ //# sourceMappingURL=bcs.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/types/bcs.ts"],
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '@haneullabs/haneul/bcs';\n\nexport const BcsOrder = bcs.struct('Order', {\n\torderId: bcs.u64(),\n\tclientOrderId: bcs.u64(),\n\tprice: bcs.u64(),\n\toriginalQuantity: bcs.u64(),\n\tquantity: bcs.u64(),\n\tisBid: bcs.bool(),\n\towner: bcs.Address,\n\texpireTimestamp: bcs.u64(),\n\tselfMatchingPrevention: bcs.u8(),\n});\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAAoB;AAEb,MAAM,WAAW,eAAI,OAAO,SAAS;AAAA,EAC3C,SAAS,eAAI,IAAI;AAAA,EACjB,eAAe,eAAI,IAAI;AAAA,EACvB,OAAO,eAAI,IAAI;AAAA,EACf,kBAAkB,eAAI,IAAI;AAAA,EAC1B,UAAU,eAAI,IAAI;AAAA,EAClB,OAAO,eAAI,KAAK;AAAA,EAChB,OAAO,eAAI;AAAA,EACX,iBAAiB,eAAI,IAAI;AAAA,EACzB,wBAAwB,eAAI,GAAG;AAChC,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,51 @@
1
+ import type { EventId } from '@haneullabs/haneul/client';
2
+ export * from './bcs.js';
3
+ export interface PoolSummary {
4
+ poolId: string;
5
+ baseAsset: string;
6
+ quoteAsset: string;
7
+ }
8
+ /**
9
+ * `next_cursor` points to the last item in the page; Reading with `next_cursor` will start from the
10
+ * next item after `next_cursor` if `next_cursor` is `Some`, otherwise it will start from the first
11
+ * item.
12
+ */
13
+ export interface PaginatedPoolSummary {
14
+ data: PoolSummary[];
15
+ hasNextPage: boolean;
16
+ nextCursor?: EventId | null;
17
+ }
18
+ export interface UserPosition {
19
+ availableBaseAmount: bigint;
20
+ lockedBaseAmount: bigint;
21
+ availableQuoteAmount: bigint;
22
+ lockedQuoteAmount: bigint;
23
+ }
24
+ export declare enum LimitOrderType {
25
+ NO_RESTRICTION = 0,
26
+ IMMEDIATE_OR_CANCEL = 1,
27
+ FILL_OR_KILL = 2,
28
+ POST_OR_ABORT = 3
29
+ }
30
+ export declare enum SelfMatchingPreventionStyle {
31
+ CANCEL_OLDEST = 0
32
+ }
33
+ export interface Order {
34
+ orderId: string;
35
+ clientOrderId: string;
36
+ price: string;
37
+ originalQuantity: string;
38
+ quantity: string;
39
+ isBid: boolean;
40
+ owner: string;
41
+ expireTimestamp: string;
42
+ selfMatchingPrevention: SelfMatchingPreventionStyle;
43
+ }
44
+ export interface MarketPrice {
45
+ bestBidPrice: bigint | undefined;
46
+ bestAskPrice: bigint | undefined;
47
+ }
48
+ export interface Level2BookStatusPoint {
49
+ price: bigint;
50
+ depth: bigint;
51
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var types_exports = {};
21
+ __export(types_exports, {
22
+ LimitOrderType: () => LimitOrderType,
23
+ SelfMatchingPreventionStyle: () => SelfMatchingPreventionStyle
24
+ });
25
+ module.exports = __toCommonJS(types_exports);
26
+ __reExport(types_exports, require("./bcs.js"), module.exports);
27
+ var LimitOrderType = /* @__PURE__ */ ((LimitOrderType2) => {
28
+ LimitOrderType2[LimitOrderType2["NO_RESTRICTION"] = 0] = "NO_RESTRICTION";
29
+ LimitOrderType2[LimitOrderType2["IMMEDIATE_OR_CANCEL"] = 1] = "IMMEDIATE_OR_CANCEL";
30
+ LimitOrderType2[LimitOrderType2["FILL_OR_KILL"] = 2] = "FILL_OR_KILL";
31
+ LimitOrderType2[LimitOrderType2["POST_OR_ABORT"] = 3] = "POST_OR_ABORT";
32
+ return LimitOrderType2;
33
+ })(LimitOrderType || {});
34
+ var SelfMatchingPreventionStyle = /* @__PURE__ */ ((SelfMatchingPreventionStyle2) => {
35
+ SelfMatchingPreventionStyle2[SelfMatchingPreventionStyle2["CANCEL_OLDEST"] = 0] = "CANCEL_OLDEST";
36
+ return SelfMatchingPreventionStyle2;
37
+ })(SelfMatchingPreventionStyle || {});
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/types/index.ts"],
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { EventId } from '@haneullabs/haneul/client';\n\nexport * from './bcs.js';\n\nexport interface PoolSummary {\n\tpoolId: string;\n\tbaseAsset: string;\n\tquoteAsset: string;\n}\n\n/**\n * `next_cursor` points to the last item in the page; Reading with `next_cursor` will start from the\n * next item after `next_cursor` if `next_cursor` is `Some`, otherwise it will start from the first\n * item.\n */\nexport interface PaginatedPoolSummary {\n\tdata: PoolSummary[];\n\thasNextPage: boolean;\n\tnextCursor?: EventId | null;\n}\n\nexport interface UserPosition {\n\tavailableBaseAmount: bigint;\n\tlockedBaseAmount: bigint;\n\tavailableQuoteAmount: bigint;\n\tlockedQuoteAmount: bigint;\n}\n\nexport enum LimitOrderType {\n\t// Fill as much quantity as possible in the current transaction as taker, and inject the remaining as a maker order.\n\tNO_RESTRICTION = 0,\n\t// Fill as much quantity as possible in the current transaction as taker, and cancel the rest of the order.\n\tIMMEDIATE_OR_CANCEL = 1,\n\t// Only fill if the entire order size can be filled as taker in the current transaction. Otherwise, abort the entire transaction.\n\tFILL_OR_KILL = 2,\n\t// Only proceed if the entire order size can be posted to the order book as maker in the current transaction. Otherwise, abort the entire transaction.\n\tPOST_OR_ABORT = 3,\n}\n\n// The self-matching prevention mechanism ensures that the matching engine takes measures to avoid unnecessary trades\n// when matching a user's buy/sell order with their own sell/buy order.\n// NOTE: we have only implemented one variant for now\nexport enum SelfMatchingPreventionStyle {\n\t// Cancel older (resting) order in full. Continue to execute the newer taking order.\n\tCANCEL_OLDEST = 0,\n}\n\nexport interface Order {\n\torderId: string;\n\tclientOrderId: string;\n\tprice: string;\n\toriginalQuantity: string;\n\tquantity: string;\n\tisBid: boolean;\n\towner: string;\n\texpireTimestamp: string;\n\tselfMatchingPrevention: SelfMatchingPreventionStyle;\n}\n\nexport interface MarketPrice {\n\tbestBidPrice: bigint | undefined;\n\tbestAskPrice: bigint | undefined;\n}\n\nexport interface Level2BookStatusPoint {\n\tprice: bigint;\n\tdepth: bigint;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,0BAAc,qBALd;AA+BO,IAAK,iBAAL,kBAAKA,oBAAL;AAEN,EAAAA,gCAAA,oBAAiB,KAAjB;AAEA,EAAAA,gCAAA,yBAAsB,KAAtB;AAEA,EAAAA,gCAAA,kBAAe,KAAf;AAEA,EAAAA,gCAAA,mBAAgB,KAAhB;AARW,SAAAA;AAAA,GAAA;AAcL,IAAK,8BAAL,kBAAKC,iCAAL;AAEN,EAAAA,0DAAA,mBAAgB,KAAhB;AAFW,SAAAA;AAAA,GAAA;",
6
+ "names": ["LimitOrderType", "SelfMatchingPreventionStyle"]
7
+ }
@@ -0,0 +1,7 @@
1
+ export declare const PACKAGE_ID = "0xdee9";
2
+ export declare const MODULE_CLOB = "clob_v2";
3
+ export declare const MODULE_CUSTODIAN = "custodian_v2";
4
+ export declare const CREATION_FEE: number;
5
+ export declare const NORMALIZED_HANEUL_COIN_TYPE: string;
6
+ export declare const ORDER_DEFAULT_EXPIRATION_IN_MS: number;
7
+ export declare const FLOAT_SCALING_FACTOR = 1000000000n;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var constants_exports = {};
20
+ __export(constants_exports, {
21
+ CREATION_FEE: () => CREATION_FEE,
22
+ FLOAT_SCALING_FACTOR: () => FLOAT_SCALING_FACTOR,
23
+ MODULE_CLOB: () => MODULE_CLOB,
24
+ MODULE_CUSTODIAN: () => MODULE_CUSTODIAN,
25
+ NORMALIZED_HANEUL_COIN_TYPE: () => NORMALIZED_HANEUL_COIN_TYPE,
26
+ ORDER_DEFAULT_EXPIRATION_IN_MS: () => ORDER_DEFAULT_EXPIRATION_IN_MS,
27
+ PACKAGE_ID: () => PACKAGE_ID
28
+ });
29
+ module.exports = __toCommonJS(constants_exports);
30
+ var import_utils = require("@haneullabs/haneul/utils");
31
+ const PACKAGE_ID = "0xdee9";
32
+ const MODULE_CLOB = "clob_v2";
33
+ const MODULE_CUSTODIAN = "custodian_v2";
34
+ const CREATION_FEE = 100 * 1e9;
35
+ const NORMALIZED_HANEUL_COIN_TYPE = (0, import_utils.normalizeStructTag)(import_utils.HANEUL_TYPE_ARG);
36
+ const ORDER_DEFAULT_EXPIRATION_IN_MS = 1e3 * 60 * 60 * 24;
37
+ const FLOAT_SCALING_FACTOR = 1000000000n;
38
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/utils/constants.ts"],
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { normalizeStructTag, HANEUL_TYPE_ARG } from '@haneullabs/haneul/utils';\n\nexport const PACKAGE_ID = '0xdee9';\n\nexport const MODULE_CLOB = 'clob_v2';\n\nexport const MODULE_CUSTODIAN = 'custodian_v2';\n\nexport const CREATION_FEE = 100 * 1e9;\n\nexport const NORMALIZED_HANEUL_COIN_TYPE = normalizeStructTag(HANEUL_TYPE_ARG);\n\nexport const ORDER_DEFAULT_EXPIRATION_IN_MS = 1000 * 60 * 60 * 24; // 24 hours\n\nexport const FLOAT_SCALING_FACTOR = 1_000_000_000n;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAAoD;AAE7C,MAAM,aAAa;AAEnB,MAAM,cAAc;AAEpB,MAAM,mBAAmB;AAEzB,MAAM,eAAe,MAAM;AAE3B,MAAM,kCAA8B,iCAAmB,4BAAe;AAEtE,MAAM,iCAAiC,MAAO,KAAK,KAAK;AAExD,MAAM,uBAAuB;",
6
+ "names": []
7
+ }
@@ -0,0 +1 @@
1
+ export * from './constants.js';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var utils_exports = {};
17
+ module.exports = __toCommonJS(utils_exports);
18
+ __reExport(utils_exports, require("./constants.js"), module.exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/utils/index.ts"],
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport * from './constants.js';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAGA,0BAAc,2BAHd;",
6
+ "names": []
7
+ }
@@ -0,0 +1,198 @@
1
+ import type { OrderArguments, PaginatedEvents, PaginationArguments } from '@haneullabs/haneul/client';
2
+ import { HaneulClient } from '@haneullabs/haneul/client';
3
+ import type { Argument, TransactionObjectInput, TransactionResult } from '@haneullabs/haneul/transactions';
4
+ import { Transaction } from '@haneullabs/haneul/transactions';
5
+ import type { Level2BookStatusPoint, MarketPrice, Order, PaginatedPoolSummary, PoolSummary, UserPosition } from './types/index.js';
6
+ import { LimitOrderType, SelfMatchingPreventionStyle } from './types/index.js';
7
+ export declare class DeepBookClient {
8
+ #private;
9
+ haneulClient: HaneulClient;
10
+ accountCap: string | undefined;
11
+ currentAddress: string;
12
+ private clientOrderId;
13
+ /**
14
+ *
15
+ * @param haneulClient connection to fullnode
16
+ * @param accountCap (optional) only required for wrting operations
17
+ * @param currentAddress (optional) address of the current user (default: DUMMY_ADDRESS)
18
+ */
19
+ constructor(haneulClient?: HaneulClient, accountCap?: string | undefined, currentAddress?: string, clientOrderId?: number);
20
+ /**
21
+ * @param cap set the account cap for interacting with DeepBook
22
+ */
23
+ setAccountCap(cap: string): Promise<void>;
24
+ /**
25
+ * @description Create pool for trading pair
26
+ * @param baseAssetType Full coin type of the base asset, eg: "0x3d0d0ce17dcd3b40c2d839d96ce66871ffb40e1154a8dd99af72292b3d10d7fc::wbtc::WBTC"
27
+ * @param quoteAssetType Full coin type of quote asset, eg: "0x3d0d0ce17dcd3b40c2d839d96ce66871ffb40e1154a8dd99af72292b3d10d7fc::usdt::USDT"
28
+ * @param tickSize Minimal Price Change Accuracy of this pool, eg: 10000000. The number must be an integer float scaled by `FLOAT_SCALING_FACTOR`.
29
+ * @param lotSize Minimal Lot Change Accuracy of this pool, eg: 10000.
30
+ */
31
+ createPool(baseAssetType: string, quoteAssetType: string, tickSize: bigint, lotSize: bigint): Transaction;
32
+ /**
33
+ * @description Create pool for trading pair
34
+ * @param baseAssetType Full coin type of the base asset, eg: "0x3d0d0ce17dcd3b40c2d839d96ce66871ffb40e1154a8dd99af72292b3d10d7fc::wbtc::WBTC"
35
+ * @param quoteAssetType Full coin type of quote asset, eg: "0x3d0d0ce17dcd3b40c2d839d96ce66871ffb40e1154a8dd99af72292b3d10d7fc::usdt::USDT"
36
+ * @param tickSize Minimal Price Change Accuracy of this pool, eg: 10000000. The number must be an interger float scaled by `FLOAT_SCALING_FACTOR`.
37
+ * @param lotSize Minimal Lot Change Accuracy of this pool, eg: 10000.
38
+ * @param takerFeeRate Customized taker fee rate, float scaled by `FLOAT_SCALING_FACTOR`, Taker_fee_rate of 0.25% should be 2_500_000 for example
39
+ * @param makerRebateRate Customized maker rebate rate, float scaled by `FLOAT_SCALING_FACTOR`, should be less than or equal to the taker_rebate_rate
40
+ */
41
+ createCustomizedPool(baseAssetType: string, quoteAssetType: string, tickSize: bigint, lotSize: bigint, takerFeeRate: bigint, makerRebateRate: bigint): Transaction;
42
+ /**
43
+ * @description Create Account Cap
44
+ * @param tx
45
+ */
46
+ createAccountCap(tx: Transaction): {
47
+ $kind: "NestedResult";
48
+ NestedResult: [number, number];
49
+ };
50
+ /**
51
+ * @description Create and Transfer custodian account to user
52
+ * @param currentAddress current address of the user
53
+ * @param tx
54
+ */
55
+ createAccount(currentAddress?: string, tx?: Transaction): Transaction;
56
+ /**
57
+ * @description Create and Transfer custodian account to user
58
+ * @param currentAddress: current user address, eg: "0xbddc9d4961b46a130c2e1f38585bbc6fa8077ce54bcb206b26874ac08d607966"
59
+ * @param accountCap: Object id of Account Capacity under user address, created after invoking createAccount, eg: "0x6f699fef193723277559c8f499ca3706121a65ac96d273151b8e52deb29135d3"
60
+ */
61
+ createChildAccountCap(currentAddress?: string, accountCap?: string | undefined): Transaction;
62
+ /**
63
+ * @description construct transaction for depositing asset into a pool.
64
+ * @param poolId the pool id for the deposit
65
+ * @param coinId the coin used for the deposit. You can omit this argument if you are depositing SUI, in which case
66
+ * gas coin will be used
67
+ * @param amount the amount of coin to deposit. If omitted, the entire balance of the coin will be deposited
68
+ */
69
+ deposit(poolId: string, coinId?: string | undefined, quantity?: bigint | undefined): Promise<Transaction>;
70
+ /**
71
+ * @description construct transaction for withdrawing asset from a pool.
72
+ * @param poolId the pool id for the withdraw
73
+ * @param amount the amount of coin to withdraw
74
+ * @param assetType Base or Quote
75
+ * @param recipientAddress the address to receive the withdrawn asset. If omitted, `this.currentAddress` will be used. The function
76
+ * will throw if the `recipientAddress === DUMMY_ADDRESS`
77
+ */
78
+ withdraw(poolId: string, quantity: bigint, assetType: 'base' | 'quote', recipientAddress?: string): Promise<Transaction>;
79
+ /**
80
+ * @description place a limit order
81
+ * @param poolId Object id of pool, created after invoking createPool, eg: "0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4"
82
+ * @param price: price of the limit order. The number must be an interger float scaled by `FLOAT_SCALING_FACTOR`.
83
+ * @param quantity: quantity of the limit order in BASE ASSET, eg: 100000000.
84
+ * @param orderType: bid for buying base with quote, ask for selling base for quote
85
+ * @param expirationTimestamp: expiration timestamp of the limit order in ms, eg: 1620000000000. If omitted, the order will expire in 1 day
86
+ * from the time this function is called(not the time the transaction is executed)
87
+ * @param restriction restrictions on limit orders, explain in doc for more details, eg: 0
88
+ * @param clientOrderId a client side defined order number for bookkeeping purpose, e.g., "1", "2", etc. If omitted, the sdk will
89
+ * assign a increasing number starting from 0. But this number might be duplicated if you are using multiple sdk instances
90
+ * @param selfMatchingPrevention: Options for self-match prevention. Right now only support `CANCEL_OLDEST`
91
+ */
92
+ placeLimitOrder(poolId: string, price: bigint, quantity: bigint, orderType: 'bid' | 'ask', expirationTimestamp?: number, restriction?: LimitOrderType, clientOrderId?: string | undefined, selfMatchingPrevention?: SelfMatchingPreventionStyle): Promise<Transaction>;
93
+ /**
94
+ * @description place a market order
95
+ * @param poolId Object id of pool, created after invoking createPool, eg: "0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4"
96
+ * @param quantity Amount of quote asset to swap in base asset
97
+ * @param orderType bid for buying base with quote, ask for selling base for quote
98
+ * @param baseCoin the objectId or the coin object of the base coin
99
+ * @param quoteCoin the objectId or the coin object of the quote coin
100
+ * @param clientOrderId a client side defined order id for bookkeeping purpose. eg: "1" , "2", ... If omitted, the sdk will
101
+ * assign an increasing number starting from 0. But this number might be duplicated if you are using multiple sdk instances
102
+ * @param accountCap
103
+ * @param recipientAddress the address to receive the swapped asset. If omitted, `this.currentAddress` will be used. The function
104
+ * @param tx
105
+ */
106
+ placeMarketOrder(accountCap: string | Extract<Argument, {
107
+ $kind: 'NestedResult';
108
+ }>, poolId: string, quantity: bigint, orderType: 'bid' | 'ask', baseCoin?: TransactionResult | string | undefined, quoteCoin?: TransactionResult | string | undefined, clientOrderId?: string | undefined, recipientAddress?: string | undefined, tx?: Transaction): Promise<Transaction>;
109
+ /**
110
+ * @description swap exact quote for base
111
+ * @param poolId Object id of pool, created after invoking createPool, eg: "0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4"
112
+ * @param tokenObjectIn Object id of the token to swap: eg: "0x6e566fec4c388eeb78a7dab832c9f0212eb2ac7e8699500e203def5b41b9c70d"
113
+ * @param amountIn amount of token to buy or sell, eg: 10000000.
114
+ * @param currentAddress current user address, eg: "0xbddc9d4961b46a130c2e1f38585bbc6fa8077ce54bcb206b26874ac08d607966"
115
+ * @param clientOrderId a client side defined order id for bookkeeping purpose, eg: "1" , "2", ... If omitted, the sdk will
116
+ * assign an increasing number starting from 0. But this number might be duplicated if you are using multiple sdk instances
117
+ * @param tx
118
+ */
119
+ swapExactQuoteForBase(poolId: string, tokenObjectIn: TransactionObjectInput, amountIn: bigint, // quantity of USDC
120
+ currentAddress: string, clientOrderId?: string, tx?: Transaction): Promise<Transaction>;
121
+ /**
122
+ * @description swap exact base for quote
123
+ * @param poolId Object id of pool, created after invoking createPool, eg: "0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4"
124
+ * @param tokenObjectIn Object id of the token to swap: eg: "0x6e566fec4c388eeb78a7dab832c9f0212eb2ac7e8699500e203def5b41b9c70d"
125
+ * @param amountIn amount of token to buy or sell, eg: 10000000
126
+ * @param currentAddress current user address, eg: "0xbddc9d4961b46a130c2e1f38585bbc6fa8077ce54bcb206b26874ac08d607966"
127
+ * @param clientOrderId a client side defined order number for bookkeeping purpose. eg: "1" , "2", ...
128
+ */
129
+ swapExactBaseForQuote(poolId: string, tokenObjectIn: string, amountIn: bigint, currentAddress: string, clientOrderId?: string | undefined): Promise<Transaction>;
130
+ /**
131
+ * @description cancel an order
132
+ * @param poolId Object id of pool, created after invoking createPool, eg: "0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4"
133
+ * @param orderId orderId of a limit order, you can find them through function query.list_open_orders eg: "0"
134
+ */
135
+ cancelOrder(poolId: string, orderId: string): Promise<Transaction>;
136
+ /**
137
+ * @description Cancel all limit orders under a certain account capacity
138
+ * @param poolId Object id of pool, created after invoking createPool, eg: "0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4"
139
+ */
140
+ cancelAllOrders(poolId: string): Promise<Transaction>;
141
+ /**
142
+ * @description batch cancel order
143
+ * @param poolId Object id of pool, created after invoking createPool, eg: "0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4"
144
+ * @param orderIds array of order ids you want to cancel, you can find your open orders by query.list_open_orders eg: ["0", "1", "2"]
145
+ */
146
+ batchCancelOrder(poolId: string, orderIds: string[]): Promise<Transaction>;
147
+ /**
148
+ * @param poolId Object id of pool, created after invoking createPool, eg: "0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4"
149
+ * @param orderIds array of expired order ids to clean, eg: ["0", "1", "2"]
150
+ * @param orderOwners array of Order owners, should be the owner addresses from the account capacities which placed the orders
151
+ */
152
+ cleanUpExpiredOrders(poolId: string, orderIds: string[], orderOwners: string[]): Promise<Transaction>;
153
+ /**
154
+ * @description returns paginated list of pools created in DeepBook by querying for the
155
+ * `PoolCreated` event. Warning: this method can return incomplete results if the upstream data source
156
+ * is pruned.
157
+ */
158
+ getAllPools(input: PaginationArguments<PaginatedEvents['nextCursor']> & OrderArguments): Promise<PaginatedPoolSummary>;
159
+ /**
160
+ * @description Fetch metadata for a pool
161
+ * @param poolId object id of the pool
162
+ * @returns Metadata for the Pool
163
+ */
164
+ getPoolInfo(poolId: string): Promise<PoolSummary>;
165
+ getPoolTypeArgs(poolId: string): Promise<string[]>;
166
+ /**
167
+ * @description get the order status
168
+ * @param poolId: the pool id, eg: 0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4
169
+ * @param orderId the order id, eg: "1"
170
+ */
171
+ getOrderStatus(poolId: string, orderId: string, accountCap?: string | undefined): Promise<Order | undefined>;
172
+ /**
173
+ * @description get the base and quote token in custodian account
174
+ * @param poolId the pool id, eg: 0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4
175
+ * @param accountCap your accountCap, eg: 0x6f699fef193723277559c8f499ca3706121a65ac96d273151b8e52deb29135d3. If not provided, `this.accountCap` will be used.
176
+ */
177
+ getUserPosition(poolId: string, accountCap?: string | undefined): Promise<UserPosition>;
178
+ /**
179
+ * @description get the open orders of the current user
180
+ * @param poolId the pool id, eg: 0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4
181
+ * @param accountCap your accountCap, eg: 0x6f699fef193723277559c8f499ca3706121a65ac96d273151b8e52deb29135d3. If not provided, `this.accountCap` will be used.
182
+ */
183
+ listOpenOrders(poolId: string, accountCap?: string | undefined): Promise<Order[]>;
184
+ /**
185
+ * @description get the market price {bestBidPrice, bestAskPrice}
186
+ * @param poolId the pool id, eg: 0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4
187
+ */
188
+ getMarketPrice(poolId: string): Promise<MarketPrice>;
189
+ /**
190
+ * @description get level2 book status
191
+ * @param poolId the pool id, eg: 0xcaee8e1c046b58e55196105f1436a2337dcaa0c340a7a8c8baf65e4afb8823a4
192
+ * @param lowerPrice lower price you want to query in the level2 book, eg: 18000000000. The number must be an integer float scaled by `FLOAT_SCALING_FACTOR`.
193
+ * @param higherPrice higher price you want to query in the level2 book, eg: 20000000000. The number must be an integer float scaled by `FLOAT_SCALING_FACTOR`.
194
+ * @param side { 'bid' | 'ask' | 'both' } bid or ask or both sides.
195
+ */
196
+ getLevel2BookStatus(poolId: string, lowerPrice: bigint, higherPrice: bigint, side: 'bid' | 'ask' | 'both'): Promise<Level2BookStatusPoint[] | Level2BookStatusPoint[][]>;
197
+ getCoinType(coinId: string): Promise<string | null>;
198
+ }