@drift-labs/sdk 2.20.0-beta.0 → 2.20.0-beta.2

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 (83) hide show
  1. package/lib/accounts/bulkAccountLoader.d.ts +2 -1
  2. package/lib/accounts/bulkAccountLoader.js +7 -7
  3. package/lib/accounts/fetch.d.ts +1 -0
  4. package/lib/accounts/fetch.js +8 -4
  5. package/lib/accounts/pollingDriftClientAccountSubscriber.js +7 -7
  6. package/lib/accounts/pollingTokenAccountSubscriber.js +2 -2
  7. package/lib/accounts/pollingUserAccountSubscriber.js +2 -2
  8. package/lib/accounts/pollingUserStatsAccountSubscriber.js +2 -2
  9. package/lib/accounts/types.d.ts +5 -4
  10. package/lib/accounts/webSocketAccountSubscriber.js +1 -1
  11. package/lib/accounts/webSocketDriftClientAccountSubscriber.js +3 -3
  12. package/lib/addresses/marketAddresses.js +1 -1
  13. package/lib/addresses/pda.d.ts +1 -0
  14. package/lib/addresses/pda.js +13 -2
  15. package/lib/adminClient.js +61 -57
  16. package/lib/config.d.ts +2 -2
  17. package/lib/constants/perpMarkets.d.ts +1 -1
  18. package/lib/constants/spotMarkets.d.ts +1 -1
  19. package/lib/dlob/DLOB.d.ts +6 -5
  20. package/lib/dlob/DLOB.js +105 -75
  21. package/lib/dlob/DLOBNode.d.ts +2 -2
  22. package/lib/dlob/DLOBNode.js +7 -7
  23. package/lib/dlob/DLOBOrders.d.ts +2 -2
  24. package/lib/dlob/NodeList.d.ts +1 -1
  25. package/lib/dlob/NodeList.js +2 -2
  26. package/lib/driftClient.d.ts +5 -2
  27. package/lib/driftClient.js +137 -95
  28. package/lib/driftClientConfig.d.ts +3 -3
  29. package/lib/events/eventSubscriber.js +2 -2
  30. package/lib/events/fetchLogs.d.ts +2 -2
  31. package/lib/events/pollingLogProvider.js +1 -1
  32. package/lib/events/types.d.ts +14 -14
  33. package/lib/examples/loadDlob.js +2 -2
  34. package/lib/examples/makeTradeExample.js +9 -9
  35. package/lib/factory/bigNum.js +13 -13
  36. package/lib/factory/oracleClient.js +4 -4
  37. package/lib/idl/drift.json +82 -4
  38. package/lib/index.js +5 -1
  39. package/lib/math/amm.d.ts +1 -1
  40. package/lib/math/amm.js +23 -23
  41. package/lib/math/auction.js +6 -6
  42. package/lib/math/exchangeStatus.js +2 -2
  43. package/lib/math/funding.js +2 -2
  44. package/lib/math/margin.js +4 -4
  45. package/lib/math/market.js +15 -15
  46. package/lib/math/oracles.js +1 -1
  47. package/lib/math/orders.js +27 -24
  48. package/lib/math/position.js +5 -5
  49. package/lib/math/repeg.js +1 -1
  50. package/lib/math/spotBalance.js +9 -9
  51. package/lib/math/spotMarket.js +3 -3
  52. package/lib/math/spotPosition.js +3 -3
  53. package/lib/math/trade.d.ts +1 -1
  54. package/lib/math/trade.js +42 -42
  55. package/lib/math/utils.js +1 -1
  56. package/lib/oracles/oracleClientCache.js +1 -1
  57. package/lib/oracles/pythClient.js +1 -1
  58. package/lib/oracles/types.d.ts +2 -2
  59. package/lib/serum/types.d.ts +1 -1
  60. package/lib/slot/SlotSubscriber.d.ts +1 -1
  61. package/lib/tokenFaucet.js +5 -1
  62. package/lib/tx/retryTxSender.d.ts +1 -1
  63. package/lib/tx/retryTxSender.js +1 -1
  64. package/lib/tx/types.d.ts +1 -1
  65. package/lib/types.d.ts +71 -44
  66. package/lib/user.js +63 -63
  67. package/lib/userConfig.d.ts +2 -2
  68. package/lib/userMap/userMap.js +1 -1
  69. package/lib/userMap/userStatsMap.js +3 -3
  70. package/lib/userStats.js +2 -2
  71. package/lib/userStatsConfig.d.ts +2 -2
  72. package/package.json +1 -1
  73. package/src/accounts/bulkAccountLoader.ts +5 -5
  74. package/src/accounts/fetch.ts +8 -0
  75. package/src/addresses/pda.ts +13 -0
  76. package/src/dlob/DLOB.ts +55 -8
  77. package/src/driftClient.ts +77 -0
  78. package/src/idl/drift.json +82 -4
  79. package/src/math/orders.ts +5 -1
  80. package/src/types.ts +29 -0
  81. package/src/userMap/userStatsMap.ts +1 -4
  82. package/tests/amm/test.ts +24 -28
  83. package/tests/dlob/test.ts +67 -73
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -44,11 +48,18 @@ const config_1 = require("./config");
44
48
  const spotMarkets_1 = require("./constants/spotMarkets");
45
49
  const userStats_1 = require("./userStats");
46
50
  const spotPosition_1 = require("./math/spotPosition");
51
+ const market_1 = require("./math/market");
47
52
  /**
48
53
  * # DriftClient
49
54
  * This class is the main way to interact with Drift Protocol. It allows you to subscribe to the various accounts where the Market's state is stored, as well as: opening positions, liquidating, settling funding, depositing & withdrawing, and more.
50
55
  */
51
56
  class DriftClient {
57
+ get isSubscribed() {
58
+ return this._isSubscribed && this.accountSubscriber.isSubscribed;
59
+ }
60
+ set isSubscribed(val) {
61
+ this._isSubscribed = val;
62
+ }
52
63
  constructor(config) {
53
64
  var _a, _b, _c, _d, _e, _f, _g, _h;
54
65
  this.users = new Map();
@@ -76,7 +87,7 @@ class DriftClient {
76
87
  if (config.userStats) {
77
88
  this.userStats = new userStats_1.UserStats({
78
89
  driftClient: this,
79
- userStatsAccountPublicKey: pda_1.getUserStatsAccountPublicKey(this.program.programId, this.authority),
90
+ userStatsAccountPublicKey: (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, this.authority),
80
91
  accountSubscription: this.userAccountSubscriptionConfig,
81
92
  });
82
93
  }
@@ -84,7 +95,7 @@ class DriftClient {
84
95
  let spotMarketIndexes = config.spotMarketIndexes;
85
96
  let oracleInfos = config.oracleInfos;
86
97
  if (config.env) {
87
- const { perpMarketIndexes: envPerpMarketIndexes, spotMarketIndexes: envSpotMarketIndexes, oracleInfos: envOracleInfos, } = config_1.getMarketsAndOraclesForSubscription(config.env);
98
+ const { perpMarketIndexes: envPerpMarketIndexes, spotMarketIndexes: envSpotMarketIndexes, oracleInfos: envOracleInfos, } = (0, config_1.getMarketsAndOraclesForSubscription)(config.env);
88
99
  perpMarketIndexes = perpMarketIndexes
89
100
  ? perpMarketIndexes
90
101
  : envPerpMarketIndexes;
@@ -106,12 +117,6 @@ class DriftClient {
106
117
  this.eventEmitter = this.accountSubscriber.eventEmitter;
107
118
  this.txSender = new retryTxSender_1.RetryTxSender(this.provider, (_f = config.txSenderConfig) === null || _f === void 0 ? void 0 : _f.timeout, (_g = config.txSenderConfig) === null || _g === void 0 ? void 0 : _g.retrySleep, (_h = config.txSenderConfig) === null || _h === void 0 ? void 0 : _h.additionalConnections);
108
119
  }
109
- get isSubscribed() {
110
- return this._isSubscribed && this.accountSubscriber.isSubscribed;
111
- }
112
- set isSubscribed(val) {
113
- this._isSubscribed = val;
114
- }
115
120
  createUsers(subAccountIds, accountSubscriptionConfig) {
116
121
  for (const subAccountId of subAccountIds) {
117
122
  const user = this.createUser(subAccountId, accountSubscriptionConfig);
@@ -119,7 +124,7 @@ class DriftClient {
119
124
  }
120
125
  }
121
126
  createUser(subAccountId, accountSubscriptionConfig) {
122
- const userAccountPublicKey = pda_1.getUserAccountPublicKeySync(this.program.programId, this.authority, subAccountId);
127
+ const userAccountPublicKey = (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, this.authority, subAccountId);
123
128
  return new user_1.User({
124
129
  driftClient: this,
125
130
  userAccountPublicKey,
@@ -164,14 +169,14 @@ class DriftClient {
164
169
  if (this.statePublicKey) {
165
170
  return this.statePublicKey;
166
171
  }
167
- this.statePublicKey = await pda_1.getDriftStateAccountPublicKey(this.program.programId);
172
+ this.statePublicKey = await (0, pda_1.getDriftStateAccountPublicKey)(this.program.programId);
168
173
  return this.statePublicKey;
169
174
  }
170
175
  getSignerPublicKey() {
171
176
  if (this.signerPublicKey) {
172
177
  return this.signerPublicKey;
173
178
  }
174
- this.signerPublicKey = pda_1.getDriftSignerPublicKey(this.program.programId);
179
+ this.signerPublicKey = (0, pda_1.getDriftSignerPublicKey)(this.program.programId);
175
180
  return this.signerPublicKey;
176
181
  }
177
182
  getStateAccount() {
@@ -232,7 +237,7 @@ class DriftClient {
232
237
  return this.accountSubscriber.getOraclePriceDataAndSlot(oraclePublicKey);
233
238
  }
234
239
  async getSerumV3FulfillmentConfig(serumMarket) {
235
- const address = await pda_1.getSerumFulfillmentConfigPublicKey(this.program.programId, serumMarket);
240
+ const address = await (0, pda_1.getSerumFulfillmentConfigPublicKey)(this.program.programId, serumMarket);
236
241
  return (await this.program.account.serumV3FulfillmentConfig.fetch(address));
237
242
  }
238
243
  async fetchMarketLookupTableAccount() {
@@ -263,7 +268,7 @@ class DriftClient {
263
268
  await this.userStats.unsubscribe();
264
269
  this.userStats = new userStats_1.UserStats({
265
270
  driftClient: this,
266
- userStatsAccountPublicKey: pda_1.getUserStatsAccountPublicKey(this.program.programId, this.authority),
271
+ userStatsAccountPublicKey: (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, this.authority),
267
272
  accountSubscription: this.userAccountSubscriptionConfig,
268
273
  });
269
274
  }
@@ -303,7 +308,7 @@ class DriftClient {
303
308
  return [txSig, userAccountPublicKey];
304
309
  }
305
310
  async getInitializeUserInstructions(subAccountId = 0, name = userName_1.DEFAULT_USER_NAME, referrerInfo) {
306
- const userAccountPublicKey = await pda_1.getUserAccountPublicKey(this.program.programId, this.wallet.publicKey, subAccountId);
311
+ const userAccountPublicKey = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.wallet.publicKey, subAccountId);
307
312
  const remainingAccounts = new Array();
308
313
  if (referrerInfo !== undefined) {
309
314
  remainingAccounts.push({
@@ -326,7 +331,7 @@ class DriftClient {
326
331
  isSigner: false,
327
332
  });
328
333
  }
329
- const nameBuffer = userName_1.encodeName(name);
334
+ const nameBuffer = (0, userName_1.encodeName)(name);
330
335
  const initializeUserAccountIx = await this.program.instruction.initializeUser(subAccountId, nameBuffer, {
331
336
  accounts: {
332
337
  user: userAccountPublicKey,
@@ -353,9 +358,27 @@ class DriftClient {
353
358
  },
354
359
  });
355
360
  }
361
+ async initializeReferrerName(name) {
362
+ const userAccountPublicKey = (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, this.wallet.publicKey, 0);
363
+ const nameBuffer = (0, userName_1.encodeName)(name);
364
+ const referrerNameAccountPublicKey = await (0, pda_1.getReferrerNamePublicKeySync)(this.program.programId, nameBuffer);
365
+ const tx = await this.program.transaction.initializeReferrerName(nameBuffer, {
366
+ accounts: {
367
+ referrerName: referrerNameAccountPublicKey,
368
+ user: userAccountPublicKey,
369
+ authority: this.wallet.publicKey,
370
+ userStats: this.getUserStatsAccountPublicKey(),
371
+ payer: this.wallet.publicKey,
372
+ rent: anchor.web3.SYSVAR_RENT_PUBKEY,
373
+ systemProgram: anchor.web3.SystemProgram.programId,
374
+ },
375
+ });
376
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
377
+ return txSig;
378
+ }
356
379
  async updateUserName(name, subAccountId = 0) {
357
- const userAccountPublicKey = pda_1.getUserAccountPublicKeySync(this.program.programId, this.wallet.publicKey, subAccountId);
358
- const nameBuffer = userName_1.encodeName(name);
380
+ const userAccountPublicKey = (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, this.wallet.publicKey, subAccountId);
381
+ const nameBuffer = (0, userName_1.encodeName)(name);
359
382
  const tx = await this.program.transaction.updateUserName(subAccountId, nameBuffer, {
360
383
  accounts: {
361
384
  user: userAccountPublicKey,
@@ -376,7 +399,7 @@ class DriftClient {
376
399
  return txSig;
377
400
  }
378
401
  async updateUserMarginTradingEnabled(marginTradingEnabled, subAccountId = 0) {
379
- const userAccountPublicKey = pda_1.getUserAccountPublicKeySync(this.program.programId, this.wallet.publicKey, subAccountId);
402
+ const userAccountPublicKey = (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, this.wallet.publicKey, subAccountId);
380
403
  await this.addUser(subAccountId);
381
404
  const remainingAccounts = this.getRemainingAccounts({
382
405
  userAccounts: [this.getUserAccount(subAccountId)],
@@ -427,7 +450,7 @@ class DriftClient {
427
450
  }
428
451
  async deleteUser(subAccountId = 0, txParams) {
429
452
  var _a;
430
- const userAccountPublicKey = pda_1.getUserAccountPublicKeySync(this.program.programId, this.wallet.publicKey, subAccountId);
453
+ const userAccountPublicKey = (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, this.wallet.publicKey, subAccountId);
431
454
  const ix = await this.program.instruction.deleteUser({
432
455
  accounts: {
433
456
  user: userAccountPublicKey,
@@ -436,7 +459,7 @@ class DriftClient {
436
459
  state: await this.getStatePublicKey(),
437
460
  },
438
461
  });
439
- const { txSig } = await this.sendTransaction(utils_1.wrapInTx(ix, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
462
+ const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(ix, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
440
463
  await ((_a = this.users.get(subAccountId)) === null || _a === void 0 ? void 0 : _a.unsubscribe());
441
464
  this.users.delete(subAccountId);
442
465
  return txSig;
@@ -454,11 +477,16 @@ class DriftClient {
454
477
  getUserStats() {
455
478
  return this.userStats;
456
479
  }
480
+ async fetchReferrerNameAccount(name) {
481
+ const nameBuffer = (0, userName_1.encodeName)(name);
482
+ const referrerNameAccountPublicKey = (0, pda_1.getReferrerNamePublicKeySync)(this.program.programId, nameBuffer);
483
+ return (await this.program.account.referrerName.fetch(referrerNameAccountPublicKey));
484
+ }
457
485
  getUserStatsAccountPublicKey() {
458
486
  if (this.userStatsAccountPublicKey) {
459
487
  return this.userStatsAccountPublicKey;
460
488
  }
461
- this.userStatsAccountPublicKey = pda_1.getUserStatsAccountPublicKey(this.program.programId, this.authority);
489
+ this.userStatsAccountPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, this.authority);
462
490
  return this.userStatsAccountPublicKey;
463
491
  }
464
492
  async getUserAccountPublicKey() {
@@ -484,7 +512,7 @@ class DriftClient {
484
512
  getQuoteAssetTokenAmount() {
485
513
  const spotMarket = this.getSpotMarketAccount(numericConstants_1.QUOTE_SPOT_MARKET_INDEX);
486
514
  const spotPosition = this.getSpotPosition(numericConstants_1.QUOTE_SPOT_MARKET_INDEX);
487
- return spotBalance_1.getTokenAmount(spotPosition.scaledBalance, spotMarket, spotPosition.balanceType);
515
+ return (0, spotBalance_1.getTokenAmount)(spotPosition.scaledBalance, spotMarket, spotPosition.balanceType);
488
516
  }
489
517
  getTokenAmount(marketIndex) {
490
518
  const spotPosition = this.getSpotPosition(marketIndex);
@@ -492,7 +520,7 @@ class DriftClient {
492
520
  return numericConstants_1.ZERO;
493
521
  }
494
522
  const spotMarket = this.getSpotMarketAccount(marketIndex);
495
- return spotBalance_1.getTokenAmount(spotPosition.scaledBalance, spotMarket, spotPosition.balanceType);
523
+ return (0, spotBalance_1.getTokenAmount)(spotPosition.scaledBalance, spotMarket, spotPosition.balanceType);
496
524
  }
497
525
  getRemainingAccounts(params) {
498
526
  var _a;
@@ -616,7 +644,7 @@ class DriftClient {
616
644
  const perpMarketAccountMap = new Map();
617
645
  for (const userAccount of userAccounts) {
618
646
  for (const spotPosition of userAccount.spotPositions) {
619
- if (!spotPosition_1.isSpotPositionAvailable(spotPosition)) {
647
+ if (!(0, spotPosition_1.isSpotPositionAvailable)(spotPosition)) {
620
648
  const spotMarket = this.getSpotMarketAccount(spotPosition.marketIndex);
621
649
  spotMarketAccountMap.set(spotPosition.marketIndex, {
622
650
  pubkey: spotMarket.pubkey,
@@ -641,7 +669,7 @@ class DriftClient {
641
669
  }
642
670
  }
643
671
  for (const position of userAccount.perpPositions) {
644
- if (!position_1.positionIsAvailable(position)) {
672
+ if (!(0, position_1.positionIsAvailable)(position)) {
645
673
  const market = this.getPerpMarketAccount(position.marketIndex);
646
674
  perpMarketAccountMap.set(position.marketIndex, {
647
675
  pubkey: market.pubkey,
@@ -700,7 +728,7 @@ class DriftClient {
700
728
  }
701
729
  async getDepositInstruction(amount, marketIndex, userTokenAccount, subAccountId, reduceOnly = false, userInitialized = true) {
702
730
  const userAccountPublicKey = subAccountId
703
- ? await pda_1.getUserAccountPublicKey(this.program.programId, this.authority, subAccountId)
731
+ ? await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.authority, subAccountId)
704
732
  : await this.getUserAccountPublicKey();
705
733
  let remainingAccounts = [];
706
734
  if (userInitialized) {
@@ -885,7 +913,7 @@ class DriftClient {
885
913
  });
886
914
  }
887
915
  async transferDeposit(amount, marketIndex, fromSubAccountId, toSubAccountId, txParams) {
888
- const { txSig, slot } = await this.sendTransaction(utils_1.wrapInTx(await this.getTransferDepositIx(amount, marketIndex, fromSubAccountId, toSubAccountId), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
916
+ const { txSig, slot } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getTransferDepositIx(amount, marketIndex, fromSubAccountId, toSubAccountId), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
889
917
  if (fromSubAccountId === this.activeSubAccountId ||
890
918
  toSubAccountId === this.activeSubAccountId) {
891
919
  this.spotMarketLastSlotCache.set(marketIndex, slot);
@@ -893,8 +921,8 @@ class DriftClient {
893
921
  return txSig;
894
922
  }
895
923
  async getTransferDepositIx(amount, marketIndex, fromSubAccountId, toSubAccountId) {
896
- const fromUser = await pda_1.getUserAccountPublicKey(this.program.programId, this.wallet.publicKey, fromSubAccountId);
897
- const toUser = await pda_1.getUserAccountPublicKey(this.program.programId, this.wallet.publicKey, toSubAccountId);
924
+ const fromUser = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.wallet.publicKey, fromSubAccountId);
925
+ const toUser = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.wallet.publicKey, toSubAccountId);
898
926
  let remainingAccounts;
899
927
  if (this.users.has(fromSubAccountId)) {
900
928
  remainingAccounts = this.getRemainingAccounts({
@@ -904,7 +932,7 @@ class DriftClient {
904
932
  });
905
933
  }
906
934
  else {
907
- const userAccountPublicKey = pda_1.getUserAccountPublicKeySync(this.program.programId, this.authority, fromSubAccountId);
935
+ const userAccountPublicKey = (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, this.authority, fromSubAccountId);
908
936
  const fromUserAccount = (await this.program.account.user.fetch(userAccountPublicKey));
909
937
  remainingAccounts = this.getRemainingAccounts({
910
938
  userAccounts: [fromUserAccount],
@@ -925,7 +953,7 @@ class DriftClient {
925
953
  });
926
954
  }
927
955
  async updateSpotMarketCumulativeInterest(marketIndex, txParams) {
928
- const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.updateSpotMarketCumulativeInterestIx(marketIndex), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
956
+ const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.updateSpotMarketCumulativeInterestIx(marketIndex), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
929
957
  return txSig;
930
958
  }
931
959
  async updateSpotMarketCumulativeInterestIx(marketIndex) {
@@ -939,7 +967,7 @@ class DriftClient {
939
967
  });
940
968
  }
941
969
  async settleLP(settleeUserAccountPublicKey, marketIndex, txParams) {
942
- const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.settleLPIx(settleeUserAccountPublicKey, marketIndex), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
970
+ const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.settleLPIx(settleeUserAccountPublicKey, marketIndex), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
943
971
  return txSig;
944
972
  }
945
973
  async settleLPIx(settleeUserAccountPublicKey, marketIndex) {
@@ -957,11 +985,11 @@ class DriftClient {
957
985
  });
958
986
  }
959
987
  async removePerpLpShares(marketIndex, sharesToBurn, txParams) {
960
- const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getRemovePerpLpSharesIx(marketIndex, sharesToBurn), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
988
+ const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getRemovePerpLpSharesIx(marketIndex, sharesToBurn), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
961
989
  return txSig;
962
990
  }
963
991
  async removePerpLpSharesInExpiringMarket(marketIndex, userAccountPublicKey, sharesToBurn, txParams) {
964
- const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getRemovePerpLpSharesInExpiringMarket(marketIndex, userAccountPublicKey, sharesToBurn), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
992
+ const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getRemovePerpLpSharesInExpiringMarket(marketIndex, userAccountPublicKey, sharesToBurn), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
965
993
  return txSig;
966
994
  }
967
995
  async getRemovePerpLpSharesInExpiringMarket(marketIndex, userAccountPublicKey, sharesToBurn) {
@@ -1007,7 +1035,7 @@ class DriftClient {
1007
1035
  });
1008
1036
  }
1009
1037
  async addPerpLpShares(amount, marketIndex, txParams) {
1010
- const { txSig, slot } = await this.sendTransaction(utils_1.wrapInTx(await this.getAddPerpLpSharesIx(amount, marketIndex), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1038
+ const { txSig, slot } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getAddPerpLpSharesIx(amount, marketIndex), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1011
1039
  this.perpMarketLastSlotCache.set(marketIndex, slot);
1012
1040
  return txSig;
1013
1041
  }
@@ -1051,8 +1079,8 @@ class DriftClient {
1051
1079
  async sendMarketOrderAndGetSignedFillTx(orderParams, userAccountPublicKey, userAccount, makerInfo, txParams) {
1052
1080
  const marketIndex = orderParams.marketIndex;
1053
1081
  const orderId = userAccount.nextOrderId;
1054
- const marketOrderTx = utils_1.wrapInTx(await this.getPlacePerpOrderIx(orderParams), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice);
1055
- const fillTx = utils_1.wrapInTx(await this.getFillPerpOrderIx(userAccountPublicKey, userAccount, {
1082
+ const marketOrderTx = (0, utils_1.wrapInTx)(await this.getPlacePerpOrderIx(orderParams), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice);
1083
+ const fillTx = (0, utils_1.wrapInTx)(await this.getFillPerpOrderIx(userAccountPublicKey, userAccount, {
1056
1084
  orderId,
1057
1085
  marketIndex,
1058
1086
  }, makerInfo), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice);
@@ -1068,7 +1096,7 @@ class DriftClient {
1068
1096
  return { txSig, signedFillTx };
1069
1097
  }
1070
1098
  async placePerpOrder(orderParams, txParams) {
1071
- const { txSig, slot } = await this.sendTransaction(utils_1.wrapInTx(await this.getPlacePerpOrderIx(orderParams), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1099
+ const { txSig, slot } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getPlacePerpOrderIx(orderParams), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1072
1100
  this.perpMarketLastSlotCache.set(orderParams.marketIndex, slot);
1073
1101
  return txSig;
1074
1102
  }
@@ -1096,7 +1124,7 @@ class DriftClient {
1096
1124
  });
1097
1125
  }
1098
1126
  async updateAMMs(marketIndexes, txParams) {
1099
- const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getUpdateAMMsIx(marketIndexes), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1127
+ const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getUpdateAMMsIx(marketIndexes), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1100
1128
  return txSig;
1101
1129
  }
1102
1130
  async getUpdateAMMsIx(marketIndexes) {
@@ -1130,7 +1158,7 @@ class DriftClient {
1130
1158
  });
1131
1159
  }
1132
1160
  async settleExpiredMarket(marketIndex, txParams) {
1133
- const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getSettleExpiredMarketIx(marketIndex), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1161
+ const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getSettleExpiredMarketIx(marketIndex), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1134
1162
  return txSig;
1135
1163
  }
1136
1164
  async getSettleExpiredMarketIx(marketIndex) {
@@ -1165,8 +1193,8 @@ class DriftClient {
1165
1193
  });
1166
1194
  }
1167
1195
  async settleExpiredMarketPoolsToRevenuePool(perpMarketIndex, txParams) {
1168
- const perpMarketPublicKey = await pda_1.getPerpMarketPublicKey(this.program.programId, perpMarketIndex);
1169
- const spotMarketPublicKey = await pda_1.getSpotMarketPublicKey(this.program.programId, numericConstants_1.QUOTE_SPOT_MARKET_INDEX);
1196
+ const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
1197
+ const spotMarketPublicKey = await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, numericConstants_1.QUOTE_SPOT_MARKET_INDEX);
1170
1198
  const ix = await this.program.instruction.settleExpiredMarketPoolsToRevenuePool({
1171
1199
  accounts: {
1172
1200
  state: await this.getStatePublicKey(),
@@ -1175,11 +1203,11 @@ class DriftClient {
1175
1203
  perpMarket: perpMarketPublicKey,
1176
1204
  },
1177
1205
  });
1178
- const { txSig } = await this.sendTransaction(utils_1.wrapInTx(ix, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1206
+ const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(ix, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1179
1207
  return txSig;
1180
1208
  }
1181
1209
  async cancelOrder(orderId, txParams) {
1182
- const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getCancelOrderIx(orderId), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1210
+ const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getCancelOrderIx(orderId), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1183
1211
  return txSig;
1184
1212
  }
1185
1213
  async getCancelOrderIx(orderId) {
@@ -1198,7 +1226,7 @@ class DriftClient {
1198
1226
  });
1199
1227
  }
1200
1228
  async cancelOrderByUserId(userOrderId, txParams) {
1201
- const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getCancelOrderByUserIdIx(userOrderId), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1229
+ const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getCancelOrderByUserIdIx(userOrderId), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1202
1230
  return txSig;
1203
1231
  }
1204
1232
  async getCancelOrderByUserIdIx(userOrderId) {
@@ -1220,7 +1248,7 @@ class DriftClient {
1220
1248
  });
1221
1249
  }
1222
1250
  async cancelOrders(marketType, marketIndex, direction, txParams) {
1223
- const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getCancelOrdersIx(marketType, marketIndex, direction), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1251
+ const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getCancelOrdersIx(marketType, marketIndex, direction), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1224
1252
  return txSig;
1225
1253
  }
1226
1254
  async getCancelOrdersIx(marketType, marketIndex, direction) {
@@ -1228,10 +1256,10 @@ class DriftClient {
1228
1256
  let readablePerpMarketIndex = undefined;
1229
1257
  let readableSpotMarketIndexes = undefined;
1230
1258
  if (marketIndex) {
1231
- if (marketType && types_1.isVariant(marketType, 'perp')) {
1259
+ if (marketType && (0, types_1.isVariant)(marketType, 'perp')) {
1232
1260
  readablePerpMarketIndex = marketIndex;
1233
1261
  }
1234
- else if (marketType && types_1.isVariant(marketType, 'spot')) {
1262
+ else if (marketType && (0, types_1.isVariant)(marketType, 'spot')) {
1235
1263
  readableSpotMarketIndexes = [marketIndex];
1236
1264
  }
1237
1265
  }
@@ -1251,11 +1279,11 @@ class DriftClient {
1251
1279
  });
1252
1280
  }
1253
1281
  async fillPerpOrder(userAccountPublicKey, user, order, makerInfo, referrerInfo, txParams) {
1254
- const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getFillPerpOrderIx(userAccountPublicKey, user, order, makerInfo, referrerInfo), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1282
+ const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getFillPerpOrderIx(userAccountPublicKey, user, order, makerInfo, referrerInfo), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1255
1283
  return txSig;
1256
1284
  }
1257
1285
  async getFillPerpOrderIx(userAccountPublicKey, userAccount, order, makerInfo, referrerInfo) {
1258
- const userStatsPublicKey = pda_1.getUserStatsAccountPublicKey(this.program.programId, userAccount.authority);
1286
+ const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, userAccount.authority);
1259
1287
  const fillerPublicKey = await this.getUserAccountPublicKey();
1260
1288
  const fillerStatsPublicKey = this.getUserStatsAccountPublicKey();
1261
1289
  const marketIndex = order
@@ -1316,7 +1344,7 @@ class DriftClient {
1316
1344
  });
1317
1345
  }
1318
1346
  async placeSpotOrder(orderParams, txParams) {
1319
- const { txSig, slot } = await this.sendTransaction(utils_1.wrapInTx(await this.getPlaceSpotOrderIx(orderParams), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1347
+ const { txSig, slot } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getPlaceSpotOrderIx(orderParams), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1320
1348
  this.spotMarketLastSlotCache.set(orderParams.marketIndex, slot);
1321
1349
  this.spotMarketLastSlotCache.set(numericConstants_1.QUOTE_SPOT_MARKET_INDEX, slot);
1322
1350
  return txSig;
@@ -1343,11 +1371,11 @@ class DriftClient {
1343
1371
  });
1344
1372
  }
1345
1373
  async fillSpotOrder(userAccountPublicKey, user, order, fulfillmentConfig, makerInfo, referrerInfo, txParams) {
1346
- const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getFillSpotOrderIx(userAccountPublicKey, user, order, fulfillmentConfig, makerInfo, referrerInfo), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1374
+ const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getFillSpotOrderIx(userAccountPublicKey, user, order, fulfillmentConfig, makerInfo, referrerInfo), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1347
1375
  return txSig;
1348
1376
  }
1349
1377
  async getFillSpotOrderIx(userAccountPublicKey, userAccount, order, fulfillmentConfig, makerInfo, referrerInfo) {
1350
- const userStatsPublicKey = pda_1.getUserStatsAccountPublicKey(this.program.programId, userAccount.authority);
1378
+ const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, userAccount.authority);
1351
1379
  const fillerPublicKey = await this.getUserAccountPublicKey();
1352
1380
  const fillerStatsPublicKey = this.getUserStatsAccountPublicKey();
1353
1381
  const marketIndex = order
@@ -1469,7 +1497,7 @@ class DriftClient {
1469
1497
  isSigner: false,
1470
1498
  });
1471
1499
  remainingAccounts.push({
1472
- pubkey: pda_1.getSerumSignerPublicKey(fulfillmentConfig.serumProgramId, fulfillmentConfig.serumMarket, fulfillmentConfig.serumSignerNonce),
1500
+ pubkey: (0, pda_1.getSerumSignerPublicKey)(fulfillmentConfig.serumProgramId, fulfillmentConfig.serumMarket, fulfillmentConfig.serumSignerNonce),
1473
1501
  isWritable: false,
1474
1502
  isSigner: false,
1475
1503
  });
@@ -1500,13 +1528,13 @@ class DriftClient {
1500
1528
  });
1501
1529
  }
1502
1530
  async triggerOrder(userAccountPublicKey, user, order, txParams) {
1503
- const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getTriggerOrderIx(userAccountPublicKey, user, order), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1531
+ const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getTriggerOrderIx(userAccountPublicKey, user, order), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1504
1532
  return txSig;
1505
1533
  }
1506
1534
  async getTriggerOrderIx(userAccountPublicKey, userAccount, order) {
1507
1535
  const fillerPublicKey = await this.getUserAccountPublicKey();
1508
1536
  let remainingAccountsParams;
1509
- if (types_1.isVariant(order.marketType, 'perp')) {
1537
+ if ((0, types_1.isVariant)(order.marketType, 'perp')) {
1510
1538
  remainingAccountsParams = {
1511
1539
  userAccounts: [userAccount],
1512
1540
  writablePerpMarketIndexes: [order.marketIndex],
@@ -1531,7 +1559,7 @@ class DriftClient {
1531
1559
  });
1532
1560
  }
1533
1561
  async forceCancelOrders(userAccountPublicKey, user, txParams) {
1534
- const { txSig } = await this.txSender.send(utils_1.wrapInTx(await this.getForceCancelOrdersIx(userAccountPublicKey, user), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1562
+ const { txSig } = await this.txSender.send((0, utils_1.wrapInTx)(await this.getForceCancelOrdersIx(userAccountPublicKey, user), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1535
1563
  return txSig;
1536
1564
  }
1537
1565
  async getForceCancelOrdersIx(userAccountPublicKey, userAccount) {
@@ -1551,7 +1579,7 @@ class DriftClient {
1551
1579
  });
1552
1580
  }
1553
1581
  async placeAndTakePerpOrder(orderParams, makerInfo, referrerInfo, txParams) {
1554
- const { txSig, slot } = await this.sendTransaction(utils_1.wrapInTx(await this.getPlaceAndTakePerpOrderIx(orderParams, makerInfo, referrerInfo), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1582
+ const { txSig, slot } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getPlaceAndTakePerpOrderIx(orderParams, makerInfo, referrerInfo), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1555
1583
  this.perpMarketLastSlotCache.set(orderParams.marketIndex, slot);
1556
1584
  return txSig;
1557
1585
  }
@@ -1605,7 +1633,7 @@ class DriftClient {
1605
1633
  });
1606
1634
  }
1607
1635
  async placeAndMakePerpOrder(orderParams, takerInfo, referrerInfo, txParams) {
1608
- const { txSig, slot } = await this.sendTransaction(utils_1.wrapInTx(await this.getPlaceAndMakePerpOrderIx(orderParams, takerInfo, referrerInfo), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1636
+ const { txSig, slot } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getPlaceAndMakePerpOrderIx(orderParams, takerInfo, referrerInfo), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1609
1637
  this.perpMarketLastSlotCache.set(orderParams.marketIndex, slot);
1610
1638
  return txSig;
1611
1639
  }
@@ -1644,7 +1672,7 @@ class DriftClient {
1644
1672
  });
1645
1673
  }
1646
1674
  async placeAndTakeSpotOrder(orderParams, fulfillmentConfig, makerInfo, referrerInfo, txParams) {
1647
- const { txSig, slot } = await this.sendTransaction(utils_1.wrapInTx(await this.getPlaceAndTakeSpotOrderIx(orderParams, fulfillmentConfig, makerInfo, referrerInfo), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1675
+ const { txSig, slot } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getPlaceAndTakeSpotOrderIx(orderParams, fulfillmentConfig, makerInfo, referrerInfo), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1648
1676
  this.spotMarketLastSlotCache.set(orderParams.marketIndex, slot);
1649
1677
  this.spotMarketLastSlotCache.set(numericConstants_1.QUOTE_SPOT_MARKET_INDEX, slot);
1650
1678
  return txSig;
@@ -1703,7 +1731,7 @@ class DriftClient {
1703
1731
  });
1704
1732
  }
1705
1733
  async placeAndMakeSpotOrder(orderParams, takerInfo, fulfillmentConfig, referrerInfo, txParams) {
1706
- const { txSig, slot } = await this.sendTransaction(utils_1.wrapInTx(await this.getPlaceAndMakeSpotOrderIx(orderParams, takerInfo, fulfillmentConfig, referrerInfo), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1734
+ const { txSig, slot } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getPlaceAndMakeSpotOrderIx(orderParams, takerInfo, fulfillmentConfig, referrerInfo), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1707
1735
  this.spotMarketLastSlotCache.set(orderParams.marketIndex, slot);
1708
1736
  this.spotMarketLastSlotCache.set(numericConstants_1.QUOTE_SPOT_MARKET_INDEX, slot);
1709
1737
  return txSig;
@@ -1759,7 +1787,7 @@ class DriftClient {
1759
1787
  return await this.placeAndTakePerpOrder({
1760
1788
  orderType: types_1.OrderType.MARKET,
1761
1789
  marketIndex,
1762
- direction: position_1.findDirectionToClose(userPosition),
1790
+ direction: (0, position_1.findDirectionToClose)(userPosition),
1763
1791
  baseAssetAmount: userPosition.baseAssetAmount.abs(),
1764
1792
  reduceOnly: true,
1765
1793
  price: limitPrice,
@@ -1823,11 +1851,11 @@ class DriftClient {
1823
1851
  }
1824
1852
  const cancelOrderIx = await this.getCancelOrderIx(orderId);
1825
1853
  const orderTypeHasTrigger = newOrderType
1826
- ? types_1.isOneOfVariant(newOrderType, ['triggerlimit', 'triggerMarket'])
1827
- : types_1.isOneOfVariant(openOrder.orderType, ['triggerLimit', 'triggerMarket']);
1854
+ ? (0, types_1.isOneOfVariant)(newOrderType, ['triggerlimit', 'triggerMarket'])
1855
+ : (0, types_1.isOneOfVariant)(openOrder.orderType, ['triggerLimit', 'triggerMarket']);
1828
1856
  const orderTypeHasLimitPrice = newOrderType
1829
- ? types_1.isOneOfVariant(newOrderType, ['triggerLimit', 'limit'])
1830
- : types_1.isOneOfVariant(openOrder.orderType, ['triggerLimit', 'limit']);
1857
+ ? (0, types_1.isOneOfVariant)(newOrderType, ['triggerLimit', 'limit'])
1858
+ : (0, types_1.isOneOfVariant)(openOrder.orderType, ['triggerLimit', 'limit']);
1831
1859
  const newOrderParams = {
1832
1860
  orderType: newOrderType || openOrder.orderType,
1833
1861
  marketType: openOrder.marketType,
@@ -1898,11 +1926,11 @@ class DriftClient {
1898
1926
  }
1899
1927
  const cancelOrderIx = await this.getCancelOrderByUserIdIx(userOrderId);
1900
1928
  const orderTypeHasTrigger = newOrderType
1901
- ? types_1.isOneOfVariant(newOrderType, ['triggerlimit', 'triggerMarket'])
1902
- : types_1.isOneOfVariant(openOrder.orderType, ['triggerLimit', 'triggerMarket']);
1929
+ ? (0, types_1.isOneOfVariant)(newOrderType, ['triggerlimit', 'triggerMarket'])
1930
+ : (0, types_1.isOneOfVariant)(openOrder.orderType, ['triggerLimit', 'triggerMarket']);
1903
1931
  const orderTypeHasLimitPrice = newOrderType
1904
- ? types_1.isOneOfVariant(newOrderType, ['triggerLimit', 'limit'])
1905
- : types_1.isOneOfVariant(openOrder.orderType, ['triggerLimit', 'limit']);
1932
+ ? (0, types_1.isOneOfVariant)(newOrderType, ['triggerLimit', 'limit'])
1933
+ : (0, types_1.isOneOfVariant)(openOrder.orderType, ['triggerLimit', 'limit']);
1906
1934
  const newOrderParams = {
1907
1935
  orderType: newOrderType || openOrder.orderType,
1908
1936
  marketType: openOrder.marketType,
@@ -1963,7 +1991,7 @@ class DriftClient {
1963
1991
  return txSig;
1964
1992
  }
1965
1993
  async settlePNL(settleeUserAccountPublicKey, settleeUserAccount, marketIndex, txParams) {
1966
- const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.settlePNLIx(settleeUserAccountPublicKey, settleeUserAccount, marketIndex), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1994
+ const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.settlePNLIx(settleeUserAccountPublicKey, settleeUserAccount, marketIndex), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1967
1995
  return txSig;
1968
1996
  }
1969
1997
  async settlePNLIx(settleeUserAccountPublicKey, settleeUserAccount, marketIndex) {
@@ -1983,12 +2011,12 @@ class DriftClient {
1983
2011
  });
1984
2012
  }
1985
2013
  async liquidatePerp(userAccountPublicKey, userAccount, marketIndex, maxBaseAssetAmount, limitPrice, txParams) {
1986
- const { txSig, slot } = await this.sendTransaction(utils_1.wrapInTx(await this.getLiquidatePerpIx(userAccountPublicKey, userAccount, marketIndex, maxBaseAssetAmount, limitPrice), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
2014
+ const { txSig, slot } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getLiquidatePerpIx(userAccountPublicKey, userAccount, marketIndex, maxBaseAssetAmount, limitPrice), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
1987
2015
  this.perpMarketLastSlotCache.set(marketIndex, slot);
1988
2016
  return txSig;
1989
2017
  }
1990
2018
  async getLiquidatePerpIx(userAccountPublicKey, userAccount, marketIndex, maxBaseAssetAmount, limitPrice) {
1991
- const userStatsPublicKey = pda_1.getUserStatsAccountPublicKey(this.program.programId, userAccount.authority);
2019
+ const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, userAccount.authority);
1992
2020
  const liquidatorPublicKey = await this.getUserAccountPublicKey();
1993
2021
  const liquidatorStatsPublicKey = this.getUserStatsAccountPublicKey();
1994
2022
  const remainingAccounts = this.getRemainingAccounts({
@@ -2009,13 +2037,13 @@ class DriftClient {
2009
2037
  });
2010
2038
  }
2011
2039
  async liquidateSpot(userAccountPublicKey, userAccount, assetMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice, txParams) {
2012
- const { txSig, slot } = await this.sendTransaction(utils_1.wrapInTx(await this.getLiquidateSpotIx(userAccountPublicKey, userAccount, assetMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
2040
+ const { txSig, slot } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getLiquidateSpotIx(userAccountPublicKey, userAccount, assetMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
2013
2041
  this.spotMarketLastSlotCache.set(assetMarketIndex, slot);
2014
2042
  this.spotMarketLastSlotCache.set(liabilityMarketIndex, slot);
2015
2043
  return txSig;
2016
2044
  }
2017
2045
  async getLiquidateSpotIx(userAccountPublicKey, userAccount, assetMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice) {
2018
- const userStatsPublicKey = pda_1.getUserStatsAccountPublicKey(this.program.programId, userAccount.authority);
2046
+ const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, userAccount.authority);
2019
2047
  const liquidatorPublicKey = await this.getUserAccountPublicKey();
2020
2048
  const liquidatorStatsPublicKey = await this.getUserStatsAccountPublicKey();
2021
2049
  const remainingAccounts = this.getRemainingAccounts({
@@ -2036,13 +2064,13 @@ class DriftClient {
2036
2064
  });
2037
2065
  }
2038
2066
  async liquidateBorrowForPerpPnl(userAccountPublicKey, userAccount, perpMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice, txParams) {
2039
- const { txSig, slot } = await this.sendTransaction(utils_1.wrapInTx(await this.getLiquidateBorrowForPerpPnlIx(userAccountPublicKey, userAccount, perpMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
2067
+ const { txSig, slot } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getLiquidateBorrowForPerpPnlIx(userAccountPublicKey, userAccount, perpMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
2040
2068
  this.perpMarketLastSlotCache.set(perpMarketIndex, slot);
2041
2069
  this.spotMarketLastSlotCache.set(liabilityMarketIndex, slot);
2042
2070
  return txSig;
2043
2071
  }
2044
2072
  async getLiquidateBorrowForPerpPnlIx(userAccountPublicKey, userAccount, perpMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice) {
2045
- const userStatsPublicKey = pda_1.getUserStatsAccountPublicKey(this.program.programId, userAccount.authority);
2073
+ const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, userAccount.authority);
2046
2074
  const liquidatorPublicKey = await this.getUserAccountPublicKey();
2047
2075
  const liquidatorStatsPublicKey = await this.getUserStatsAccountPublicKey();
2048
2076
  const remainingAccounts = this.getRemainingAccounts({
@@ -2063,13 +2091,13 @@ class DriftClient {
2063
2091
  });
2064
2092
  }
2065
2093
  async liquidatePerpPnlForDeposit(userAccountPublicKey, userAccount, perpMarketIndex, assetMarketIndex, maxPnlTransfer, limitPrice, txParams) {
2066
- const { txSig, slot } = await this.sendTransaction(utils_1.wrapInTx(await this.getLiquidatePerpPnlForDepositIx(userAccountPublicKey, userAccount, perpMarketIndex, assetMarketIndex, maxPnlTransfer, limitPrice), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
2094
+ const { txSig, slot } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getLiquidatePerpPnlForDepositIx(userAccountPublicKey, userAccount, perpMarketIndex, assetMarketIndex, maxPnlTransfer, limitPrice), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
2067
2095
  this.perpMarketLastSlotCache.set(perpMarketIndex, slot);
2068
2096
  this.spotMarketLastSlotCache.set(assetMarketIndex, slot);
2069
2097
  return txSig;
2070
2098
  }
2071
2099
  async getLiquidatePerpPnlForDepositIx(userAccountPublicKey, userAccount, perpMarketIndex, assetMarketIndex, maxPnlTransfer, limitPrice) {
2072
- const userStatsPublicKey = pda_1.getUserStatsAccountPublicKey(this.program.programId, userAccount.authority);
2100
+ const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, userAccount.authority);
2073
2101
  const liquidatorPublicKey = await this.getUserAccountPublicKey();
2074
2102
  const liquidatorStatsPublicKey = await this.getUserStatsAccountPublicKey();
2075
2103
  const remainingAccounts = this.getRemainingAccounts({
@@ -2090,11 +2118,11 @@ class DriftClient {
2090
2118
  });
2091
2119
  }
2092
2120
  async resolvePerpBankruptcy(userAccountPublicKey, userAccount, marketIndex, txParams) {
2093
- const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getResolvePerpBankruptcyIx(userAccountPublicKey, userAccount, marketIndex), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
2121
+ const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getResolvePerpBankruptcyIx(userAccountPublicKey, userAccount, marketIndex), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
2094
2122
  return txSig;
2095
2123
  }
2096
2124
  async getResolvePerpBankruptcyIx(userAccountPublicKey, userAccount, marketIndex) {
2097
- const userStatsPublicKey = pda_1.getUserStatsAccountPublicKey(this.program.programId, userAccount.authority);
2125
+ const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, userAccount.authority);
2098
2126
  const liquidatorPublicKey = await this.getUserAccountPublicKey();
2099
2127
  const liquidatorStatsPublicKey = await this.getUserStatsAccountPublicKey();
2100
2128
  const remainingAccounts = this.getRemainingAccounts({
@@ -2120,11 +2148,11 @@ class DriftClient {
2120
2148
  });
2121
2149
  }
2122
2150
  async resolveSpotBankruptcy(userAccountPublicKey, userAccount, marketIndex, txParams) {
2123
- const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getResolveSpotBankruptcyIx(userAccountPublicKey, userAccount, marketIndex), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
2151
+ const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getResolveSpotBankruptcyIx(userAccountPublicKey, userAccount, marketIndex), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
2124
2152
  return txSig;
2125
2153
  }
2126
2154
  async getResolveSpotBankruptcyIx(userAccountPublicKey, userAccount, marketIndex) {
2127
- const userStatsPublicKey = pda_1.getUserStatsAccountPublicKey(this.program.programId, userAccount.authority);
2155
+ const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, userAccount.authority);
2128
2156
  const liquidatorPublicKey = await this.getUserAccountPublicKey();
2129
2157
  const liquidatorStatsPublicKey = await this.getUserStatsAccountPublicKey();
2130
2158
  const remainingAccounts = this.getRemainingAccounts({
@@ -2149,11 +2177,11 @@ class DriftClient {
2149
2177
  });
2150
2178
  }
2151
2179
  async updateFundingRate(perpMarketIndex, oracle, txParams) {
2152
- const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getUpdateFundingRateIx(perpMarketIndex, oracle), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
2180
+ const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getUpdateFundingRateIx(perpMarketIndex, oracle), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
2153
2181
  return txSig;
2154
2182
  }
2155
2183
  async getUpdateFundingRateIx(perpMarketIndex, oracle) {
2156
- const perpMarketPublicKey = await pda_1.getPerpMarketPublicKey(this.program.programId, perpMarketIndex);
2184
+ const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
2157
2185
  return await this.program.instruction.updateFundingRate(perpMarketIndex, {
2158
2186
  accounts: {
2159
2187
  state: await this.getStatePublicKey(),
@@ -2163,14 +2191,14 @@ class DriftClient {
2163
2191
  });
2164
2192
  }
2165
2193
  async settleFundingPayment(userAccountPublicKey, txParams) {
2166
- const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getSettleFundingPaymentIx(userAccountPublicKey), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
2194
+ const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getSettleFundingPaymentIx(userAccountPublicKey), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
2167
2195
  return txSig;
2168
2196
  }
2169
2197
  async getSettleFundingPaymentIx(userAccountPublicKey) {
2170
2198
  const userAccount = (await this.program.account.user.fetch(userAccountPublicKey));
2171
2199
  const writablePerpMarketIndexes = [];
2172
2200
  for (const position of userAccount.perpPositions) {
2173
- if (!position_1.positionIsAvailable(position)) {
2201
+ if (!(0, position_1.positionIsAvailable)(position)) {
2174
2202
  writablePerpMarketIndexes.push(position.marketIndex);
2175
2203
  }
2176
2204
  }
@@ -2200,11 +2228,11 @@ class DriftClient {
2200
2228
  return oracleData;
2201
2229
  }
2202
2230
  async initializeInsuranceFundStake(marketIndex, txParams) {
2203
- const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getInitializeInsuranceFundStakeIx(marketIndex), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
2231
+ const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getInitializeInsuranceFundStakeIx(marketIndex), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
2204
2232
  return txSig;
2205
2233
  }
2206
2234
  async getInitializeInsuranceFundStakeIx(marketIndex) {
2207
- const ifStakeAccountPublicKey = pda_1.getInsuranceFundStakeAccountPublicKey(this.program.programId, this.wallet.publicKey, marketIndex);
2235
+ const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, this.wallet.publicKey, marketIndex);
2208
2236
  return await this.program.instruction.initializeInsuranceFundStake(marketIndex, {
2209
2237
  accounts: {
2210
2238
  insuranceFundStake: ifStakeAccountPublicKey,
@@ -2220,7 +2248,7 @@ class DriftClient {
2220
2248
  }
2221
2249
  async addInsuranceFundStake(marketIndex, amount, collateralAccountPublicKey) {
2222
2250
  const spotMarket = this.getSpotMarketAccount(marketIndex);
2223
- const ifStakeAccountPublicKey = pda_1.getInsuranceFundStakeAccountPublicKey(this.program.programId, this.wallet.publicKey, marketIndex);
2251
+ const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, this.wallet.publicKey, marketIndex);
2224
2252
  const remainingAccounts = this.getRemainingAccounts({
2225
2253
  userAccounts: [this.getUserAccount()],
2226
2254
  useMarketLastSlotCache: true,
@@ -2246,7 +2274,7 @@ class DriftClient {
2246
2274
  }
2247
2275
  async requestRemoveInsuranceFundStake(marketIndex, amount) {
2248
2276
  const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
2249
- const ifStakeAccountPublicKey = pda_1.getInsuranceFundStakeAccountPublicKey(this.program.programId, this.wallet.publicKey, marketIndex);
2277
+ const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, this.wallet.publicKey, marketIndex);
2250
2278
  const remainingAccounts = this.getRemainingAccounts({
2251
2279
  userAccounts: [this.getUserAccount()],
2252
2280
  useMarketLastSlotCache: true,
@@ -2268,7 +2296,7 @@ class DriftClient {
2268
2296
  }
2269
2297
  async cancelRequestRemoveInsuranceFundStake(marketIndex) {
2270
2298
  const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
2271
- const ifStakeAccountPublicKey = pda_1.getInsuranceFundStakeAccountPublicKey(this.program.programId, this.wallet.publicKey, marketIndex);
2299
+ const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, this.wallet.publicKey, marketIndex);
2272
2300
  const remainingAccounts = this.getRemainingAccounts({
2273
2301
  userAccounts: [this.getUserAccount()],
2274
2302
  useMarketLastSlotCache: true,
@@ -2290,7 +2318,7 @@ class DriftClient {
2290
2318
  }
2291
2319
  async removeInsuranceFundStake(marketIndex, collateralAccountPublicKey) {
2292
2320
  const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
2293
- const ifStakeAccountPublicKey = pda_1.getInsuranceFundStakeAccountPublicKey(this.program.programId, this.wallet.publicKey, marketIndex);
2321
+ const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, this.wallet.publicKey, marketIndex);
2294
2322
  const remainingAccounts = this.getRemainingAccounts({
2295
2323
  userAccounts: [this.getUserAccount()],
2296
2324
  useMarketLastSlotCache: true,
@@ -2335,7 +2363,7 @@ class DriftClient {
2335
2363
  return txSig;
2336
2364
  }
2337
2365
  async resolvePerpPnlDeficit(spotMarketIndex, perpMarketIndex, txParams) {
2338
- const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getResolvePerpPnlDeficitIx(spotMarketIndex, perpMarketIndex), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
2366
+ const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getResolvePerpPnlDeficitIx(spotMarketIndex, perpMarketIndex), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
2339
2367
  return txSig;
2340
2368
  }
2341
2369
  async getResolvePerpPnlDeficitIx(spotMarketIndex, perpMarketIndex) {
@@ -2358,6 +2386,20 @@ class DriftClient {
2358
2386
  remainingAccounts: remainingAccounts,
2359
2387
  });
2360
2388
  }
2389
+ getPerpMarketExtendedInfo(marketIndex) {
2390
+ var _a, _b;
2391
+ const marketAccount = this.getPerpMarketAccount(marketIndex);
2392
+ const quoteAccount = this.getSpotMarketAccount(numericConstants_1.QUOTE_SPOT_MARKET_INDEX);
2393
+ const extendedInfo = {
2394
+ marketIndex,
2395
+ minOrderSize: (_a = marketAccount.amm) === null || _a === void 0 ? void 0 : _a.minOrderSize,
2396
+ marginMaintenance: marketAccount.marginRatioMaintenance,
2397
+ pnlPoolValue: (0, spotBalance_1.getTokenAmount)((_b = marketAccount.pnlPool) === null || _b === void 0 ? void 0 : _b.scaledBalance, quoteAccount, types_1.SpotBalanceType.DEPOSIT),
2398
+ contractTier: marketAccount.contractTier,
2399
+ availableInsurance: (0, market_1.calculateMarketMaxAvailableInsurance)(marketAccount, quoteAccount),
2400
+ };
2401
+ return extendedInfo;
2402
+ }
2361
2403
  sendTransaction(tx, additionalSigners, opts, preSigned) {
2362
2404
  return this.txSender.send(tx, additionalSigners, opts, preSigned);
2363
2405
  }