@drift-labs/sdk 2.84.0-beta.5 → 2.84.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.
@@ -44,6 +44,7 @@ import {
44
44
  SwapReduceOnly,
45
45
  SettlePnlMode,
46
46
  SignedTxData,
47
+ MappedRecord,
47
48
  } from './types';
48
49
  import * as anchor from '@coral-xyz/anchor';
49
50
  import driftIDL from './idl/drift.json';
@@ -2762,18 +2763,7 @@ export class DriftClient {
2762
2763
  return txSig;
2763
2764
  }
2764
2765
 
2765
- /**
2766
- * Sends a market order and returns a signed tx which can fill the order against the vamm, which the caller can use to fill their own order if required.
2767
- * @param orderParams
2768
- * @param userAccountPublicKey
2769
- * @param userAccount
2770
- * @param makerInfo
2771
- * @param txParams
2772
- * @param bracketOrdersParams
2773
- * @param cancelExistingOrders - Builds and returns an extra transaciton to cancel the existing orders in the same perp market. Intended use is to auto-cancel TP/SL orders when closing a position. Ignored if orderParams.marketType is not MarketType.PERP
2774
- * @returns
2775
- */
2776
- public async sendMarketOrderAndGetSignedFillTx(
2766
+ public async prepareMarketOrderTxs(
2777
2767
  orderParams: OptionalOrderParams,
2778
2768
  userAccountPublicKey: PublicKey,
2779
2769
  userAccount: UserAccount,
@@ -2784,86 +2774,128 @@ export class DriftClient {
2784
2774
  cancelExistingOrders?: boolean,
2785
2775
  settlePnl?: boolean
2786
2776
  ): Promise<{
2787
- txSig: TransactionSignature;
2788
- signedFillTx?: Transaction;
2789
- signedCancelExistingOrdersTx?: Transaction;
2790
- signedSettlePnlTx?: Transaction;
2777
+ cancelExistingOrdersTx?: Transaction | VersionedTransaction;
2778
+ settlePnlTx?: Transaction | VersionedTransaction;
2779
+ fillTx?: Transaction | VersionedTransaction;
2780
+ marketOrderTx: Transaction | VersionedTransaction;
2791
2781
  }> {
2782
+ type TxKeys =
2783
+ | 'cancelExistingOrdersTx'
2784
+ | 'settlePnlTx'
2785
+ | 'fillTx'
2786
+ | 'marketOrderTx';
2787
+
2792
2788
  const marketIndex = orderParams.marketIndex;
2793
2789
  const orderId = userAccount.nextOrderId;
2794
2790
 
2795
- const ordersIx = await this.getPlaceOrdersIx(
2791
+ const ixPromisesForTxs: Record<TxKeys, Promise<TransactionInstruction>> = {
2792
+ cancelExistingOrdersTx: undefined,
2793
+ settlePnlTx: undefined,
2794
+ fillTx: undefined,
2795
+ marketOrderTx: undefined,
2796
+ };
2797
+
2798
+ const txKeys = Object.keys(ixPromisesForTxs);
2799
+
2800
+ ixPromisesForTxs.marketOrderTx = this.getPlaceOrdersIx(
2796
2801
  [orderParams, ...bracketOrdersParams],
2797
2802
  userAccount.subAccountId
2798
2803
  );
2799
2804
 
2800
- const ixsToSign: { key: string; ix: TransactionInstruction }[] = [];
2801
-
2802
- const keys = {
2803
- signedCancelExistingOrdersTx: 'signedCancelExistingOrdersTx',
2804
- signedSettlePnlTx: 'signedSettlePnlTx',
2805
- signedFillTx: 'signedFillTx',
2806
- signedMarketOrderTx: 'signedMarketOrderTx',
2807
- };
2808
-
2809
2805
  /* Cancel open orders in market if requested */
2810
-
2811
2806
  if (cancelExistingOrders && isVariant(orderParams.marketType, 'perp')) {
2812
- ixsToSign.push({
2813
- key: keys.signedCancelExistingOrdersTx,
2814
- ix: await this.getCancelOrdersIx(
2815
- orderParams.marketType,
2816
- orderParams.marketIndex,
2817
- null,
2818
- userAccount.subAccountId
2819
- ),
2820
- });
2807
+ ixPromisesForTxs.cancelExistingOrdersTx = this.getCancelOrdersIx(
2808
+ orderParams.marketType,
2809
+ orderParams.marketIndex,
2810
+ null,
2811
+ userAccount.subAccountId
2812
+ );
2821
2813
  }
2822
2814
 
2823
2815
  /* Settle PnL after fill if requested */
2824
2816
  if (settlePnl && isVariant(orderParams.marketType, 'perp')) {
2825
- ixsToSign.push({
2826
- key: keys.signedSettlePnlTx,
2827
- ix: await this.settlePNLIx(
2828
- userAccountPublicKey,
2829
- userAccount,
2830
- marketIndex
2831
- ),
2832
- });
2817
+ ixPromisesForTxs.settlePnlTx = this.settlePNLIx(
2818
+ userAccountPublicKey,
2819
+ userAccount,
2820
+ marketIndex
2821
+ );
2833
2822
  }
2834
2823
 
2835
2824
  // use versioned transactions if there is a lookup table account and wallet is compatible
2836
2825
  if (this.txVersion === 0) {
2837
- ixsToSign.push({
2838
- key: keys.signedFillTx,
2839
- ix: await this.getFillPerpOrderIx(
2840
- userAccountPublicKey,
2841
- userAccount,
2842
- {
2843
- orderId,
2844
- marketIndex,
2845
- },
2846
- makerInfo,
2847
- referrerInfo,
2848
- userAccount.subAccountId
2849
- ),
2850
- });
2826
+ ixPromisesForTxs.fillTx = this.getFillPerpOrderIx(
2827
+ userAccountPublicKey,
2828
+ userAccount,
2829
+ {
2830
+ orderId,
2831
+ marketIndex,
2832
+ },
2833
+ makerInfo,
2834
+ referrerInfo,
2835
+ userAccount.subAccountId
2836
+ );
2851
2837
  }
2852
2838
 
2853
- // Apply the latest blockhash to the txs so that we can sign before sending them
2854
- ixsToSign.push({
2855
- key: keys.signedMarketOrderTx,
2856
- ix: ordersIx,
2857
- });
2839
+ const ixs = await Promise.all(Object.values(ixPromisesForTxs));
2840
+
2841
+ const ixsMap = ixs.reduce((acc, ix, i) => {
2842
+ acc[txKeys[i]] = ix;
2843
+ return acc;
2844
+ }, {}) as MappedRecord<typeof ixPromisesForTxs, TransactionInstruction>;
2858
2845
 
2859
- const signedTransactions = await this.buildAndSignBulkTransactions(
2860
- ixsToSign.map((ix) => ix.ix),
2861
- ixsToSign.map((ix) => ix.key),
2846
+ const txsMap = (await this.buildTransactionsMap(
2847
+ ixsMap,
2862
2848
  txParams
2849
+ )) as MappedRecord<typeof ixsMap, Transaction | VersionedTransaction>;
2850
+
2851
+ return txsMap;
2852
+ }
2853
+
2854
+ /**
2855
+ * Sends a market order and returns a signed tx which can fill the order against the vamm, which the caller can use to fill their own order if required.
2856
+ * @param orderParams
2857
+ * @param userAccountPublicKey
2858
+ * @param userAccount
2859
+ * @param makerInfo
2860
+ * @param txParams
2861
+ * @param bracketOrdersParams
2862
+ * @param cancelExistingOrders - Builds and returns an extra transaciton to cancel the existing orders in the same perp market. Intended use is to auto-cancel TP/SL orders when closing a position. Ignored if orderParams.marketType is not MarketType.PERP
2863
+ * @returns
2864
+ */
2865
+ public async sendMarketOrderAndGetSignedFillTx(
2866
+ orderParams: OptionalOrderParams,
2867
+ userAccountPublicKey: PublicKey,
2868
+ userAccount: UserAccount,
2869
+ makerInfo?: MakerInfo | MakerInfo[],
2870
+ txParams?: TxParams,
2871
+ bracketOrdersParams = new Array<OptionalOrderParams>(),
2872
+ referrerInfo?: ReferrerInfo,
2873
+ cancelExistingOrders?: boolean,
2874
+ settlePnl?: boolean
2875
+ ): Promise<{
2876
+ txSig: TransactionSignature;
2877
+ signedFillTx?: Transaction;
2878
+ signedCancelExistingOrdersTx?: Transaction;
2879
+ signedSettlePnlTx?: Transaction;
2880
+ }> {
2881
+ const preppedTxs = await this.prepareMarketOrderTxs(
2882
+ orderParams,
2883
+ userAccountPublicKey,
2884
+ userAccount,
2885
+ makerInfo,
2886
+ txParams,
2887
+ bracketOrdersParams,
2888
+ referrerInfo,
2889
+ cancelExistingOrders,
2890
+ settlePnl
2863
2891
  );
2864
2892
 
2893
+ const signedTxs = (
2894
+ await this.txHandler.getSignedTransactionMap(preppedTxs, this.wallet)
2895
+ ).signedTxMap;
2896
+
2865
2897
  const { txSig, slot } = await this.sendTransaction(
2866
- signedTransactions[keys.signedMarketOrderTx],
2898
+ signedTxs.marketOrderTx,
2867
2899
  [],
2868
2900
  this.opts,
2869
2901
  true
@@ -2873,13 +2905,10 @@ export class DriftClient {
2873
2905
 
2874
2906
  return {
2875
2907
  txSig,
2876
- signedFillTx: signedTransactions?.[keys.signedFillTx] as Transaction,
2877
- signedCancelExistingOrdersTx: signedTransactions?.[
2878
- keys.signedCancelExistingOrdersTx
2879
- ] as Transaction,
2880
- signedSettlePnlTx: signedTransactions?.[
2881
- keys.signedSettlePnlTx
2882
- ] as Transaction,
2908
+ signedFillTx: signedTxs.fillTx as Transaction,
2909
+ signedCancelExistingOrdersTx:
2910
+ signedTxs.cancelExistingOrdersTx as Transaction,
2911
+ signedSettlePnlTx: signedTxs.settlePnlTx as Transaction,
2883
2912
  };
2884
2913
  }
2885
2914
 
@@ -3269,16 +3298,30 @@ export class DriftClient {
3269
3298
  subAccountId?: number
3270
3299
  ): Promise<TransactionSignature> {
3271
3300
  const { txSig } = await this.sendTransaction(
3272
- await this.buildTransaction(
3273
- await this.getPlaceOrdersIx(params, subAccountId),
3274
- txParams
3275
- ),
3301
+ (await this.preparePlaceOrdersTx(params, txParams, subAccountId))
3302
+ .placeOrdersTx,
3276
3303
  [],
3277
- this.opts
3304
+ this.opts,
3305
+ false
3278
3306
  );
3279
3307
  return txSig;
3280
3308
  }
3281
3309
 
3310
+ public async preparePlaceOrdersTx(
3311
+ params: OrderParams[],
3312
+ txParams?: TxParams,
3313
+ subAccountId?: number
3314
+ ) {
3315
+ const tx = await this.buildTransaction(
3316
+ await this.getPlaceOrdersIx(params, subAccountId),
3317
+ txParams
3318
+ );
3319
+
3320
+ return {
3321
+ placeOrdersTx: tx,
3322
+ };
3323
+ }
3324
+
3282
3325
  public async getPlaceOrdersIx(
3283
3326
  params: OptionalOrderParams[],
3284
3327
  subAccountId?: number
@@ -3449,18 +3492,32 @@ export class DriftClient {
3449
3492
  subAccountId?: number
3450
3493
  ): Promise<TransactionSignature> {
3451
3494
  const { txSig, slot } = await this.sendTransaction(
3452
- await this.buildTransaction(
3453
- await this.getPlaceSpotOrderIx(orderParams, subAccountId),
3454
- txParams
3455
- ),
3495
+ (await this.preparePlaceSpotOrderTx(orderParams, txParams, subAccountId))
3496
+ .placeSpotOrderTx,
3456
3497
  [],
3457
- this.opts
3498
+ this.opts,
3499
+ false
3458
3500
  );
3459
3501
  this.spotMarketLastSlotCache.set(orderParams.marketIndex, slot);
3460
3502
  this.spotMarketLastSlotCache.set(QUOTE_SPOT_MARKET_INDEX, slot);
3461
3503
  return txSig;
3462
3504
  }
3463
3505
 
3506
+ public async preparePlaceSpotOrderTx(
3507
+ orderParams: OptionalOrderParams,
3508
+ txParams?: TxParams,
3509
+ subAccountId?: number
3510
+ ) {
3511
+ const tx = await this.buildTransaction(
3512
+ await this.getPlaceSpotOrderIx(orderParams, subAccountId),
3513
+ txParams
3514
+ );
3515
+
3516
+ return {
3517
+ placeSpotOrderTx: tx,
3518
+ };
3519
+ }
3520
+
3464
3521
  public async getPlaceSpotOrderIx(
3465
3522
  orderParams: OptionalOrderParams,
3466
3523
  subAccountId?: number
@@ -4515,7 +4572,7 @@ export class DriftClient {
4515
4572
  return txSig;
4516
4573
  }
4517
4574
 
4518
- public async placeAndTakePerpWithAdditionalOrders(
4575
+ public async preparePlaceAndTakePerpOrderWithAdditionalOrders(
4519
4576
  orderParams: OptionalOrderParams,
4520
4577
  makerInfo?: MakerInfo | MakerInfo[],
4521
4578
  referrerInfo?: ReferrerInfo,
@@ -4526,21 +4583,18 @@ export class DriftClient {
4526
4583
  settlePnl?: boolean,
4527
4584
  exitEarlyIfSimFails?: boolean
4528
4585
  ): Promise<{
4529
- txSig: TransactionSignature;
4530
- signedCancelExistingOrdersTx?: Transaction;
4531
- signedSettlePnlTx?: Transaction;
4586
+ placeAndTakeTx: Transaction | VersionedTransaction;
4587
+ cancelExistingOrdersTx: Transaction | VersionedTransaction;
4588
+ settlePnlTx: Transaction | VersionedTransaction;
4532
4589
  }> {
4533
4590
  const placeAndTakeIxs: TransactionInstruction[] = [];
4534
4591
 
4535
- const txsToSign: {
4536
- key: string;
4537
- tx: Transaction | VersionedTransaction;
4538
- }[] = [];
4592
+ type TxKeys = 'placeAndTakeTx' | 'cancelExistingOrdersTx' | 'settlePnlTx';
4539
4593
 
4540
- const keys = {
4541
- placeAndTakeIx: 'placeAndTakeIx',
4542
- cancelExistingOrdersTx: 'cancelExistingOrdersTx',
4543
- settlePnlTx: 'settlePnlTx',
4594
+ const txsToSign: Record<TxKeys, Transaction | VersionedTransaction> = {
4595
+ placeAndTakeTx: undefined,
4596
+ cancelExistingOrdersTx: undefined,
4597
+ settlePnlTx: undefined,
4544
4598
  };
4545
4599
 
4546
4600
  // Get recent block hash so that we can re-use it for all transactions. Makes this logic run faster with fewer RPC requests
@@ -4598,32 +4652,26 @@ export class DriftClient {
4598
4652
  return;
4599
4653
  }
4600
4654
 
4601
- txsToSign.push({
4602
- key: keys.placeAndTakeIx,
4603
- tx: await this.buildTransaction(
4604
- placeAndTakeIxs,
4605
- {
4606
- ...txParamsWithoutImplicitSimulation,
4607
- computeUnits: simulationResult.computeUnits,
4608
- },
4609
- undefined,
4610
- undefined,
4611
- undefined,
4612
- recentBlockHash
4613
- ),
4614
- });
4655
+ txsToSign.placeAndTakeTx = await this.buildTransaction(
4656
+ placeAndTakeIxs,
4657
+ {
4658
+ ...txParamsWithoutImplicitSimulation,
4659
+ computeUnits: simulationResult.computeUnits,
4660
+ },
4661
+ undefined,
4662
+ undefined,
4663
+ undefined,
4664
+ recentBlockHash
4665
+ );
4615
4666
  } else {
4616
- txsToSign.push({
4617
- key: keys.placeAndTakeIx,
4618
- tx: await this.buildTransaction(
4619
- placeAndTakeIxs,
4620
- txParams,
4621
- undefined,
4622
- undefined,
4623
- undefined,
4624
- recentBlockHash
4625
- ),
4626
- });
4667
+ txsToSign.placeAndTakeTx = await this.buildTransaction(
4668
+ placeAndTakeIxs,
4669
+ txParams,
4670
+ undefined,
4671
+ undefined,
4672
+ undefined,
4673
+ recentBlockHash
4674
+ );
4627
4675
  }
4628
4676
 
4629
4677
  return;
@@ -4638,17 +4686,14 @@ export class DriftClient {
4638
4686
  subAccountId
4639
4687
  );
4640
4688
 
4641
- txsToSign.push({
4642
- key: keys.cancelExistingOrdersTx,
4643
- tx: await this.buildTransaction(
4644
- [cancelOrdersIx],
4645
- txParams,
4646
- this.txVersion,
4647
- undefined,
4648
- undefined,
4649
- recentBlockHash
4650
- ),
4651
- });
4689
+ txsToSign.cancelExistingOrdersTx = await this.buildTransaction(
4690
+ [cancelOrdersIx],
4691
+ txParams,
4692
+ this.txVersion,
4693
+ undefined,
4694
+ undefined,
4695
+ recentBlockHash
4696
+ );
4652
4697
  }
4653
4698
 
4654
4699
  return;
@@ -4666,17 +4711,14 @@ export class DriftClient {
4666
4711
  orderParams.marketIndex
4667
4712
  );
4668
4713
 
4669
- txsToSign.push({
4670
- key: keys.settlePnlTx,
4671
- tx: await this.buildTransaction(
4672
- [settlePnlIx],
4673
- txParams,
4674
- this.txVersion,
4675
- undefined,
4676
- undefined,
4677
- recentBlockHash
4678
- ),
4679
- });
4714
+ txsToSign.settlePnlTx = await this.buildTransaction(
4715
+ [settlePnlIx],
4716
+ txParams,
4717
+ this.txVersion,
4718
+ undefined,
4719
+ undefined,
4720
+ recentBlockHash
4721
+ );
4680
4722
  }
4681
4723
  return;
4682
4724
  };
@@ -4691,14 +4733,46 @@ export class DriftClient {
4691
4733
  return null;
4692
4734
  }
4693
4735
 
4694
- const signedTxs = await this.txHandler.getSignedTransactionMap(
4695
- txsToSign.map((tx) => tx.tx),
4696
- txsToSign.map((tx) => tx.key),
4697
- this.provider.wallet
4698
- );
4736
+ return txsToSign;
4737
+ }
4738
+
4739
+ public async placeAndTakePerpWithAdditionalOrders(
4740
+ orderParams: OptionalOrderParams,
4741
+ makerInfo?: MakerInfo | MakerInfo[],
4742
+ referrerInfo?: ReferrerInfo,
4743
+ bracketOrdersParams = new Array<OptionalOrderParams>(),
4744
+ txParams?: TxParams,
4745
+ subAccountId?: number,
4746
+ cancelExistingOrders?: boolean,
4747
+ settlePnl?: boolean,
4748
+ exitEarlyIfSimFails?: boolean
4749
+ ): Promise<{
4750
+ txSig: TransactionSignature;
4751
+ signedCancelExistingOrdersTx?: Transaction;
4752
+ signedSettlePnlTx?: Transaction;
4753
+ }> {
4754
+ const txsToSign =
4755
+ await this.preparePlaceAndTakePerpOrderWithAdditionalOrders(
4756
+ orderParams,
4757
+ makerInfo,
4758
+ referrerInfo,
4759
+ bracketOrdersParams,
4760
+ txParams,
4761
+ subAccountId,
4762
+ cancelExistingOrders,
4763
+ settlePnl,
4764
+ exitEarlyIfSimFails
4765
+ );
4766
+
4767
+ const signedTxs = (
4768
+ await this.txHandler.getSignedTransactionMap(
4769
+ txsToSign,
4770
+ this.provider.wallet
4771
+ )
4772
+ ).signedTxMap;
4699
4773
 
4700
4774
  const { txSig, slot } = await this.sendTransaction(
4701
- signedTxs[keys.placeAndTakeIx],
4775
+ signedTxs.placeAndTakeTx,
4702
4776
  [],
4703
4777
  this.opts,
4704
4778
  true
@@ -4708,10 +4782,9 @@ export class DriftClient {
4708
4782
 
4709
4783
  return {
4710
4784
  txSig,
4711
- signedCancelExistingOrdersTx: signedTxs[
4712
- keys.cancelExistingOrdersTx
4713
- ] as Transaction,
4714
- signedSettlePnlTx: signedTxs[keys.settlePnlTx] as Transaction,
4785
+ signedCancelExistingOrdersTx:
4786
+ signedTxs.cancelExistingOrdersTx as Transaction,
4787
+ signedSettlePnlTx: signedTxs.settlePnlTx as Transaction,
4715
4788
  };
4716
4789
  }
4717
4790
 
@@ -4864,6 +4937,30 @@ export class DriftClient {
4864
4937
  );
4865
4938
  }
4866
4939
 
4940
+ public async preparePlaceAndTakeSpotOrder(
4941
+ orderParams: OptionalOrderParams,
4942
+ fulfillmentConfig?: SerumV3FulfillmentConfigAccount,
4943
+ makerInfo?: MakerInfo,
4944
+ referrerInfo?: ReferrerInfo,
4945
+ txParams?: TxParams,
4946
+ subAccountId?: number
4947
+ ) {
4948
+ const tx = await this.buildTransaction(
4949
+ await this.getPlaceAndTakeSpotOrderIx(
4950
+ orderParams,
4951
+ fulfillmentConfig,
4952
+ makerInfo,
4953
+ referrerInfo,
4954
+ subAccountId
4955
+ ),
4956
+ txParams
4957
+ );
4958
+
4959
+ return {
4960
+ placeAndTakeSpotOrderTx: tx,
4961
+ };
4962
+ }
4963
+
4867
4964
  public async placeAndTakeSpotOrder(
4868
4965
  orderParams: OptionalOrderParams,
4869
4966
  fulfillmentConfig?: SerumV3FulfillmentConfigAccount,
@@ -4873,18 +4970,19 @@ export class DriftClient {
4873
4970
  subAccountId?: number
4874
4971
  ): Promise<TransactionSignature> {
4875
4972
  const { txSig, slot } = await this.sendTransaction(
4876
- await this.buildTransaction(
4877
- await this.getPlaceAndTakeSpotOrderIx(
4973
+ (
4974
+ await this.preparePlaceAndTakeSpotOrder(
4878
4975
  orderParams,
4879
4976
  fulfillmentConfig,
4880
4977
  makerInfo,
4881
4978
  referrerInfo,
4979
+ txParams,
4882
4980
  subAccountId
4883
- ),
4884
- txParams
4885
- ),
4981
+ )
4982
+ ).placeAndTakeSpotOrderTx,
4886
4983
  [],
4887
- this.opts
4984
+ this.opts,
4985
+ false
4888
4986
  );
4889
4987
  this.spotMarketLastSlotCache.set(orderParams.marketIndex, slot);
4890
4988
  this.spotMarketLastSlotCache.set(QUOTE_SPOT_MARKET_INDEX, slot);
@@ -5229,9 +5327,9 @@ export class DriftClient {
5229
5327
  oraclePriceOffset: newOraclePriceOffset || null,
5230
5328
  triggerPrice: newTriggerPrice || null,
5231
5329
  triggerCondition: newTriggerCondition || null,
5232
- auctionDuration: auctionDuration || 0,
5233
- auctionStartPrice: auctionStartPrice || ZERO,
5234
- auctionEndPrice: auctionEndPrice || ZERO,
5330
+ auctionDuration: auctionDuration || null,
5331
+ auctionStartPrice: auctionStartPrice || null,
5332
+ auctionEndPrice: auctionEndPrice || null,
5235
5333
  reduceOnly: reduceOnly != undefined ? reduceOnly : null,
5236
5334
  postOnly: postOnly != undefined ? postOnly : null,
5237
5335
  immediateOrCancel:
@@ -6814,16 +6912,41 @@ export class DriftClient {
6814
6912
  });
6815
6913
  }
6816
6914
 
6817
- async buildAndSignBulkTransactions(
6818
- instructions: (TransactionInstruction | TransactionInstruction[])[],
6819
- keys: string[],
6915
+ async buildTransactionsMap(
6916
+ instructionsMap: Record<
6917
+ string,
6918
+ TransactionInstruction | TransactionInstruction[]
6919
+ >,
6920
+ txParams?: TxParams,
6921
+ txVersion?: TransactionVersion,
6922
+ lookupTables?: AddressLookupTableAccount[],
6923
+ forceVersionedTransaction?: boolean
6924
+ ) {
6925
+ return this.txHandler.buildTransactionsMap({
6926
+ instructionsMap,
6927
+ txVersion: txVersion ?? this.txVersion,
6928
+ txParams: txParams ?? this.txParams,
6929
+ connection: this.connection,
6930
+ preFlightCommitment: this.opts.preflightCommitment,
6931
+ fetchMarketLookupTableAccount:
6932
+ this.fetchMarketLookupTableAccount.bind(this),
6933
+ lookupTables,
6934
+ forceVersionedTransaction,
6935
+ });
6936
+ }
6937
+
6938
+ async buildAndSignTransactionsMap(
6939
+ instructionsMap: Record<
6940
+ string,
6941
+ TransactionInstruction | TransactionInstruction[]
6942
+ >,
6820
6943
  txParams?: TxParams,
6821
6944
  txVersion?: TransactionVersion,
6822
6945
  lookupTables?: AddressLookupTableAccount[],
6823
6946
  forceVersionedTransaction?: boolean
6824
6947
  ) {
6825
6948
  return this.txHandler.buildAndSignTransactionMap({
6826
- instructions,
6949
+ instructionsMap,
6827
6950
  txVersion: txVersion ?? this.txVersion,
6828
6951
  txParams: txParams ?? this.txParams,
6829
6952
  connection: this.connection,
@@ -6832,7 +6955,6 @@ export class DriftClient {
6832
6955
  this.fetchMarketLookupTableAccount.bind(this),
6833
6956
  lookupTables,
6834
6957
  forceVersionedTransaction,
6835
- keys,
6836
6958
  });
6837
6959
  }
6838
6960
  }
@@ -7,6 +7,7 @@ import { QuoteAssetOracleClient } from '../oracles/quoteAssetOracleClient';
7
7
  import { BN, Program } from '@coral-xyz/anchor';
8
8
  import { PrelaunchOracleClient } from '../oracles/prelaunchOracleClient';
9
9
  import { SwitchboardClient } from '../oracles/switchboardClient';
10
+ import { PythPullClient } from '../oracles/pythPullClient';
10
11
 
11
12
  export function getOracleClient(
12
13
  oracleSource: OracleSource,
@@ -17,18 +18,34 @@ export function getOracleClient(
17
18
  return new PythClient(connection);
18
19
  }
19
20
 
21
+ if (isVariant(oracleSource, 'pythPull')) {
22
+ return new PythPullClient(connection);
23
+ }
24
+
20
25
  if (isVariant(oracleSource, 'pyth1K')) {
21
26
  return new PythClient(connection, new BN(1000));
22
27
  }
23
28
 
29
+ if (isVariant(oracleSource, 'pyth1KPull')) {
30
+ return new PythPullClient(connection, new BN(1000));
31
+ }
32
+
24
33
  if (isVariant(oracleSource, 'pyth1M')) {
25
34
  return new PythClient(connection, new BN(1000000));
26
35
  }
27
36
 
37
+ if (isVariant(oracleSource, 'pyth1MPull')) {
38
+ return new PythPullClient(connection, new BN(1000000));
39
+ }
40
+
28
41
  if (isVariant(oracleSource, 'pythStableCoin')) {
29
42
  return new PythClient(connection, undefined, true);
30
43
  }
31
44
 
45
+ if (isVariant(oracleSource, 'pythStableCoinPull')) {
46
+ return new PythPullClient(connection, undefined, true);
47
+ }
48
+
32
49
  if (isVariant(oracleSource, 'switchboard')) {
33
50
  return new SwitchboardClient(connection);
34
51
  }