@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,525 @@
1
+ var __typeError = (msg) => {
2
+ throw TypeError(msg);
3
+ };
4
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
5
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
6
+ 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);
7
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
8
+ var _config;
9
+ import { coinWithBalance } from "@mysten/sui/transactions";
10
+ import { SUI_CLOCK_OBJECT_ID } from "@mysten/sui/utils";
11
+ import { OrderType, SelfMatchingOptions } from "../types/index.js";
12
+ import { DEEP_SCALAR, FLOAT_SCALAR, GAS_BUDGET, MAX_TIMESTAMP } from "../utils/config.js";
13
+ class DeepBookContract {
14
+ /**
15
+ * @param {DeepBookConfig} config Configuration for DeepBookContract
16
+ */
17
+ constructor(config) {
18
+ __privateAdd(this, _config);
19
+ /**
20
+ * @description Place a limit order
21
+ * @param {PlaceLimitOrderParams} params Parameters for placing a limit order
22
+ * @returns A function that takes a Transaction object
23
+ */
24
+ this.placeLimitOrder = (params) => (tx) => {
25
+ const {
26
+ poolKey,
27
+ balanceManagerKey,
28
+ clientOrderId,
29
+ price,
30
+ quantity,
31
+ isBid,
32
+ expiration = MAX_TIMESTAMP,
33
+ orderType = OrderType.NO_RESTRICTION,
34
+ selfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,
35
+ payWithDeep = true
36
+ } = params;
37
+ tx.setGasBudgetIfNotSet(GAS_BUDGET);
38
+ const pool = __privateGet(this, _config).getPool(poolKey);
39
+ const balanceManager = __privateGet(this, _config).getBalanceManager(balanceManagerKey);
40
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
41
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
42
+ const inputPrice = price * FLOAT_SCALAR * quoteCoin.scalar / baseCoin.scalar;
43
+ const inputQuantity = quantity * baseCoin.scalar;
44
+ const tradeProof = tx.add(__privateGet(this, _config).balanceManager.generateProof(balanceManagerKey));
45
+ tx.moveCall({
46
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::place_limit_order`,
47
+ arguments: [
48
+ tx.object(pool.address),
49
+ tx.object(balanceManager.address),
50
+ tradeProof,
51
+ tx.pure.u64(clientOrderId),
52
+ tx.pure.u8(orderType),
53
+ tx.pure.u8(selfMatchingOption),
54
+ tx.pure.u64(inputPrice),
55
+ tx.pure.u64(inputQuantity),
56
+ tx.pure.bool(isBid),
57
+ tx.pure.bool(payWithDeep),
58
+ tx.pure.u64(expiration),
59
+ tx.object(SUI_CLOCK_OBJECT_ID)
60
+ ],
61
+ typeArguments: [baseCoin.type, quoteCoin.type]
62
+ });
63
+ };
64
+ /**
65
+ * @description Place a market order
66
+ * @param {PlaceMarketOrderParams} params Parameters for placing a market order
67
+ * @returns A function that takes a Transaction object
68
+ */
69
+ this.placeMarketOrder = (params) => (tx) => {
70
+ const {
71
+ poolKey,
72
+ balanceManagerKey,
73
+ clientOrderId,
74
+ quantity,
75
+ isBid,
76
+ selfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,
77
+ payWithDeep = true
78
+ } = params;
79
+ tx.setGasBudgetIfNotSet(GAS_BUDGET);
80
+ const pool = __privateGet(this, _config).getPool(poolKey);
81
+ const balanceManager = __privateGet(this, _config).getBalanceManager(balanceManagerKey);
82
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
83
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
84
+ const tradeProof = tx.add(__privateGet(this, _config).balanceManager.generateProof(balanceManagerKey));
85
+ tx.moveCall({
86
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::place_market_order`,
87
+ arguments: [
88
+ tx.object(pool.address),
89
+ tx.object(balanceManager.address),
90
+ tradeProof,
91
+ tx.pure.u64(clientOrderId),
92
+ tx.pure.u8(selfMatchingOption),
93
+ tx.pure.u64(quantity * baseCoin.scalar),
94
+ tx.pure.bool(isBid),
95
+ tx.pure.bool(payWithDeep),
96
+ tx.object(SUI_CLOCK_OBJECT_ID)
97
+ ],
98
+ typeArguments: [baseCoin.type, quoteCoin.type]
99
+ });
100
+ };
101
+ /**
102
+ * @description Modify an existing order
103
+ * @param {string} poolKey The key to identify the pool
104
+ * @param {string} balanceManagerKey The key to identify the BalanceManager
105
+ * @param {string} orderId Order ID to modify
106
+ * @param {number} newQuantity New quantity for the order
107
+ * @returns A function that takes a Transaction object
108
+ */
109
+ this.modifyOrder = (poolKey, balanceManagerKey, orderId, newQuantity) => (tx) => {
110
+ const pool = __privateGet(this, _config).getPool(poolKey);
111
+ const balanceManager = __privateGet(this, _config).getBalanceManager(balanceManagerKey);
112
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
113
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
114
+ const tradeProof = tx.add(__privateGet(this, _config).balanceManager.generateProof(balanceManagerKey));
115
+ tx.moveCall({
116
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::modify_order`,
117
+ arguments: [
118
+ tx.object(pool.address),
119
+ tx.object(balanceManager.address),
120
+ tradeProof,
121
+ tx.pure.u128(orderId),
122
+ tx.pure.u64(newQuantity),
123
+ tx.object(SUI_CLOCK_OBJECT_ID)
124
+ ],
125
+ typeArguments: [baseCoin.type, quoteCoin.type]
126
+ });
127
+ };
128
+ /**
129
+ * @description Cancel an existing order
130
+ * @param {string} poolKey The key to identify the pool
131
+ * @param {string} balanceManagerKey The key to identify the BalanceManager
132
+ * @param {string} orderId Order ID to cancel
133
+ * @returns A function that takes a Transaction object
134
+ */
135
+ this.cancelOrder = (poolKey, balanceManagerKey, orderId) => (tx) => {
136
+ tx.setGasBudgetIfNotSet(GAS_BUDGET);
137
+ const pool = __privateGet(this, _config).getPool(poolKey);
138
+ const balanceManager = __privateGet(this, _config).getBalanceManager(balanceManagerKey);
139
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
140
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
141
+ const tradeProof = tx.add(__privateGet(this, _config).balanceManager.generateProof(balanceManagerKey));
142
+ tx.moveCall({
143
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::cancel_order`,
144
+ arguments: [
145
+ tx.object(pool.address),
146
+ tx.object(balanceManager.address),
147
+ tradeProof,
148
+ tx.pure.u128(orderId),
149
+ tx.object(SUI_CLOCK_OBJECT_ID)
150
+ ],
151
+ typeArguments: [baseCoin.type, quoteCoin.type]
152
+ });
153
+ };
154
+ /**
155
+ * @description Cancel all open orders for a balance manager
156
+ * @param {string} poolKey The key to identify the pool
157
+ * @param {string} balanceManagerKey The key to identify the BalanceManager
158
+ * @returns A function that takes a Transaction object
159
+ */
160
+ this.cancelAllOrders = (poolKey, balanceManagerKey) => (tx) => {
161
+ tx.setGasBudgetIfNotSet(GAS_BUDGET);
162
+ const pool = __privateGet(this, _config).getPool(poolKey);
163
+ const balanceManager = __privateGet(this, _config).getBalanceManager(balanceManagerKey);
164
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
165
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
166
+ const tradeProof = tx.add(__privateGet(this, _config).balanceManager.generateProof(balanceManagerKey));
167
+ tx.moveCall({
168
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::cancel_all_orders`,
169
+ arguments: [
170
+ tx.object(pool.address),
171
+ tx.object(balanceManager.address),
172
+ tradeProof,
173
+ tx.object(SUI_CLOCK_OBJECT_ID)
174
+ ],
175
+ typeArguments: [baseCoin.type, quoteCoin.type]
176
+ });
177
+ };
178
+ /**
179
+ * @description Withdraw settled amounts for a balance manager
180
+ * @param {string} poolKey The key to identify the pool
181
+ * @param {string} balanceManagerKey The key to identify the BalanceManager
182
+ * @returns A function that takes a Transaction object
183
+ */
184
+ this.withdrawSettledAmounts = (poolKey, balanceManagerKey) => (tx) => {
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::withdraw_settled_amounts`,
192
+ arguments: [tx.object(pool.address), tx.object(balanceManager.address), tradeProof],
193
+ typeArguments: [baseCoin.type, quoteCoin.type]
194
+ });
195
+ };
196
+ /**
197
+ * @description Add a deep price point for a target pool using a reference pool
198
+ * @param {string} targetPoolKey The key to identify the target pool
199
+ * @param {string} referencePoolKey The key to identify the reference pool
200
+ * @returns A function that takes a Transaction object
201
+ */
202
+ this.addDeepPricePoint = (targetPoolKey, referencePoolKey) => (tx) => {
203
+ const targetPool = __privateGet(this, _config).getPool(targetPoolKey);
204
+ const referencePool = __privateGet(this, _config).getPool(referencePoolKey);
205
+ const targetBaseCoin = __privateGet(this, _config).getCoin(targetPool.baseCoin);
206
+ const targetQuoteCoin = __privateGet(this, _config).getCoin(targetPool.quoteCoin);
207
+ const referenceBaseCoin = __privateGet(this, _config).getCoin(referencePool.baseCoin);
208
+ const referenceQuoteCoin = __privateGet(this, _config).getCoin(referencePool.quoteCoin);
209
+ tx.moveCall({
210
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::add_deep_price_point`,
211
+ arguments: [
212
+ tx.object(targetPool.address),
213
+ tx.object(referencePool.address),
214
+ tx.object(SUI_CLOCK_OBJECT_ID)
215
+ ],
216
+ typeArguments: [
217
+ targetBaseCoin.type,
218
+ targetQuoteCoin.type,
219
+ referenceBaseCoin.type,
220
+ referenceQuoteCoin.type
221
+ ]
222
+ });
223
+ };
224
+ /**
225
+ * @description Claim rebates for a balance manager
226
+ * @param {string} poolKey The key to identify the pool
227
+ * @param {string} balanceManagerKey The key to identify the BalanceManager
228
+ * @returns A function that takes a Transaction object
229
+ */
230
+ this.claimRebates = (poolKey, balanceManagerKey) => (tx) => {
231
+ const pool = __privateGet(this, _config).getPool(poolKey);
232
+ const balanceManager = __privateGet(this, _config).getBalanceManager(balanceManagerKey);
233
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
234
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
235
+ const tradeProof = tx.add(__privateGet(this, _config).balanceManager.generateProof(balanceManagerKey));
236
+ tx.moveCall({
237
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::claim_rebates`,
238
+ arguments: [tx.object(pool.address), tx.object(balanceManager.address), tradeProof],
239
+ typeArguments: [baseCoin.type, quoteCoin.type]
240
+ });
241
+ };
242
+ /**
243
+ * @description Gets an order
244
+ * @param {string} poolKey The key to identify the pool
245
+ * @param {string} orderId Order ID to get
246
+ * @returns A function that takes a Transaction object
247
+ */
248
+ this.getOrder = (poolKey, orderId) => (tx) => {
249
+ const pool = __privateGet(this, _config).getPool(poolKey);
250
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
251
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
252
+ tx.moveCall({
253
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::get_order`,
254
+ arguments: [tx.object(pool.address), tx.pure.u128(orderId)],
255
+ typeArguments: [baseCoin.type, quoteCoin.type]
256
+ });
257
+ };
258
+ /**
259
+ * @description Burn DEEP tokens from the pool
260
+ * @param {string} poolKey The key to identify the pool
261
+ * @returns A function that takes a Transaction object
262
+ */
263
+ this.burnDeep = (poolKey) => (tx) => {
264
+ const pool = __privateGet(this, _config).getPool(poolKey);
265
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
266
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
267
+ tx.moveCall({
268
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::burn_deep`,
269
+ arguments: [tx.object(pool.address), tx.object(__privateGet(this, _config).DEEP_TREASURY_ID)],
270
+ typeArguments: [baseCoin.type, quoteCoin.type]
271
+ });
272
+ };
273
+ /**
274
+ * @description Get the mid price for a pool
275
+ * @param {string} poolKey The key to identify the pool
276
+ * @returns A function that takes a Transaction object
277
+ */
278
+ this.midPrice = (poolKey) => (tx) => {
279
+ const pool = __privateGet(this, _config).getPool(poolKey);
280
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
281
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
282
+ tx.moveCall({
283
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::mid_price`,
284
+ arguments: [tx.object(pool.address), tx.object(SUI_CLOCK_OBJECT_ID)],
285
+ typeArguments: [baseCoin.type, quoteCoin.type]
286
+ });
287
+ };
288
+ /**
289
+ * @description Check if a pool is whitelisted
290
+ * @param {string} poolKey The key to identify the pool
291
+ * @returns A function that takes a Transaction object
292
+ */
293
+ this.whitelisted = (poolKey) => (tx) => {
294
+ const pool = __privateGet(this, _config).getPool(poolKey);
295
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
296
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
297
+ tx.moveCall({
298
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::whitelisted`,
299
+ arguments: [tx.object(pool.address)],
300
+ typeArguments: [baseCoin.type, quoteCoin.type]
301
+ });
302
+ };
303
+ /**
304
+ * @description Get the quote quantity out for a given base quantity in
305
+ * @param {string} poolKey The key to identify the pool
306
+ * @param {number} baseQuantity Base quantity to convert
307
+ * @returns A function that takes a Transaction object
308
+ */
309
+ this.getQuoteQuantityOut = (poolKey, baseQuantity) => (tx) => {
310
+ const pool = __privateGet(this, _config).getPool(poolKey);
311
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
312
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
313
+ tx.moveCall({
314
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::get_quote_quantity_out`,
315
+ arguments: [
316
+ tx.object(pool.address),
317
+ tx.pure.u64(baseQuantity * baseCoin.scalar),
318
+ tx.object(SUI_CLOCK_OBJECT_ID)
319
+ ],
320
+ typeArguments: [baseCoin.type, quoteCoin.type]
321
+ });
322
+ };
323
+ /**
324
+ * @description Get the base quantity out for a given quote quantity in
325
+ * @param {string} poolKey The key to identify the pool
326
+ * @param {number} quoteQuantity Quote quantity to convert
327
+ * @returns A function that takes a Transaction object
328
+ */
329
+ this.getBaseQuantityOut = (poolKey, quoteQuantity) => (tx) => {
330
+ const pool = __privateGet(this, _config).getPool(poolKey);
331
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
332
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
333
+ const quoteScalar = quoteCoin.scalar;
334
+ tx.moveCall({
335
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::get_base_quantity_out`,
336
+ arguments: [
337
+ tx.object(pool.address),
338
+ tx.pure.u64(quoteQuantity * quoteScalar),
339
+ tx.object(SUI_CLOCK_OBJECT_ID)
340
+ ],
341
+ typeArguments: [baseCoin.type, quoteCoin.type]
342
+ });
343
+ };
344
+ /**
345
+ * @description Get the quantity out for a given base or quote quantity
346
+ * @param {string} poolKey The key to identify the pool
347
+ * @param {number} baseQuantity Base quantity to convert
348
+ * @param {number} quoteQuantity Quote quantity to convert
349
+ * @returns A function that takes a Transaction object
350
+ */
351
+ this.getQuantityOut = (poolKey, baseQuantity, quoteQuantity) => (tx) => {
352
+ const pool = __privateGet(this, _config).getPool(poolKey);
353
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
354
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
355
+ const quoteScalar = quoteCoin.scalar;
356
+ tx.moveCall({
357
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::get_quantity_out`,
358
+ arguments: [
359
+ tx.object(pool.address),
360
+ tx.pure.u64(baseQuantity * baseCoin.scalar),
361
+ tx.pure.u64(quoteQuantity * quoteScalar),
362
+ tx.object(SUI_CLOCK_OBJECT_ID)
363
+ ],
364
+ typeArguments: [baseCoin.type, quoteCoin.type]
365
+ });
366
+ };
367
+ /**
368
+ * @description Get open orders for a balance manager in a pool
369
+ * @param {string} poolKey The key to identify the pool
370
+ * @param {string} managerKey Key of the balance manager
371
+ * @returns A function that takes a Transaction object
372
+ */
373
+ this.accountOpenOrders = (poolKey, managerKey) => (tx) => {
374
+ const pool = __privateGet(this, _config).getPool(poolKey);
375
+ const manager = __privateGet(this, _config).getBalanceManager(managerKey);
376
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
377
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
378
+ tx.moveCall({
379
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::account_open_orders`,
380
+ arguments: [tx.object(pool.address), tx.object(manager.address)],
381
+ typeArguments: [baseCoin.type, quoteCoin.type]
382
+ });
383
+ };
384
+ /**
385
+ * @description Get level 2 order book specifying range of price
386
+ * @param {string} poolKey The key to identify the pool
387
+ * @param {number} priceLow Lower bound of the price range
388
+ * @param {number} priceHigh Upper bound of the price range
389
+ * @param {boolean} isBid Whether to get bid or ask orders
390
+ * @returns A function that takes a Transaction object
391
+ */
392
+ this.getLevel2Range = (poolKey, priceLow, priceHigh, isBid) => (tx) => {
393
+ const pool = __privateGet(this, _config).getPool(poolKey);
394
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
395
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
396
+ tx.moveCall({
397
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::get_level2_range`,
398
+ arguments: [
399
+ tx.object(pool.address),
400
+ tx.pure.u64(priceLow * FLOAT_SCALAR * quoteCoin.scalar / baseCoin.scalar),
401
+ tx.pure.u64(priceHigh * FLOAT_SCALAR * quoteCoin.scalar / baseCoin.scalar),
402
+ tx.pure.bool(isBid),
403
+ tx.object(SUI_CLOCK_OBJECT_ID)
404
+ ],
405
+ typeArguments: [baseCoin.type, quoteCoin.type]
406
+ });
407
+ };
408
+ /**
409
+ * @description Get level 2 order book ticks from mid-price for a pool
410
+ * @param {string} poolKey The key to identify the pool
411
+ * @param {number} tickFromMid Number of ticks from mid-price
412
+ * @returns A function that takes a Transaction object
413
+ */
414
+ this.getLevel2TicksFromMid = (poolKey, tickFromMid) => (tx) => {
415
+ const pool = __privateGet(this, _config).getPool(poolKey);
416
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
417
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
418
+ tx.moveCall({
419
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::get_level2_ticks_from_mid`,
420
+ arguments: [
421
+ tx.object(pool.address),
422
+ tx.pure.u64(tickFromMid),
423
+ tx.object(SUI_CLOCK_OBJECT_ID)
424
+ ],
425
+ typeArguments: [baseCoin.type, quoteCoin.type]
426
+ });
427
+ };
428
+ /**
429
+ * @description Get the vault balances for a pool
430
+ * @param {string} poolKey The key to identify the pool
431
+ * @returns A function that takes a Transaction object
432
+ */
433
+ this.vaultBalances = (poolKey) => (tx) => {
434
+ const pool = __privateGet(this, _config).getPool(poolKey);
435
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
436
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
437
+ tx.moveCall({
438
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::vault_balances`,
439
+ arguments: [tx.object(pool.address)],
440
+ typeArguments: [baseCoin.type, quoteCoin.type]
441
+ });
442
+ };
443
+ /**
444
+ * @description Get the pool ID by asset types
445
+ * @param {string} baseType Type of the base asset
446
+ * @param {string} quoteType Type of the quote asset
447
+ * @returns A function that takes a Transaction object
448
+ */
449
+ this.getPoolIdByAssets = (baseType, quoteType) => (tx) => {
450
+ tx.moveCall({
451
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::get_pool_id_by_asset`,
452
+ arguments: [tx.object(__privateGet(this, _config).REGISTRY_ID)],
453
+ typeArguments: [baseType, quoteType]
454
+ });
455
+ };
456
+ /**
457
+ * @description Swap exact base amount for quote amount
458
+ * @param {SwapParams} params Parameters for the swap
459
+ * @returns A function that takes a Transaction object
460
+ */
461
+ this.swapExactBaseForQuote = (params) => (tx) => {
462
+ tx.setGasBudgetIfNotSet(GAS_BUDGET);
463
+ tx.setSenderIfNotSet(__privateGet(this, _config).address);
464
+ if (params.quoteCoin) {
465
+ throw new Error("quoteCoin is not accepted for swapping base asset");
466
+ }
467
+ const { poolKey, amount: baseAmount, deepAmount, minOut: minQuote } = params;
468
+ let pool = __privateGet(this, _config).getPool(poolKey);
469
+ let deepCoinType = __privateGet(this, _config).getCoin("DEEP").type;
470
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
471
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
472
+ const baseCoinInput = params.baseCoin ?? coinWithBalance({ type: baseCoin.type, balance: baseAmount * baseCoin.scalar });
473
+ const deepCoin = params.deepCoin ?? coinWithBalance({ type: deepCoinType, balance: deepAmount * DEEP_SCALAR });
474
+ const [baseCoinResult, quoteCoinResult, deepCoinResult] = tx.moveCall({
475
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::swap_exact_base_for_quote`,
476
+ arguments: [
477
+ tx.object(pool.address),
478
+ baseCoinInput,
479
+ deepCoin,
480
+ tx.pure.u64(quoteCoin.scalar * minQuote),
481
+ tx.object(SUI_CLOCK_OBJECT_ID)
482
+ ],
483
+ typeArguments: [baseCoin.type, quoteCoin.type]
484
+ });
485
+ return [baseCoinResult, quoteCoinResult, deepCoinResult];
486
+ };
487
+ /**
488
+ * @description Swap exact quote amount for base amount
489
+ * @param {SwapParams} params Parameters for the swap
490
+ * @returns A function that takes a Transaction object
491
+ */
492
+ this.swapExactQuoteForBase = (params) => (tx) => {
493
+ tx.setGasBudgetIfNotSet(GAS_BUDGET);
494
+ tx.setSenderIfNotSet(__privateGet(this, _config).address);
495
+ if (params.baseCoin) {
496
+ throw new Error("baseCoin is not accepted for swapping quote asset");
497
+ }
498
+ const { poolKey, amount: quoteAmount, deepAmount, minOut: minBase } = params;
499
+ let pool = __privateGet(this, _config).getPool(poolKey);
500
+ let deepCoinType = __privateGet(this, _config).getCoin("DEEP").type;
501
+ const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
502
+ const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
503
+ const quoteCoinInput = params.quoteCoin ?? coinWithBalance({ type: quoteCoin.type, balance: quoteAmount * quoteCoin.scalar });
504
+ const deepCoin = params.deepCoin ?? coinWithBalance({ type: deepCoinType, balance: deepAmount * DEEP_SCALAR });
505
+ const [baseCoinResult, quoteCoinResult, deepCoinResult] = tx.moveCall({
506
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::swap_exact_quote_for_base`,
507
+ arguments: [
508
+ tx.object(pool.address),
509
+ quoteCoinInput,
510
+ deepCoin,
511
+ tx.pure.u64(baseCoin.scalar * minBase),
512
+ tx.object(SUI_CLOCK_OBJECT_ID)
513
+ ],
514
+ typeArguments: [baseCoin.type, quoteCoin.type]
515
+ });
516
+ return [baseCoinResult, quoteCoinResult, deepCoinResult];
517
+ };
518
+ __privateSet(this, _config, config);
519
+ }
520
+ }
521
+ _config = new WeakMap();
522
+ export {
523
+ DeepBookContract
524
+ };
525
+ //# 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;AAEA,SAAS,uBAAuB;AAEhC,SAAS,2BAA2B;AAEpC,SAAS,WAAW,2BAA2B;AAG/C,SAAS,aAAa,cAAc,YAAY,qBAAqB;AAK9D,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,UAAU;AAAA,QACtB,qBAAqB,oBAAoB;AAAA,QACzC,cAAc;AAAA,MACf,IAAI;AAEJ,SAAG,qBAAqB,UAAU;AAClC,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YAAM,CAAC,gBAAgB,iBAAiB,cAAc,IAAI,GAAG,SAAS;AAAA,QACrE,QAAQ,GAAG,mBAAK,SAAQ,mBAAmB;AAAA,QAC3C,WAAW;AAAA,UACV,GAAG,OAAO,KAAK,OAAO;AAAA,UACtB;AAAA,UACA;AAAA,UACA,GAAG,KAAK,IAAI,SAAS,SAAS,OAAO;AAAA,UACrC,GAAG,OAAO,mBAAmB;AAAA,QAC9B;AAAA,QACA,eAAe,CAAC,SAAS,MAAM,UAAU,IAAI;AAAA,MAC9C,CAAC;AAED,aAAO,CAAC,gBAAgB,iBAAiB,cAAc;AAAA,IACxD;AApjBC,uBAAK,SAAU;AAAA,EAChB;AAojBD;AA3jBC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,43 @@
1
+ import type { Transaction } from '@mysten/sui/transactions';
2
+ import type { CreatePoolAdminParams } from '../types/index.js';
3
+ import type { DeepBookConfig } from '../utils/config.js';
4
+ /**
5
+ * DeepBookAdminContract class for managing admin actions.
6
+ */
7
+ export declare class DeepBookAdminContract {
8
+ #private;
9
+ /**
10
+ * @param {DeepBookConfig} config Configuration for DeepBookAdminContract
11
+ */
12
+ constructor(config: DeepBookConfig);
13
+ /**
14
+ * @description Create a new pool as admin
15
+ * @param {CreatePoolAdminParams} params Parameters for creating pool as admin
16
+ * @returns A function that takes a Transaction object
17
+ */
18
+ createPoolAdmin: (params: CreatePoolAdminParams) => (tx: Transaction) => void;
19
+ /**
20
+ * @description Unregister a pool as admin
21
+ * @param {string} poolKey The key of the pool to be unregistered by admin
22
+ * @returns A function that takes a Transaction object
23
+ */
24
+ unregisterPoolAdmin: (poolKey: string) => (tx: Transaction) => void;
25
+ /**
26
+ * @description Update the allowed versions for a pool
27
+ * @param {string} poolKey The key of the pool to be updated
28
+ * @returns A function that takes a Transaction object
29
+ */
30
+ updateAllowedVersions: (poolKey: string) => (tx: Transaction) => void;
31
+ /**
32
+ * @description Enable a specific version
33
+ * @param {number} version The version to be enabled
34
+ * @returns A function that takes a Transaction object
35
+ */
36
+ enableVersion: (version: number) => (tx: Transaction) => void;
37
+ /**
38
+ * @description Disable a specific version
39
+ * @param {number} version The version to be disabled
40
+ * @returns A function that takes a Transaction object
41
+ */
42
+ disableVersion: (version: number) => (tx: Transaction) => void;
43
+ }