@drift-labs/sdk 2.152.0-beta.2 → 2.153.0-beta.0

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.
Files changed (44) hide show
  1. package/VERSION +1 -1
  2. package/build-browser.js +58 -0
  3. package/bun.lock +182 -1
  4. package/esbuild-shims.js +12 -0
  5. package/lib/browser/constants/perpMarkets.js +12 -0
  6. package/lib/browser/constants/txConstants.d.ts +1 -0
  7. package/lib/browser/constants/txConstants.js +2 -1
  8. package/lib/browser/driftClient.d.ts +13 -6
  9. package/lib/browser/driftClient.js +280 -36
  10. package/lib/browser/idl/drift.json +207 -18
  11. package/lib/browser/markets.d.ts +5 -0
  12. package/lib/browser/markets.js +16 -0
  13. package/lib/browser/swap/UnifiedSwapClient.js +2 -0
  14. package/lib/browser/titan/titanClient.d.ts +3 -0
  15. package/lib/browser/titan/titanClient.js +58 -60
  16. package/lib/browser/user.d.ts +1 -1
  17. package/lib/node/constants/perpMarkets.d.ts.map +1 -1
  18. package/lib/node/constants/perpMarkets.js +12 -0
  19. package/lib/node/constants/txConstants.d.ts +1 -0
  20. package/lib/node/constants/txConstants.d.ts.map +1 -1
  21. package/lib/node/constants/txConstants.js +2 -1
  22. package/lib/node/driftClient.d.ts +13 -6
  23. package/lib/node/driftClient.d.ts.map +1 -1
  24. package/lib/node/driftClient.js +280 -36
  25. package/lib/node/idl/drift.json +207 -18
  26. package/lib/node/markets.d.ts +6 -0
  27. package/lib/node/markets.d.ts.map +1 -0
  28. package/lib/node/markets.js +16 -0
  29. package/lib/node/swap/UnifiedSwapClient.d.ts.map +1 -1
  30. package/lib/node/swap/UnifiedSwapClient.js +2 -0
  31. package/lib/node/titan/titanClient.d.ts +3 -0
  32. package/lib/node/titan/titanClient.d.ts.map +1 -1
  33. package/lib/node/titan/titanClient.js +58 -60
  34. package/lib/node/user.d.ts +1 -1
  35. package/lib/node/user.d.ts.map +1 -1
  36. package/package.json +10 -2
  37. package/src/constants/perpMarkets.ts +13 -0
  38. package/src/constants/txConstants.ts +2 -0
  39. package/src/driftClient.ts +477 -52
  40. package/src/idl/drift.json +207 -18
  41. package/src/markets.ts +24 -0
  42. package/src/swap/UnifiedSwapClient.ts +2 -0
  43. package/src/titan/titanClient.ts +88 -72
  44. package/src/user.ts +1 -1
@@ -221,6 +221,7 @@ import {
221
221
  } from './math/builder';
222
222
  import { TitanClient, SwapMode as TitanSwapMode } from './titan/titanClient';
223
223
  import { UnifiedSwapClient } from './swap/UnifiedSwapClient';
224
+ import { DEFAULT_COMMITMENT_LEVEL } from './constants';
224
225
 
225
226
  /**
226
227
  * Union type for swap clients (Titan and Jupiter) - Legacy type
@@ -428,19 +429,17 @@ export class DriftClient {
428
429
  });
429
430
  }
430
431
 
431
- this.marketLookupTable = config.marketLookupTable;
432
- if (!this.marketLookupTable) {
433
- this.marketLookupTable = new PublicKey(
434
- configs[this.env].MARKET_LOOKUP_TABLE
435
- );
436
- }
432
+ this.marketLookupTable = config.marketLookupTable
433
+ ? config.marketLookupTable
434
+ : (this.marketLookupTable = new PublicKey(
435
+ configs[this.env].MARKET_LOOKUP_TABLE
436
+ ));
437
437
 
438
- this.marketLookupTables = config.marketLookupTables;
439
- if (!this.marketLookupTables) {
440
- this.marketLookupTables = configs[this.env].MARKET_LOOKUP_TABLES.map(
441
- (tableAddr) => new PublicKey(tableAddr)
442
- );
443
- }
438
+ this.marketLookupTables = config.marketLookupTables
439
+ ? config.marketLookupTables
440
+ : configs[this.env].MARKET_LOOKUP_TABLES.map(
441
+ (tableAddr) => new PublicKey(tableAddr)
442
+ );
444
443
 
445
444
  const delistedMarketSetting =
446
445
  config.delistedMarketSetting || DelistedMarketSetting.Unsubscribe;
@@ -2469,6 +2468,15 @@ export class DriftClient {
2469
2468
  return this.getTokenAmount(QUOTE_SPOT_MARKET_INDEX);
2470
2469
  }
2471
2470
 
2471
+ public getIsolatedPerpPositionTokenAmount(
2472
+ perpMarketIndex: number,
2473
+ subAccountId?: number
2474
+ ): BN {
2475
+ return this.getUser(subAccountId).getIsolatePerpPositionTokenAmount(
2476
+ perpMarketIndex
2477
+ );
2478
+ }
2479
+
2472
2480
  /**
2473
2481
  * Returns the token amount for a given market. The spot market precision is based on the token mint decimals.
2474
2482
  * Positive if it is a deposit, negative if it is a borrow.
@@ -3367,6 +3375,25 @@ export class DriftClient {
3367
3375
  ixs.push(...startIxs);
3368
3376
  }
3369
3377
 
3378
+ // For Token2022 tokens, check if the user's token account exists and create it if it doesn't
3379
+ const tokenProgram = this.getTokenProgramForSpotMarket(spotMarket);
3380
+ if (
3381
+ !isSolMarket &&
3382
+ !isFromSubaccount &&
3383
+ !tokenProgram.equals(TOKEN_PROGRAM_ID)
3384
+ ) {
3385
+ const accountExists = await this.checkIfAccountExists(userTokenAccount);
3386
+
3387
+ if (!accountExists) {
3388
+ const createAtaIx = this.getAssociatedTokenAccountCreationIx(
3389
+ spotMarket.mint,
3390
+ userTokenAccount,
3391
+ tokenProgram
3392
+ );
3393
+ ixs.push(createAtaIx);
3394
+ }
3395
+ }
3396
+
3370
3397
  const depositCollateralIx = isFromSubaccount
3371
3398
  ? await this.getTransferDepositIx(
3372
3399
  amount,
@@ -4082,6 +4109,191 @@ export class DriftClient {
4082
4109
  );
4083
4110
  }
4084
4111
 
4112
+ async depositIntoIsolatedPerpPosition(
4113
+ amount: BN,
4114
+ perpMarketIndex: number,
4115
+ userTokenAccount: PublicKey,
4116
+ subAccountId?: number,
4117
+ txParams?: TxParams
4118
+ ): Promise<TransactionSignature> {
4119
+ const { txSig } = await this.sendTransaction(
4120
+ await this.buildTransaction(
4121
+ await this.getDepositIntoIsolatedPerpPositionIx(
4122
+ amount,
4123
+ perpMarketIndex,
4124
+ userTokenAccount,
4125
+ subAccountId
4126
+ ),
4127
+ txParams
4128
+ ),
4129
+ [],
4130
+ this.opts
4131
+ );
4132
+ return txSig;
4133
+ }
4134
+
4135
+ async getDepositIntoIsolatedPerpPositionIx(
4136
+ amount: BN,
4137
+ perpMarketIndex: number,
4138
+ userTokenAccount: PublicKey,
4139
+ subAccountId?: number
4140
+ ): Promise<TransactionInstruction> {
4141
+ const userAccountPublicKey = await getUserAccountPublicKey(
4142
+ this.program.programId,
4143
+ this.authority,
4144
+ subAccountId ?? this.activeSubAccountId
4145
+ );
4146
+
4147
+ const perpMarketAccount = this.getPerpMarketAccount(perpMarketIndex);
4148
+ const spotMarketIndex = perpMarketAccount.quoteSpotMarketIndex;
4149
+ const spotMarketAccount = this.getSpotMarketAccount(spotMarketIndex);
4150
+
4151
+ const remainingAccounts = this.getRemainingAccounts({
4152
+ userAccounts: [],
4153
+ writableSpotMarketIndexes: [spotMarketIndex],
4154
+ readablePerpMarketIndex: [perpMarketIndex],
4155
+ });
4156
+
4157
+ const tokenProgram = this.getTokenProgramForSpotMarket(spotMarketAccount);
4158
+ return await this.program.instruction.depositIntoIsolatedPerpPosition(
4159
+ spotMarketIndex,
4160
+ perpMarketIndex,
4161
+ amount,
4162
+ {
4163
+ accounts: {
4164
+ state: await this.getStatePublicKey(),
4165
+ spotMarketVault: spotMarketAccount.vault,
4166
+ user: userAccountPublicKey,
4167
+ userStats: this.getUserStatsAccountPublicKey(),
4168
+ userTokenAccount: userTokenAccount,
4169
+ authority: this.wallet.publicKey,
4170
+ tokenProgram,
4171
+ },
4172
+ remainingAccounts,
4173
+ }
4174
+ );
4175
+ }
4176
+
4177
+ public async transferIsolatedPerpPositionDeposit(
4178
+ amount: BN,
4179
+ perpMarketIndex: number,
4180
+ subAccountId?: number,
4181
+ txParams?: TxParams
4182
+ ): Promise<TransactionSignature> {
4183
+ const { txSig } = await this.sendTransaction(
4184
+ await this.buildTransaction(
4185
+ await this.getTransferIsolatedPerpPositionDepositIx(
4186
+ amount,
4187
+ perpMarketIndex,
4188
+ subAccountId
4189
+ ),
4190
+ txParams
4191
+ ),
4192
+ [],
4193
+ this.opts
4194
+ );
4195
+ return txSig;
4196
+ }
4197
+
4198
+ public async getTransferIsolatedPerpPositionDepositIx(
4199
+ amount: BN,
4200
+ perpMarketIndex: number,
4201
+ subAccountId?: number
4202
+ ): Promise<TransactionInstruction> {
4203
+ const userAccountPublicKey = await getUserAccountPublicKey(
4204
+ this.program.programId,
4205
+ this.authority,
4206
+ subAccountId ?? this.activeSubAccountId
4207
+ );
4208
+
4209
+ const perpMarketAccount = this.getPerpMarketAccount(perpMarketIndex);
4210
+ const spotMarketIndex = perpMarketAccount.quoteSpotMarketIndex;
4211
+ const spotMarketAccount = this.getSpotMarketAccount(spotMarketIndex);
4212
+ const user = await this.getUserAccount(subAccountId);
4213
+ const remainingAccounts = this.getRemainingAccounts({
4214
+ userAccounts: [user],
4215
+ writableSpotMarketIndexes: [spotMarketIndex],
4216
+ readablePerpMarketIndex: [perpMarketIndex],
4217
+ });
4218
+
4219
+ return await this.program.instruction.transferIsolatedPerpPositionDeposit(
4220
+ spotMarketIndex,
4221
+ perpMarketIndex,
4222
+ amount,
4223
+ {
4224
+ accounts: {
4225
+ state: await this.getStatePublicKey(),
4226
+ spotMarketVault: spotMarketAccount.vault,
4227
+ user: userAccountPublicKey,
4228
+ userStats: this.getUserStatsAccountPublicKey(),
4229
+ authority: this.wallet.publicKey,
4230
+ },
4231
+ remainingAccounts,
4232
+ }
4233
+ );
4234
+ }
4235
+
4236
+ public async withdrawFromIsolatedPerpPosition(
4237
+ amount: BN,
4238
+ perpMarketIndex: number,
4239
+ userTokenAccount: PublicKey,
4240
+ subAccountId?: number,
4241
+ txParams?: TxParams
4242
+ ): Promise<TransactionSignature> {
4243
+ const { txSig } = await this.sendTransaction(
4244
+ await this.buildTransaction(
4245
+ await this.getWithdrawFromIsolatedPerpPositionIx(
4246
+ amount,
4247
+ perpMarketIndex,
4248
+ userTokenAccount,
4249
+ subAccountId
4250
+ ),
4251
+ txParams
4252
+ )
4253
+ );
4254
+ return txSig;
4255
+ }
4256
+
4257
+ public async getWithdrawFromIsolatedPerpPositionIx(
4258
+ amount: BN,
4259
+ perpMarketIndex: number,
4260
+ userTokenAccount: PublicKey,
4261
+ subAccountId?: number
4262
+ ): Promise<TransactionInstruction> {
4263
+ const userAccountPublicKey = await getUserAccountPublicKey(
4264
+ this.program.programId,
4265
+ this.authority,
4266
+ subAccountId ?? this.activeSubAccountId
4267
+ );
4268
+ const perpMarketAccount = this.getPerpMarketAccount(perpMarketIndex);
4269
+ const spotMarketIndex = perpMarketAccount.quoteSpotMarketIndex;
4270
+ const spotMarketAccount = this.getSpotMarketAccount(spotMarketIndex);
4271
+ const remainingAccounts = this.getRemainingAccounts({
4272
+ userAccounts: [this.getUserAccount(subAccountId)],
4273
+ writableSpotMarketIndexes: [spotMarketIndex],
4274
+ readablePerpMarketIndex: [perpMarketIndex],
4275
+ });
4276
+
4277
+ return await this.program.instruction.withdrawFromIsolatedPerpPosition(
4278
+ spotMarketIndex,
4279
+ perpMarketIndex,
4280
+ amount,
4281
+ {
4282
+ accounts: {
4283
+ state: await this.getStatePublicKey(),
4284
+ spotMarketVault: spotMarketAccount.vault,
4285
+ user: userAccountPublicKey,
4286
+ userStats: this.getUserStatsAccountPublicKey(),
4287
+ authority: this.wallet.publicKey,
4288
+ userTokenAccount: userTokenAccount,
4289
+ tokenProgram: this.getTokenProgramForSpotMarket(spotMarketAccount),
4290
+ driftSigner: this.getSignerPublicKey(),
4291
+ },
4292
+ remainingAccounts,
4293
+ }
4294
+ );
4295
+ }
4296
+
4085
4297
  public async updateSpotMarketCumulativeInterest(
4086
4298
  marketIndex: number,
4087
4299
  txParams?: TxParams
@@ -8862,8 +9074,14 @@ export class DriftClient {
8862
9074
  );
8863
9075
  const liquidatorStatsPublicKey = this.getUserStatsAccountPublicKey();
8864
9076
 
9077
+ const liquidatorUser = this.getUserAccount(liquidatorSubAccountId);
9078
+ if (!liquidatorUser) {
9079
+ throw new Error(
9080
+ `Liquidator user account not found for subaccount id ${liquidatorSubAccountId}`
9081
+ );
9082
+ }
8865
9083
  const remainingAccounts = this.getRemainingAccounts({
8866
- userAccounts: [this.getUserAccount(liquidatorSubAccountId), userAccount],
9084
+ userAccounts: [liquidatorUser, userAccount],
8867
9085
  useMarketLastSlotCache: true,
8868
9086
  writableSpotMarketIndexes: [liabilityMarketIndex, assetMarketIndex],
8869
9087
  });
@@ -8924,7 +9142,17 @@ export class DriftClient {
8924
9142
  lookupTables: AddressLookupTableAccount[];
8925
9143
  }> {
8926
9144
  const liabilityMarket = this.getSpotMarketAccount(liabilityMarketIndex);
9145
+ if (!liabilityMarket) {
9146
+ throw new Error(
9147
+ `Liability spot market account not found for index ${liabilityMarketIndex}`
9148
+ );
9149
+ }
8927
9150
  const assetMarket = this.getSpotMarketAccount(assetMarketIndex);
9151
+ if (!assetMarket) {
9152
+ throw new Error(
9153
+ `Asset spot market account not found for index ${assetMarketIndex}`
9154
+ );
9155
+ }
8928
9156
 
8929
9157
  if (!quote) {
8930
9158
  const fetchedQuote = await jupiterClient.getQuote({
@@ -8963,7 +9191,7 @@ export class DriftClient {
8963
9191
  outputMint: liabilityMarket.mint,
8964
9192
  });
8965
9193
 
8966
- const preInstructions = [];
9194
+ const preInstructions: TransactionInstruction[] = [];
8967
9195
  if (!liabilityTokenAccount) {
8968
9196
  const tokenProgram = this.getTokenProgramForSpotMarket(liabilityMarket);
8969
9197
  liabilityTokenAccount = await this.getAssociatedTokenAccount(
@@ -9073,7 +9301,17 @@ export class DriftClient {
9073
9301
  });
9074
9302
 
9075
9303
  const liabilitySpotMarket = this.getSpotMarketAccount(liabilityMarketIndex);
9304
+ if (!liabilitySpotMarket) {
9305
+ throw new Error(
9306
+ `Liability spot market account not found for index ${liabilityMarketIndex}`
9307
+ );
9308
+ }
9076
9309
  const assetSpotMarket = this.getSpotMarketAccount(assetMarketIndex);
9310
+ if (!assetSpotMarket) {
9311
+ throw new Error(
9312
+ `Asset spot market account not found for index ${assetMarketIndex}`
9313
+ );
9314
+ }
9077
9315
 
9078
9316
  const liabilityTokenProgram =
9079
9317
  this.getTokenProgramForSpotMarket(liabilitySpotMarket);
@@ -9189,7 +9427,17 @@ export class DriftClient {
9189
9427
  });
9190
9428
 
9191
9429
  const inSpotMarket = this.getSpotMarketAccount(inMarketIndex);
9430
+ if (!inSpotMarket) {
9431
+ throw new Error(
9432
+ `In spot market account not found for index ${inMarketIndex}`
9433
+ );
9434
+ }
9192
9435
  const outSpotMarket = this.getSpotMarketAccount(outMarketIndex);
9436
+ if (!outSpotMarket) {
9437
+ throw new Error(
9438
+ `Out spot market account not found for index ${outMarketIndex}`
9439
+ );
9440
+ }
9193
9441
 
9194
9442
  if (this.isToken2022(inSpotMarket) || this.isToken2022(outSpotMarket)) {
9195
9443
  remainingAccounts.push({
@@ -9315,9 +9563,15 @@ export class DriftClient {
9315
9563
  liquidatorSubAccountId
9316
9564
  );
9317
9565
  const liquidatorStatsPublicKey = this.getUserStatsAccountPublicKey();
9566
+ const liquidatorUser = this.getUserAccount(liquidatorSubAccountId);
9567
+ if (!liquidatorUser) {
9568
+ throw new Error(
9569
+ `Liquidator user account not found for subaccount id ${liquidatorSubAccountId}`
9570
+ );
9571
+ }
9318
9572
 
9319
9573
  const remainingAccounts = this.getRemainingAccounts({
9320
- userAccounts: [this.getUserAccount(liquidatorSubAccountId), userAccount],
9574
+ userAccounts: [liquidatorUser, userAccount],
9321
9575
  writablePerpMarketIndexes: [perpMarketIndex],
9322
9576
  writableSpotMarketIndexes: [liabilityMarketIndex],
9323
9577
  });
@@ -9390,9 +9644,15 @@ export class DriftClient {
9390
9644
  liquidatorSubAccountId
9391
9645
  );
9392
9646
  const liquidatorStatsPublicKey = this.getUserStatsAccountPublicKey();
9647
+ const liquidatorUser = this.getUserAccount(liquidatorSubAccountId);
9648
+ if (!liquidatorUser) {
9649
+ throw new Error(
9650
+ `Liquidator user account not found for subaccount id ${liquidatorSubAccountId}`
9651
+ );
9652
+ }
9393
9653
 
9394
9654
  const remainingAccounts = this.getRemainingAccounts({
9395
- userAccounts: [this.getUserAccount(liquidatorSubAccountId), userAccount],
9655
+ userAccounts: [liquidatorUser, userAccount],
9396
9656
  writablePerpMarketIndexes: [perpMarketIndex],
9397
9657
  writableSpotMarketIndexes: [assetMarketIndex],
9398
9658
  });
@@ -9454,9 +9714,15 @@ export class DriftClient {
9454
9714
  liquidatorSubAccountId
9455
9715
  );
9456
9716
  const liquidatorStatsPublicKey = this.getUserStatsAccountPublicKey();
9717
+ const liquidatorUser = this.getUserAccount(liquidatorSubAccountId);
9718
+ if (!liquidatorUser) {
9719
+ throw new Error(
9720
+ `Liquidator user account not found for subaccount id ${liquidatorSubAccountId}`
9721
+ );
9722
+ }
9457
9723
 
9458
9724
  const remainingAccounts = this.getRemainingAccounts({
9459
- userAccounts: [this.getUserAccount(liquidatorSubAccountId), userAccount],
9725
+ userAccounts: [liquidatorUser, userAccount],
9460
9726
  writablePerpMarketIndexes: [marketIndex],
9461
9727
  writableSpotMarketIndexes: [QUOTE_SPOT_MARKET_INDEX],
9462
9728
  });
@@ -9523,12 +9789,22 @@ export class DriftClient {
9523
9789
  );
9524
9790
  const liquidatorStatsPublicKey = this.getUserStatsAccountPublicKey();
9525
9791
 
9792
+ const liquidatorUser = this.getUserAccount(liquidatorSubAccountId);
9793
+ if (!liquidatorUser) {
9794
+ throw new Error(
9795
+ `Liquidator user account not found for subaccount id ${liquidatorSubAccountId}`
9796
+ );
9797
+ }
9798
+
9526
9799
  const remainingAccounts = this.getRemainingAccounts({
9527
- userAccounts: [this.getUserAccount(liquidatorSubAccountId), userAccount],
9800
+ userAccounts: [liquidatorUser, userAccount],
9528
9801
  writableSpotMarketIndexes: [marketIndex],
9529
9802
  });
9530
9803
 
9531
9804
  const spotMarket = this.getSpotMarketAccount(marketIndex);
9805
+ if (!spotMarket) {
9806
+ throw new Error(`Spot market account not found for index ${marketIndex}`);
9807
+ }
9532
9808
  const tokenProgramId = this.getTokenProgramForSpotMarket(spotMarket);
9533
9809
 
9534
9810
  this.addTokenMintToRemainingAccounts(spotMarket, remainingAccounts);
@@ -9608,6 +9884,11 @@ export class DriftClient {
9608
9884
  perpMarketIndex: number
9609
9885
  ): Promise<TransactionInstruction> {
9610
9886
  const perpMarket = this.getPerpMarketAccount(perpMarketIndex);
9887
+ if (!perpMarket) {
9888
+ throw new Error(
9889
+ `Perp market account not found for index ${perpMarketIndex}`
9890
+ );
9891
+ }
9611
9892
 
9612
9893
  if (!isVariant(perpMarket.amm.oracleSource, 'prelaunch')) {
9613
9894
  throw new Error(`Wrong oracle source ${perpMarket.amm.oracleSource}`);
@@ -9643,8 +9924,13 @@ export class DriftClient {
9643
9924
  makers: [PublicKey, PublicKey][]
9644
9925
  ): Promise<TransactionInstruction> {
9645
9926
  const perpMarket = this.getPerpMarketAccount(perpMarketIndex);
9927
+ if (!perpMarket) {
9928
+ throw new Error(
9929
+ `Perp market account not found for index ${perpMarketIndex}`
9930
+ );
9931
+ }
9646
9932
 
9647
- const remainingAccounts = [];
9933
+ const remainingAccounts: AccountMeta[] = [];
9648
9934
  for (const [maker, makerStats] of makers) {
9649
9935
  remainingAccounts.push({
9650
9936
  pubkey: maker,
@@ -9692,7 +9978,7 @@ export class DriftClient {
9692
9978
  userAccountPublicKey
9693
9979
  )) as UserAccount;
9694
9980
 
9695
- const writablePerpMarketIndexes = [];
9981
+ const writablePerpMarketIndexes: number[] = [];
9696
9982
  for (const position of userAccount.perpPositions) {
9697
9983
  if (!positionIsAvailable(position)) {
9698
9984
  writablePerpMarketIndexes.push(position.marketIndex);
@@ -9717,15 +10003,25 @@ export class DriftClient {
9717
10003
  this.eventEmitter.emit(eventName, data);
9718
10004
  }
9719
10005
 
9720
- public getOracleDataForPerpMarket(marketIndex: number): OraclePriceData {
10006
+ public getOracleDataForPerpMarket(
10007
+ marketIndex: number
10008
+ ): OraclePriceData | undefined {
9721
10009
  return this.accountSubscriber.getOraclePriceDataAndSlotForPerpMarket(
9722
10010
  marketIndex
9723
- ).data;
10011
+ )?.data;
9724
10012
  }
9725
10013
 
9726
- public getMMOracleDataForPerpMarket(marketIndex: number): MMOraclePriceData {
10014
+ public getMMOracleDataForPerpMarket(
10015
+ marketIndex: number
10016
+ ): MMOraclePriceData | undefined {
9727
10017
  const perpMarket = this.getPerpMarketAccount(marketIndex);
10018
+ if (!perpMarket) {
10019
+ throw new Error(`Perp market account not found for index ${marketIndex}`);
10020
+ }
9728
10021
  const oracleData = this.getOracleDataForPerpMarket(marketIndex);
10022
+ if (!oracleData) {
10023
+ return undefined;
10024
+ }
9729
10025
  const stateAccountAndSlot = this.accountSubscriber.getStateAccountAndSlot();
9730
10026
  const isMMOracleActive = !perpMarket.amm.mmOracleSlot.eq(ZERO);
9731
10027
  const pctDiff = perpMarket.amm.mmOraclePrice
@@ -9754,7 +10050,7 @@ export class DriftClient {
9754
10050
  isExchangeOracleMoreRecent = false;
9755
10051
  } else if (
9756
10052
  !doSlotCheckForRecency &&
9757
- oracleData.sequenceId < mmOracleSequenceId
10053
+ (oracleData.sequenceId ?? ZERO) < mmOracleSequenceId
9758
10054
  ) {
9759
10055
  isExchangeOracleMoreRecent = false;
9760
10056
  }
@@ -9791,10 +10087,12 @@ export class DriftClient {
9791
10087
  }
9792
10088
  }
9793
10089
 
9794
- public getOracleDataForSpotMarket(marketIndex: number): OraclePriceData {
10090
+ public getOracleDataForSpotMarket(
10091
+ marketIndex: number
10092
+ ): OraclePriceData | undefined {
9795
10093
  return this.accountSubscriber.getOraclePriceDataAndSlotForSpotMarket(
9796
10094
  marketIndex
9797
- ).data;
10095
+ )?.data;
9798
10096
  }
9799
10097
 
9800
10098
  public async initializeInsuranceFundStake(
@@ -9821,9 +10119,14 @@ export class DriftClient {
9821
10119
  marketIndex
9822
10120
  );
9823
10121
 
10122
+ const spotMarket = this.getSpotMarketAccount(marketIndex);
10123
+ if (!spotMarket) {
10124
+ throw new Error(`Spot market account not found for index ${marketIndex}`);
10125
+ }
10126
+
9824
10127
  const accounts = {
9825
10128
  insuranceFundStake: ifStakeAccountPublicKey,
9826
- spotMarket: this.getSpotMarketAccount(marketIndex).pubkey,
10129
+ spotMarket: spotMarket.pubkey,
9827
10130
  userStats: getUserStatsAccountPublicKey(
9828
10131
  this.program.programId,
9829
10132
  this.wallet.publicKey // only allow payer to initialize own insurance fund stake account
@@ -9849,6 +10152,9 @@ export class DriftClient {
9849
10152
  collateralAccountPublicKey: PublicKey
9850
10153
  ): Promise<TransactionInstruction> {
9851
10154
  const spotMarket = this.getSpotMarketAccount(marketIndex);
10155
+ if (!spotMarket) {
10156
+ throw new Error(`Spot market account not found for index ${marketIndex}`);
10157
+ }
9852
10158
  const ifStakeAccountPublicKey = getInsuranceFundStakeAccountPublicKey(
9853
10159
  this.program.programId,
9854
10160
  this.wallet.publicKey,
@@ -9969,9 +10275,12 @@ export class DriftClient {
9969
10275
  */
9970
10276
  fromSubaccount?: boolean;
9971
10277
  }): Promise<TransactionInstruction[]> {
9972
- const addIfStakeIxs = [];
10278
+ const addIfStakeIxs: TransactionInstruction[] = [];
9973
10279
 
9974
10280
  const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
10281
+ if (!spotMarketAccount) {
10282
+ throw new Error(`Spot market account not found for index ${marketIndex}`);
10283
+ }
9975
10284
  const isSolMarket = spotMarketAccount.mint.equals(WRAPPED_SOL_MINT);
9976
10285
  const createWSOLTokenAccount =
9977
10286
  isSolMarket && collateralAccountPublicKey.equals(this.wallet.publicKey);
@@ -10065,6 +10374,9 @@ export class DriftClient {
10065
10374
  txParams?: TxParams
10066
10375
  ): Promise<TransactionSignature> {
10067
10376
  const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
10377
+ if (!spotMarketAccount) {
10378
+ throw new Error(`Spot market account not found for index ${marketIndex}`);
10379
+ }
10068
10380
  const ifStakeAccountPublicKey = getInsuranceFundStakeAccountPublicKey(
10069
10381
  this.program.programId,
10070
10382
  this.wallet.publicKey,
@@ -10100,6 +10412,9 @@ export class DriftClient {
10100
10412
  txParams?: TxParams
10101
10413
  ): Promise<TransactionSignature> {
10102
10414
  const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
10415
+ if (!spotMarketAccount) {
10416
+ throw new Error(`Spot market account not found for index ${marketIndex}`);
10417
+ }
10103
10418
  const ifStakeAccountPublicKey = getInsuranceFundStakeAccountPublicKey(
10104
10419
  this.program.programId,
10105
10420
  this.wallet.publicKey,
@@ -10135,8 +10450,11 @@ export class DriftClient {
10135
10450
  collateralAccountPublicKey: PublicKey,
10136
10451
  txParams?: TxParams
10137
10452
  ): Promise<TransactionSignature> {
10138
- const removeIfStakeIxs = [];
10453
+ const removeIfStakeIxs: TransactionInstruction[] = [];
10139
10454
  const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
10455
+ if (!spotMarketAccount) {
10456
+ throw new Error(`Spot market account not found for index ${marketIndex}`);
10457
+ }
10140
10458
  const ifStakeAccountPublicKey = getInsuranceFundStakeAccountPublicKey(
10141
10459
  this.program.programId,
10142
10460
  this.wallet.publicKey,
@@ -10246,6 +10564,9 @@ export class DriftClient {
10246
10564
  ): Promise<TransactionInstruction> {
10247
10565
  const marketIndex = QUOTE_SPOT_MARKET_INDEX;
10248
10566
  const spotMarket = this.getSpotMarketAccount(marketIndex);
10567
+ if (!spotMarket) {
10568
+ throw new Error(`Spot market account not found for index ${marketIndex}`);
10569
+ }
10249
10570
  const ifStakeAccountPublicKey = getInsuranceFundStakeAccountPublicKey(
10250
10571
  this.program.programId,
10251
10572
  authority,
@@ -10285,6 +10606,9 @@ export class DriftClient {
10285
10606
  ): Promise<TransactionInstruction> {
10286
10607
  const marketIndex = GOV_SPOT_MARKET_INDEX;
10287
10608
  const spotMarket = this.getSpotMarketAccount(marketIndex);
10609
+ if (!spotMarket) {
10610
+ throw new Error(`Spot market account not found for index ${marketIndex}`);
10611
+ }
10288
10612
  const ifStakeAccountPublicKey = getInsuranceFundStakeAccountPublicKey(
10289
10613
  this.program.programId,
10290
10614
  authority,
@@ -10325,6 +10649,11 @@ export class DriftClient {
10325
10649
  spotMarketIndex: number
10326
10650
  ): Promise<TransactionInstruction> {
10327
10651
  const spotMarketAccount = this.getSpotMarketAccount(spotMarketIndex);
10652
+ if (!spotMarketAccount) {
10653
+ throw new Error(
10654
+ `Spot market account not found for index ${spotMarketIndex}`
10655
+ );
10656
+ }
10328
10657
  const tokenProgramId = this.getTokenProgramForSpotMarket(spotMarketAccount);
10329
10658
 
10330
10659
  const remainingAccounts = [];
@@ -10373,13 +10702,24 @@ export class DriftClient {
10373
10702
  spotMarketIndex: number,
10374
10703
  perpMarketIndex: number
10375
10704
  ): Promise<TransactionInstruction> {
10705
+ const userAccount = this.getUserAccount();
10706
+ if (!userAccount) {
10707
+ throw new Error(
10708
+ `User account not found. Something is wrong with driftClient config`
10709
+ );
10710
+ }
10376
10711
  const remainingAccounts = this.getRemainingAccounts({
10377
- userAccounts: [this.getUserAccount()],
10712
+ userAccounts: [userAccount],
10378
10713
  writablePerpMarketIndexes: [perpMarketIndex],
10379
10714
  writableSpotMarketIndexes: [spotMarketIndex],
10380
10715
  });
10381
10716
 
10382
10717
  const spotMarket = this.getSpotMarketAccount(spotMarketIndex);
10718
+ if (!spotMarket) {
10719
+ throw new Error(
10720
+ `Spot market account not found for index ${spotMarketIndex}`
10721
+ );
10722
+ }
10383
10723
  const tokenProgramId = this.getTokenProgramForSpotMarket(spotMarket);
10384
10724
 
10385
10725
  return await this.program.instruction.resolvePerpPnlDeficit(
@@ -10405,6 +10745,9 @@ export class DriftClient {
10405
10745
  userTokenAccountPublicKey: PublicKey
10406
10746
  ): Promise<TransactionInstruction> {
10407
10747
  const spotMarket = await this.getSpotMarketAccount(marketIndex);
10748
+ if (!spotMarket) {
10749
+ throw new Error(`Spot market account not found for index ${marketIndex}`);
10750
+ }
10408
10751
 
10409
10752
  const remainingAccounts = [];
10410
10753
  this.addTokenMintToRemainingAccounts(spotMarket, remainingAccounts);
@@ -10458,9 +10801,17 @@ export class DriftClient {
10458
10801
 
10459
10802
  public getPerpMarketExtendedInfo(
10460
10803
  marketIndex: number
10461
- ): PerpMarketExtendedInfo {
10804
+ ): PerpMarketExtendedInfo | undefined {
10462
10805
  const marketAccount = this.getPerpMarketAccount(marketIndex);
10806
+ if (!marketAccount) {
10807
+ return undefined;
10808
+ }
10463
10809
  const quoteAccount = this.getSpotMarketAccount(QUOTE_SPOT_MARKET_INDEX);
10810
+ if (!quoteAccount) {
10811
+ throw new Error(
10812
+ `Quote spot market account not found. Something is wrong with driftClient config`
10813
+ );
10814
+ }
10464
10815
 
10465
10816
  const extendedInfo: PerpMarketExtendedInfo = {
10466
10817
  marketIndex,
@@ -10511,18 +10862,23 @@ export class DriftClient {
10511
10862
  feeTier.makerRebateNumerator / feeTier.makerRebateDenominator;
10512
10863
 
10513
10864
  if (marketIndex !== undefined) {
10514
- let marketAccount = null;
10865
+ let marketAccount:
10866
+ | null
10867
+ | undefined
10868
+ | PerpMarketAccount
10869
+ | SpotMarketAccount = null;
10870
+ let feeAdjustment = 1;
10515
10871
  if (isVariant(marketType, 'perp')) {
10516
10872
  marketAccount = this.getPerpMarketAccount(marketIndex);
10873
+ feeAdjustment = marketAccount?.feeAdjustment ?? 0;
10517
10874
  } else {
10518
10875
  marketAccount = this.getSpotMarketAccount(marketIndex);
10519
10876
  }
10520
-
10521
- takerFee += (takerFee * marketAccount.feeAdjustment) / 100;
10877
+ takerFee += (takerFee * feeAdjustment) / 100;
10522
10878
  if (userHLM) {
10523
10879
  takerFee *= 2;
10524
10880
  }
10525
- makerFee += (makerFee * marketAccount.feeAdjustment) / 100;
10881
+ makerFee += (makerFee * feeAdjustment) / 100;
10526
10882
  }
10527
10883
 
10528
10884
  return {
@@ -10573,7 +10929,9 @@ export class DriftClient {
10573
10929
  return this.receiverProgram;
10574
10930
  }
10575
10931
 
10576
- public async getSwitchboardOnDemandProgram(): Promise<Program30<Idl30>> {
10932
+ public async getSwitchboardOnDemandProgram(): Promise<
10933
+ Program30<Idl30> | undefined
10934
+ > {
10577
10935
  if (this.sbOnDemandProgram === undefined) {
10578
10936
  this.sbOnDemandProgram = await AnchorUtils.loadProgramFromConnection(
10579
10937
  this.connection
@@ -10876,6 +11234,9 @@ export class DriftClient {
10876
11234
  numSignatures = 3
10877
11235
  ): Promise<TransactionInstruction | undefined> {
10878
11236
  const program = await this.getSwitchboardOnDemandProgram();
11237
+ if (!program) {
11238
+ return undefined;
11239
+ }
10879
11240
  const feedAccount = new PullFeed(program, feed);
10880
11241
  if (!this.sbProgramFeedConfigs) {
10881
11242
  this.sbProgramFeedConfigs = new Map();
@@ -10904,7 +11265,7 @@ export class DriftClient {
10904
11265
  feed: PublicKey,
10905
11266
  recentSlothash?: Slothash,
10906
11267
  numSignatures = 3
10907
- ): Promise<TransactionSignature> {
11268
+ ): Promise<TransactionSignature | undefined> {
10908
11269
  const pullIx = await this.getPostSwitchboardOnDemandUpdateAtomicIx(
10909
11270
  feed,
10910
11271
  recentSlothash,
@@ -11037,7 +11398,12 @@ export class DriftClient {
11037
11398
  const signingAuthority =
11038
11399
  overrides?.signingAuthority ?? this.wallet.publicKey;
11039
11400
  const userAccount =
11040
- overrides?.user.getUserAccount() ?? this.getUserAccount(subAccountId);
11401
+ overrides?.user?.getUserAccount() ?? this.getUserAccount(subAccountId);
11402
+ if (!userAccount) {
11403
+ throw new Error(
11404
+ `User account not found for subAccountId ${subAccountId}`
11405
+ );
11406
+ }
11041
11407
 
11042
11408
  const remainingAccounts = this.getRemainingAccounts({
11043
11409
  userAccounts: depositToTradeArgs?.isMakingNewAccount ? [] : [userAccount],
@@ -11177,6 +11543,11 @@ export class DriftClient {
11177
11543
  spotMarketIndex: number
11178
11544
  ): Promise<TransactionInstruction> {
11179
11545
  const spotMarket = await this.getSpotMarketAccount(spotMarketIndex);
11546
+ if (!spotMarket) {
11547
+ throw new Error(
11548
+ `Spot market account not found for index ${spotMarketIndex}`
11549
+ );
11550
+ }
11180
11551
  return this.program.instruction.pauseSpotMarketDepositWithdraw({
11181
11552
  accounts: {
11182
11553
  state: await this.getStatePublicKey(),
@@ -11233,12 +11604,17 @@ export class DriftClient {
11233
11604
  data.set(oraclePrice.toArrayLike(Buffer, 'le', 8), 5); // next 8 bytes
11234
11605
  data.set(oracleSequenceId.toArrayLike(Buffer, 'le', 8), 13); // next 8 bytes
11235
11606
 
11607
+ const perpMarket = this.getPerpMarketAccount(marketIndex);
11608
+ if (!perpMarket) {
11609
+ throw new Error(`Perp market account not found for index ${marketIndex}`);
11610
+ }
11611
+
11236
11612
  // Build the instruction manually
11237
11613
  return new TransactionInstruction({
11238
11614
  programId: this.program.programId,
11239
11615
  keys: [
11240
11616
  {
11241
- pubkey: this.getPerpMarketAccount(marketIndex).pubkey,
11617
+ pubkey: perpMarket.pubkey,
11242
11618
  isWritable: true,
11243
11619
  isSigner: false,
11244
11620
  },
@@ -11289,12 +11665,16 @@ export class DriftClient {
11289
11665
  data.set(discriminatorBuffer, 0);
11290
11666
  data.writeInt8(ammSpreadAdjustment, 5); // next byte
11291
11667
 
11668
+ const perpMarket = this.getPerpMarketAccount(marketIndex);
11669
+ if (!perpMarket) {
11670
+ throw new Error(`Perp market account not found for index ${marketIndex}`);
11671
+ }
11292
11672
  // Build the instruction manually
11293
11673
  return new TransactionInstruction({
11294
11674
  programId: this.program.programId,
11295
11675
  keys: [
11296
11676
  {
11297
- pubkey: this.getPerpMarketAccount(marketIndex).pubkey,
11677
+ pubkey: perpMarket.pubkey,
11298
11678
  isWritable: true,
11299
11679
  isSigner: false,
11300
11680
  },
@@ -11463,12 +11843,17 @@ export class DriftClient {
11463
11843
  readablePerpMarketIndex: perpMarketIndexes,
11464
11844
  });
11465
11845
 
11846
+ const quoteMarket = this.getSpotMarketAccount(0);
11847
+ if (!quoteMarket) {
11848
+ throw new Error(`Quote spot market account not found for index 0`);
11849
+ }
11850
+
11466
11851
  return this.program.instruction.updateAmmCache({
11467
11852
  accounts: {
11468
11853
  state: await this.getStatePublicKey(),
11469
11854
  keeper: this.wallet.publicKey,
11470
11855
  ammCache: getAmmCachePublicKey(this.program.programId),
11471
- quoteMarket: this.getSpotMarketAccount(0).pubkey,
11856
+ quoteMarket: quoteMarket.pubkey,
11472
11857
  },
11473
11858
  remainingAccounts,
11474
11859
  });
@@ -11492,6 +11877,11 @@ export class DriftClient {
11492
11877
  constituent: ConstituentAccount
11493
11878
  ): Promise<TransactionInstruction> {
11494
11879
  const spotMarket = this.getSpotMarketAccount(constituent.spotMarketIndex);
11880
+ if (!spotMarket) {
11881
+ throw new Error(
11882
+ `Spot market account not found for index ${constituent.spotMarketIndex}`
11883
+ );
11884
+ }
11495
11885
  return this.program.instruction.updateConstituentOracleInfo({
11496
11886
  accounts: {
11497
11887
  keeper: this.wallet.publicKey,
@@ -11553,12 +11943,26 @@ export class DriftClient {
11553
11943
  lpPool,
11554
11944
  outMarketIndex
11555
11945
  );
11946
+
11947
+ const inSpotMarket = this.getSpotMarketAccount(inMarketIndex);
11948
+ if (!inSpotMarket) {
11949
+ throw new Error(
11950
+ `Spot market account not found for index ${inMarketIndex}`
11951
+ );
11952
+ }
11953
+ const outSpotMarket = this.getSpotMarketAccount(outMarketIndex);
11954
+ if (!outSpotMarket) {
11955
+ throw new Error(
11956
+ `Spot market account not found for index ${outMarketIndex}`
11957
+ );
11958
+ }
11959
+
11556
11960
  const userInTokenAccount = await getAssociatedTokenAddress(
11557
- this.getSpotMarketAccount(inMarketIndex).mint,
11961
+ inSpotMarket.mint,
11558
11962
  userAuthority
11559
11963
  );
11560
11964
  const userOutTokenAccount = await getAssociatedTokenAddress(
11561
- this.getSpotMarketAccount(outMarketIndex).mint,
11965
+ outSpotMarket.mint,
11562
11966
  userAuthority
11563
11967
  );
11564
11968
  const inConstituent = getConstituentPublicKey(
@@ -11571,8 +11975,8 @@ export class DriftClient {
11571
11975
  lpPool,
11572
11976
  outMarketIndex
11573
11977
  );
11574
- const inMarketMint = this.getSpotMarketAccount(inMarketIndex).mint;
11575
- const outMarketMint = this.getSpotMarketAccount(outMarketIndex).mint;
11978
+ const inMarketMint = inSpotMarket.mint;
11979
+ const outMarketMint = outSpotMarket.mint;
11576
11980
 
11577
11981
  const constituentTargetBase = getConstituentTargetBasePublicKey(
11578
11982
  this.program.programId,
@@ -11771,6 +12175,11 @@ export class DriftClient {
11771
12175
  });
11772
12176
 
11773
12177
  const spotMarket = this.getSpotMarketAccount(inMarketIndex);
12178
+ if (!spotMarket) {
12179
+ throw new Error(
12180
+ `Spot market account not found for index ${inMarketIndex}`
12181
+ );
12182
+ }
11774
12183
  const inMarketMint = spotMarket.mint;
11775
12184
  const isSolMarket = inMarketMint.equals(WRAPPED_SOL_MINT);
11776
12185
 
@@ -11986,6 +12395,11 @@ export class DriftClient {
11986
12395
  });
11987
12396
 
11988
12397
  const spotMarket = this.getSpotMarketAccount(outMarketIndex);
12398
+ if (!spotMarket) {
12399
+ throw new Error(
12400
+ `Spot market account not found for index ${outMarketIndex}`
12401
+ );
12402
+ }
11989
12403
  const outMarketMint = spotMarket.mint;
11990
12404
  const outConstituent = getConstituentPublicKey(
11991
12405
  this.program.programId,
@@ -12097,6 +12511,11 @@ export class DriftClient {
12097
12511
  });
12098
12512
 
12099
12513
  const spotMarket = this.getSpotMarketAccount(outMarketIndex);
12514
+ if (!spotMarket) {
12515
+ throw new Error(
12516
+ `Spot market account not found for index ${outMarketIndex}`
12517
+ );
12518
+ }
12100
12519
  const outMarketMint = spotMarket.mint;
12101
12520
  const outConstituent = getConstituentPublicKey(
12102
12521
  this.program.programId,
@@ -12331,11 +12750,11 @@ export class DriftClient {
12331
12750
  lpPoolId: number,
12332
12751
  perpMarketIndexes: number[]
12333
12752
  ): Promise<TransactionInstruction> {
12334
- const remainingAccounts = [];
12753
+ const remainingAccounts: AccountMeta[] = [];
12335
12754
  remainingAccounts.push(
12336
12755
  ...perpMarketIndexes.map((index) => {
12337
12756
  return {
12338
- pubkey: this.getPerpMarketAccount(index).pubkey,
12757
+ pubkey: this.getPerpMarketAccount(index)?.pubkey ?? PublicKey.default,
12339
12758
  isSigner: false,
12340
12759
  isWritable: true,
12341
12760
  };
@@ -12443,7 +12862,8 @@ export class DriftClient {
12443
12862
  txVersion: txVersion ?? this.txVersion,
12444
12863
  txParams: txParams ?? this.txParams,
12445
12864
  connection: this.connection,
12446
- preFlightCommitment: this.opts.preflightCommitment,
12865
+ preFlightCommitment:
12866
+ this.opts?.preflightCommitment ?? DEFAULT_COMMITMENT_LEVEL,
12447
12867
  fetchAllMarketLookupTableAccounts:
12448
12868
  this.fetchAllLookupTableAccounts.bind(this),
12449
12869
  lookupTables,
@@ -12460,17 +12880,20 @@ export class DriftClient {
12460
12880
  lookupTables?: AddressLookupTableAccount[],
12461
12881
  forceVersionedTransaction?: boolean
12462
12882
  ): Promise<(Transaction | VersionedTransaction)[]> {
12463
- return this.txHandler.buildBulkTransactions({
12883
+ const txns = await this.txHandler.buildBulkTransactions({
12464
12884
  instructions,
12465
12885
  txVersion: txVersion ?? this.txVersion,
12466
12886
  txParams: txParams ?? this.txParams,
12467
12887
  connection: this.connection,
12468
- preFlightCommitment: this.opts.preflightCommitment,
12888
+ preFlightCommitment:
12889
+ this.opts?.preflightCommitment ?? DEFAULT_COMMITMENT_LEVEL,
12469
12890
  fetchAllMarketLookupTableAccounts:
12470
12891
  this.fetchAllLookupTableAccounts.bind(this),
12471
12892
  lookupTables,
12472
12893
  forceVersionedTransaction,
12473
12894
  });
12895
+
12896
+ return txns.filter(Boolean) as (Transaction | VersionedTransaction)[];
12474
12897
  }
12475
12898
 
12476
12899
  async buildTransactionsMap(
@@ -12488,7 +12911,8 @@ export class DriftClient {
12488
12911
  txVersion: txVersion ?? this.txVersion,
12489
12912
  txParams: txParams ?? this.txParams,
12490
12913
  connection: this.connection,
12491
- preFlightCommitment: this.opts.preflightCommitment,
12914
+ preFlightCommitment:
12915
+ this.opts?.preflightCommitment ?? DEFAULT_COMMITMENT_LEVEL,
12492
12916
  fetchAllMarketLookupTableAccounts:
12493
12917
  this.fetchAllLookupTableAccounts.bind(this),
12494
12918
  lookupTables,
@@ -12511,7 +12935,8 @@ export class DriftClient {
12511
12935
  txVersion: txVersion ?? this.txVersion,
12512
12936
  txParams: txParams ?? this.txParams,
12513
12937
  connection: this.connection,
12514
- preFlightCommitment: this.opts.preflightCommitment,
12938
+ preFlightCommitment:
12939
+ this.opts?.preflightCommitment ?? DEFAULT_COMMITMENT_LEVEL,
12515
12940
  fetchAllMarketLookupTableAccounts:
12516
12941
  this.fetchAllLookupTableAccounts.bind(this),
12517
12942
  lookupTables,