@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,545 @@
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 deepbook_exports = {};
27
+ __export(deepbook_exports, {
28
+ DeepBookContract: () => DeepBookContract
29
+ });
30
+ module.exports = __toCommonJS(deepbook_exports);
31
+ var import_transactions = require("@mysten/sui/transactions");
32
+ var import_utils = require("@mysten/sui/utils");
33
+ var import_types = require("../types/index.js");
34
+ var import_config = require("../utils/config.js");
35
+ var _config;
36
+ class DeepBookContract {
37
+ /**
38
+ * @param {DeepBookConfig} config Configuration for DeepBookContract
39
+ */
40
+ constructor(config) {
41
+ __privateAdd(this, _config);
42
+ /**
43
+ * @description Place a limit order
44
+ * @param {PlaceLimitOrderParams} params Parameters for placing a limit order
45
+ * @returns A function that takes a Transaction object
46
+ */
47
+ this.placeLimitOrder = (params) => (tx) => {
48
+ const {
49
+ poolKey,
50
+ balanceManagerKey,
51
+ clientOrderId,
52
+ price,
53
+ quantity,
54
+ isBid,
55
+ expiration = import_config.MAX_TIMESTAMP,
56
+ orderType = import_types.OrderType.NO_RESTRICTION,
57
+ selfMatchingOption = import_types.SelfMatchingOptions.SELF_MATCHING_ALLOWED,
58
+ payWithDeep = true
59
+ } = params;
60
+ tx.setGasBudgetIfNotSet(import_config.GAS_BUDGET);
61
+ const pool = __privateGet(this, _config).getPool(poolKey);
62
+ const balanceManager = __privateGet(this, _config).getBalanceManager(balanceManagerKey);
63
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
64
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
65
+ const inputPrice = price * import_config.FLOAT_SCALAR * quoteCoin.scalar / baseCoin.scalar;
66
+ const inputQuantity = quantity * baseCoin.scalar;
67
+ const tradeProof = tx.add(__privateGet(this, _config).balanceManager.generateProof(balanceManagerKey));
68
+ tx.moveCall({
69
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::place_limit_order`,
70
+ arguments: [
71
+ tx.object(pool.address),
72
+ tx.object(balanceManager.address),
73
+ tradeProof,
74
+ tx.pure.u64(clientOrderId),
75
+ tx.pure.u8(orderType),
76
+ tx.pure.u8(selfMatchingOption),
77
+ tx.pure.u64(inputPrice),
78
+ tx.pure.u64(inputQuantity),
79
+ tx.pure.bool(isBid),
80
+ tx.pure.bool(payWithDeep),
81
+ tx.pure.u64(expiration),
82
+ tx.object(import_utils.SUI_CLOCK_OBJECT_ID)
83
+ ],
84
+ typeArguments: [baseCoin.type, quoteCoin.type]
85
+ });
86
+ };
87
+ /**
88
+ * @description Place a market order
89
+ * @param {PlaceMarketOrderParams} params Parameters for placing a market order
90
+ * @returns A function that takes a Transaction object
91
+ */
92
+ this.placeMarketOrder = (params) => (tx) => {
93
+ const {
94
+ poolKey,
95
+ balanceManagerKey,
96
+ clientOrderId,
97
+ quantity,
98
+ isBid,
99
+ selfMatchingOption = import_types.SelfMatchingOptions.SELF_MATCHING_ALLOWED,
100
+ payWithDeep = true
101
+ } = params;
102
+ tx.setGasBudgetIfNotSet(import_config.GAS_BUDGET);
103
+ const pool = __privateGet(this, _config).getPool(poolKey);
104
+ const balanceManager = __privateGet(this, _config).getBalanceManager(balanceManagerKey);
105
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
106
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
107
+ const tradeProof = tx.add(__privateGet(this, _config).balanceManager.generateProof(balanceManagerKey));
108
+ tx.moveCall({
109
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::place_market_order`,
110
+ arguments: [
111
+ tx.object(pool.address),
112
+ tx.object(balanceManager.address),
113
+ tradeProof,
114
+ tx.pure.u64(clientOrderId),
115
+ tx.pure.u8(selfMatchingOption),
116
+ tx.pure.u64(quantity * baseCoin.scalar),
117
+ tx.pure.bool(isBid),
118
+ tx.pure.bool(payWithDeep),
119
+ tx.object(import_utils.SUI_CLOCK_OBJECT_ID)
120
+ ],
121
+ typeArguments: [baseCoin.type, quoteCoin.type]
122
+ });
123
+ };
124
+ /**
125
+ * @description Modify an existing order
126
+ * @param {string} poolKey The key to identify the pool
127
+ * @param {string} balanceManagerKey The key to identify the BalanceManager
128
+ * @param {string} orderId Order ID to modify
129
+ * @param {number} newQuantity New quantity for the order
130
+ * @returns A function that takes a Transaction object
131
+ */
132
+ this.modifyOrder = (poolKey, balanceManagerKey, orderId, newQuantity) => (tx) => {
133
+ const pool = __privateGet(this, _config).getPool(poolKey);
134
+ const balanceManager = __privateGet(this, _config).getBalanceManager(balanceManagerKey);
135
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
136
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
137
+ const tradeProof = tx.add(__privateGet(this, _config).balanceManager.generateProof(balanceManagerKey));
138
+ tx.moveCall({
139
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::modify_order`,
140
+ arguments: [
141
+ tx.object(pool.address),
142
+ tx.object(balanceManager.address),
143
+ tradeProof,
144
+ tx.pure.u128(orderId),
145
+ tx.pure.u64(newQuantity),
146
+ tx.object(import_utils.SUI_CLOCK_OBJECT_ID)
147
+ ],
148
+ typeArguments: [baseCoin.type, quoteCoin.type]
149
+ });
150
+ };
151
+ /**
152
+ * @description Cancel an existing order
153
+ * @param {string} poolKey The key to identify the pool
154
+ * @param {string} balanceManagerKey The key to identify the BalanceManager
155
+ * @param {string} orderId Order ID to cancel
156
+ * @returns A function that takes a Transaction object
157
+ */
158
+ this.cancelOrder = (poolKey, balanceManagerKey, orderId) => (tx) => {
159
+ tx.setGasBudgetIfNotSet(import_config.GAS_BUDGET);
160
+ const pool = __privateGet(this, _config).getPool(poolKey);
161
+ const balanceManager = __privateGet(this, _config).getBalanceManager(balanceManagerKey);
162
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
163
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
164
+ const tradeProof = tx.add(__privateGet(this, _config).balanceManager.generateProof(balanceManagerKey));
165
+ tx.moveCall({
166
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::cancel_order`,
167
+ arguments: [
168
+ tx.object(pool.address),
169
+ tx.object(balanceManager.address),
170
+ tradeProof,
171
+ tx.pure.u128(orderId),
172
+ tx.object(import_utils.SUI_CLOCK_OBJECT_ID)
173
+ ],
174
+ typeArguments: [baseCoin.type, quoteCoin.type]
175
+ });
176
+ };
177
+ /**
178
+ * @description Cancel all open orders for a balance manager
179
+ * @param {string} poolKey The key to identify the pool
180
+ * @param {string} balanceManagerKey The key to identify the BalanceManager
181
+ * @returns A function that takes a Transaction object
182
+ */
183
+ this.cancelAllOrders = (poolKey, balanceManagerKey) => (tx) => {
184
+ tx.setGasBudgetIfNotSet(import_config.GAS_BUDGET);
185
+ const pool = __privateGet(this, _config).getPool(poolKey);
186
+ const balanceManager = __privateGet(this, _config).getBalanceManager(balanceManagerKey);
187
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
188
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
189
+ const tradeProof = tx.add(__privateGet(this, _config).balanceManager.generateProof(balanceManagerKey));
190
+ tx.moveCall({
191
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::cancel_all_orders`,
192
+ arguments: [
193
+ tx.object(pool.address),
194
+ tx.object(balanceManager.address),
195
+ tradeProof,
196
+ tx.object(import_utils.SUI_CLOCK_OBJECT_ID)
197
+ ],
198
+ typeArguments: [baseCoin.type, quoteCoin.type]
199
+ });
200
+ };
201
+ /**
202
+ * @description Withdraw settled amounts for a balance manager
203
+ * @param {string} poolKey The key to identify the pool
204
+ * @param {string} balanceManagerKey The key to identify the BalanceManager
205
+ * @returns A function that takes a Transaction object
206
+ */
207
+ this.withdrawSettledAmounts = (poolKey, balanceManagerKey) => (tx) => {
208
+ const pool = __privateGet(this, _config).getPool(poolKey);
209
+ const balanceManager = __privateGet(this, _config).getBalanceManager(balanceManagerKey);
210
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
211
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
212
+ const tradeProof = tx.add(__privateGet(this, _config).balanceManager.generateProof(balanceManagerKey));
213
+ tx.moveCall({
214
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::withdraw_settled_amounts`,
215
+ arguments: [tx.object(pool.address), tx.object(balanceManager.address), tradeProof],
216
+ typeArguments: [baseCoin.type, quoteCoin.type]
217
+ });
218
+ };
219
+ /**
220
+ * @description Add a deep price point for a target pool using a reference pool
221
+ * @param {string} targetPoolKey The key to identify the target pool
222
+ * @param {string} referencePoolKey The key to identify the reference pool
223
+ * @returns A function that takes a Transaction object
224
+ */
225
+ this.addDeepPricePoint = (targetPoolKey, referencePoolKey) => (tx) => {
226
+ const targetPool = __privateGet(this, _config).getPool(targetPoolKey);
227
+ const referencePool = __privateGet(this, _config).getPool(referencePoolKey);
228
+ const targetBaseCoin = __privateGet(this, _config).getCoin(targetPool.baseCoin);
229
+ const targetQuoteCoin = __privateGet(this, _config).getCoin(targetPool.quoteCoin);
230
+ const referenceBaseCoin = __privateGet(this, _config).getCoin(referencePool.baseCoin);
231
+ const referenceQuoteCoin = __privateGet(this, _config).getCoin(referencePool.quoteCoin);
232
+ tx.moveCall({
233
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::add_deep_price_point`,
234
+ arguments: [
235
+ tx.object(targetPool.address),
236
+ tx.object(referencePool.address),
237
+ tx.object(import_utils.SUI_CLOCK_OBJECT_ID)
238
+ ],
239
+ typeArguments: [
240
+ targetBaseCoin.type,
241
+ targetQuoteCoin.type,
242
+ referenceBaseCoin.type,
243
+ referenceQuoteCoin.type
244
+ ]
245
+ });
246
+ };
247
+ /**
248
+ * @description Claim rebates for a balance manager
249
+ * @param {string} poolKey The key to identify the pool
250
+ * @param {string} balanceManagerKey The key to identify the BalanceManager
251
+ * @returns A function that takes a Transaction object
252
+ */
253
+ this.claimRebates = (poolKey, balanceManagerKey) => (tx) => {
254
+ const pool = __privateGet(this, _config).getPool(poolKey);
255
+ const balanceManager = __privateGet(this, _config).getBalanceManager(balanceManagerKey);
256
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
257
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
258
+ const tradeProof = tx.add(__privateGet(this, _config).balanceManager.generateProof(balanceManagerKey));
259
+ tx.moveCall({
260
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::claim_rebates`,
261
+ arguments: [tx.object(pool.address), tx.object(balanceManager.address), tradeProof],
262
+ typeArguments: [baseCoin.type, quoteCoin.type]
263
+ });
264
+ };
265
+ /**
266
+ * @description Gets an order
267
+ * @param {string} poolKey The key to identify the pool
268
+ * @param {string} orderId Order ID to get
269
+ * @returns A function that takes a Transaction object
270
+ */
271
+ this.getOrder = (poolKey, orderId) => (tx) => {
272
+ const pool = __privateGet(this, _config).getPool(poolKey);
273
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
274
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
275
+ tx.moveCall({
276
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::get_order`,
277
+ arguments: [tx.object(pool.address), tx.pure.u128(orderId)],
278
+ typeArguments: [baseCoin.type, quoteCoin.type]
279
+ });
280
+ };
281
+ /**
282
+ * @description Burn DEEP tokens from the pool
283
+ * @param {string} poolKey The key to identify the pool
284
+ * @returns A function that takes a Transaction object
285
+ */
286
+ this.burnDeep = (poolKey) => (tx) => {
287
+ const pool = __privateGet(this, _config).getPool(poolKey);
288
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
289
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
290
+ tx.moveCall({
291
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::burn_deep`,
292
+ arguments: [tx.object(pool.address), tx.object(__privateGet(this, _config).DEEP_TREASURY_ID)],
293
+ typeArguments: [baseCoin.type, quoteCoin.type]
294
+ });
295
+ };
296
+ /**
297
+ * @description Get the mid price for a pool
298
+ * @param {string} poolKey The key to identify the pool
299
+ * @returns A function that takes a Transaction object
300
+ */
301
+ this.midPrice = (poolKey) => (tx) => {
302
+ const pool = __privateGet(this, _config).getPool(poolKey);
303
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
304
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
305
+ tx.moveCall({
306
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::mid_price`,
307
+ arguments: [tx.object(pool.address), tx.object(import_utils.SUI_CLOCK_OBJECT_ID)],
308
+ typeArguments: [baseCoin.type, quoteCoin.type]
309
+ });
310
+ };
311
+ /**
312
+ * @description Check if a pool is whitelisted
313
+ * @param {string} poolKey The key to identify the pool
314
+ * @returns A function that takes a Transaction object
315
+ */
316
+ this.whitelisted = (poolKey) => (tx) => {
317
+ const pool = __privateGet(this, _config).getPool(poolKey);
318
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
319
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
320
+ tx.moveCall({
321
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::whitelisted`,
322
+ arguments: [tx.object(pool.address)],
323
+ typeArguments: [baseCoin.type, quoteCoin.type]
324
+ });
325
+ };
326
+ /**
327
+ * @description Get the quote quantity out for a given base quantity in
328
+ * @param {string} poolKey The key to identify the pool
329
+ * @param {number} baseQuantity Base quantity to convert
330
+ * @returns A function that takes a Transaction object
331
+ */
332
+ this.getQuoteQuantityOut = (poolKey, baseQuantity) => (tx) => {
333
+ const pool = __privateGet(this, _config).getPool(poolKey);
334
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
335
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
336
+ tx.moveCall({
337
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::get_quote_quantity_out`,
338
+ arguments: [
339
+ tx.object(pool.address),
340
+ tx.pure.u64(baseQuantity * baseCoin.scalar),
341
+ tx.object(import_utils.SUI_CLOCK_OBJECT_ID)
342
+ ],
343
+ typeArguments: [baseCoin.type, quoteCoin.type]
344
+ });
345
+ };
346
+ /**
347
+ * @description Get the base quantity out for a given quote quantity in
348
+ * @param {string} poolKey The key to identify the pool
349
+ * @param {number} quoteQuantity Quote quantity to convert
350
+ * @returns A function that takes a Transaction object
351
+ */
352
+ this.getBaseQuantityOut = (poolKey, quoteQuantity) => (tx) => {
353
+ const pool = __privateGet(this, _config).getPool(poolKey);
354
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
355
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
356
+ const quoteScalar = quoteCoin.scalar;
357
+ tx.moveCall({
358
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::get_base_quantity_out`,
359
+ arguments: [
360
+ tx.object(pool.address),
361
+ tx.pure.u64(quoteQuantity * quoteScalar),
362
+ tx.object(import_utils.SUI_CLOCK_OBJECT_ID)
363
+ ],
364
+ typeArguments: [baseCoin.type, quoteCoin.type]
365
+ });
366
+ };
367
+ /**
368
+ * @description Get the quantity out for a given base or quote quantity
369
+ * @param {string} poolKey The key to identify the pool
370
+ * @param {number} baseQuantity Base quantity to convert
371
+ * @param {number} quoteQuantity Quote quantity to convert
372
+ * @returns A function that takes a Transaction object
373
+ */
374
+ this.getQuantityOut = (poolKey, baseQuantity, quoteQuantity) => (tx) => {
375
+ const pool = __privateGet(this, _config).getPool(poolKey);
376
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
377
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
378
+ const quoteScalar = quoteCoin.scalar;
379
+ tx.moveCall({
380
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::get_quantity_out`,
381
+ arguments: [
382
+ tx.object(pool.address),
383
+ tx.pure.u64(baseQuantity * baseCoin.scalar),
384
+ tx.pure.u64(quoteQuantity * quoteScalar),
385
+ tx.object(import_utils.SUI_CLOCK_OBJECT_ID)
386
+ ],
387
+ typeArguments: [baseCoin.type, quoteCoin.type]
388
+ });
389
+ };
390
+ /**
391
+ * @description Get open orders for a balance manager in a pool
392
+ * @param {string} poolKey The key to identify the pool
393
+ * @param {string} managerKey Key of the balance manager
394
+ * @returns A function that takes a Transaction object
395
+ */
396
+ this.accountOpenOrders = (poolKey, managerKey) => (tx) => {
397
+ const pool = __privateGet(this, _config).getPool(poolKey);
398
+ const manager = __privateGet(this, _config).getBalanceManager(managerKey);
399
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
400
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
401
+ tx.moveCall({
402
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::account_open_orders`,
403
+ arguments: [tx.object(pool.address), tx.object(manager.address)],
404
+ typeArguments: [baseCoin.type, quoteCoin.type]
405
+ });
406
+ };
407
+ /**
408
+ * @description Get level 2 order book specifying range of price
409
+ * @param {string} poolKey The key to identify the pool
410
+ * @param {number} priceLow Lower bound of the price range
411
+ * @param {number} priceHigh Upper bound of the price range
412
+ * @param {boolean} isBid Whether to get bid or ask orders
413
+ * @returns A function that takes a Transaction object
414
+ */
415
+ this.getLevel2Range = (poolKey, priceLow, priceHigh, isBid) => (tx) => {
416
+ const pool = __privateGet(this, _config).getPool(poolKey);
417
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
418
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
419
+ tx.moveCall({
420
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::get_level2_range`,
421
+ arguments: [
422
+ tx.object(pool.address),
423
+ tx.pure.u64(priceLow * import_config.FLOAT_SCALAR * quoteCoin.scalar / baseCoin.scalar),
424
+ tx.pure.u64(priceHigh * import_config.FLOAT_SCALAR * quoteCoin.scalar / baseCoin.scalar),
425
+ tx.pure.bool(isBid),
426
+ tx.object(import_utils.SUI_CLOCK_OBJECT_ID)
427
+ ],
428
+ typeArguments: [baseCoin.type, quoteCoin.type]
429
+ });
430
+ };
431
+ /**
432
+ * @description Get level 2 order book ticks from mid-price for a pool
433
+ * @param {string} poolKey The key to identify the pool
434
+ * @param {number} tickFromMid Number of ticks from mid-price
435
+ * @returns A function that takes a Transaction object
436
+ */
437
+ this.getLevel2TicksFromMid = (poolKey, tickFromMid) => (tx) => {
438
+ const pool = __privateGet(this, _config).getPool(poolKey);
439
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
440
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
441
+ tx.moveCall({
442
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::get_level2_ticks_from_mid`,
443
+ arguments: [
444
+ tx.object(pool.address),
445
+ tx.pure.u64(tickFromMid),
446
+ tx.object(import_utils.SUI_CLOCK_OBJECT_ID)
447
+ ],
448
+ typeArguments: [baseCoin.type, quoteCoin.type]
449
+ });
450
+ };
451
+ /**
452
+ * @description Get the vault balances for a pool
453
+ * @param {string} poolKey The key to identify the pool
454
+ * @returns A function that takes a Transaction object
455
+ */
456
+ this.vaultBalances = (poolKey) => (tx) => {
457
+ const pool = __privateGet(this, _config).getPool(poolKey);
458
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
459
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
460
+ tx.moveCall({
461
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::vault_balances`,
462
+ arguments: [tx.object(pool.address)],
463
+ typeArguments: [baseCoin.type, quoteCoin.type]
464
+ });
465
+ };
466
+ /**
467
+ * @description Get the pool ID by asset types
468
+ * @param {string} baseType Type of the base asset
469
+ * @param {string} quoteType Type of the quote asset
470
+ * @returns A function that takes a Transaction object
471
+ */
472
+ this.getPoolIdByAssets = (baseType, quoteType) => (tx) => {
473
+ tx.moveCall({
474
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::get_pool_id_by_asset`,
475
+ arguments: [tx.object(__privateGet(this, _config).REGISTRY_ID)],
476
+ typeArguments: [baseType, quoteType]
477
+ });
478
+ };
479
+ /**
480
+ * @description Swap exact base amount for quote amount
481
+ * @param {SwapParams} params Parameters for the swap
482
+ * @returns A function that takes a Transaction object
483
+ */
484
+ this.swapExactBaseForQuote = (params) => (tx) => {
485
+ tx.setGasBudgetIfNotSet(import_config.GAS_BUDGET);
486
+ tx.setSenderIfNotSet(__privateGet(this, _config).address);
487
+ if (params.quoteCoin) {
488
+ throw new Error("quoteCoin is not accepted for swapping base asset");
489
+ }
490
+ const { poolKey, amount: baseAmount, deepAmount, minOut: minQuote } = params;
491
+ let pool = __privateGet(this, _config).getPool(poolKey);
492
+ let deepCoinType = __privateGet(this, _config).getCoin("DEEP").type;
493
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
494
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
495
+ const baseCoinInput = params.baseCoin ?? (0, import_transactions.coinWithBalance)({ type: baseCoin.type, balance: baseAmount * baseCoin.scalar });
496
+ const deepCoin = params.deepCoin ?? (0, import_transactions.coinWithBalance)({ type: deepCoinType, balance: deepAmount * import_config.DEEP_SCALAR });
497
+ const [baseCoinResult, quoteCoinResult, deepCoinResult] = tx.moveCall({
498
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::swap_exact_base_for_quote`,
499
+ arguments: [
500
+ tx.object(pool.address),
501
+ baseCoinInput,
502
+ deepCoin,
503
+ tx.pure.u64(quoteCoin.scalar * minQuote),
504
+ tx.object(import_utils.SUI_CLOCK_OBJECT_ID)
505
+ ],
506
+ typeArguments: [baseCoin.type, quoteCoin.type]
507
+ });
508
+ return [baseCoinResult, quoteCoinResult, deepCoinResult];
509
+ };
510
+ /**
511
+ * @description Swap exact quote amount for base amount
512
+ * @param {SwapParams} params Parameters for the swap
513
+ * @returns A function that takes a Transaction object
514
+ */
515
+ this.swapExactQuoteForBase = (params) => (tx) => {
516
+ tx.setGasBudgetIfNotSet(import_config.GAS_BUDGET);
517
+ tx.setSenderIfNotSet(__privateGet(this, _config).address);
518
+ if (params.baseCoin) {
519
+ throw new Error("baseCoin is not accepted for swapping quote asset");
520
+ }
521
+ const { poolKey, amount: quoteAmount, deepAmount, minOut: minBase } = params;
522
+ let pool = __privateGet(this, _config).getPool(poolKey);
523
+ let deepCoinType = __privateGet(this, _config).getCoin("DEEP").type;
524
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
525
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
526
+ const quoteCoinInput = params.quoteCoin ?? (0, import_transactions.coinWithBalance)({ type: quoteCoin.type, balance: quoteAmount * quoteCoin.scalar });
527
+ const deepCoin = params.deepCoin ?? (0, import_transactions.coinWithBalance)({ type: deepCoinType, balance: deepAmount * import_config.DEEP_SCALAR });
528
+ const [baseCoinResult, quoteCoinResult, deepCoinResult] = tx.moveCall({
529
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::swap_exact_quote_for_base`,
530
+ arguments: [
531
+ tx.object(pool.address),
532
+ quoteCoinInput,
533
+ deepCoin,
534
+ tx.pure.u64(baseCoin.scalar * minBase),
535
+ tx.object(import_utils.SUI_CLOCK_OBJECT_ID)
536
+ ],
537
+ typeArguments: [baseCoin.type, quoteCoin.type]
538
+ });
539
+ return [baseCoinResult, quoteCoinResult, deepCoinResult];
540
+ };
541
+ __privateSet(this, _config, config);
542
+ }
543
+ }
544
+ _config = new WeakMap();
545
+ //# sourceMappingURL=deepbook.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/transactions/deepbook.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';\nimport { SUI_CLOCK_OBJECT_ID } from '@mysten/sui/utils';\n\nimport { OrderType, SelfMatchingOptions } from '../types/index.js';\nimport type { PlaceLimitOrderParams, PlaceMarketOrderParams, SwapParams } from '../types/index.js';\nimport type { DeepBookConfig } from '../utils/config.js';\nimport { DEEP_SCALAR, FLOAT_SCALAR, GAS_BUDGET, MAX_TIMESTAMP } from '../utils/config.js';\n\n/**\n * DeepBookContract class for managing DeepBook operations.\n */\nexport class DeepBookContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for DeepBookContract\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t/**\n\t * @description Place a limit order\n\t * @param {PlaceLimitOrderParams} params Parameters for placing a limit order\n\t * @returns A function that takes a Transaction object\n\t */\n\tplaceLimitOrder = (params: PlaceLimitOrderParams) => (tx: Transaction) => {\n\t\tconst {\n\t\t\tpoolKey,\n\t\t\tbalanceManagerKey,\n\t\t\tclientOrderId,\n\t\t\tprice,\n\t\t\tquantity,\n\t\t\tisBid,\n\t\t\texpiration = MAX_TIMESTAMP,\n\t\t\torderType = OrderType.NO_RESTRICTION,\n\t\t\tselfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,\n\t\t\tpayWithDeep = true,\n\t\t} = params;\n\n\t\ttx.setGasBudgetIfNotSet(GAS_BUDGET);\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst balanceManager = this.#config.getBalanceManager(balanceManagerKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst inputPrice = (price * FLOAT_SCALAR * quoteCoin.scalar) / baseCoin.scalar;\n\t\tconst inputQuantity = quantity * baseCoin.scalar;\n\n\t\tconst tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::place_limit_order`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.object(balanceManager.address),\n\t\t\t\ttradeProof,\n\t\t\t\ttx.pure.u64(clientOrderId),\n\t\t\t\ttx.pure.u8(orderType),\n\t\t\t\ttx.pure.u8(selfMatchingOption),\n\t\t\t\ttx.pure.u64(inputPrice),\n\t\t\t\ttx.pure.u64(inputQuantity),\n\t\t\t\ttx.pure.bool(isBid),\n\t\t\t\ttx.pure.bool(payWithDeep),\n\t\t\t\ttx.pure.u64(expiration),\n\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Place a market order\n\t * @param {PlaceMarketOrderParams} params Parameters for placing a market order\n\t * @returns A function that takes a Transaction object\n\t */\n\tplaceMarketOrder = (params: PlaceMarketOrderParams) => (tx: Transaction) => {\n\t\tconst {\n\t\t\tpoolKey,\n\t\t\tbalanceManagerKey,\n\t\t\tclientOrderId,\n\t\t\tquantity,\n\t\t\tisBid,\n\t\t\tselfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,\n\t\t\tpayWithDeep = true,\n\t\t} = params;\n\n\t\ttx.setGasBudgetIfNotSet(GAS_BUDGET);\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst balanceManager = this.#config.getBalanceManager(balanceManagerKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::place_market_order`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.object(balanceManager.address),\n\t\t\t\ttradeProof,\n\t\t\t\ttx.pure.u64(clientOrderId),\n\t\t\t\ttx.pure.u8(selfMatchingOption),\n\t\t\t\ttx.pure.u64(quantity * baseCoin.scalar),\n\t\t\t\ttx.pure.bool(isBid),\n\t\t\t\ttx.pure.bool(payWithDeep),\n\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Modify an existing order\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} balanceManagerKey The key to identify the BalanceManager\n\t * @param {string} orderId Order ID to modify\n\t * @param {number} newQuantity New quantity for the order\n\t * @returns A function that takes a Transaction object\n\t */\n\tmodifyOrder =\n\t\t(poolKey: string, balanceManagerKey: string, orderId: string, newQuantity: number) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst balanceManager = this.#config.getBalanceManager(balanceManagerKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));\n\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::modify_order`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(pool.address),\n\t\t\t\t\ttx.object(balanceManager.address),\n\t\t\t\t\ttradeProof,\n\t\t\t\t\ttx.pure.u128(orderId),\n\t\t\t\t\ttx.pure.u64(newQuantity),\n\t\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Cancel an existing order\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} balanceManagerKey The key to identify the BalanceManager\n\t * @param {string} orderId Order ID to cancel\n\t * @returns A function that takes a Transaction object\n\t */\n\tcancelOrder =\n\t\t(poolKey: string, balanceManagerKey: string, orderId: string) => (tx: Transaction) => {\n\t\t\ttx.setGasBudgetIfNotSet(GAS_BUDGET);\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst balanceManager = this.#config.getBalanceManager(balanceManagerKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));\n\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::cancel_order`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(pool.address),\n\t\t\t\t\ttx.object(balanceManager.address),\n\t\t\t\t\ttradeProof,\n\t\t\t\t\ttx.pure.u128(orderId),\n\t\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Cancel all open orders for a balance manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} balanceManagerKey The key to identify the BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tcancelAllOrders = (poolKey: string, balanceManagerKey: string) => (tx: Transaction) => {\n\t\ttx.setGasBudgetIfNotSet(GAS_BUDGET);\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst balanceManager = this.#config.getBalanceManager(balanceManagerKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::cancel_all_orders`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.object(balanceManager.address),\n\t\t\t\ttradeProof,\n\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Withdraw settled amounts for a balance manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} balanceManagerKey The key to identify the BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawSettledAmounts = (poolKey: string, balanceManagerKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst balanceManager = this.#config.getBalanceManager(balanceManagerKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::withdraw_settled_amounts`,\n\t\t\targuments: [tx.object(pool.address), tx.object(balanceManager.address), tradeProof],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Add a deep price point for a target pool using a reference pool\n\t * @param {string} targetPoolKey The key to identify the target pool\n\t * @param {string} referencePoolKey The key to identify the reference pool\n\t * @returns A function that takes a Transaction object\n\t */\n\taddDeepPricePoint = (targetPoolKey: string, referencePoolKey: string) => (tx: Transaction) => {\n\t\tconst targetPool = this.#config.getPool(targetPoolKey);\n\t\tconst referencePool = this.#config.getPool(referencePoolKey);\n\t\tconst targetBaseCoin = this.#config.getCoin(targetPool.baseCoin);\n\t\tconst targetQuoteCoin = this.#config.getCoin(targetPool.quoteCoin);\n\t\tconst referenceBaseCoin = this.#config.getCoin(referencePool.baseCoin);\n\t\tconst referenceQuoteCoin = this.#config.getCoin(referencePool.quoteCoin);\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::add_deep_price_point`,\n\t\t\targuments: [\n\t\t\t\ttx.object(targetPool.address),\n\t\t\t\ttx.object(referencePool.address),\n\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t],\n\t\t\ttypeArguments: [\n\t\t\t\ttargetBaseCoin.type,\n\t\t\t\ttargetQuoteCoin.type,\n\t\t\t\treferenceBaseCoin.type,\n\t\t\t\treferenceQuoteCoin.type,\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @description Claim rebates for a balance manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} balanceManagerKey The key to identify the BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tclaimRebates = (poolKey: string, balanceManagerKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst balanceManager = this.#config.getBalanceManager(balanceManagerKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::claim_rebates`,\n\t\t\targuments: [tx.object(pool.address), tx.object(balanceManager.address), tradeProof],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Gets an order\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} orderId Order ID to get\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetOrder = (poolKey: string, orderId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_order`,\n\t\t\targuments: [tx.object(pool.address), tx.pure.u128(orderId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Burn DEEP tokens from the pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tburnDeep = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::burn_deep`,\n\t\t\targuments: [tx.object(pool.address), tx.object(this.#config.DEEP_TREASURY_ID)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the mid price for a pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tmidPrice = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::mid_price`,\n\t\t\targuments: [tx.object(pool.address), tx.object(SUI_CLOCK_OBJECT_ID)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Check if a pool is whitelisted\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\twhitelisted = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::whitelisted`,\n\t\t\targuments: [tx.object(pool.address)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the quote quantity out for a given base quantity in\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} baseQuantity Base quantity to convert\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetQuoteQuantityOut = (poolKey: string, baseQuantity: number) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_quote_quantity_out`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.pure.u64(baseQuantity * baseCoin.scalar),\n\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the base quantity out for a given quote quantity in\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} quoteQuantity Quote quantity to convert\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetBaseQuantityOut = (poolKey: string, quoteQuantity: number) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst quoteScalar = quoteCoin.scalar;\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_base_quantity_out`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.pure.u64(quoteQuantity * quoteScalar),\n\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the quantity out for a given base or quote quantity\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} baseQuantity Base quantity to convert\n\t * @param {number} quoteQuantity Quote quantity to convert\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetQuantityOut =\n\t\t(poolKey: string, baseQuantity: number, quoteQuantity: number) => (tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst quoteScalar = quoteCoin.scalar;\n\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_quantity_out`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(pool.address),\n\t\t\t\t\ttx.pure.u64(baseQuantity * baseCoin.scalar),\n\t\t\t\t\ttx.pure.u64(quoteQuantity * quoteScalar),\n\t\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Get open orders for a balance manager in a pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} managerKey Key of the balance manager\n\t * @returns A function that takes a Transaction object\n\t */\n\taccountOpenOrders = (poolKey: string, managerKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst manager = this.#config.getBalanceManager(managerKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::account_open_orders`,\n\t\t\targuments: [tx.object(pool.address), tx.object(manager.address)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get level 2 order book specifying range of price\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} priceLow Lower bound of the price range\n\t * @param {number} priceHigh Upper bound of the price range\n\t * @param {boolean} isBid Whether to get bid or ask orders\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetLevel2Range =\n\t\t(poolKey: string, priceLow: number, priceHigh: number, isBid: boolean) => (tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_level2_range`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(pool.address),\n\t\t\t\t\ttx.pure.u64((priceLow * FLOAT_SCALAR * quoteCoin.scalar) / baseCoin.scalar),\n\t\t\t\t\ttx.pure.u64((priceHigh * FLOAT_SCALAR * quoteCoin.scalar) / baseCoin.scalar),\n\t\t\t\t\ttx.pure.bool(isBid),\n\t\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Get level 2 order book ticks from mid-price for a pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} tickFromMid Number of ticks from mid-price\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetLevel2TicksFromMid = (poolKey: string, tickFromMid: number) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_level2_ticks_from_mid`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.pure.u64(tickFromMid),\n\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the vault balances for a pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tvaultBalances = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::vault_balances`,\n\t\t\targuments: [tx.object(pool.address)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the pool ID by asset types\n\t * @param {string} baseType Type of the base asset\n\t * @param {string} quoteType Type of the quote asset\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetPoolIdByAssets = (baseType: string, quoteType: string) => (tx: Transaction) => {\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_pool_id_by_asset`,\n\t\t\targuments: [tx.object(this.#config.REGISTRY_ID)],\n\t\t\ttypeArguments: [baseType, quoteType],\n\t\t});\n\t};\n\n\t/**\n\t * @description Swap exact base amount for quote amount\n\t * @param {SwapParams} params Parameters for the swap\n\t * @returns A function that takes a Transaction object\n\t */\n\tswapExactBaseForQuote = (params: SwapParams) => (tx: Transaction) => {\n\t\ttx.setGasBudgetIfNotSet(GAS_BUDGET);\n\t\ttx.setSenderIfNotSet(this.#config.address);\n\n\t\tif (params.quoteCoin) {\n\t\t\tthrow new Error('quoteCoin is not accepted for swapping base asset');\n\t\t}\n\t\tconst { poolKey, amount: baseAmount, deepAmount, minOut: minQuote } = params;\n\n\t\tlet pool = this.#config.getPool(poolKey);\n\t\tlet deepCoinType = this.#config.getCoin('DEEP').type;\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\tconst baseCoinInput =\n\t\t\tparams.baseCoin ??\n\t\t\tcoinWithBalance({ type: baseCoin.type, balance: baseAmount * baseCoin.scalar });\n\n\t\tconst deepCoin =\n\t\t\tparams.deepCoin ?? coinWithBalance({ type: deepCoinType, balance: deepAmount * DEEP_SCALAR });\n\n\t\tconst [baseCoinResult, quoteCoinResult, deepCoinResult] = tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::swap_exact_base_for_quote`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\tbaseCoinInput,\n\t\t\t\tdeepCoin,\n\t\t\t\ttx.pure.u64(quoteCoin.scalar * minQuote),\n\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\n\t\treturn [baseCoinResult, quoteCoinResult, deepCoinResult] as const;\n\t};\n\n\t/**\n\t * @description Swap exact quote amount for base amount\n\t * @param {SwapParams} params Parameters for the swap\n\t * @returns A function that takes a Transaction object\n\t */\n\tswapExactQuoteForBase = (params: SwapParams) => (tx: Transaction) => {\n\t\ttx.setGasBudgetIfNotSet(GAS_BUDGET);\n\t\ttx.setSenderIfNotSet(this.#config.address);\n\n\t\tif (params.baseCoin) {\n\t\t\tthrow new Error('baseCoin is not accepted for swapping quote asset');\n\t\t}\n\t\tconst { poolKey, amount: quoteAmount, deepAmount, minOut: minBase } = params;\n\n\t\tlet pool = this.#config.getPool(poolKey);\n\t\tlet deepCoinType = this.#config.getCoin('DEEP').type;\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\tconst quoteCoinInput =\n\t\t\tparams.quoteCoin ??\n\t\t\tcoinWithBalance({ type: quoteCoin.type, balance: quoteAmount * quoteCoin.scalar });\n\n\t\tconst deepCoin =\n\t\t\tparams.deepCoin ?? coinWithBalance({ type: deepCoinType, balance: deepAmount * DEEP_SCALAR });\n\n\t\tconst [baseCoinResult, quoteCoinResult, deepCoinResult] = tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::swap_exact_quote_for_base`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\tquoteCoinInput,\n\t\t\t\tdeepCoin,\n\t\t\t\ttx.pure.u64(baseCoin.scalar * minBase),\n\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\n\t\treturn [baseCoinResult, quoteCoinResult, deepCoinResult] as const;\n\t};\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,0BAAgC;AAEhC,mBAAoC;AAEpC,mBAA+C;AAG/C,oBAAqE;AATrE;AAcO,MAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA,EAM7B,YAAY,QAAwB;AALpC;AAcA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAAkB,CAAC,WAAkC,CAAC,OAAoB;AACzE,YAAM;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,aAAa;AAAA,QACb,YAAY,uBAAU;AAAA,QACtB,qBAAqB,iCAAoB;AAAA,QACzC,cAAc;AAAA,MACf,IAAI;AAEJ,SAAG,qBAAqB,wBAAU;AAClC,YAAM,OAAO,mBAAK,SAAQ,QAAQ,OAAO;AACzC,YAAM,iBAAiB,mBAAK,SAAQ,kBAAkB,iBAAiB;AACvE,YAAM,WAAW,mBAAK,SAAQ,QAAQ,KAAK,QAAQ;AACnD,YAAM,YAAY,mBAAK,SAAQ,QAAQ,KAAK,SAAS;AACrD,YAAM,aAAc,QAAQ,6BAAe,UAAU,SAAU,SAAS;AACxE,YAAM,gBAAgB,WAAW,SAAS;AAE1C,YAAM,aAAa,GAAG,IAAI,mBAAK,SAAQ,eAAe,cAAc,iBAAiB,CAAC;AAEtF,SAAG,SAAS;AAAA,QACX,QAAQ,GAAG,mBAAK,SAAQ,mBAAmB;AAAA,QAC3C,WAAW;AAAA,UACV,GAAG,OAAO,KAAK,OAAO;AAAA,UACtB,GAAG,OAAO,eAAe,OAAO;AAAA,UAChC;AAAA,UACA,GAAG,KA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