@mysten/deepbook-v3 0.22.2 → 0.23.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 (65) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/client.d.ts +167 -1
  3. package/dist/cjs/client.js +354 -3
  4. package/dist/cjs/client.js.map +2 -2
  5. package/dist/cjs/contracts/utils/index.d.ts +13 -0
  6. package/dist/cjs/contracts/utils/index.js +6 -9
  7. package/dist/cjs/contracts/utils/index.js.map +2 -2
  8. package/dist/cjs/index.d.ts +3 -1
  9. package/dist/cjs/index.js +16 -3
  10. package/dist/cjs/index.js.map +2 -2
  11. package/dist/cjs/transactions/deepbook.d.ts +189 -1
  12. package/dist/cjs/transactions/deepbook.js +548 -1
  13. package/dist/cjs/transactions/deepbook.js.map +2 -2
  14. package/dist/cjs/types/index.d.ts +41 -0
  15. package/dist/cjs/types/index.js.map +1 -1
  16. package/dist/cjs/utils/config.d.ts +8 -8
  17. package/dist/cjs/utils/config.js +12 -11
  18. package/dist/cjs/utils/config.js.map +2 -2
  19. package/dist/cjs/utils/constants.d.ts +8 -0
  20. package/dist/cjs/utils/constants.js +18 -7
  21. package/dist/cjs/utils/constants.js.map +2 -2
  22. package/dist/cjs/utils/errors.d.ts +42 -0
  23. package/dist/cjs/utils/errors.js +70 -0
  24. package/dist/cjs/utils/errors.js.map +7 -0
  25. package/dist/cjs/utils/validation.d.ts +50 -0
  26. package/dist/cjs/utils/validation.js +67 -0
  27. package/dist/cjs/utils/validation.js.map +7 -0
  28. package/dist/esm/client.d.ts +167 -1
  29. package/dist/esm/client.js +355 -4
  30. package/dist/esm/client.js.map +2 -2
  31. package/dist/esm/contracts/utils/index.d.ts +13 -0
  32. package/dist/esm/contracts/utils/index.js +6 -9
  33. package/dist/esm/contracts/utils/index.js.map +2 -2
  34. package/dist/esm/index.d.ts +3 -1
  35. package/dist/esm/index.js +31 -5
  36. package/dist/esm/index.js.map +2 -2
  37. package/dist/esm/transactions/deepbook.d.ts +189 -1
  38. package/dist/esm/transactions/deepbook.js +549 -2
  39. package/dist/esm/transactions/deepbook.js.map +2 -2
  40. package/dist/esm/types/index.d.ts +41 -0
  41. package/dist/esm/types/index.js.map +1 -1
  42. package/dist/esm/utils/config.d.ts +8 -8
  43. package/dist/esm/utils/config.js +12 -11
  44. package/dist/esm/utils/config.js.map +2 -2
  45. package/dist/esm/utils/constants.d.ts +8 -0
  46. package/dist/esm/utils/constants.js +18 -7
  47. package/dist/esm/utils/constants.js.map +2 -2
  48. package/dist/esm/utils/errors.d.ts +42 -0
  49. package/dist/esm/utils/errors.js +50 -0
  50. package/dist/esm/utils/errors.js.map +7 -0
  51. package/dist/esm/utils/validation.d.ts +50 -0
  52. package/dist/esm/utils/validation.js +47 -0
  53. package/dist/esm/utils/validation.js.map +7 -0
  54. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  55. package/dist/tsconfig.tsbuildinfo +1 -1
  56. package/package.json +15 -8
  57. package/src/client.ts +427 -4
  58. package/src/contracts/utils/index.ts +27 -11
  59. package/src/index.ts +21 -2
  60. package/src/transactions/deepbook.ts +647 -2
  61. package/src/types/index.ts +47 -0
  62. package/src/utils/config.ts +28 -15
  63. package/src/utils/constants.ts +17 -6
  64. package/src/utils/errors.ts +67 -0
  65. package/src/utils/validation.ts +91 -0
@@ -2,7 +2,20 @@ import type { BcsType, TypeTag } from '@mysten/sui/bcs';
2
2
  import { BcsStruct, BcsEnum, BcsTuple } from '@mysten/sui/bcs';
3
3
  import type { TransactionArgument } from '@mysten/sui/transactions';
4
4
  export type RawTransactionArgument<T> = T | TransactionArgument;
5
+ /**
6
+ * @description Get the BCS schema for a given type tag
7
+ * @param {string | TypeTag} typeTag - The Move type tag to get the schema for
8
+ * @returns {BcsType<any> | null} The BCS schema if found, null otherwise
9
+ */
5
10
  export declare function getPureBcsSchema(typeTag: string | TypeTag): BcsType<any> | null;
11
+ /**
12
+ * @description Normalize Move function arguments to TransactionArguments
13
+ * @param {unknown[] | object} args - The arguments to normalize
14
+ * @param {string[]} argTypes - The expected Move type strings for each argument
15
+ * @param {string[]} [parameterNames] - Optional parameter names when args is an object
16
+ * @returns {TransactionArgument[]} Array of normalized transaction arguments
17
+ * @throws {Error} If arguments are invalid or don't match expected types
18
+ */
6
19
  export declare function normalizeMoveArguments(args: unknown[] | object, argTypes: string[], parameterNames?: string[]): TransactionArgument[];
7
20
  export declare class MoveStruct<T extends Record<string, BcsType<any>>, const Name extends string = string> extends BcsStruct<T, Name> {
8
21
  }
@@ -28,6 +28,7 @@ module.exports = __toCommonJS(utils_exports);
28
28
  var import_bcs = require("@mysten/sui/bcs");
29
29
  var import_utils = require("@mysten/sui/utils");
30
30
  var import_transactions = require("@mysten/sui/transactions");
31
+ var import_errors = require("../../utils/errors.js");
31
32
  const MOVE_STDLIB_ADDRESS = (0, import_utils.normalizeSuiAddress)("0x1");
32
33
  const SUI_FRAMEWORK_ADDRESS = (0, import_utils.normalizeSuiAddress)("0x2");
33
34
  const SUI_SYSTEM_ADDRESS = (0, import_utils.normalizeSuiAddress)("0x3");
@@ -73,9 +74,7 @@ function getPureBcsSchema(typeTag) {
73
74
  function normalizeMoveArguments(args, argTypes, parameterNames) {
74
75
  const argLen = Array.isArray(args) ? args.length : Object.keys(args).length;
75
76
  if (parameterNames && argLen !== parameterNames.length) {
76
- throw new Error(
77
- `Invalid number of arguments, expected ${parameterNames.length}, got ${argLen}`
78
- );
77
+ throw new import_errors.ValidationError(import_errors.ErrorMessages.INVALID_ARGUMENT_COUNT(parameterNames.length, argLen));
79
78
  }
80
79
  const normalizedArgs = [];
81
80
  let index = 0;
@@ -99,19 +98,17 @@ function normalizeMoveArguments(args, argTypes, parameterNames) {
99
98
  let arg;
100
99
  if (Array.isArray(args)) {
101
100
  if (index >= args.length) {
102
- throw new Error(
103
- `Invalid number of arguments, expected at least ${index + 1}, got ${args.length}`
104
- );
101
+ throw new import_errors.ValidationError(import_errors.ErrorMessages.INVALID_ARGUMENT_COUNT(index + 1, args.length));
105
102
  }
106
103
  arg = args[index];
107
104
  } else {
108
105
  if (!parameterNames) {
109
- throw new Error(`Expected arguments to be passed as an array`);
106
+ throw new import_errors.ValidationError(`Expected arguments to be passed as an array`);
110
107
  }
111
108
  const name = parameterNames[index];
112
109
  arg = args[name];
113
110
  if (arg == null) {
114
- throw new Error(`Parameter ${name} is required`);
111
+ throw new import_errors.ValidationError(import_errors.ErrorMessages.PARAMETER_REQUIRED(name));
115
112
  }
116
113
  }
117
114
  index += 1;
@@ -129,7 +126,7 @@ function normalizeMoveArguments(args, argTypes, parameterNames) {
129
126
  normalizedArgs.push((tx) => tx.object(arg));
130
127
  continue;
131
128
  }
132
- throw new Error(`Invalid argument ${stringify(arg)} for type ${type}`);
129
+ throw new import_errors.ValidationError(import_errors.ErrorMessages.INVALID_ARGUMENT(stringify(arg), type));
133
130
  }
134
131
  return normalizedArgs;
135
132
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/contracts/utils/index.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { BcsType, TypeTag } from '@mysten/sui/bcs';\nimport { bcs, TypeTagSerializer, BcsStruct, BcsEnum, BcsTuple } from '@mysten/sui/bcs';\nimport { normalizeSuiAddress } from '@mysten/sui/utils';\nimport type { TransactionArgument } from '@mysten/sui/transactions';\nimport { isArgument } from '@mysten/sui/transactions';\n\nconst MOVE_STDLIB_ADDRESS = normalizeSuiAddress('0x1');\nconst SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress('0x2');\nconst SUI_SYSTEM_ADDRESS = normalizeSuiAddress('0x3');\n\nexport type RawTransactionArgument<T> = T | TransactionArgument;\n\nexport function getPureBcsSchema(typeTag: string | TypeTag): BcsType<any> | null {\n\tconst parsedTag = typeof typeTag === 'string' ? TypeTagSerializer.parseFromStr(typeTag) : typeTag;\n\n\tif ('u8' in parsedTag) {\n\t\treturn bcs.U8;\n\t} else if ('u16' in parsedTag) {\n\t\treturn bcs.U16;\n\t} else if ('u32' in parsedTag) {\n\t\treturn bcs.U32;\n\t} else if ('u64' in parsedTag) {\n\t\treturn bcs.U64;\n\t} else if ('u128' in parsedTag) {\n\t\treturn bcs.U128;\n\t} else if ('u256' in parsedTag) {\n\t\treturn bcs.U256;\n\t} else if ('address' in parsedTag) {\n\t\treturn bcs.Address;\n\t} else if ('bool' in parsedTag) {\n\t\treturn bcs.Bool;\n\t} else if ('vector' in parsedTag) {\n\t\tconst type = getPureBcsSchema(parsedTag.vector);\n\t\treturn type ? bcs.vector(type) : null;\n\t} else if ('struct' in parsedTag) {\n\t\tconst structTag = parsedTag.struct;\n\t\tconst pkg = normalizeSuiAddress(parsedTag.struct.address);\n\n\t\tif (pkg === MOVE_STDLIB_ADDRESS) {\n\t\t\tif (\n\t\t\t\t(structTag.module === 'ascii' || structTag.module === 'string') &&\n\t\t\t\tstructTag.name === 'String'\n\t\t\t) {\n\t\t\t\treturn bcs.String;\n\t\t\t}\n\n\t\t\tif (structTag.module === 'option' && structTag.name === 'Option') {\n\t\t\t\tconst type = getPureBcsSchema(structTag.typeParams[0]!);\n\t\t\t\treturn type ? bcs.vector(type) : null;\n\t\t\t}\n\t\t}\n\n\t\tif (pkg === SUI_FRAMEWORK_ADDRESS && structTag.module === 'Object' && structTag.name === 'ID') {\n\t\t\treturn bcs.Address;\n\t\t}\n\t}\n\n\treturn null;\n}\n\nexport function normalizeMoveArguments(\n\targs: unknown[] | object,\n\targTypes: string[],\n\tparameterNames?: string[],\n) {\n\tconst argLen = Array.isArray(args) ? args.length : Object.keys(args).length;\n\tif (parameterNames && argLen !== parameterNames.length) {\n\t\tthrow new Error(\n\t\t\t`Invalid number of arguments, expected ${parameterNames.length}, got ${argLen}`,\n\t\t);\n\t}\n\n\tconst normalizedArgs: TransactionArgument[] = [];\n\n\tlet index = 0;\n\tfor (const [i, argType] of argTypes.entries()) {\n\t\tif (argType === `${SUI_FRAMEWORK_ADDRESS}::deny_list::DenyList`) {\n\t\t\tnormalizedArgs.push((tx) => tx.object.denyList());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === `${SUI_FRAMEWORK_ADDRESS}::random::Random`) {\n\t\t\tnormalizedArgs.push((tx) => tx.object.random());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === `${SUI_FRAMEWORK_ADDRESS}::clock::Clock`) {\n\t\t\tnormalizedArgs.push((tx) => tx.object.clock());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === `${SUI_SYSTEM_ADDRESS}::sui_system::SuiSystemState`) {\n\t\t\tnormalizedArgs.push((tx) => tx.object.system());\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet arg;\n\t\tif (Array.isArray(args)) {\n\t\t\tif (index >= args.length) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Invalid number of arguments, expected at least ${index + 1}, got ${args.length}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\targ = args[index];\n\t\t} else {\n\t\t\tif (!parameterNames) {\n\t\t\t\tthrow new Error(`Expected arguments to be passed as an array`);\n\t\t\t}\n\t\t\tconst name = parameterNames[index];\n\t\t\targ = args[name as keyof typeof args];\n\n\t\t\tif (arg == null) {\n\t\t\t\tthrow new Error(`Parameter ${name} is required`);\n\t\t\t}\n\t\t}\n\n\t\tindex += 1;\n\n\t\tif (typeof arg === 'function' || isArgument(arg)) {\n\t\t\tnormalizedArgs.push(arg as TransactionArgument);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst type = argTypes[i]!;\n\t\tconst bcsType = getPureBcsSchema(type);\n\n\t\tif (bcsType) {\n\t\t\tconst bytes = bcsType.serialize(arg as never);\n\t\t\tnormalizedArgs.push((tx) => tx.pure(bytes));\n\t\t\tcontinue;\n\t\t} else if (typeof arg === 'string') {\n\t\t\tnormalizedArgs.push((tx) => tx.object(arg));\n\t\t\tcontinue;\n\t\t}\n\n\t\tthrow new Error(`Invalid argument ${stringify(arg)} for type ${type}`);\n\t}\n\n\treturn normalizedArgs;\n}\n\nexport class MoveStruct<\n\tT extends Record<string, BcsType<any>>,\n\tconst Name extends string = string,\n> extends BcsStruct<T, Name> {}\n\nexport class MoveEnum<\n\tT extends Record<string, BcsType<any> | null>,\n\tconst Name extends string,\n> extends BcsEnum<T, Name> {}\n\nexport class MoveTuple<\n\tT extends readonly BcsType<any>[],\n\tconst Name extends string,\n> extends BcsTuple<T, Name> {}\n\nfunction stringify(val: unknown) {\n\tif (typeof val === 'object') {\n\t\treturn JSON.stringify(val, (val: unknown) => val);\n\t}\n\tif (typeof val === 'bigint') {\n\t\treturn val.toString();\n\t}\n\n\treturn val;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAAqE;AACrE,mBAAoC;AAEpC,0BAA2B;AAE3B,MAAM,0BAAsB,kCAAoB,KAAK;AACrD,MAAM,4BAAwB,kCAAoB,KAAK;AACvD,MAAM,yBAAqB,kCAAoB,KAAK;AAI7C,SAAS,iBAAiB,SAAgD;AAChF,QAAM,YAAY,OAAO,YAAY,WAAW,6BAAkB,aAAa,OAAO,IAAI;AAE1F,MAAI,QAAQ,WAAW;AACtB,WAAO,eAAI;AAAA,EACZ,WAAW,SAAS,WAAW;AAC9B,WAAO,eAAI;AAAA,EACZ,WAAW,SAAS,WAAW;AAC9B,WAAO,eAAI;AAAA,EACZ,WAAW,SAAS,WAAW;AAC9B,WAAO,eAAI;AAAA,EACZ,WAAW,UAAU,WAAW;AAC/B,WAAO,eAAI;AAAA,EACZ,WAAW,UAAU,WAAW;AAC/B,WAAO,eAAI;AAAA,EACZ,WAAW,aAAa,WAAW;AAClC,WAAO,eAAI;AAAA,EACZ,WAAW,UAAU,WAAW;AAC/B,WAAO,eAAI;AAAA,EACZ,WAAW,YAAY,WAAW;AACjC,UAAM,OAAO,iBAAiB,UAAU,MAAM;AAC9C,WAAO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A,IAAG;AAAA,EACjD;AACA,MAAI,OAAO,QAAQ,UAAU;AAC5B,WAAO,IAAI,SAAS;AAAA,EACrB;AAEA,SAAO;AACR;",
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { BcsType, TypeTag } from '@mysten/sui/bcs';\nimport { bcs, TypeTagSerializer, BcsStruct, BcsEnum, BcsTuple } from '@mysten/sui/bcs';\nimport { normalizeSuiAddress } from '@mysten/sui/utils';\nimport type { TransactionArgument } from '@mysten/sui/transactions';\nimport { isArgument } from '@mysten/sui/transactions';\nimport { ValidationError, ErrorMessages } from '../../utils/errors.js';\n\nconst MOVE_STDLIB_ADDRESS = normalizeSuiAddress('0x1');\nconst SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress('0x2');\nconst SUI_SYSTEM_ADDRESS = normalizeSuiAddress('0x3');\n\nexport type RawTransactionArgument<T> = T | TransactionArgument;\n\n/**\n * @description Get the BCS schema for a given type tag\n * @param {string | TypeTag} typeTag - The Move type tag to get the schema for\n * @returns {BcsType<any> | null} The BCS schema if found, null otherwise\n */\nexport function getPureBcsSchema(typeTag: string | TypeTag): BcsType<any> | null {\n\tconst parsedTag = typeof typeTag === 'string' ? TypeTagSerializer.parseFromStr(typeTag) : typeTag;\n\n\tif ('u8' in parsedTag) {\n\t\treturn bcs.U8;\n\t} else if ('u16' in parsedTag) {\n\t\treturn bcs.U16;\n\t} else if ('u32' in parsedTag) {\n\t\treturn bcs.U32;\n\t} else if ('u64' in parsedTag) {\n\t\treturn bcs.U64;\n\t} else if ('u128' in parsedTag) {\n\t\treturn bcs.U128;\n\t} else if ('u256' in parsedTag) {\n\t\treturn bcs.U256;\n\t} else if ('address' in parsedTag) {\n\t\treturn bcs.Address;\n\t} else if ('bool' in parsedTag) {\n\t\treturn bcs.Bool;\n\t} else if ('vector' in parsedTag) {\n\t\tconst type = getPureBcsSchema(parsedTag.vector);\n\t\treturn type ? bcs.vector(type) : null;\n\t} else if ('struct' in parsedTag) {\n\t\tconst structTag = parsedTag.struct;\n\t\tconst pkg = normalizeSuiAddress(parsedTag.struct.address);\n\n\t\tif (pkg === MOVE_STDLIB_ADDRESS) {\n\t\t\tif (\n\t\t\t\t(structTag.module === 'ascii' || structTag.module === 'string') &&\n\t\t\t\tstructTag.name === 'String'\n\t\t\t) {\n\t\t\t\treturn bcs.String;\n\t\t\t}\n\n\t\t\tif (structTag.module === 'option' && structTag.name === 'Option') {\n\t\t\t\tconst type = getPureBcsSchema(structTag.typeParams[0]!);\n\t\t\t\treturn type ? bcs.vector(type) : null;\n\t\t\t}\n\t\t}\n\n\t\tif (pkg === SUI_FRAMEWORK_ADDRESS && structTag.module === 'Object' && structTag.name === 'ID') {\n\t\t\treturn bcs.Address;\n\t\t}\n\t}\n\n\treturn null;\n}\n\n/**\n * @description Normalize Move function arguments to TransactionArguments\n * @param {unknown[] | object} args - The arguments to normalize\n * @param {string[]} argTypes - The expected Move type strings for each argument\n * @param {string[]} [parameterNames] - Optional parameter names when args is an object\n * @returns {TransactionArgument[]} Array of normalized transaction arguments\n * @throws {Error} If arguments are invalid or don't match expected types\n */\nexport function normalizeMoveArguments(\n\targs: unknown[] | object,\n\targTypes: string[],\n\tparameterNames?: string[],\n): TransactionArgument[] {\n\tconst argLen = Array.isArray(args) ? args.length : Object.keys(args).length;\n\tif (parameterNames && argLen !== parameterNames.length) {\n\t\tthrow new ValidationError(ErrorMessages.INVALID_ARGUMENT_COUNT(parameterNames.length, argLen));\n\t}\n\n\tconst normalizedArgs: TransactionArgument[] = [];\n\n\tlet index = 0;\n\tfor (const [i, argType] of argTypes.entries()) {\n\t\tif (argType === `${SUI_FRAMEWORK_ADDRESS}::deny_list::DenyList`) {\n\t\t\tnormalizedArgs.push((tx) => tx.object.denyList());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === `${SUI_FRAMEWORK_ADDRESS}::random::Random`) {\n\t\t\tnormalizedArgs.push((tx) => tx.object.random());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === `${SUI_FRAMEWORK_ADDRESS}::clock::Clock`) {\n\t\t\tnormalizedArgs.push((tx) => tx.object.clock());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === `${SUI_SYSTEM_ADDRESS}::sui_system::SuiSystemState`) {\n\t\t\tnormalizedArgs.push((tx) => tx.object.system());\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet arg;\n\t\tif (Array.isArray(args)) {\n\t\t\tif (index >= args.length) {\n\t\t\t\tthrow new ValidationError(ErrorMessages.INVALID_ARGUMENT_COUNT(index + 1, args.length));\n\t\t\t}\n\t\t\targ = args[index];\n\t\t} else {\n\t\t\tif (!parameterNames) {\n\t\t\t\tthrow new ValidationError(`Expected arguments to be passed as an array`);\n\t\t\t}\n\t\t\tconst name = parameterNames[index];\n\t\t\targ = args[name as keyof typeof args];\n\n\t\t\tif (arg == null) {\n\t\t\t\tthrow new ValidationError(ErrorMessages.PARAMETER_REQUIRED(name));\n\t\t\t}\n\t\t}\n\n\t\tindex += 1;\n\n\t\tif (typeof arg === 'function' || isArgument(arg)) {\n\t\t\tnormalizedArgs.push(arg as TransactionArgument);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst type = argTypes[i]!;\n\t\tconst bcsType = getPureBcsSchema(type);\n\n\t\tif (bcsType) {\n\t\t\tconst bytes = bcsType.serialize(arg as never);\n\t\t\tnormalizedArgs.push((tx) => tx.pure(bytes));\n\t\t\tcontinue;\n\t\t} else if (typeof arg === 'string') {\n\t\t\tnormalizedArgs.push((tx) => tx.object(arg));\n\t\t\tcontinue;\n\t\t}\n\n\t\tthrow new ValidationError(ErrorMessages.INVALID_ARGUMENT(stringify(arg) as string, type));\n\t}\n\n\treturn normalizedArgs;\n}\n\nexport class MoveStruct<\n\tT extends Record<string, BcsType<any>>,\n\tconst Name extends string = string,\n> extends BcsStruct<T, Name> {}\n\nexport class MoveEnum<\n\tT extends Record<string, BcsType<any> | null>,\n\tconst Name extends string,\n> extends BcsEnum<T, Name> {}\n\nexport class MoveTuple<\n\tT extends readonly BcsType<any>[],\n\tconst Name extends string,\n> extends BcsTuple<T, Name> {}\n\n/**\n * @description Convert a value to string representation for error messages\n * @param {unknown} val - The value to stringify\n * @returns {unknown} String representation of the value\n * @private\n */\nfunction stringify(val: unknown): unknown {\n\tif (typeof val === 'object') {\n\t\treturn JSON.stringify(val, (val: unknown) => val);\n\t}\n\tif (typeof val === 'bigint') {\n\t\treturn val.toString();\n\t}\n\n\treturn val;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAAqE;AACrE,mBAAoC;AAEpC,0BAA2B;AAC3B,oBAA+C;AAE/C,MAAM,0BAAsB,kCAAoB,KAAK;AACrD,MAAM,4BAAwB,kCAAoB,KAAK;AACvD,MAAM,yBAAqB,kCAAoB,KAAK;AAS7C,SAAS,iBAAiB,SAAgD;AAChF,QAAM,YAAY,OAAO,YAAY,WAAW,6BAAkB,aAAa,OAAO,IAAI;AAE1F,MAAI,QAAQ,WAAW;AACtB,WAAO,eAAI;AAAA,EACZ,WAAW,SAAS,WAAW;AAC9B,WAAO,eAAI;AAAA,EACZ,WAAW,SAAS,WAAW;AAC9B,WAAO,eAAI;AAAA,EACZ,WAAW,SAAS,WAAW;AAC9B,WAAO,eAAI;AAAA,EACZ,WAAW,UAAU,WAAW;AAC/B,WAAO,eAAI;AAAA,EACZ,WAAW,UAAU,WAAW;AAC/B,WAAO,eAAI;AAAA,EACZ,WAAW,aAAa,WAAW;AAClC,WAAO,eAAI;AAAA,EACZ,WAAW,UAAU,WAAW;AAC/B,WAAO,eAAI;AAAA,EACZ,WAAW,YAAY,WAAW;AACjC,UAAM,OAAO,iBAAiB,UAAU,MAAM;AAC9C,WAAO,OAAO,eAAI,OAAO,IAAI,IAAI;AAAA,EAClC,WAAW,YAAY,WAAW;AACjC,UAAM,YAAY,UAAU;AAC5B,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EACrB;AAEA,SAAO;AACR;",
6
6
  "names": ["val"]
7
7
  }
@@ -16,4 +16,6 @@ export type { BalanceManager, Coin, Pool, MarginManager, MarginPool, Environment
16
16
  export type { PlaceLimitOrderParams, PlaceMarketOrderParams, PlaceMarginLimitOrderParams, PlaceMarginMarketOrderParams, SwapParams, ProposalParams, MarginProposalParams, CreatePoolAdminParams, CreatePermissionlessPoolParams, SetEwmaParams, PoolConfigParams, MarginPoolConfigParams, InterestConfigParams, } from './types/index.js';
17
17
  export { OrderType, SelfMatchingOptions } from './types/index.js';
18
18
  export type { CoinMap, PoolMap, MarginPoolMap } from './utils/constants.js';
19
- export { DEEP_SCALAR, FLOAT_SCALAR, GAS_BUDGET, MAX_TIMESTAMP, POOL_CREATION_FEE, PRICE_INFO_OBJECT_MAX_AGE, } from './utils/config.js';
19
+ export { DEEP_SCALAR, FLOAT_SCALAR, GAS_BUDGET, MAX_TIMESTAMP, POOL_CREATION_FEE_DEEP, PRICE_INFO_OBJECT_MAX_AGE_MS, } from './utils/config.js';
20
+ export { DeepBookError, ResourceNotFoundError, ConfigurationError, ValidationError, ErrorMessages, } from './utils/errors.js';
21
+ export { validateRequired, validateAddress, validatePositiveNumber, validateNonNegativeNumber, validateRange, validateNonEmptyArray, } from './utils/validation.js';
package/dist/cjs/index.js CHANGED
@@ -21,11 +21,14 @@ __export(index_exports, {
21
21
  Account: () => import_bcs.Account,
22
22
  BalanceManagerContract: () => import_balanceManager.BalanceManagerContract,
23
23
  Balances: () => import_bcs.Balances,
24
+ ConfigurationError: () => import_errors.ConfigurationError,
24
25
  DEEP_SCALAR: () => import_config2.DEEP_SCALAR,
25
26
  DeepBookAdminContract: () => import_deepbookAdmin.DeepBookAdminContract,
26
27
  DeepBookClient: () => import_client.DeepBookClient,
27
28
  DeepBookConfig: () => import_config.DeepBookConfig,
28
29
  DeepBookContract: () => import_deepbook.DeepBookContract,
30
+ DeepBookError: () => import_errors.DeepBookError,
31
+ ErrorMessages: () => import_errors.ErrorMessages,
29
32
  FLOAT_SCALAR: () => import_config2.FLOAT_SCALAR,
30
33
  FlashLoanContract: () => import_flashLoans.FlashLoanContract,
31
34
  GAS_BUDGET: () => import_config2.GAS_BUDGET,
@@ -38,13 +41,21 @@ __export(index_exports, {
38
41
  Order: () => import_bcs.Order,
39
42
  OrderDeepPrice: () => import_bcs.OrderDeepPrice,
40
43
  OrderType: () => import_types.OrderType,
41
- POOL_CREATION_FEE: () => import_config2.POOL_CREATION_FEE,
42
- PRICE_INFO_OBJECT_MAX_AGE: () => import_config2.PRICE_INFO_OBJECT_MAX_AGE,
44
+ POOL_CREATION_FEE_DEEP: () => import_config2.POOL_CREATION_FEE_DEEP,
45
+ PRICE_INFO_OBJECT_MAX_AGE_MS: () => import_config2.PRICE_INFO_OBJECT_MAX_AGE_MS,
43
46
  PoolProxyContract: () => import_poolProxy.PoolProxyContract,
47
+ ResourceNotFoundError: () => import_errors.ResourceNotFoundError,
44
48
  SelfMatchingOptions: () => import_types.SelfMatchingOptions,
45
49
  SuiPriceServiceConnection: () => import_pyth.SuiPriceServiceConnection,
46
50
  SuiPythClient: () => import_pyth.SuiPythClient,
47
- VecSet: () => import_bcs.VecSet
51
+ ValidationError: () => import_errors.ValidationError,
52
+ VecSet: () => import_bcs.VecSet,
53
+ validateAddress: () => import_validation.validateAddress,
54
+ validateNonEmptyArray: () => import_validation.validateNonEmptyArray,
55
+ validateNonNegativeNumber: () => import_validation.validateNonNegativeNumber,
56
+ validatePositiveNumber: () => import_validation.validatePositiveNumber,
57
+ validateRange: () => import_validation.validateRange,
58
+ validateRequired: () => import_validation.validateRequired
48
59
  });
49
60
  module.exports = __toCommonJS(index_exports);
50
61
  var import_client = require("./client.js");
@@ -63,4 +74,6 @@ var import_pyth = require("./pyth/pyth.js");
63
74
  var import_bcs = require("./types/bcs.js");
64
75
  var import_types = require("./types/index.js");
65
76
  var import_config2 = require("./utils/config.js");
77
+ var import_errors = require("./utils/errors.js");
78
+ var import_validation = require("./utils/validation.js");
66
79
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n// Main client and configuration\nexport { DeepBookClient } from './client.js';\nexport { DeepBookConfig } from './utils/config.js';\n\n// Core contract classes\nexport { BalanceManagerContract } from './transactions/balanceManager.js';\nexport { DeepBookContract } from './transactions/deepbook.js';\nexport { DeepBookAdminContract } from './transactions/deepbookAdmin.js';\nexport { FlashLoanContract } from './transactions/flashLoans.js';\nexport { GovernanceContract } from './transactions/governance.js';\n\n// Margin trading contracts\nexport { MarginAdminContract } from './transactions/marginAdmin.js';\nexport { MarginMaintainerContract } from './transactions/marginMaintainer.js';\nexport { MarginManagerContract } from './transactions/marginManager.js';\nexport { MarginPoolContract } from './transactions/marginPool.js';\nexport { PoolProxyContract } from './transactions/poolProxy.js';\n\n// Pyth price feed integration\nexport { SuiPythClient, SuiPriceServiceConnection } from './pyth/pyth.js';\n\n// BCS types for parsing on-chain data\nexport { Account, Balances, Order, OrderDeepPrice, VecSet } from './types/bcs.js';\n\n// TypeScript interfaces and types\nexport type {\n\tBalanceManager,\n\tCoin,\n\tPool,\n\tMarginManager,\n\tMarginPool,\n\tEnvironment,\n\tConfig,\n} from './types/index.js';\n\n// Trading parameter interfaces\nexport type {\n\tPlaceLimitOrderParams,\n\tPlaceMarketOrderParams,\n\tPlaceMarginLimitOrderParams,\n\tPlaceMarginMarketOrderParams,\n\tSwapParams,\n\tProposalParams,\n\tMarginProposalParams,\n\tCreatePoolAdminParams,\n\tCreatePermissionlessPoolParams,\n\tSetEwmaParams,\n\tPoolConfigParams,\n\tMarginPoolConfigParams,\n\tInterestConfigParams,\n} from './types/index.js';\n\n// Enums for trading\nexport { OrderType, SelfMatchingOptions } from './types/index.js';\n\n// Constants and configuration maps\nexport type { CoinMap, PoolMap, MarginPoolMap } from './utils/constants.js';\nexport {\n\tDEEP_SCALAR,\n\tFLOAT_SCALAR,\n\tGAS_BUDGET,\n\tMAX_TIMESTAMP,\n\tPOOL_CREATION_FEE,\n\tPRICE_INFO_OBJECT_MAX_AGE,\n} from './utils/config.js';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,oBAA+B;AAC/B,oBAA+B;AAG/B,4BAAuC;AACvC,sBAAiC;AACjC,2BAAsC;AACtC,wBAAkC;AAClC,wBAAmC;AAGnC,yBAAoC;AACpC,8BAAyC;AACzC,2BAAsC;AACtC,wBAAmC;AACnC,uBAAkC;AAGlC,kBAAyD;AAGzD,iBAAiE;AA+BjE,mBAA+C;AAI/C,IAAAA,iBAOO;",
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n// Main client and configuration\nexport { DeepBookClient } from './client.js';\nexport { DeepBookConfig } from './utils/config.js';\n\n// Core contract classes\nexport { BalanceManagerContract } from './transactions/balanceManager.js';\nexport { DeepBookContract } from './transactions/deepbook.js';\nexport { DeepBookAdminContract } from './transactions/deepbookAdmin.js';\nexport { FlashLoanContract } from './transactions/flashLoans.js';\nexport { GovernanceContract } from './transactions/governance.js';\n\n// Margin trading contracts\nexport { MarginAdminContract } from './transactions/marginAdmin.js';\nexport { MarginMaintainerContract } from './transactions/marginMaintainer.js';\nexport { MarginManagerContract } from './transactions/marginManager.js';\nexport { MarginPoolContract } from './transactions/marginPool.js';\nexport { PoolProxyContract } from './transactions/poolProxy.js';\n\n// Pyth price feed integration\nexport { SuiPythClient, SuiPriceServiceConnection } from './pyth/pyth.js';\n\n// BCS types for parsing on-chain data\nexport { Account, Balances, Order, OrderDeepPrice, VecSet } from './types/bcs.js';\n\n// TypeScript interfaces and types\nexport type {\n\tBalanceManager,\n\tCoin,\n\tPool,\n\tMarginManager,\n\tMarginPool,\n\tEnvironment,\n\tConfig,\n} from './types/index.js';\n\n// Trading parameter interfaces\nexport type {\n\tPlaceLimitOrderParams,\n\tPlaceMarketOrderParams,\n\tPlaceMarginLimitOrderParams,\n\tPlaceMarginMarketOrderParams,\n\tSwapParams,\n\tProposalParams,\n\tMarginProposalParams,\n\tCreatePoolAdminParams,\n\tCreatePermissionlessPoolParams,\n\tSetEwmaParams,\n\tPoolConfigParams,\n\tMarginPoolConfigParams,\n\tInterestConfigParams,\n} from './types/index.js';\n\n// Enums for trading\nexport { OrderType, SelfMatchingOptions } from './types/index.js';\n\n// Constants and configuration maps\nexport type { CoinMap, PoolMap, MarginPoolMap } from './utils/constants.js';\nexport {\n\tDEEP_SCALAR,\n\tFLOAT_SCALAR,\n\tGAS_BUDGET,\n\tMAX_TIMESTAMP,\n\tPOOL_CREATION_FEE_DEEP,\n\tPRICE_INFO_OBJECT_MAX_AGE_MS,\n} from './utils/config.js';\n\n// Error handling utilities\nexport {\n\tDeepBookError,\n\tResourceNotFoundError,\n\tConfigurationError,\n\tValidationError,\n\tErrorMessages,\n} from './utils/errors.js';\n\n// Validation utilities\nexport {\n\tvalidateRequired,\n\tvalidateAddress,\n\tvalidatePositiveNumber,\n\tvalidateNonNegativeNumber,\n\tvalidateRange,\n\tvalidateNonEmptyArray,\n} from './utils/validation.js';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,oBAA+B;AAC/B,oBAA+B;AAG/B,4BAAuC;AACvC,sBAAiC;AACjC,2BAAsC;AACtC,wBAAkC;AAClC,wBAAmC;AAGnC,yBAAoC;AACpC,8BAAyC;AACzC,2BAAsC;AACtC,wBAAmC;AACnC,uBAAkC;AAGlC,kBAAyD;AAGzD,iBAAiE;AA+BjE,mBAA+C;AAI/C,IAAAA,iBAOO;AAGP,oBAMO;AAGP,wBAOO;",
6
6
  "names": ["import_config"]
7
7
  }
@@ -1,5 +1,5 @@
1
1
  import type { Transaction } from '@mysten/sui/transactions';
2
- import type { CreatePermissionlessPoolParams, PlaceLimitOrderParams, PlaceMarketOrderParams, SwapParams } from '../types/index.js';
2
+ import type { CanPlaceLimitOrderParams, CanPlaceMarketOrderParams, CreatePermissionlessPoolParams, PlaceLimitOrderParams, PlaceMarketOrderParams, SwapParams, SwapWithManagerParams } from '../types/index.js';
3
3
  import type { DeepBookConfig } from '../utils/config.js';
4
4
  /**
5
5
  * DeepBookContract class for managing DeepBook operations.
@@ -39,6 +39,14 @@ export declare class DeepBookContract {
39
39
  * @returns A function that takes a Transaction object
40
40
  */
41
41
  cancelOrder: (poolKey: string, balanceManagerKey: string, orderId: string) => (tx: Transaction) => void;
42
+ /**
43
+ * @description Cancel multiple orders
44
+ * @param {string} poolKey The key to identify the pool
45
+ * @param {string} balanceManagerKey The key to identify the BalanceManager
46
+ * @param {string[]} orderIds Array of order IDs to cancel
47
+ * @returns A function that takes a Transaction object
48
+ */
49
+ cancelOrders: (poolKey: string, balanceManagerKey: string, orderIds: string[]) => (tx: Transaction) => void;
42
50
  /**
43
51
  * @description Cancel all open orders for a balance manager
44
52
  * @param {string} poolKey The key to identify the pool
@@ -53,6 +61,13 @@ export declare class DeepBookContract {
53
61
  * @returns A function that takes a Transaction object
54
62
  */
55
63
  withdrawSettledAmounts: (poolKey: string, balanceManagerKey: string) => (tx: Transaction) => void;
64
+ /**
65
+ * @description Withdraw settled amounts permissionlessly for a balance manager
66
+ * @param {string} poolKey The key to identify the pool
67
+ * @param {string} balanceManagerKey The key to identify the BalanceManager
68
+ * @returns A function that takes a Transaction object
69
+ */
70
+ withdrawSettledAmountsPermissionless: (poolKey: string, balanceManagerKey: string) => (tx: Transaction) => void;
56
71
  /**
57
72
  * @description Add a deep price point for a target pool using a reference pool
58
73
  * @param {string} targetPoolKey The key to identify the target pool
@@ -227,6 +242,61 @@ export declare class DeepBookContract {
227
242
  $kind: "NestedResult";
228
243
  NestedResult: [number, number];
229
244
  }];
245
+ /**
246
+ * @description Swap exact quantity without a balance manager
247
+ * @param {SwapParams & {isBaseToCoin: boolean}} params Parameters for the swap
248
+ * @returns A function that takes a Transaction object
249
+ */
250
+ swapExactQuantity: (params: SwapParams & {
251
+ isBaseToCoin: boolean;
252
+ }) => (tx: Transaction) => readonly [{
253
+ $kind: "NestedResult";
254
+ NestedResult: [number, number];
255
+ }, {
256
+ $kind: "NestedResult";
257
+ NestedResult: [number, number];
258
+ }, {
259
+ $kind: "NestedResult";
260
+ NestedResult: [number, number];
261
+ }];
262
+ /**
263
+ * @description Swap exact base for quote with a balance manager
264
+ * @param {SwapWithManagerParams} params Parameters for the swap
265
+ * @returns A function that takes a Transaction object
266
+ */
267
+ swapExactBaseForQuoteWithManager: (params: SwapWithManagerParams) => (tx: Transaction) => readonly [{
268
+ $kind: "NestedResult";
269
+ NestedResult: [number, number];
270
+ }, {
271
+ $kind: "NestedResult";
272
+ NestedResult: [number, number];
273
+ }];
274
+ /**
275
+ * @description Swap exact quote for base with a balance manager
276
+ * @param {SwapWithManagerParams} params Parameters for the swap
277
+ * @returns A function that takes a Transaction object
278
+ */
279
+ swapExactQuoteForBaseWithManager: (params: SwapWithManagerParams) => (tx: Transaction) => readonly [{
280
+ $kind: "NestedResult";
281
+ NestedResult: [number, number];
282
+ }, {
283
+ $kind: "NestedResult";
284
+ NestedResult: [number, number];
285
+ }];
286
+ /**
287
+ * @description Swap exact quantity (base or quote) with a balance manager
288
+ * @param {SwapWithManagerParams & {isBaseToCoin: boolean}} params Parameters for the swap
289
+ * @returns A function that takes a Transaction object
290
+ */
291
+ swapExactQuantityWithManager: (params: SwapWithManagerParams & {
292
+ isBaseToCoin: boolean;
293
+ }) => (tx: Transaction) => readonly [{
294
+ $kind: "NestedResult";
295
+ NestedResult: [number, number];
296
+ }, {
297
+ $kind: "NestedResult";
298
+ NestedResult: [number, number];
299
+ }];
230
300
  /**
231
301
  * @description Create a new pool permissionlessly
232
302
  * @param {CreatePermissionlessPoolParams} params Parameters for creating permissionless pool
@@ -278,4 +348,122 @@ export declare class DeepBookContract {
278
348
  * @returns A function that takes a Transaction object
279
349
  */
280
350
  getReferralBalances: (poolKey: string, referral: string) => (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
351
+ /**
352
+ * @description Check if a pool is a stable pool
353
+ * @param {string} poolKey The key to identify the pool
354
+ * @returns A function that takes a Transaction object
355
+ */
356
+ stablePool: (poolKey: string) => (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
357
+ /**
358
+ * @description Check if a pool is registered
359
+ * @param {string} poolKey The key to identify the pool
360
+ * @returns A function that takes a Transaction object
361
+ */
362
+ registeredPool: (poolKey: string) => (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
363
+ /**
364
+ * @description Get the quote quantity out for a given base quantity using input token as fee
365
+ * @param {string} poolKey The key to identify the pool
366
+ * @param {number} baseQuantity Base quantity to convert
367
+ * @returns A function that takes a Transaction object
368
+ */
369
+ getQuoteQuantityOutInputFee: (poolKey: string, baseQuantity: number) => (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
370
+ /**
371
+ * @description Get the base quantity out for a given quote quantity using input token as fee
372
+ * @param {string} poolKey The key to identify the pool
373
+ * @param {number} quoteQuantity Quote quantity to convert
374
+ * @returns A function that takes a Transaction object
375
+ */
376
+ getBaseQuantityOutInputFee: (poolKey: string, quoteQuantity: number) => (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
377
+ /**
378
+ * @description Get the quantity out for a given base or quote quantity using input token as fee
379
+ * @param {string} poolKey The key to identify the pool
380
+ * @param {number} baseQuantity Base quantity to convert
381
+ * @param {number} quoteQuantity Quote quantity to convert
382
+ * @returns A function that takes a Transaction object
383
+ */
384
+ getQuantityOutInputFee: (poolKey: string, baseQuantity: number, quoteQuantity: number) => (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
385
+ /**
386
+ * @description Get the base quantity needed to receive a target quote quantity
387
+ * @param {string} poolKey The key to identify the pool
388
+ * @param {number} targetQuoteQuantity Target quote quantity
389
+ * @param {boolean} payWithDeep Whether to pay fees with DEEP
390
+ * @returns A function that takes a Transaction object
391
+ */
392
+ getBaseQuantityIn: (poolKey: string, targetQuoteQuantity: number, payWithDeep: boolean) => (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
393
+ /**
394
+ * @description Get the quote quantity needed to receive a target base quantity
395
+ * @param {string} poolKey The key to identify the pool
396
+ * @param {number} targetBaseQuantity Target base quantity
397
+ * @param {boolean} payWithDeep Whether to pay fees with DEEP
398
+ * @returns A function that takes a Transaction object
399
+ */
400
+ getQuoteQuantityIn: (poolKey: string, targetBaseQuantity: number, payWithDeep: boolean) => (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
401
+ /**
402
+ * @description Get account order details for a balance manager
403
+ * @param {string} poolKey The key to identify the pool
404
+ * @param {string} managerKey Key of the balance manager
405
+ * @returns A function that takes a Transaction object
406
+ */
407
+ getAccountOrderDetails: (poolKey: string, managerKey: string) => (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
408
+ /**
409
+ * @description Get the DEEP required for an order
410
+ * @param {string} poolKey The key to identify the pool
411
+ * @param {number} baseQuantity Base quantity
412
+ * @param {number} price Price
413
+ * @returns A function that takes a Transaction object
414
+ */
415
+ getOrderDeepRequired: (poolKey: string, baseQuantity: number, price: number) => (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
416
+ /**
417
+ * @description Check if account exists for a balance manager
418
+ * @param {string} poolKey The key to identify the pool
419
+ * @param {string} managerKey Key of the balance manager
420
+ * @returns A function that takes a Transaction object
421
+ */
422
+ accountExists: (poolKey: string, managerKey: string) => (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
423
+ /**
424
+ * @description Get the next epoch trade parameters for a pool
425
+ * @param {string} poolKey The key to identify the pool
426
+ * @returns A function that takes a Transaction object
427
+ */
428
+ poolTradeParamsNext: (poolKey: string) => (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
429
+ /**
430
+ * @description Get the quorum for a pool
431
+ * @param {string} poolKey The key to identify the pool
432
+ * @returns A function that takes a Transaction object
433
+ */
434
+ quorum: (poolKey: string) => (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
435
+ /**
436
+ * @description Get the pool ID
437
+ * @param {string} poolKey The key to identify the pool
438
+ * @returns A function that takes a Transaction object
439
+ */
440
+ poolId: (poolKey: string) => (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
441
+ /**
442
+ * @description Check if a limit order can be placed
443
+ * @param {CanPlaceLimitOrderParams} params Parameters for checking limit order validity
444
+ * @returns A function that takes a Transaction object
445
+ */
446
+ canPlaceLimitOrder: (params: CanPlaceLimitOrderParams) => (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
447
+ /**
448
+ * @description Check if a market order can be placed
449
+ * @param {CanPlaceMarketOrderParams} params Parameters for checking market order validity
450
+ * @returns A function that takes a Transaction object
451
+ */
452
+ canPlaceMarketOrder: (params: CanPlaceMarketOrderParams) => (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
453
+ /**
454
+ * @description Check if market order params are valid
455
+ * @param {string} poolKey The key to identify the pool
456
+ * @param {number} quantity Quantity
457
+ * @returns A function that takes a Transaction object
458
+ */
459
+ checkMarketOrderParams: (poolKey: string, quantity: number) => (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
460
+ /**
461
+ * @description Check if limit order params are valid
462
+ * @param {string} poolKey The key to identify the pool
463
+ * @param {number} price Price
464
+ * @param {number} quantity Quantity
465
+ * @param {number} expireTimestamp Expiration timestamp
466
+ * @returns A function that takes a Transaction object
467
+ */
468
+ checkLimitOrderParams: (poolKey: string, price: number, quantity: number, expireTimestamp: number) => (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
281
469
  }