@drift-labs/sdk 2.74.0-beta.5 → 2.74.0-beta.6

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.74.0-beta.5
1
+ 2.74.0-beta.6
@@ -134,6 +134,11 @@ export declare class DriftClient {
134
134
  subAccountId: number;
135
135
  }[]): Promise<TransactionSignature>;
136
136
  getUpdateAdvancedDlpIx(advancedLp: boolean, subAccountId: number): Promise<anchor.web3.TransactionInstruction>;
137
+ updateUserReduceOnly(updates: {
138
+ reduceOnly: boolean;
139
+ subAccountId: number;
140
+ }[]): Promise<TransactionSignature>;
141
+ getUpdateUserReduceOnlyIx(reduceOnly: boolean, subAccountId: number): Promise<anchor.web3.TransactionInstruction>;
137
142
  fetchAllUserAccounts(includeIdle?: boolean): Promise<ProgramAccount<UserAccount>[]>;
138
143
  getUserAccountsForDelegate(delegate: PublicKey): Promise<UserAccount[]>;
139
144
  getUserAccountsAndAddressesForAuthority(authority: PublicKey): Promise<ProgramAccount<UserAccount>[]>;
@@ -627,6 +627,23 @@ class DriftClient {
627
627
  });
628
628
  return ix;
629
629
  }
630
+ async updateUserReduceOnly(updates) {
631
+ const ixs = await Promise.all(updates.map(async ({ reduceOnly, subAccountId }) => {
632
+ return await this.getUpdateUserReduceOnlyIx(reduceOnly, subAccountId);
633
+ }));
634
+ const tx = await this.buildTransaction(ixs, this.txParams);
635
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
636
+ return txSig;
637
+ }
638
+ async getUpdateUserReduceOnlyIx(reduceOnly, subAccountId) {
639
+ const ix = await this.program.instruction.updateUserReduceOnly(subAccountId, reduceOnly, {
640
+ accounts: {
641
+ user: (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, this.wallet.publicKey, subAccountId),
642
+ authority: this.wallet.publicKey,
643
+ },
644
+ });
645
+ return ix;
646
+ }
630
647
  async fetchAllUserAccounts(includeIdle = true) {
631
648
  let filters = undefined;
632
649
  if (!includeIdle) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.74.0-beta.5",
3
+ "version": "2.74.0-beta.6",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -1074,6 +1074,43 @@ export class DriftClient {
1074
1074
  return ix;
1075
1075
  }
1076
1076
 
1077
+ public async updateUserReduceOnly(
1078
+ updates: { reduceOnly: boolean; subAccountId: number }[]
1079
+ ): Promise<TransactionSignature> {
1080
+ const ixs = await Promise.all(
1081
+ updates.map(async ({ reduceOnly, subAccountId }) => {
1082
+ return await this.getUpdateUserReduceOnlyIx(reduceOnly, subAccountId);
1083
+ })
1084
+ );
1085
+
1086
+ const tx = await this.buildTransaction(ixs, this.txParams);
1087
+
1088
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
1089
+ return txSig;
1090
+ }
1091
+
1092
+ public async getUpdateUserReduceOnlyIx(
1093
+ reduceOnly: boolean,
1094
+ subAccountId: number
1095
+ ) {
1096
+ const ix = await this.program.instruction.updateUserReduceOnly(
1097
+ subAccountId,
1098
+ reduceOnly,
1099
+ {
1100
+ accounts: {
1101
+ user: getUserAccountPublicKeySync(
1102
+ this.program.programId,
1103
+ this.wallet.publicKey,
1104
+ subAccountId
1105
+ ),
1106
+ authority: this.wallet.publicKey,
1107
+ },
1108
+ }
1109
+ );
1110
+
1111
+ return ix;
1112
+ }
1113
+
1077
1114
  public async fetchAllUserAccounts(
1078
1115
  includeIdle = true
1079
1116
  ): Promise<ProgramAccount<UserAccount>[]> {