@mysten/deepbook-v3 1.2.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/client.d.mts.map +1 -1
  3. package/dist/contracts/deepbook/account.d.mts +0 -1
  4. package/dist/contracts/deepbook/account.d.mts.map +1 -1
  5. package/dist/contracts/deepbook/balances.d.mts +0 -1
  6. package/dist/contracts/deepbook/balances.d.mts.map +1 -1
  7. package/dist/contracts/deepbook/deep_price.d.mts +0 -1
  8. package/dist/contracts/deepbook/deep_price.d.mts.map +1 -1
  9. package/dist/contracts/deepbook/deps/sui/vec_set.d.mts +0 -1
  10. package/dist/contracts/deepbook/deps/sui/vec_set.d.mts.map +1 -1
  11. package/dist/contracts/deepbook/order.d.mts +0 -1
  12. package/dist/contracts/deepbook/order.d.mts.map +1 -1
  13. package/dist/contracts/utils/index.d.mts.map +1 -1
  14. package/dist/contracts/utils/index.mjs.map +1 -1
  15. package/dist/pyth/PriceServiceConnection.d.mts.map +1 -1
  16. package/dist/pyth/pyth.d.mts.map +1 -1
  17. package/dist/transactions/balanceManager.d.mts +12 -12
  18. package/dist/transactions/balanceManager.d.mts.map +1 -1
  19. package/dist/transactions/deepbook.d.mts +42 -20
  20. package/dist/transactions/deepbook.d.mts.map +1 -1
  21. package/dist/transactions/deepbook.mjs +38 -0
  22. package/dist/transactions/deepbook.mjs.map +1 -1
  23. package/dist/transactions/deepbookAdmin.d.mts +2 -2
  24. package/dist/transactions/deepbookAdmin.d.mts.map +1 -1
  25. package/dist/transactions/flashLoans.d.mts +0 -1
  26. package/dist/transactions/flashLoans.d.mts.map +1 -1
  27. package/dist/transactions/governance.d.mts +0 -1
  28. package/dist/transactions/governance.d.mts.map +1 -1
  29. package/dist/transactions/marginAdmin.d.mts +7 -8
  30. package/dist/transactions/marginAdmin.d.mts.map +1 -1
  31. package/dist/transactions/marginLiquidations.d.mts.map +1 -1
  32. package/dist/transactions/marginMaintainer.d.mts +5 -5
  33. package/dist/transactions/marginMaintainer.d.mts.map +1 -1
  34. package/dist/transactions/marginManager.d.mts +23 -23
  35. package/dist/transactions/marginManager.d.mts.map +1 -1
  36. package/dist/transactions/marginPool.d.mts.map +1 -1
  37. package/dist/transactions/marginRegistry.d.mts.map +1 -1
  38. package/dist/transactions/marginTPSL.d.mts.map +1 -1
  39. package/dist/transactions/poolProxy.d.mts.map +1 -1
  40. package/dist/types/index.d.mts +2 -2
  41. package/dist/types/index.d.mts.map +1 -1
  42. package/dist/utils/config.d.mts.map +1 -1
  43. package/dist/utils/constants.d.mts.map +1 -1
  44. package/dist/utils/constants.mjs +1 -1
  45. package/dist/utils/constants.mjs.map +1 -1
  46. package/dist/utils/errors.d.mts.map +1 -1
  47. package/dist/utils/validation.d.mts.map +1 -1
  48. package/package.json +6 -6
  49. package/src/contracts/utils/index.ts +4 -4
  50. package/src/transactions/deepbook.ts +64 -0
  51. package/src/utils/constants.ts +1 -1
@@ -216,6 +216,70 @@ export class DeepBookContract {
216
216
  });
217
217
  };
218
218
 
219
+ /**
220
+ * @description Cancel an existing order, no-op if the order is not currently in the
221
+ * balance manager's open orders (e.g. already filled, cancelled, expired-and-swept,
222
+ * or not owned by this balance manager). Unlike `cancelOrder`, this will not abort
223
+ * on unknown order ids.
224
+ * @param {string} poolKey The key to identify the pool
225
+ * @param {string} balanceManagerKey The key to identify the BalanceManager
226
+ * @param {string} orderId Order ID to cancel
227
+ * @returns A function that takes a Transaction object
228
+ */
229
+ cancelLiveOrder =
230
+ (poolKey: string, balanceManagerKey: string, orderId: string) => (tx: Transaction) => {
231
+ tx.setGasBudgetIfNotSet(GAS_BUDGET);
232
+ const pool = this.#config.getPool(poolKey);
233
+ const balanceManager = this.#config.getBalanceManager(balanceManagerKey);
234
+ const baseCoin = this.#config.getCoin(pool.baseCoin);
235
+ const quoteCoin = this.#config.getCoin(pool.quoteCoin);
236
+ const tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));
237
+
238
+ tx.moveCall({
239
+ target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::cancel_live_order`,
240
+ arguments: [
241
+ tx.object(pool.address),
242
+ tx.object(balanceManager.address),
243
+ tradeProof,
244
+ tx.pure.u128(orderId),
245
+ tx.object.clock(),
246
+ ],
247
+ typeArguments: [baseCoin.type, quoteCoin.type],
248
+ });
249
+ };
250
+
251
+ /**
252
+ * @description Cancel multiple orders, skipping any order_id that is not currently in
253
+ * the balance manager's open orders (e.g. already filled, cancelled, expired-and-swept,
254
+ * or not owned by this balance manager). Duplicate ids in the input vector are handled
255
+ * gracefully. Unlike `cancelOrders`, this will not abort on unknown order ids.
256
+ * @param {string} poolKey The key to identify the pool
257
+ * @param {string} balanceManagerKey The key to identify the BalanceManager
258
+ * @param {string[]} orderIds Array of order IDs to cancel
259
+ * @returns A function that takes a Transaction object
260
+ */
261
+ cancelLiveOrders =
262
+ (poolKey: string, balanceManagerKey: string, orderIds: string[]) => (tx: Transaction) => {
263
+ tx.setGasBudgetIfNotSet(GAS_BUDGET);
264
+ const pool = this.#config.getPool(poolKey);
265
+ const balanceManager = this.#config.getBalanceManager(balanceManagerKey);
266
+ const baseCoin = this.#config.getCoin(pool.baseCoin);
267
+ const quoteCoin = this.#config.getCoin(pool.quoteCoin);
268
+ const tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));
269
+
270
+ tx.moveCall({
271
+ target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::cancel_live_orders`,
272
+ arguments: [
273
+ tx.object(pool.address),
274
+ tx.object(balanceManager.address),
275
+ tradeProof,
276
+ tx.pure.vector('u128', orderIds),
277
+ tx.object.clock(),
278
+ ],
279
+ typeArguments: [baseCoin.type, quoteCoin.type],
280
+ });
281
+ };
282
+
219
283
  /**
220
284
  * @description Cancel all open orders for a balance manager
221
285
  * @param {string} poolKey The key to identify the pool
@@ -25,7 +25,7 @@ export const testnetPackageIds = {
25
25
  } satisfies DeepbookPackageIds;
26
26
 
27
27
  export const mainnetPackageIds = {
28
- DEEPBOOK_PACKAGE_ID: '0x337f4f4f6567fcd778d5454f27c16c70e2f274cc6377ea6249ddf491482ef497',
28
+ DEEPBOOK_PACKAGE_ID: '0xf48222c4e057fa468baf136bff8e12504209d43850c5778f76159292a96f621e',
29
29
  REGISTRY_ID: '0xaf16199a2dff736e9f07a845f23c5da6df6f756eddb631aed9d24a93efc4549d',
30
30
  DEEP_TREASURY_ID: '0x032abf8948dda67a271bcc18e776dbbcfb0d58c8d288a700ff0d5521e57a1ffe',
31
31
  MARGIN_PACKAGE_ID: '0xfbd322126f1452fd4c89aedbaeb9fd0c44df9b5cedbe70d76bf80dc086031377',