@drift-labs/sdk-browser 2.110.0-beta.6 → 2.110.0-beta.7

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.110.0-beta.6
1
+ 2.110.0-beta.7
@@ -560,21 +560,25 @@ export declare class DriftClient {
560
560
  taker: PublicKey;
561
561
  takerStats: PublicKey;
562
562
  takerUserAccount: UserAccount;
563
+ signingAuthority: PublicKey;
563
564
  }, precedingIxs?: TransactionInstruction[], overrideIxCount?: number, txParams?: TxParams): Promise<TransactionSignature>;
564
565
  getPlaceSwiftTakerPerpOrderIxs(signedSwiftOrderParams: SignedSwiftOrderParams, marketIndex: number, takerInfo: {
565
566
  taker: PublicKey;
566
567
  takerStats: PublicKey;
567
568
  takerUserAccount: UserAccount;
568
- }, authority?: PublicKey, precedingIxs?: TransactionInstruction[], overrideIxCount?: number): Promise<TransactionInstruction[]>;
569
+ signingAuthority: PublicKey;
570
+ }, precedingIxs?: TransactionInstruction[], overrideIxCount?: number): Promise<TransactionInstruction[]>;
569
571
  placeAndMakeSwiftPerpOrder(signedSwiftOrderParams: SignedSwiftOrderParams, swiftOrderUuid: Uint8Array, takerInfo: {
570
572
  taker: PublicKey;
571
573
  takerStats: PublicKey;
572
574
  takerUserAccount: UserAccount;
575
+ signingAuthority: PublicKey;
573
576
  }, orderParams: OptionalOrderParams, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number, precedingIxs?: TransactionInstruction[], overrideIxCount?: number): Promise<TransactionSignature>;
574
577
  getPlaceAndMakeSwiftPerpOrderIxs(signedSwiftOrderParams: SignedSwiftOrderParams, swiftOrderUuid: Uint8Array, takerInfo: {
575
578
  taker: PublicKey;
576
579
  takerStats: PublicKey;
577
580
  takerUserAccount: UserAccount;
581
+ signingAuthority: PublicKey;
578
582
  }, orderParams: OptionalOrderParams, referrerInfo?: ReferrerInfo, subAccountId?: number, precedingIxs?: TransactionInstruction[], overrideIxCount?: number): Promise<TransactionInstruction[]>;
579
583
  encodeRFQMakerOrderParams(message: RFQMakerOrderParams): Buffer;
580
584
  placeAndMatchRFQOrders(rfqMatches: RFQMatch[], txParams?: TxParams): Promise<TransactionSignature>;
@@ -3269,30 +3269,27 @@ class DriftClient {
3269
3269
  return Buffer.from(tweetnacl_1.default.sign.detached(message, keypair.secretKey));
3270
3270
  }
3271
3271
  async placeSwiftTakerOrder(signedSwiftOrderParams, marketIndex, takerInfo, precedingIxs = [], overrideIxCount, txParams) {
3272
- const ixs = await this.getPlaceSwiftTakerPerpOrderIxs(signedSwiftOrderParams, marketIndex, takerInfo, undefined, precedingIxs, overrideIxCount);
3272
+ const ixs = await this.getPlaceSwiftTakerPerpOrderIxs(signedSwiftOrderParams, marketIndex, takerInfo, precedingIxs, overrideIxCount);
3273
3273
  const { txSig } = await this.sendTransaction(await this.buildTransaction(ixs, txParams), [], this.opts);
3274
3274
  return txSig;
3275
3275
  }
3276
- async getPlaceSwiftTakerPerpOrderIxs(signedSwiftOrderParams, marketIndex, takerInfo, authority, precedingIxs = [], overrideIxCount) {
3277
- if (!authority && !takerInfo.takerUserAccount) {
3278
- throw new Error('authority or takerUserAccount must be provided');
3279
- }
3276
+ async getPlaceSwiftTakerPerpOrderIxs(signedSwiftOrderParams, marketIndex, takerInfo, precedingIxs = [], overrideIxCount) {
3280
3277
  const remainingAccounts = this.getRemainingAccounts({
3281
3278
  userAccounts: [takerInfo.takerUserAccount],
3282
3279
  useMarketLastSlotCache: true,
3283
3280
  readablePerpMarketIndex: marketIndex,
3284
3281
  });
3285
- const authorityToUse = authority || takerInfo.takerUserAccount.authority;
3286
3282
  const messageLengthBuffer = Buffer.alloc(2);
3287
3283
  messageLengthBuffer.writeUInt16LE(signedSwiftOrderParams.orderParams.length);
3288
3284
  const swiftIxData = Buffer.concat([
3289
3285
  signedSwiftOrderParams.signature,
3290
- authorityToUse.toBytes(),
3286
+ takerInfo.signingAuthority.toBytes(),
3291
3287
  messageLengthBuffer,
3292
3288
  signedSwiftOrderParams.orderParams,
3293
3289
  ]);
3294
3290
  const swiftOrderParamsSignatureIx = (0, pythOracleUtils_1.createMinimalEd25519VerifyIx)(overrideIxCount || precedingIxs.length + 1, 12, swiftIxData, 0);
3295
- const placeTakerSwiftPerpOrderIx = this.program.instruction.placeSwiftTakerOrder(swiftIxData, {
3291
+ const isDelegateSigner = takerInfo.signingAuthority.equals(takerInfo.takerUserAccount.delegate);
3292
+ const placeTakerSwiftPerpOrderIx = this.program.instruction.placeSwiftTakerOrder(swiftIxData, isDelegateSigner, {
3296
3293
  accounts: {
3297
3294
  state: await this.getStatePublicKey(),
3298
3295
  user: takerInfo.taker,
@@ -3312,7 +3309,7 @@ class DriftClient {
3312
3309
  return txSig;
3313
3310
  }
3314
3311
  async getPlaceAndMakeSwiftPerpOrderIxs(signedSwiftOrderParams, swiftOrderUuid, takerInfo, orderParams, referrerInfo, subAccountId, precedingIxs = [], overrideIxCount) {
3315
- const [swiftOrderSignatureIx, placeTakerSwiftPerpOrderIx] = await this.getPlaceSwiftTakerPerpOrderIxs(signedSwiftOrderParams, orderParams.marketIndex, takerInfo, undefined, precedingIxs, overrideIxCount);
3312
+ const [swiftOrderSignatureIx, placeTakerSwiftPerpOrderIx] = await this.getPlaceSwiftTakerPerpOrderIxs(signedSwiftOrderParams, orderParams.marketIndex, takerInfo, precedingIxs, overrideIxCount);
3316
3313
  orderParams = (0, orderParams_1.getOrderParams)(orderParams, { marketType: types_1.MarketType.PERP });
3317
3314
  const userStatsPublicKey = this.getUserStatsAccountPublicKey();
3318
3315
  const user = await this.getUserAccountPublicKey(subAccountId);
@@ -244,6 +244,11 @@
244
244
  "name": "authority",
245
245
  "isMut": false,
246
246
  "isSigner": false
247
+ },
248
+ {
249
+ "name": "signer",
250
+ "isMut": false,
251
+ "isSigner": true
247
252
  }
248
253
  ],
249
254
  "args": []
@@ -889,6 +894,10 @@
889
894
  {
890
895
  "name": "swiftOrderParamsMessageBytes",
891
896
  "type": "bytes"
897
+ },
898
+ {
899
+ "name": "isDelegateSigner",
900
+ "type": "bool"
892
901
  }
893
902
  ]
894
903
  },
@@ -102,6 +102,7 @@ class SwiftOrderSubscriber {
102
102
  taker: takerUserPubkey,
103
103
  takerUserAccount,
104
104
  takerStats: (0, __1.getUserStatsAccountPublicKey)(this.driftClient.program.programId, takerUserAccount.authority),
105
+ signingAuthority: takerAuthority,
105
106
  }, Object.assign({}, makerOrderParams, {
106
107
  postOnly: __1.PostOnlyParams.MUST_POST_ONLY,
107
108
  immediateOrCancel: true,
@@ -560,21 +560,25 @@ export declare class DriftClient {
560
560
  taker: PublicKey;
561
561
  takerStats: PublicKey;
562
562
  takerUserAccount: UserAccount;
563
+ signingAuthority: PublicKey;
563
564
  }, precedingIxs?: TransactionInstruction[], overrideIxCount?: number, txParams?: TxParams): Promise<TransactionSignature>;
564
565
  getPlaceSwiftTakerPerpOrderIxs(signedSwiftOrderParams: SignedSwiftOrderParams, marketIndex: number, takerInfo: {
565
566
  taker: PublicKey;
566
567
  takerStats: PublicKey;
567
568
  takerUserAccount: UserAccount;
568
- }, authority?: PublicKey, precedingIxs?: TransactionInstruction[], overrideIxCount?: number): Promise<TransactionInstruction[]>;
569
+ signingAuthority: PublicKey;
570
+ }, precedingIxs?: TransactionInstruction[], overrideIxCount?: number): Promise<TransactionInstruction[]>;
569
571
  placeAndMakeSwiftPerpOrder(signedSwiftOrderParams: SignedSwiftOrderParams, swiftOrderUuid: Uint8Array, takerInfo: {
570
572
  taker: PublicKey;
571
573
  takerStats: PublicKey;
572
574
  takerUserAccount: UserAccount;
575
+ signingAuthority: PublicKey;
573
576
  }, orderParams: OptionalOrderParams, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number, precedingIxs?: TransactionInstruction[], overrideIxCount?: number): Promise<TransactionSignature>;
574
577
  getPlaceAndMakeSwiftPerpOrderIxs(signedSwiftOrderParams: SignedSwiftOrderParams, swiftOrderUuid: Uint8Array, takerInfo: {
575
578
  taker: PublicKey;
576
579
  takerStats: PublicKey;
577
580
  takerUserAccount: UserAccount;
581
+ signingAuthority: PublicKey;
578
582
  }, orderParams: OptionalOrderParams, referrerInfo?: ReferrerInfo, subAccountId?: number, precedingIxs?: TransactionInstruction[], overrideIxCount?: number): Promise<TransactionInstruction[]>;
579
583
  encodeRFQMakerOrderParams(message: RFQMakerOrderParams): Buffer;
580
584
  placeAndMatchRFQOrders(rfqMatches: RFQMatch[], txParams?: TxParams): Promise<TransactionSignature>;
@@ -3269,30 +3269,27 @@ class DriftClient {
3269
3269
  return Buffer.from(tweetnacl_1.default.sign.detached(message, keypair.secretKey));
3270
3270
  }
3271
3271
  async placeSwiftTakerOrder(signedSwiftOrderParams, marketIndex, takerInfo, precedingIxs = [], overrideIxCount, txParams) {
3272
- const ixs = await this.getPlaceSwiftTakerPerpOrderIxs(signedSwiftOrderParams, marketIndex, takerInfo, undefined, precedingIxs, overrideIxCount);
3272
+ const ixs = await this.getPlaceSwiftTakerPerpOrderIxs(signedSwiftOrderParams, marketIndex, takerInfo, precedingIxs, overrideIxCount);
3273
3273
  const { txSig } = await this.sendTransaction(await this.buildTransaction(ixs, txParams), [], this.opts);
3274
3274
  return txSig;
3275
3275
  }
3276
- async getPlaceSwiftTakerPerpOrderIxs(signedSwiftOrderParams, marketIndex, takerInfo, authority, precedingIxs = [], overrideIxCount) {
3277
- if (!authority && !takerInfo.takerUserAccount) {
3278
- throw new Error('authority or takerUserAccount must be provided');
3279
- }
3276
+ async getPlaceSwiftTakerPerpOrderIxs(signedSwiftOrderParams, marketIndex, takerInfo, precedingIxs = [], overrideIxCount) {
3280
3277
  const remainingAccounts = this.getRemainingAccounts({
3281
3278
  userAccounts: [takerInfo.takerUserAccount],
3282
3279
  useMarketLastSlotCache: true,
3283
3280
  readablePerpMarketIndex: marketIndex,
3284
3281
  });
3285
- const authorityToUse = authority || takerInfo.takerUserAccount.authority;
3286
3282
  const messageLengthBuffer = Buffer.alloc(2);
3287
3283
  messageLengthBuffer.writeUInt16LE(signedSwiftOrderParams.orderParams.length);
3288
3284
  const swiftIxData = Buffer.concat([
3289
3285
  signedSwiftOrderParams.signature,
3290
- authorityToUse.toBytes(),
3286
+ takerInfo.signingAuthority.toBytes(),
3291
3287
  messageLengthBuffer,
3292
3288
  signedSwiftOrderParams.orderParams,
3293
3289
  ]);
3294
3290
  const swiftOrderParamsSignatureIx = (0, pythOracleUtils_1.createMinimalEd25519VerifyIx)(overrideIxCount || precedingIxs.length + 1, 12, swiftIxData, 0);
3295
- const placeTakerSwiftPerpOrderIx = this.program.instruction.placeSwiftTakerOrder(swiftIxData, {
3291
+ const isDelegateSigner = takerInfo.signingAuthority.equals(takerInfo.takerUserAccount.delegate);
3292
+ const placeTakerSwiftPerpOrderIx = this.program.instruction.placeSwiftTakerOrder(swiftIxData, isDelegateSigner, {
3296
3293
  accounts: {
3297
3294
  state: await this.getStatePublicKey(),
3298
3295
  user: takerInfo.taker,
@@ -3312,7 +3309,7 @@ class DriftClient {
3312
3309
  return txSig;
3313
3310
  }
3314
3311
  async getPlaceAndMakeSwiftPerpOrderIxs(signedSwiftOrderParams, swiftOrderUuid, takerInfo, orderParams, referrerInfo, subAccountId, precedingIxs = [], overrideIxCount) {
3315
- const [swiftOrderSignatureIx, placeTakerSwiftPerpOrderIx] = await this.getPlaceSwiftTakerPerpOrderIxs(signedSwiftOrderParams, orderParams.marketIndex, takerInfo, undefined, precedingIxs, overrideIxCount);
3312
+ const [swiftOrderSignatureIx, placeTakerSwiftPerpOrderIx] = await this.getPlaceSwiftTakerPerpOrderIxs(signedSwiftOrderParams, orderParams.marketIndex, takerInfo, precedingIxs, overrideIxCount);
3316
3313
  orderParams = (0, orderParams_1.getOrderParams)(orderParams, { marketType: types_1.MarketType.PERP });
3317
3314
  const userStatsPublicKey = this.getUserStatsAccountPublicKey();
3318
3315
  const user = await this.getUserAccountPublicKey(subAccountId);
@@ -244,6 +244,11 @@
244
244
  "name": "authority",
245
245
  "isMut": false,
246
246
  "isSigner": false
247
+ },
248
+ {
249
+ "name": "signer",
250
+ "isMut": false,
251
+ "isSigner": true
247
252
  }
248
253
  ],
249
254
  "args": []
@@ -889,6 +894,10 @@
889
894
  {
890
895
  "name": "swiftOrderParamsMessageBytes",
891
896
  "type": "bytes"
897
+ },
898
+ {
899
+ "name": "isDelegateSigner",
900
+ "type": "bool"
892
901
  }
893
902
  ]
894
903
  },
@@ -102,6 +102,7 @@ class SwiftOrderSubscriber {
102
102
  taker: takerUserPubkey,
103
103
  takerUserAccount,
104
104
  takerStats: (0, __1.getUserStatsAccountPublicKey)(this.driftClient.program.programId, takerUserAccount.authority),
105
+ signingAuthority: takerAuthority,
105
106
  }, Object.assign({}, makerOrderParams, {
106
107
  postOnly: __1.PostOnlyParams.MUST_POST_ONLY,
107
108
  immediateOrCancel: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk-browser",
3
- "version": "2.110.0-beta.6",
3
+ "version": "2.110.0-beta.7",
4
4
  "main": "lib/node/index.js",
5
5
  "types": "lib/node/index.d.ts",
6
6
  "browser": "./lib/browser/index.js",
@@ -6058,6 +6058,7 @@ export class DriftClient {
6058
6058
  taker: PublicKey;
6059
6059
  takerStats: PublicKey;
6060
6060
  takerUserAccount: UserAccount;
6061
+ signingAuthority: PublicKey;
6061
6062
  },
6062
6063
  precedingIxs: TransactionInstruction[] = [],
6063
6064
  overrideIxCount?: number,
@@ -6067,7 +6068,6 @@ export class DriftClient {
6067
6068
  signedSwiftOrderParams,
6068
6069
  marketIndex,
6069
6070
  takerInfo,
6070
- undefined,
6071
6071
  precedingIxs,
6072
6072
  overrideIxCount
6073
6073
  );
@@ -6086,23 +6086,17 @@ export class DriftClient {
6086
6086
  taker: PublicKey;
6087
6087
  takerStats: PublicKey;
6088
6088
  takerUserAccount: UserAccount;
6089
+ signingAuthority: PublicKey;
6089
6090
  },
6090
- authority?: PublicKey,
6091
6091
  precedingIxs: TransactionInstruction[] = [],
6092
6092
  overrideIxCount?: number
6093
6093
  ): Promise<TransactionInstruction[]> {
6094
- if (!authority && !takerInfo.takerUserAccount) {
6095
- throw new Error('authority or takerUserAccount must be provided');
6096
- }
6097
-
6098
6094
  const remainingAccounts = this.getRemainingAccounts({
6099
6095
  userAccounts: [takerInfo.takerUserAccount],
6100
6096
  useMarketLastSlotCache: true,
6101
6097
  readablePerpMarketIndex: marketIndex,
6102
6098
  });
6103
6099
 
6104
- const authorityToUse = authority || takerInfo.takerUserAccount.authority;
6105
-
6106
6100
  const messageLengthBuffer = Buffer.alloc(2);
6107
6101
  messageLengthBuffer.writeUInt16LE(
6108
6102
  signedSwiftOrderParams.orderParams.length
@@ -6110,7 +6104,7 @@ export class DriftClient {
6110
6104
 
6111
6105
  const swiftIxData = Buffer.concat([
6112
6106
  signedSwiftOrderParams.signature,
6113
- authorityToUse.toBytes(),
6107
+ takerInfo.signingAuthority.toBytes(),
6114
6108
  messageLengthBuffer,
6115
6109
  signedSwiftOrderParams.orderParams,
6116
6110
  ]);
@@ -6122,21 +6116,28 @@ export class DriftClient {
6122
6116
  0
6123
6117
  );
6124
6118
 
6119
+ const isDelegateSigner = takerInfo.signingAuthority.equals(
6120
+ takerInfo.takerUserAccount.delegate
6121
+ );
6125
6122
  const placeTakerSwiftPerpOrderIx =
6126
- this.program.instruction.placeSwiftTakerOrder(swiftIxData, {
6127
- accounts: {
6128
- state: await this.getStatePublicKey(),
6129
- user: takerInfo.taker,
6130
- userStats: takerInfo.takerStats,
6131
- swiftUserOrders: getSwiftUserAccountPublicKey(
6132
- this.program.programId,
6133
- takerInfo.takerUserAccount.authority
6134
- ),
6135
- authority: this.wallet.publicKey,
6136
- ixSysvar: SYSVAR_INSTRUCTIONS_PUBKEY,
6137
- },
6138
- remainingAccounts,
6139
- });
6123
+ this.program.instruction.placeSwiftTakerOrder(
6124
+ swiftIxData,
6125
+ isDelegateSigner,
6126
+ {
6127
+ accounts: {
6128
+ state: await this.getStatePublicKey(),
6129
+ user: takerInfo.taker,
6130
+ userStats: takerInfo.takerStats,
6131
+ swiftUserOrders: getSwiftUserAccountPublicKey(
6132
+ this.program.programId,
6133
+ takerInfo.takerUserAccount.authority
6134
+ ),
6135
+ authority: this.wallet.publicKey,
6136
+ ixSysvar: SYSVAR_INSTRUCTIONS_PUBKEY,
6137
+ },
6138
+ remainingAccounts,
6139
+ }
6140
+ );
6140
6141
 
6141
6142
  return [swiftOrderParamsSignatureIx, placeTakerSwiftPerpOrderIx];
6142
6143
  }
@@ -6148,6 +6149,7 @@ export class DriftClient {
6148
6149
  taker: PublicKey;
6149
6150
  takerStats: PublicKey;
6150
6151
  takerUserAccount: UserAccount;
6152
+ signingAuthority: PublicKey;
6151
6153
  },
6152
6154
  orderParams: OptionalOrderParams,
6153
6155
  referrerInfo?: ReferrerInfo,
@@ -6183,6 +6185,7 @@ export class DriftClient {
6183
6185
  taker: PublicKey;
6184
6186
  takerStats: PublicKey;
6185
6187
  takerUserAccount: UserAccount;
6188
+ signingAuthority: PublicKey;
6186
6189
  },
6187
6190
  orderParams: OptionalOrderParams,
6188
6191
  referrerInfo?: ReferrerInfo,
@@ -6195,7 +6198,6 @@ export class DriftClient {
6195
6198
  signedSwiftOrderParams,
6196
6199
  orderParams.marketIndex,
6197
6200
  takerInfo,
6198
- undefined,
6199
6201
  precedingIxs,
6200
6202
  overrideIxCount
6201
6203
  );
@@ -244,6 +244,11 @@
244
244
  "name": "authority",
245
245
  "isMut": false,
246
246
  "isSigner": false
247
+ },
248
+ {
249
+ "name": "signer",
250
+ "isMut": false,
251
+ "isSigner": true
247
252
  }
248
253
  ],
249
254
  "args": []
@@ -889,6 +894,10 @@
889
894
  {
890
895
  "name": "swiftOrderParamsMessageBytes",
891
896
  "type": "bytes"
897
+ },
898
+ {
899
+ "name": "isDelegateSigner",
900
+ "type": "bool"
892
901
  }
893
902
  ]
894
903
  },
@@ -182,6 +182,7 @@ export class SwiftOrderSubscriber {
182
182
  this.driftClient.program.programId,
183
183
  takerUserAccount.authority
184
184
  ),
185
+ signingAuthority: takerAuthority,
185
186
  },
186
187
  Object.assign({}, makerOrderParams, {
187
188
  postOnly: PostOnlyParams.MUST_POST_ONLY,