@drift-labs/sdk 2.62.0-beta.0 → 2.62.0-beta.1

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.62.0-beta.0
1
+ 2.62.0-beta.1
@@ -129,7 +129,11 @@ export declare class DriftClient {
129
129
  subAccountId: number;
130
130
  }[]): Promise<TransactionSignature>;
131
131
  updateUserDelegate(delegate: PublicKey, subAccountId?: number): Promise<TransactionSignature>;
132
- updateUserAdvancedLp(advancedLp: boolean, subAccountId?: number): Promise<TransactionSignature>;
132
+ updateUserAdvancedLp(updates: {
133
+ advancedLp: boolean;
134
+ subAccountId: number;
135
+ }[]): Promise<TransactionSignature>;
136
+ getUpdateAdvancedDlpIx(advancedLp: boolean, subAccountId: number): Promise<anchor.web3.TransactionInstruction>;
133
137
  fetchAllUserAccounts(includeIdle?: boolean): Promise<ProgramAccount<UserAccount>[]>;
134
138
  getUserAccountsForDelegate(delegate: PublicKey): Promise<UserAccount[]>;
135
139
  getUserAccountsAndAddressesForAuthority(authority: PublicKey): Promise<ProgramAccount<UserAccount>[]>;
@@ -600,15 +600,22 @@ class DriftClient {
600
600
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
601
601
  return txSig;
602
602
  }
603
- async updateUserAdvancedLp(advancedLp, subAccountId = 0) {
604
- const tx = await this.program.transaction.updateUserAdvancedLp(subAccountId, advancedLp, {
603
+ async updateUserAdvancedLp(updates) {
604
+ const ixs = await Promise.all(updates.map(async ({ advancedLp, subAccountId }) => {
605
+ return await this.getUpdateAdvancedDlpIx(advancedLp, subAccountId);
606
+ }));
607
+ const tx = await this.buildTransaction(ixs, this.txParams);
608
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
609
+ return txSig;
610
+ }
611
+ async getUpdateAdvancedDlpIx(advancedLp, subAccountId) {
612
+ const ix = await this.program.instruction.updateUserAdvancedLp(subAccountId, advancedLp, {
605
613
  accounts: {
606
- user: await this.getUserAccountPublicKey(),
614
+ user: (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, this.wallet.publicKey, subAccountId),
607
615
  authority: this.wallet.publicKey,
608
616
  },
609
617
  });
610
- const { txSig } = await this.sendTransaction(tx, [], this.opts);
611
- return txSig;
618
+ return ix;
612
619
  }
613
620
  async fetchAllUserAccounts(includeIdle = true) {
614
621
  let filters = undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.62.0-beta.0",
3
+ "version": "2.62.0-beta.1",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -1025,22 +1025,40 @@ export class DriftClient {
1025
1025
  }
1026
1026
 
1027
1027
  public async updateUserAdvancedLp(
1028
- advancedLp: boolean,
1029
- subAccountId = 0
1028
+ updates: { advancedLp: boolean; subAccountId: number }[]
1030
1029
  ): Promise<TransactionSignature> {
1031
- const tx = await this.program.transaction.updateUserAdvancedLp(
1030
+ const ixs = await Promise.all(
1031
+ updates.map(async ({ advancedLp, subAccountId }) => {
1032
+ return await this.getUpdateAdvancedDlpIx(advancedLp, subAccountId);
1033
+ })
1034
+ );
1035
+
1036
+ const tx = await this.buildTransaction(ixs, this.txParams);
1037
+
1038
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
1039
+ return txSig;
1040
+ }
1041
+
1042
+ public async getUpdateAdvancedDlpIx(
1043
+ advancedLp: boolean,
1044
+ subAccountId: number
1045
+ ) {
1046
+ const ix = await this.program.instruction.updateUserAdvancedLp(
1032
1047
  subAccountId,
1033
1048
  advancedLp,
1034
1049
  {
1035
1050
  accounts: {
1036
- user: await this.getUserAccountPublicKey(),
1051
+ user: getUserAccountPublicKeySync(
1052
+ this.program.programId,
1053
+ this.wallet.publicKey,
1054
+ subAccountId
1055
+ ),
1037
1056
  authority: this.wallet.publicKey,
1038
1057
  },
1039
1058
  }
1040
1059
  );
1041
1060
 
1042
- const { txSig } = await this.sendTransaction(tx, [], this.opts);
1043
- return txSig;
1061
+ return ix;
1044
1062
  }
1045
1063
 
1046
1064
  public async fetchAllUserAccounts(