@drift-labs/sdk 2.34.1-beta.7 → 2.34.1-beta.9

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.
package/VERSION CHANGED
@@ -1 +1 @@
1
- 2.34.1-beta.7
1
+ 2.34.1-beta.9
@@ -283,6 +283,8 @@ export declare class DriftClient {
283
283
  getCancelOrderIx(orderId?: number): Promise<TransactionInstruction>;
284
284
  cancelOrderByUserId(userOrderId: number, txParams?: TxParams): Promise<TransactionSignature>;
285
285
  getCancelOrderByUserIdIx(userOrderId: number): Promise<TransactionInstruction>;
286
+ cancelOrdersByIds(orderIds?: number[], txParams?: TxParams): Promise<TransactionSignature>;
287
+ getCancelOrdersByIdsIx(orderIds?: number[]): Promise<TransactionInstruction>;
286
288
  cancelOrders(marketType?: MarketType, marketIndex?: number, direction?: PositionDirection, txParams?: TxParams): Promise<TransactionSignature>;
287
289
  getCancelOrdersIx(marketType: MarketType | null, marketIndex: number | null, direction: PositionDirection | null): Promise<TransactionInstruction>;
288
290
  cancelAndPlaceOrders(cancelOrderParams: {
@@ -1540,6 +1540,25 @@ class DriftClient {
1540
1540
  remainingAccounts,
1541
1541
  });
1542
1542
  }
1543
+ async cancelOrdersByIds(orderIds, txParams) {
1544
+ const { txSig } = await this.sendTransaction(await this.buildTransaction(await this.getCancelOrdersByIdsIx(orderIds), txParams), [], this.opts);
1545
+ return txSig;
1546
+ }
1547
+ async getCancelOrdersByIdsIx(orderIds) {
1548
+ const userAccountPublicKey = await this.getUserAccountPublicKey();
1549
+ const remainingAccounts = this.getRemainingAccounts({
1550
+ userAccounts: [this.getUserAccount()],
1551
+ useMarketLastSlotCache: true,
1552
+ });
1553
+ return await this.program.instruction.cancelOrdersByIds(orderIds, {
1554
+ accounts: {
1555
+ state: await this.getStatePublicKey(),
1556
+ user: userAccountPublicKey,
1557
+ authority: this.wallet.publicKey,
1558
+ },
1559
+ remainingAccounts,
1560
+ });
1561
+ }
1543
1562
  async cancelOrders(marketType, marketIndex, direction, txParams) {
1544
1563
  const { txSig } = await this.sendTransaction(await this.buildTransaction(await this.getCancelOrdersIx(marketType, marketIndex, direction), txParams), [], this.opts);
1545
1564
  return txSig;
@@ -428,6 +428,34 @@
428
428
  }
429
429
  ]
430
430
  },
431
+ {
432
+ "name": "cancelOrdersByIds",
433
+ "accounts": [
434
+ {
435
+ "name": "state",
436
+ "isMut": false,
437
+ "isSigner": false
438
+ },
439
+ {
440
+ "name": "user",
441
+ "isMut": true,
442
+ "isSigner": false
443
+ },
444
+ {
445
+ "name": "authority",
446
+ "isMut": false,
447
+ "isSigner": true
448
+ }
449
+ ],
450
+ "args": [
451
+ {
452
+ "name": "orderIds",
453
+ "type": {
454
+ "vec": "u32"
455
+ }
456
+ }
457
+ ]
458
+ },
431
459
  {
432
460
  "name": "modifyOrder",
433
461
  "accounts": [
package/lib/types.d.ts CHANGED
@@ -949,6 +949,9 @@ export declare class PostOnlyParams {
949
949
  static readonly TRY_POST_ONLY: {
950
950
  tryPostOnly: {};
951
951
  };
952
+ static readonly SLIDE: {
953
+ slide: {};
954
+ };
952
955
  }
953
956
  export type NecessaryOrderParams = {
954
957
  orderType: OrderType;
package/lib/types.js CHANGED
@@ -248,6 +248,7 @@ exports.PostOnlyParams = PostOnlyParams;
248
248
  PostOnlyParams.NONE = { none: {} };
249
249
  PostOnlyParams.MUST_POST_ONLY = { mustPostOnly: {} }; // Tx fails if order can't be post only
250
250
  PostOnlyParams.TRY_POST_ONLY = { tryPostOnly: {} }; // Tx succeeds and order not placed if can't be post only
251
+ PostOnlyParams.SLIDE = { slide: {} }; // Modify price to be post only if can't be post only
251
252
  class ModifyOrderPolicy {
252
253
  }
253
254
  exports.ModifyOrderPolicy = ModifyOrderPolicy;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.34.1-beta.7",
3
+ "version": "2.34.1-beta.9",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -2758,6 +2758,41 @@ export class DriftClient {
2758
2758
  });
2759
2759
  }
2760
2760
 
2761
+ public async cancelOrdersByIds(
2762
+ orderIds?: number[],
2763
+ txParams?: TxParams
2764
+ ): Promise<TransactionSignature> {
2765
+ const { txSig } = await this.sendTransaction(
2766
+ await this.buildTransaction(
2767
+ await this.getCancelOrdersByIdsIx(orderIds),
2768
+ txParams
2769
+ ),
2770
+ [],
2771
+ this.opts
2772
+ );
2773
+ return txSig;
2774
+ }
2775
+
2776
+ public async getCancelOrdersByIdsIx(
2777
+ orderIds?: number[]
2778
+ ): Promise<TransactionInstruction> {
2779
+ const userAccountPublicKey = await this.getUserAccountPublicKey();
2780
+
2781
+ const remainingAccounts = this.getRemainingAccounts({
2782
+ userAccounts: [this.getUserAccount()],
2783
+ useMarketLastSlotCache: true,
2784
+ });
2785
+
2786
+ return await this.program.instruction.cancelOrdersByIds(orderIds, {
2787
+ accounts: {
2788
+ state: await this.getStatePublicKey(),
2789
+ user: userAccountPublicKey,
2790
+ authority: this.wallet.publicKey,
2791
+ },
2792
+ remainingAccounts,
2793
+ });
2794
+ }
2795
+
2761
2796
  public async cancelOrders(
2762
2797
  marketType?: MarketType,
2763
2798
  marketIndex?: number,
@@ -428,6 +428,34 @@
428
428
  }
429
429
  ]
430
430
  },
431
+ {
432
+ "name": "cancelOrdersByIds",
433
+ "accounts": [
434
+ {
435
+ "name": "state",
436
+ "isMut": false,
437
+ "isSigner": false
438
+ },
439
+ {
440
+ "name": "user",
441
+ "isMut": true,
442
+ "isSigner": false
443
+ },
444
+ {
445
+ "name": "authority",
446
+ "isMut": false,
447
+ "isSigner": true
448
+ }
449
+ ],
450
+ "args": [
451
+ {
452
+ "name": "orderIds",
453
+ "type": {
454
+ "vec": "u32"
455
+ }
456
+ }
457
+ ]
458
+ },
431
459
  {
432
460
  "name": "modifyOrder",
433
461
  "accounts": [
package/src/types.ts CHANGED
@@ -899,6 +899,7 @@ export class PostOnlyParams {
899
899
  static readonly NONE = { none: {} };
900
900
  static readonly MUST_POST_ONLY = { mustPostOnly: {} }; // Tx fails if order can't be post only
901
901
  static readonly TRY_POST_ONLY = { tryPostOnly: {} }; // Tx succeeds and order not placed if can't be post only
902
+ static readonly SLIDE = { slide: {} }; // Modify price to be post only if can't be post only
902
903
  }
903
904
 
904
905
  export type NecessaryOrderParams = {