@mysten/deepbook-v3 0.0.0-experimental-20240730220552

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 (78) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +201 -0
  3. package/README.md +1 -0
  4. package/dist/cjs/client.d.ts +177 -0
  5. package/dist/cjs/client.js +387 -0
  6. package/dist/cjs/client.js.map +7 -0
  7. package/dist/cjs/index.d.ts +7 -0
  8. package/dist/cjs/index.js +37 -0
  9. package/dist/cjs/index.js.map +7 -0
  10. package/dist/cjs/package.json +4 -0
  11. package/dist/cjs/transactions/balanceManager.d.ts +80 -0
  12. package/dist/cjs/transactions/balanceManager.js +185 -0
  13. package/dist/cjs/transactions/balanceManager.js.map +7 -0
  14. package/dist/cjs/transactions/deepbook.d.ts +183 -0
  15. package/dist/cjs/transactions/deepbook.js +545 -0
  16. package/dist/cjs/transactions/deepbook.js.map +7 -0
  17. package/dist/cjs/transactions/deepbookAdmin.d.ts +43 -0
  18. package/dist/cjs/transactions/deepbookAdmin.js +159 -0
  19. package/dist/cjs/transactions/deepbookAdmin.js.map +7 -0
  20. package/dist/cjs/transactions/flashLoans.d.ts +56 -0
  21. package/dist/cjs/transactions/flashLoans.js +122 -0
  22. package/dist/cjs/transactions/flashLoans.js.map +7 -0
  23. package/dist/cjs/transactions/governance.d.ts +42 -0
  24. package/dist/cjs/transactions/governance.js +131 -0
  25. package/dist/cjs/transactions/governance.js.map +7 -0
  26. package/dist/cjs/types/index.d.ts +80 -0
  27. package/dist/cjs/types/index.js +38 -0
  28. package/dist/cjs/types/index.js.map +7 -0
  29. package/dist/cjs/utils/config.d.ts +38 -0
  30. package/dist/cjs/utils/config.js +103 -0
  31. package/dist/cjs/utils/config.js.map +7 -0
  32. package/dist/cjs/utils/constants.d.ts +22 -0
  33. package/dist/cjs/utils/constants.js +117 -0
  34. package/dist/cjs/utils/constants.js.map +7 -0
  35. package/dist/esm/client.d.ts +177 -0
  36. package/dist/esm/client.js +367 -0
  37. package/dist/esm/client.js.map +7 -0
  38. package/dist/esm/index.d.ts +7 -0
  39. package/dist/esm/index.js +17 -0
  40. package/dist/esm/index.js.map +7 -0
  41. package/dist/esm/package.json +4 -0
  42. package/dist/esm/transactions/balanceManager.d.ts +80 -0
  43. package/dist/esm/transactions/balanceManager.js +165 -0
  44. package/dist/esm/transactions/balanceManager.js.map +7 -0
  45. package/dist/esm/transactions/deepbook.d.ts +183 -0
  46. package/dist/esm/transactions/deepbook.js +525 -0
  47. package/dist/esm/transactions/deepbook.js.map +7 -0
  48. package/dist/esm/transactions/deepbookAdmin.d.ts +43 -0
  49. package/dist/esm/transactions/deepbookAdmin.js +139 -0
  50. package/dist/esm/transactions/deepbookAdmin.js.map +7 -0
  51. package/dist/esm/transactions/flashLoans.d.ts +56 -0
  52. package/dist/esm/transactions/flashLoans.js +102 -0
  53. package/dist/esm/transactions/flashLoans.js.map +7 -0
  54. package/dist/esm/transactions/governance.d.ts +42 -0
  55. package/dist/esm/transactions/governance.js +111 -0
  56. package/dist/esm/transactions/governance.js.map +7 -0
  57. package/dist/esm/types/index.d.ts +80 -0
  58. package/dist/esm/types/index.js +18 -0
  59. package/dist/esm/types/index.js.map +7 -0
  60. package/dist/esm/utils/config.d.ts +38 -0
  61. package/dist/esm/utils/config.js +90 -0
  62. package/dist/esm/utils/config.js.map +7 -0
  63. package/dist/esm/utils/constants.d.ts +22 -0
  64. package/dist/esm/utils/constants.js +97 -0
  65. package/dist/esm/utils/constants.js.map +7 -0
  66. package/dist/tsconfig.esm.tsbuildinfo +1 -0
  67. package/dist/tsconfig.tsbuildinfo +1 -0
  68. package/package.json +52 -0
  69. package/src/client.ts +429 -0
  70. package/src/index.ts +10 -0
  71. package/src/transactions/balanceManager.ts +182 -0
  72. package/src/transactions/deepbook.ts +587 -0
  73. package/src/transactions/deepbookAdmin.ts +140 -0
  74. package/src/transactions/flashLoans.ts +121 -0
  75. package/src/transactions/governance.ts +119 -0
  76. package/src/types/index.ts +98 -0
  77. package/src/utils/config.ts +103 -0
  78. package/src/utils/constants.ts +106 -0
@@ -0,0 +1,185 @@
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 __typeError = (msg) => {
7
+ throw TypeError(msg);
8
+ };
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
23
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
24
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
25
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
26
+ var balanceManager_exports = {};
27
+ __export(balanceManager_exports, {
28
+ BalanceManagerContract: () => BalanceManagerContract
29
+ });
30
+ module.exports = __toCommonJS(balanceManager_exports);
31
+ var import_transactions = require("@mysten/sui/transactions");
32
+ var _config;
33
+ class BalanceManagerContract {
34
+ /**
35
+ * @param {DeepBookConfig} config Configuration for BalanceManagerContract
36
+ */
37
+ constructor(config) {
38
+ __privateAdd(this, _config);
39
+ /**
40
+ * @description Create and share a new BalanceManager
41
+ * @returns A function that takes a Transaction object
42
+ */
43
+ this.createAndShareBalanceManager = () => (tx) => {
44
+ const manager = tx.moveCall({
45
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::new`
46
+ });
47
+ tx.moveCall({
48
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::share`,
49
+ arguments: [manager]
50
+ });
51
+ };
52
+ /**
53
+ * @description Deposit funds into the BalanceManager
54
+ * @param {string} managerKey The key of the BalanceManager
55
+ * @param {string} coinKey The key of the coin to deposit
56
+ * @param {number} amountToDeposit The amount to deposit
57
+ * @returns A function that takes a Transaction object
58
+ */
59
+ this.depositIntoManager = (managerKey, coinKey, amountToDeposit) => (tx) => {
60
+ tx.setSenderIfNotSet(__privateGet(this, _config).address);
61
+ const managerId = __privateGet(this, _config).getBalanceManager(managerKey).address;
62
+ const coin = __privateGet(this, _config).getCoin(coinKey);
63
+ const deposit = (0, import_transactions.coinWithBalance)({
64
+ type: coin.type,
65
+ balance: amountToDeposit * coin.scalar
66
+ });
67
+ tx.moveCall({
68
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::deposit`,
69
+ arguments: [tx.object(managerId), deposit],
70
+ typeArguments: [coin.type]
71
+ });
72
+ };
73
+ /**
74
+ * @description Withdraw funds from the BalanceManager
75
+ * @param {string} managerKey The key of the BalanceManager
76
+ * @param {string} coinKey The key of the coin to withdraw
77
+ * @param {number} amountToWithdraw The amount to withdraw
78
+ * @param {string} recipient The recipient of the withdrawn funds
79
+ * @returns A function that takes a Transaction object
80
+ */
81
+ this.withdrawFromManager = (managerKey, coinKey, amountToWithdraw, recipient) => (tx) => {
82
+ const managerId = __privateGet(this, _config).getBalanceManager(managerKey).address;
83
+ const coin = __privateGet(this, _config).getCoin(coinKey);
84
+ const coinObject = tx.moveCall({
85
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::withdraw`,
86
+ arguments: [tx.object(managerId), tx.pure.u64(amountToWithdraw * coin.scalar)],
87
+ typeArguments: [coin.type]
88
+ });
89
+ tx.transferObjects([coinObject], recipient);
90
+ };
91
+ /**
92
+ * @description Withdraw all funds from the BalanceManager
93
+ * @param {string} managerKey The key of the BalanceManager
94
+ * @param {string} coinKey The key of the coin to withdraw
95
+ * @param {string} recipient The recipient of the withdrawn funds
96
+ * @returns A function that takes a Transaction object
97
+ */
98
+ this.withdrawAllFromManager = (managerKey, coinKey, recipient) => (tx) => {
99
+ const managerId = __privateGet(this, _config).getBalanceManager(managerKey).address;
100
+ const coin = __privateGet(this, _config).getCoin(coinKey);
101
+ const withdrawalCoin = tx.moveCall({
102
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::withdraw_all`,
103
+ arguments: [tx.object(managerId)],
104
+ typeArguments: [coin.type]
105
+ });
106
+ tx.transferObjects([withdrawalCoin], recipient);
107
+ };
108
+ /**
109
+ * @description Check the balance of the BalanceManager
110
+ * @param {string} managerKey The key of the BalanceManager
111
+ * @param {string} coinKey The key of the coin to check the balance of
112
+ * @returns A function that takes a Transaction object
113
+ */
114
+ this.checkManagerBalance = (managerKey, coinKey) => (tx) => {
115
+ const managerId = __privateGet(this, _config).getBalanceManager(managerKey).address;
116
+ const coin = __privateGet(this, _config).getCoin(coinKey);
117
+ tx.moveCall({
118
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::balance`,
119
+ arguments: [tx.object(managerId)],
120
+ typeArguments: [coin.type]
121
+ });
122
+ };
123
+ /**
124
+ * @description Generate a trade proof for the BalanceManager. Calls the appropriate function based on whether tradeCap is set.
125
+ * @param {string} managerKey The key of the BalanceManager
126
+ * @returns A function that takes a Transaction object
127
+ */
128
+ this.generateProof = (managerKey) => (tx) => {
129
+ const balanceManager = __privateGet(this, _config).getBalanceManager(managerKey);
130
+ return tx.add(
131
+ balanceManager.tradeCap ? this.generateProofAsTrader(balanceManager.address, balanceManager.tradeCap) : this.generateProofAsOwner(balanceManager.address)
132
+ );
133
+ };
134
+ /**
135
+ * @description Generate a trade proof as the owner
136
+ * @param {string} managerId The ID of the BalanceManager
137
+ * @returns A function that takes a Transaction object
138
+ */
139
+ this.generateProofAsOwner = (managerId) => (tx) => {
140
+ return tx.moveCall({
141
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::generate_proof_as_owner`,
142
+ arguments: [tx.object(managerId)]
143
+ });
144
+ };
145
+ /**
146
+ * @description Generate a trade proof as a trader
147
+ * @param {string} managerId The ID of the BalanceManager
148
+ * @param {string} tradeCapId The ID of the tradeCap
149
+ * @returns A function that takes a Transaction object
150
+ */
151
+ this.generateProofAsTrader = (managerId, tradeCapId) => (tx) => {
152
+ return tx.moveCall({
153
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::generate_proof_as_trader`,
154
+ arguments: [tx.object(managerId), tx.object(tradeCapId)]
155
+ });
156
+ };
157
+ /**
158
+ * @description Get the owner of the BalanceManager
159
+ * @param {string} managerKey The key of the BalanceManager
160
+ * @returns A function that takes a Transaction object
161
+ */
162
+ this.owner = (managerKey) => (tx) => {
163
+ const managerId = __privateGet(this, _config).getBalanceManager(managerKey).address;
164
+ tx.moveCall({
165
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::owner`,
166
+ arguments: [tx.object(managerId)]
167
+ });
168
+ };
169
+ /**
170
+ * @description Get the ID of the BalanceManager
171
+ * @param {string} managerKey The key of the BalanceManager
172
+ * @returns A function that takes a Transaction object
173
+ */
174
+ this.id = (managerKey) => (tx) => {
175
+ const managerId = __privateGet(this, _config).getBalanceManager(managerKey).address;
176
+ tx.moveCall({
177
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::id`,
178
+ arguments: [tx.object(managerId)]
179
+ });
180
+ };
181
+ __privateSet(this, _config, config);
182
+ }
183
+ }
184
+ _config = new WeakMap();
185
+ //# sourceMappingURL=balanceManager.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/transactions/balanceManager.ts"],
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { coinWithBalance } from '@mysten/sui/transactions';\nimport type { Transaction } from '@mysten/sui/transactions';\n\nimport type { DeepBookConfig } from '../utils/config.js';\n\n/**\n * BalanceManagerContract class for managing BalanceManager operations.\n */\nexport class BalanceManagerContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for BalanceManagerContract\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t/**\n\t * @description Create and share a new BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tcreateAndShareBalanceManager = () => (tx: Transaction) => {\n\t\tconst manager = tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::new`,\n\t\t});\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::share`,\n\t\t\targuments: [manager],\n\t\t});\n\t};\n\n\t/**\n\t * @description Deposit funds into the BalanceManager\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @param {string} coinKey The key of the coin to deposit\n\t * @param {number} amountToDeposit The amount to deposit\n\t * @returns A function that takes a Transaction object\n\t */\n\tdepositIntoManager =\n\t\t(managerKey: string, coinKey: string, amountToDeposit: number) => (tx: Transaction) => {\n\t\t\ttx.setSenderIfNotSet(this.#config.address);\n\t\t\tconst managerId = this.#config.getBalanceManager(managerKey).address;\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\tconst deposit = coinWithBalance({\n\t\t\t\ttype: coin.type,\n\t\t\t\tbalance: amountToDeposit * coin.scalar,\n\t\t\t});\n\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::deposit`,\n\t\t\t\targuments: [tx.object(managerId), deposit],\n\t\t\t\ttypeArguments: [coin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Withdraw funds from the BalanceManager\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @param {string} coinKey The key of the coin to withdraw\n\t * @param {number} amountToWithdraw The amount to withdraw\n\t * @param {string} recipient The recipient of the withdrawn funds\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawFromManager =\n\t\t(managerKey: string, coinKey: string, amountToWithdraw: number, recipient: string) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst managerId = this.#config.getBalanceManager(managerKey).address;\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\tconst coinObject = tx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::withdraw`,\n\t\t\t\targuments: [tx.object(managerId), tx.pure.u64(amountToWithdraw * coin.scalar)],\n\t\t\t\ttypeArguments: [coin.type],\n\t\t\t});\n\n\t\t\ttx.transferObjects([coinObject], recipient);\n\t\t};\n\n\t/**\n\t * @description Withdraw all funds from the BalanceManager\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @param {string} coinKey The key of the coin to withdraw\n\t * @param {string} recipient The recipient of the withdrawn funds\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawAllFromManager =\n\t\t(managerKey: string, coinKey: string, recipient: string) => (tx: Transaction) => {\n\t\t\tconst managerId = this.#config.getBalanceManager(managerKey).address;\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\tconst withdrawalCoin = tx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::withdraw_all`,\n\t\t\t\targuments: [tx.object(managerId)],\n\t\t\t\ttypeArguments: [coin.type],\n\t\t\t});\n\n\t\t\ttx.transferObjects([withdrawalCoin], recipient);\n\t\t};\n\n\t/**\n\t * @description Check the balance of the BalanceManager\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @param {string} coinKey The key of the coin to check the balance of\n\t * @returns A function that takes a Transaction object\n\t */\n\tcheckManagerBalance = (managerKey: string, coinKey: string) => (tx: Transaction) => {\n\t\tconst managerId = this.#config.getBalanceManager(managerKey).address;\n\t\tconst coin = this.#config.getCoin(coinKey);\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::balance`,\n\t\t\targuments: [tx.object(managerId)],\n\t\t\ttypeArguments: [coin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Generate a trade proof for the BalanceManager. Calls the appropriate function based on whether tradeCap is set.\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tgenerateProof = (managerKey: string) => (tx: Transaction) => {\n\t\tconst balanceManager = this.#config.getBalanceManager(managerKey);\n\t\treturn tx.add(\n\t\t\tbalanceManager.tradeCap\n\t\t\t\t? this.generateProofAsTrader(balanceManager.address, balanceManager.tradeCap)\n\t\t\t\t: this.generateProofAsOwner(balanceManager.address),\n\t\t);\n\t};\n\n\t/**\n\t * @description Generate a trade proof as the owner\n\t * @param {string} managerId The ID of the BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tgenerateProofAsOwner = (managerId: string) => (tx: Transaction) => {\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::generate_proof_as_owner`,\n\t\t\targuments: [tx.object(managerId)],\n\t\t});\n\t};\n\n\t/**\n\t * @description Generate a trade proof as a trader\n\t * @param {string} managerId The ID of the BalanceManager\n\t * @param {string} tradeCapId The ID of the tradeCap\n\t * @returns A function that takes a Transaction object\n\t */\n\tgenerateProofAsTrader = (managerId: string, tradeCapId: string) => (tx: Transaction) => {\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::generate_proof_as_trader`,\n\t\t\targuments: [tx.object(managerId), tx.object(tradeCapId)],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the owner of the BalanceManager\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\towner = (managerKey: string) => (tx: Transaction) => {\n\t\tconst managerId = this.#config.getBalanceManager(managerKey).address;\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::owner`,\n\t\t\targuments: [tx.object(managerId)],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the ID of the BalanceManager\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tid = (managerKey: string) => (tx: Transaction) => {\n\t\tconst managerId = this.#config.getBalanceManager(managerKey).address;\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::id`,\n\t\t\targuments: [tx.object(managerId)],\n\t\t});\n\t};\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,0BAAgC;AAFhC;AAUO,MAAM,uBAAuB;AAAA;AAAA;AAAA;AAAA,EAMnC,YAAY,QAAwB;AALpC;AAaA;AAAA;AAAA;AAAA;AAAA,wCAA+B,MAAM,CAAC,OAAoB;AACzD,YAAM,UAAU,GAAG,SAAS;AAAA,QAC3B,QAAQ,GAAG,mBAAK,SAAQ,mBAAmB;AAAA,MAC5C,CAAC;AAED,SAAG,SAAS;AAAA,QACX,QAAQ,GAAG,mBAAK,SAAQ,mBAAmB;AAAA,QAC3C,WAAW,CAAC,OAAO;AAAA,MACpB,CAAC;AAAA,IACF;AASA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BACC,CAAC,YAAoB,SAAiB,oBAA4B,CAAC,OAAoB;AACtF,SAAG,kBAAkB,mBAAK,SAAQ,OAAO;AACzC,YAAM,YAAY,mBAAK,SAAQ,kBAAkB,UAAU,EAAE;AAC7D,YAAM,OAAO,mBA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AE;AAC7D,SAAG,SAAS;AAAA,QACX,QAAQ,GAAG,mBAAK,SAAQ,mBAAmB;AAAA,QAC3C,WAAW,CAAC,GAAG,OAAO,SAAS,CAAC;AAAA,MACjC,CAAC;AAAA,IACF;AAOA;AAAA;AAAA;AAAA;AAAA;AAAA,cAAK,CAAC,eAAuB,CAAC,OAAoB;AACjD,YAAM,YAAY,mBAAK,SAAQ,kBAAkB,UAAU,EAAE;AAC7D,SAAG,SAAS;AAAA,QACX,QAAQ,GAAG,mBAAK,SAAQ,mBAAmB;AAAA,QAC3C,WAAW,CAAC,GAAG,OAAO,SAAS,CAAC;AAAA,MACjC,CAAC;AAAA,IACF;AAnKC,uBAAK,SAAU;AAAA,EAChB;AAmKD;AA1KC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,183 @@
1
+ import type { Transaction } from '@mysten/sui/transactions';
2
+ import type { PlaceLimitOrderParams, PlaceMarketOrderParams, SwapParams } from '../types/index.js';
3
+ import type { DeepBookConfig } from '../utils/config.js';
4
+ /**
5
+ * DeepBookContract class for managing DeepBook operations.
6
+ */
7
+ export declare class DeepBookContract {
8
+ #private;
9
+ /**
10
+ * @param {DeepBookConfig} config Configuration for DeepBookContract
11
+ */
12
+ constructor(config: DeepBookConfig);
13
+ /**
14
+ * @description Place a limit order
15
+ * @param {PlaceLimitOrderParams} params Parameters for placing a limit order
16
+ * @returns A function that takes a Transaction object
17
+ */
18
+ placeLimitOrder: (params: PlaceLimitOrderParams) => (tx: Transaction) => void;
19
+ /**
20
+ * @description Place a market order
21
+ * @param {PlaceMarketOrderParams} params Parameters for placing a market order
22
+ * @returns A function that takes a Transaction object
23
+ */
24
+ placeMarketOrder: (params: PlaceMarketOrderParams) => (tx: Transaction) => void;
25
+ /**
26
+ * @description Modify an existing order
27
+ * @param {string} poolKey The key to identify the pool
28
+ * @param {string} balanceManagerKey The key to identify the BalanceManager
29
+ * @param {string} orderId Order ID to modify
30
+ * @param {number} newQuantity New quantity for the order
31
+ * @returns A function that takes a Transaction object
32
+ */
33
+ modifyOrder: (poolKey: string, balanceManagerKey: string, orderId: string, newQuantity: number) => (tx: Transaction) => void;
34
+ /**
35
+ * @description Cancel an existing order
36
+ * @param {string} poolKey The key to identify the pool
37
+ * @param {string} balanceManagerKey The key to identify the BalanceManager
38
+ * @param {string} orderId Order ID to cancel
39
+ * @returns A function that takes a Transaction object
40
+ */
41
+ cancelOrder: (poolKey: string, balanceManagerKey: string, orderId: string) => (tx: Transaction) => void;
42
+ /**
43
+ * @description Cancel all open orders for a balance manager
44
+ * @param {string} poolKey The key to identify the pool
45
+ * @param {string} balanceManagerKey The key to identify the BalanceManager
46
+ * @returns A function that takes a Transaction object
47
+ */
48
+ cancelAllOrders: (poolKey: string, balanceManagerKey: string) => (tx: Transaction) => void;
49
+ /**
50
+ * @description Withdraw settled amounts for a balance manager
51
+ * @param {string} poolKey The key to identify the pool
52
+ * @param {string} balanceManagerKey The key to identify the BalanceManager
53
+ * @returns A function that takes a Transaction object
54
+ */
55
+ withdrawSettledAmounts: (poolKey: string, balanceManagerKey: string) => (tx: Transaction) => void;
56
+ /**
57
+ * @description Add a deep price point for a target pool using a reference pool
58
+ * @param {string} targetPoolKey The key to identify the target pool
59
+ * @param {string} referencePoolKey The key to identify the reference pool
60
+ * @returns A function that takes a Transaction object
61
+ */
62
+ addDeepPricePoint: (targetPoolKey: string, referencePoolKey: string) => (tx: Transaction) => void;
63
+ /**
64
+ * @description Claim rebates for a balance manager
65
+ * @param {string} poolKey The key to identify the pool
66
+ * @param {string} balanceManagerKey The key to identify the BalanceManager
67
+ * @returns A function that takes a Transaction object
68
+ */
69
+ claimRebates: (poolKey: string, balanceManagerKey: string) => (tx: Transaction) => void;
70
+ /**
71
+ * @description Gets an order
72
+ * @param {string} poolKey The key to identify the pool
73
+ * @param {string} orderId Order ID to get
74
+ * @returns A function that takes a Transaction object
75
+ */
76
+ getOrder: (poolKey: string, orderId: string) => (tx: Transaction) => void;
77
+ /**
78
+ * @description Burn DEEP tokens from the pool
79
+ * @param {string} poolKey The key to identify the pool
80
+ * @returns A function that takes a Transaction object
81
+ */
82
+ burnDeep: (poolKey: string) => (tx: Transaction) => void;
83
+ /**
84
+ * @description Get the mid price for a pool
85
+ * @param {string} poolKey The key to identify the pool
86
+ * @returns A function that takes a Transaction object
87
+ */
88
+ midPrice: (poolKey: string) => (tx: Transaction) => void;
89
+ /**
90
+ * @description Check if a pool is whitelisted
91
+ * @param {string} poolKey The key to identify the pool
92
+ * @returns A function that takes a Transaction object
93
+ */
94
+ whitelisted: (poolKey: string) => (tx: Transaction) => void;
95
+ /**
96
+ * @description Get the quote quantity out for a given base quantity in
97
+ * @param {string} poolKey The key to identify the pool
98
+ * @param {number} baseQuantity Base quantity to convert
99
+ * @returns A function that takes a Transaction object
100
+ */
101
+ getQuoteQuantityOut: (poolKey: string, baseQuantity: number) => (tx: Transaction) => void;
102
+ /**
103
+ * @description Get the base quantity out for a given quote quantity in
104
+ * @param {string} poolKey The key to identify the pool
105
+ * @param {number} quoteQuantity Quote quantity to convert
106
+ * @returns A function that takes a Transaction object
107
+ */
108
+ getBaseQuantityOut: (poolKey: string, quoteQuantity: number) => (tx: Transaction) => void;
109
+ /**
110
+ * @description Get the quantity out for a given base or quote quantity
111
+ * @param {string} poolKey The key to identify the pool
112
+ * @param {number} baseQuantity Base quantity to convert
113
+ * @param {number} quoteQuantity Quote quantity to convert
114
+ * @returns A function that takes a Transaction object
115
+ */
116
+ getQuantityOut: (poolKey: string, baseQuantity: number, quoteQuantity: number) => (tx: Transaction) => void;
117
+ /**
118
+ * @description Get open orders for a balance manager in a pool
119
+ * @param {string} poolKey The key to identify the pool
120
+ * @param {string} managerKey Key of the balance manager
121
+ * @returns A function that takes a Transaction object
122
+ */
123
+ accountOpenOrders: (poolKey: string, managerKey: string) => (tx: Transaction) => void;
124
+ /**
125
+ * @description Get level 2 order book specifying range of price
126
+ * @param {string} poolKey The key to identify the pool
127
+ * @param {number} priceLow Lower bound of the price range
128
+ * @param {number} priceHigh Upper bound of the price range
129
+ * @param {boolean} isBid Whether to get bid or ask orders
130
+ * @returns A function that takes a Transaction object
131
+ */
132
+ getLevel2Range: (poolKey: string, priceLow: number, priceHigh: number, isBid: boolean) => (tx: Transaction) => void;
133
+ /**
134
+ * @description Get level 2 order book ticks from mid-price for a pool
135
+ * @param {string} poolKey The key to identify the pool
136
+ * @param {number} tickFromMid Number of ticks from mid-price
137
+ * @returns A function that takes a Transaction object
138
+ */
139
+ getLevel2TicksFromMid: (poolKey: string, tickFromMid: number) => (tx: Transaction) => void;
140
+ /**
141
+ * @description Get the vault balances for a pool
142
+ * @param {string} poolKey The key to identify the pool
143
+ * @returns A function that takes a Transaction object
144
+ */
145
+ vaultBalances: (poolKey: string) => (tx: Transaction) => void;
146
+ /**
147
+ * @description Get the pool ID by asset types
148
+ * @param {string} baseType Type of the base asset
149
+ * @param {string} quoteType Type of the quote asset
150
+ * @returns A function that takes a Transaction object
151
+ */
152
+ getPoolIdByAssets: (baseType: string, quoteType: string) => (tx: Transaction) => void;
153
+ /**
154
+ * @description Swap exact base amount for quote amount
155
+ * @param {SwapParams} params Parameters for the swap
156
+ * @returns A function that takes a Transaction object
157
+ */
158
+ swapExactBaseForQuote: (params: SwapParams) => (tx: Transaction) => readonly [{
159
+ $kind: "NestedResult";
160
+ NestedResult: [number, number];
161
+ }, {
162
+ $kind: "NestedResult";
163
+ NestedResult: [number, number];
164
+ }, {
165
+ $kind: "NestedResult";
166
+ NestedResult: [number, number];
167
+ }];
168
+ /**
169
+ * @description Swap exact quote amount for base amount
170
+ * @param {SwapParams} params Parameters for the swap
171
+ * @returns A function that takes a Transaction object
172
+ */
173
+ swapExactQuoteForBase: (params: SwapParams) => (tx: Transaction) => readonly [{
174
+ $kind: "NestedResult";
175
+ NestedResult: [number, number];
176
+ }, {
177
+ $kind: "NestedResult";
178
+ NestedResult: [number, number];
179
+ }, {
180
+ $kind: "NestedResult";
181
+ NestedResult: [number, number];
182
+ }];
183
+ }