@drift-labs/sdk 2.18.0 → 2.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/lib/accounts/bulkAccountLoader.d.ts +2 -1
  2. package/lib/accounts/bulkAccountLoader.js +3 -3
  3. package/lib/accounts/fetch.js +2 -2
  4. package/lib/accounts/pollingDriftClientAccountSubscriber.js +7 -7
  5. package/lib/accounts/pollingTokenAccountSubscriber.js +2 -2
  6. package/lib/accounts/pollingUserAccountSubscriber.js +2 -2
  7. package/lib/accounts/pollingUserStatsAccountSubscriber.js +2 -2
  8. package/lib/accounts/types.d.ts +5 -4
  9. package/lib/accounts/webSocketAccountSubscriber.js +1 -1
  10. package/lib/accounts/webSocketDriftClientAccountSubscriber.js +3 -3
  11. package/lib/addresses/marketAddresses.js +1 -1
  12. package/lib/addresses/pda.js +5 -1
  13. package/lib/adminClient.js +61 -57
  14. package/lib/config.d.ts +2 -2
  15. package/lib/constants/perpMarkets.d.ts +1 -1
  16. package/lib/constants/perpMarkets.js +33 -3
  17. package/lib/constants/spotMarkets.d.ts +1 -1
  18. package/lib/dlob/DLOB.d.ts +4 -4
  19. package/lib/dlob/DLOB.js +89 -76
  20. package/lib/dlob/DLOBNode.d.ts +2 -2
  21. package/lib/dlob/DLOBNode.js +7 -7
  22. package/lib/dlob/DLOBOrders.d.ts +2 -2
  23. package/lib/dlob/NodeList.d.ts +2 -2
  24. package/lib/dlob/NodeList.js +4 -4
  25. package/lib/driftClient.d.ts +1 -1
  26. package/lib/driftClient.js +99 -95
  27. package/lib/driftClientConfig.d.ts +3 -3
  28. package/lib/events/eventSubscriber.js +2 -2
  29. package/lib/events/fetchLogs.d.ts +2 -2
  30. package/lib/events/pollingLogProvider.js +1 -1
  31. package/lib/events/types.d.ts +14 -14
  32. package/lib/examples/loadDlob.js +2 -2
  33. package/lib/examples/makeTradeExample.js +9 -9
  34. package/lib/factory/bigNum.js +13 -13
  35. package/lib/factory/oracleClient.js +6 -3
  36. package/lib/idl/drift.json +7 -4
  37. package/lib/index.js +5 -1
  38. package/lib/math/amm.d.ts +1 -1
  39. package/lib/math/amm.js +33 -38
  40. package/lib/math/auction.js +6 -6
  41. package/lib/math/exchangeStatus.js +2 -2
  42. package/lib/math/funding.js +2 -2
  43. package/lib/math/margin.js +4 -4
  44. package/lib/math/market.js +15 -15
  45. package/lib/math/oracles.js +1 -1
  46. package/lib/math/orders.js +24 -24
  47. package/lib/math/position.js +5 -5
  48. package/lib/math/repeg.js +1 -1
  49. package/lib/math/spotBalance.js +9 -9
  50. package/lib/math/spotMarket.js +3 -3
  51. package/lib/math/spotPosition.js +3 -3
  52. package/lib/math/trade.d.ts +1 -1
  53. package/lib/math/trade.js +43 -43
  54. package/lib/math/utils.js +1 -1
  55. package/lib/oracles/oracleClientCache.js +1 -1
  56. package/lib/oracles/pythClient.js +1 -1
  57. package/lib/oracles/types.d.ts +2 -2
  58. package/lib/serum/serumSubscriber.d.ts +4 -3
  59. package/lib/serum/serumSubscriber.js +40 -11
  60. package/lib/serum/types.d.ts +3 -1
  61. package/lib/slot/SlotSubscriber.d.ts +1 -1
  62. package/lib/tokenFaucet.js +5 -1
  63. package/lib/tx/retryTxSender.d.ts +1 -1
  64. package/lib/tx/retryTxSender.js +1 -1
  65. package/lib/tx/types.d.ts +1 -1
  66. package/lib/types.d.ts +49 -46
  67. package/lib/types.js +2 -1
  68. package/lib/user.js +63 -63
  69. package/lib/userConfig.d.ts +2 -2
  70. package/lib/userMap/userMap.js +1 -1
  71. package/lib/userMap/userStatsMap.js +3 -3
  72. package/lib/userStats.js +2 -2
  73. package/lib/userStatsConfig.d.ts +2 -2
  74. package/package.json +1 -1
  75. package/src/constants/perpMarkets.ts +33 -3
  76. package/src/dlob/DLOB.ts +17 -5
  77. package/src/dlob/NodeList.ts +2 -5
  78. package/src/factory/oracleClient.ts +5 -1
  79. package/src/idl/drift.json +7 -4
  80. package/src/math/amm.ts +22 -23
  81. package/src/math/trade.ts +1 -1
  82. package/src/serum/serumSubscriber.ts +62 -20
  83. package/src/serum/types.ts +9 -5
  84. package/src/types.ts +2 -1
  85. package/tests/amm/test.ts +177 -5
  86. package/tests/dlob/test.ts +2 -1
@@ -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];
@@ -49,6 +53,12 @@ const spotPosition_1 = require("./math/spotPosition");
49
53
  * 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
54
  */
51
55
  class DriftClient {
56
+ get isSubscribed() {
57
+ return this._isSubscribed && this.accountSubscriber.isSubscribed;
58
+ }
59
+ set isSubscribed(val) {
60
+ this._isSubscribed = val;
61
+ }
52
62
  constructor(config) {
53
63
  var _a, _b, _c, _d, _e, _f, _g, _h;
54
64
  this.users = new Map();
@@ -76,7 +86,7 @@ class DriftClient {
76
86
  if (config.userStats) {
77
87
  this.userStats = new userStats_1.UserStats({
78
88
  driftClient: this,
79
- userStatsAccountPublicKey: pda_1.getUserStatsAccountPublicKey(this.program.programId, this.authority),
89
+ userStatsAccountPublicKey: (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, this.authority),
80
90
  accountSubscription: this.userAccountSubscriptionConfig,
81
91
  });
82
92
  }
@@ -84,7 +94,7 @@ class DriftClient {
84
94
  let spotMarketIndexes = config.spotMarketIndexes;
85
95
  let oracleInfos = config.oracleInfos;
86
96
  if (config.env) {
87
- const { perpMarketIndexes: envPerpMarketIndexes, spotMarketIndexes: envSpotMarketIndexes, oracleInfos: envOracleInfos, } = config_1.getMarketsAndOraclesForSubscription(config.env);
97
+ const { perpMarketIndexes: envPerpMarketIndexes, spotMarketIndexes: envSpotMarketIndexes, oracleInfos: envOracleInfos, } = (0, config_1.getMarketsAndOraclesForSubscription)(config.env);
88
98
  perpMarketIndexes = perpMarketIndexes
89
99
  ? perpMarketIndexes
90
100
  : envPerpMarketIndexes;
@@ -106,12 +116,6 @@ class DriftClient {
106
116
  this.eventEmitter = this.accountSubscriber.eventEmitter;
107
117
  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
118
  }
109
- get isSubscribed() {
110
- return this._isSubscribed && this.accountSubscriber.isSubscribed;
111
- }
112
- set isSubscribed(val) {
113
- this._isSubscribed = val;
114
- }
115
119
  createUsers(subAccountIds, accountSubscriptionConfig) {
116
120
  for (const subAccountId of subAccountIds) {
117
121
  const user = this.createUser(subAccountId, accountSubscriptionConfig);
@@ -119,7 +123,7 @@ class DriftClient {
119
123
  }
120
124
  }
121
125
  createUser(subAccountId, accountSubscriptionConfig) {
122
- const userAccountPublicKey = pda_1.getUserAccountPublicKeySync(this.program.programId, this.authority, subAccountId);
126
+ const userAccountPublicKey = (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, this.authority, subAccountId);
123
127
  return new user_1.User({
124
128
  driftClient: this,
125
129
  userAccountPublicKey,
@@ -164,14 +168,14 @@ class DriftClient {
164
168
  if (this.statePublicKey) {
165
169
  return this.statePublicKey;
166
170
  }
167
- this.statePublicKey = await pda_1.getDriftStateAccountPublicKey(this.program.programId);
171
+ this.statePublicKey = await (0, pda_1.getDriftStateAccountPublicKey)(this.program.programId);
168
172
  return this.statePublicKey;
169
173
  }
170
174
  getSignerPublicKey() {
171
175
  if (this.signerPublicKey) {
172
176
  return this.signerPublicKey;
173
177
  }
174
- this.signerPublicKey = pda_1.getDriftSignerPublicKey(this.program.programId);
178
+ this.signerPublicKey = (0, pda_1.getDriftSignerPublicKey)(this.program.programId);
175
179
  return this.signerPublicKey;
176
180
  }
177
181
  getStateAccount() {
@@ -232,7 +236,7 @@ class DriftClient {
232
236
  return this.accountSubscriber.getOraclePriceDataAndSlot(oraclePublicKey);
233
237
  }
234
238
  async getSerumV3FulfillmentConfig(serumMarket) {
235
- const address = await pda_1.getSerumFulfillmentConfigPublicKey(this.program.programId, serumMarket);
239
+ const address = await (0, pda_1.getSerumFulfillmentConfigPublicKey)(this.program.programId, serumMarket);
236
240
  return (await this.program.account.serumV3FulfillmentConfig.fetch(address));
237
241
  }
238
242
  async fetchMarketLookupTableAccount() {
@@ -263,7 +267,7 @@ class DriftClient {
263
267
  await this.userStats.unsubscribe();
264
268
  this.userStats = new userStats_1.UserStats({
265
269
  driftClient: this,
266
- userStatsAccountPublicKey: pda_1.getUserStatsAccountPublicKey(this.program.programId, this.authority),
270
+ userStatsAccountPublicKey: (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, this.authority),
267
271
  accountSubscription: this.userAccountSubscriptionConfig,
268
272
  });
269
273
  }
@@ -303,7 +307,7 @@ class DriftClient {
303
307
  return [txSig, userAccountPublicKey];
304
308
  }
305
309
  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);
310
+ const userAccountPublicKey = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.wallet.publicKey, subAccountId);
307
311
  const remainingAccounts = new Array();
308
312
  if (referrerInfo !== undefined) {
309
313
  remainingAccounts.push({
@@ -326,7 +330,7 @@ class DriftClient {
326
330
  isSigner: false,
327
331
  });
328
332
  }
329
- const nameBuffer = userName_1.encodeName(name);
333
+ const nameBuffer = (0, userName_1.encodeName)(name);
330
334
  const initializeUserAccountIx = await this.program.instruction.initializeUser(subAccountId, nameBuffer, {
331
335
  accounts: {
332
336
  user: userAccountPublicKey,
@@ -354,8 +358,8 @@ class DriftClient {
354
358
  });
355
359
  }
356
360
  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);
361
+ const userAccountPublicKey = (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, this.wallet.publicKey, subAccountId);
362
+ const nameBuffer = (0, userName_1.encodeName)(name);
359
363
  const tx = await this.program.transaction.updateUserName(subAccountId, nameBuffer, {
360
364
  accounts: {
361
365
  user: userAccountPublicKey,
@@ -376,7 +380,7 @@ class DriftClient {
376
380
  return txSig;
377
381
  }
378
382
  async updateUserMarginTradingEnabled(marginTradingEnabled, subAccountId = 0) {
379
- const userAccountPublicKey = pda_1.getUserAccountPublicKeySync(this.program.programId, this.wallet.publicKey, subAccountId);
383
+ const userAccountPublicKey = (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, this.wallet.publicKey, subAccountId);
380
384
  await this.addUser(subAccountId);
381
385
  const remainingAccounts = this.getRemainingAccounts({
382
386
  userAccounts: [this.getUserAccount(subAccountId)],
@@ -427,7 +431,7 @@ class DriftClient {
427
431
  }
428
432
  async deleteUser(subAccountId = 0, txParams) {
429
433
  var _a;
430
- const userAccountPublicKey = pda_1.getUserAccountPublicKeySync(this.program.programId, this.wallet.publicKey, subAccountId);
434
+ const userAccountPublicKey = (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, this.wallet.publicKey, subAccountId);
431
435
  const ix = await this.program.instruction.deleteUser({
432
436
  accounts: {
433
437
  user: userAccountPublicKey,
@@ -436,7 +440,7 @@ class DriftClient {
436
440
  state: await this.getStatePublicKey(),
437
441
  },
438
442
  });
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);
443
+ 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
444
  await ((_a = this.users.get(subAccountId)) === null || _a === void 0 ? void 0 : _a.unsubscribe());
441
445
  this.users.delete(subAccountId);
442
446
  return txSig;
@@ -458,7 +462,7 @@ class DriftClient {
458
462
  if (this.userStatsAccountPublicKey) {
459
463
  return this.userStatsAccountPublicKey;
460
464
  }
461
- this.userStatsAccountPublicKey = pda_1.getUserStatsAccountPublicKey(this.program.programId, this.authority);
465
+ this.userStatsAccountPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, this.authority);
462
466
  return this.userStatsAccountPublicKey;
463
467
  }
464
468
  async getUserAccountPublicKey() {
@@ -484,7 +488,7 @@ class DriftClient {
484
488
  getQuoteAssetTokenAmount() {
485
489
  const spotMarket = this.getSpotMarketAccount(numericConstants_1.QUOTE_SPOT_MARKET_INDEX);
486
490
  const spotPosition = this.getSpotPosition(numericConstants_1.QUOTE_SPOT_MARKET_INDEX);
487
- return spotBalance_1.getTokenAmount(spotPosition.scaledBalance, spotMarket, spotPosition.balanceType);
491
+ return (0, spotBalance_1.getTokenAmount)(spotPosition.scaledBalance, spotMarket, spotPosition.balanceType);
488
492
  }
489
493
  getTokenAmount(marketIndex) {
490
494
  const spotPosition = this.getSpotPosition(marketIndex);
@@ -492,7 +496,7 @@ class DriftClient {
492
496
  return numericConstants_1.ZERO;
493
497
  }
494
498
  const spotMarket = this.getSpotMarketAccount(marketIndex);
495
- return spotBalance_1.getTokenAmount(spotPosition.scaledBalance, spotMarket, spotPosition.balanceType);
499
+ return (0, spotBalance_1.getTokenAmount)(spotPosition.scaledBalance, spotMarket, spotPosition.balanceType);
496
500
  }
497
501
  getRemainingAccounts(params) {
498
502
  var _a;
@@ -616,7 +620,7 @@ class DriftClient {
616
620
  const perpMarketAccountMap = new Map();
617
621
  for (const userAccount of userAccounts) {
618
622
  for (const spotPosition of userAccount.spotPositions) {
619
- if (!spotPosition_1.isSpotPositionAvailable(spotPosition)) {
623
+ if (!(0, spotPosition_1.isSpotPositionAvailable)(spotPosition)) {
620
624
  const spotMarket = this.getSpotMarketAccount(spotPosition.marketIndex);
621
625
  spotMarketAccountMap.set(spotPosition.marketIndex, {
622
626
  pubkey: spotMarket.pubkey,
@@ -641,7 +645,7 @@ class DriftClient {
641
645
  }
642
646
  }
643
647
  for (const position of userAccount.perpPositions) {
644
- if (!position_1.positionIsAvailable(position)) {
648
+ if (!(0, position_1.positionIsAvailable)(position)) {
645
649
  const market = this.getPerpMarketAccount(position.marketIndex);
646
650
  perpMarketAccountMap.set(position.marketIndex, {
647
651
  pubkey: market.pubkey,
@@ -700,7 +704,7 @@ class DriftClient {
700
704
  }
701
705
  async getDepositInstruction(amount, marketIndex, userTokenAccount, subAccountId, reduceOnly = false, userInitialized = true) {
702
706
  const userAccountPublicKey = subAccountId
703
- ? await pda_1.getUserAccountPublicKey(this.program.programId, this.authority, subAccountId)
707
+ ? await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.authority, subAccountId)
704
708
  : await this.getUserAccountPublicKey();
705
709
  let remainingAccounts = [];
706
710
  if (userInitialized) {
@@ -885,7 +889,7 @@ class DriftClient {
885
889
  });
886
890
  }
887
891
  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);
892
+ 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
893
  if (fromSubAccountId === this.activeSubAccountId ||
890
894
  toSubAccountId === this.activeSubAccountId) {
891
895
  this.spotMarketLastSlotCache.set(marketIndex, slot);
@@ -893,8 +897,8 @@ class DriftClient {
893
897
  return txSig;
894
898
  }
895
899
  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);
900
+ const fromUser = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.wallet.publicKey, fromSubAccountId);
901
+ const toUser = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.wallet.publicKey, toSubAccountId);
898
902
  let remainingAccounts;
899
903
  if (this.users.has(fromSubAccountId)) {
900
904
  remainingAccounts = this.getRemainingAccounts({
@@ -904,7 +908,7 @@ class DriftClient {
904
908
  });
905
909
  }
906
910
  else {
907
- const userAccountPublicKey = pda_1.getUserAccountPublicKeySync(this.program.programId, this.authority, fromSubAccountId);
911
+ const userAccountPublicKey = (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, this.authority, fromSubAccountId);
908
912
  const fromUserAccount = (await this.program.account.user.fetch(userAccountPublicKey));
909
913
  remainingAccounts = this.getRemainingAccounts({
910
914
  userAccounts: [fromUserAccount],
@@ -925,7 +929,7 @@ class DriftClient {
925
929
  });
926
930
  }
927
931
  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);
932
+ 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
933
  return txSig;
930
934
  }
931
935
  async updateSpotMarketCumulativeInterestIx(marketIndex) {
@@ -939,7 +943,7 @@ class DriftClient {
939
943
  });
940
944
  }
941
945
  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);
946
+ 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
947
  return txSig;
944
948
  }
945
949
  async settleLPIx(settleeUserAccountPublicKey, marketIndex) {
@@ -957,11 +961,11 @@ class DriftClient {
957
961
  });
958
962
  }
959
963
  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);
964
+ 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
965
  return txSig;
962
966
  }
963
967
  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);
968
+ 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
969
  return txSig;
966
970
  }
967
971
  async getRemovePerpLpSharesInExpiringMarket(marketIndex, userAccountPublicKey, sharesToBurn) {
@@ -1007,7 +1011,7 @@ class DriftClient {
1007
1011
  });
1008
1012
  }
1009
1013
  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);
1014
+ 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
1015
  this.perpMarketLastSlotCache.set(marketIndex, slot);
1012
1016
  return txSig;
1013
1017
  }
@@ -1051,8 +1055,8 @@ class DriftClient {
1051
1055
  async sendMarketOrderAndGetSignedFillTx(orderParams, userAccountPublicKey, userAccount, makerInfo, txParams) {
1052
1056
  const marketIndex = orderParams.marketIndex;
1053
1057
  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, {
1058
+ 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);
1059
+ const fillTx = (0, utils_1.wrapInTx)(await this.getFillPerpOrderIx(userAccountPublicKey, userAccount, {
1056
1060
  orderId,
1057
1061
  marketIndex,
1058
1062
  }, makerInfo), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice);
@@ -1068,7 +1072,7 @@ class DriftClient {
1068
1072
  return { txSig, signedFillTx };
1069
1073
  }
1070
1074
  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);
1075
+ 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
1076
  this.perpMarketLastSlotCache.set(orderParams.marketIndex, slot);
1073
1077
  return txSig;
1074
1078
  }
@@ -1096,7 +1100,7 @@ class DriftClient {
1096
1100
  });
1097
1101
  }
1098
1102
  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);
1103
+ 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
1104
  return txSig;
1101
1105
  }
1102
1106
  async getUpdateAMMsIx(marketIndexes) {
@@ -1130,7 +1134,7 @@ class DriftClient {
1130
1134
  });
1131
1135
  }
1132
1136
  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);
1137
+ 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
1138
  return txSig;
1135
1139
  }
1136
1140
  async getSettleExpiredMarketIx(marketIndex) {
@@ -1165,8 +1169,8 @@ class DriftClient {
1165
1169
  });
1166
1170
  }
1167
1171
  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);
1172
+ const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
1173
+ const spotMarketPublicKey = await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, numericConstants_1.QUOTE_SPOT_MARKET_INDEX);
1170
1174
  const ix = await this.program.instruction.settleExpiredMarketPoolsToRevenuePool({
1171
1175
  accounts: {
1172
1176
  state: await this.getStatePublicKey(),
@@ -1175,11 +1179,11 @@ class DriftClient {
1175
1179
  perpMarket: perpMarketPublicKey,
1176
1180
  },
1177
1181
  });
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);
1182
+ 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
1183
  return txSig;
1180
1184
  }
1181
1185
  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);
1186
+ 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
1187
  return txSig;
1184
1188
  }
1185
1189
  async getCancelOrderIx(orderId) {
@@ -1198,7 +1202,7 @@ class DriftClient {
1198
1202
  });
1199
1203
  }
1200
1204
  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);
1205
+ 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
1206
  return txSig;
1203
1207
  }
1204
1208
  async getCancelOrderByUserIdIx(userOrderId) {
@@ -1220,7 +1224,7 @@ class DriftClient {
1220
1224
  });
1221
1225
  }
1222
1226
  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);
1227
+ 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
1228
  return txSig;
1225
1229
  }
1226
1230
  async getCancelOrdersIx(marketType, marketIndex, direction) {
@@ -1228,10 +1232,10 @@ class DriftClient {
1228
1232
  let readablePerpMarketIndex = undefined;
1229
1233
  let readableSpotMarketIndexes = undefined;
1230
1234
  if (marketIndex) {
1231
- if (marketType && types_1.isVariant(marketType, 'perp')) {
1235
+ if (marketType && (0, types_1.isVariant)(marketType, 'perp')) {
1232
1236
  readablePerpMarketIndex = marketIndex;
1233
1237
  }
1234
- else if (marketType && types_1.isVariant(marketType, 'spot')) {
1238
+ else if (marketType && (0, types_1.isVariant)(marketType, 'spot')) {
1235
1239
  readableSpotMarketIndexes = [marketIndex];
1236
1240
  }
1237
1241
  }
@@ -1251,11 +1255,11 @@ class DriftClient {
1251
1255
  });
1252
1256
  }
1253
1257
  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);
1258
+ 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
1259
  return txSig;
1256
1260
  }
1257
1261
  async getFillPerpOrderIx(userAccountPublicKey, userAccount, order, makerInfo, referrerInfo) {
1258
- const userStatsPublicKey = pda_1.getUserStatsAccountPublicKey(this.program.programId, userAccount.authority);
1262
+ const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, userAccount.authority);
1259
1263
  const fillerPublicKey = await this.getUserAccountPublicKey();
1260
1264
  const fillerStatsPublicKey = this.getUserStatsAccountPublicKey();
1261
1265
  const marketIndex = order
@@ -1308,7 +1312,7 @@ class DriftClient {
1308
1312
  });
1309
1313
  }
1310
1314
  async placeSpotOrder(orderParams, txParams) {
1311
- 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);
1315
+ 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);
1312
1316
  this.spotMarketLastSlotCache.set(orderParams.marketIndex, slot);
1313
1317
  this.spotMarketLastSlotCache.set(numericConstants_1.QUOTE_SPOT_MARKET_INDEX, slot);
1314
1318
  return txSig;
@@ -1335,11 +1339,11 @@ class DriftClient {
1335
1339
  });
1336
1340
  }
1337
1341
  async fillSpotOrder(userAccountPublicKey, user, order, fulfillmentConfig, makerInfo, referrerInfo, txParams) {
1338
- 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);
1342
+ 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);
1339
1343
  return txSig;
1340
1344
  }
1341
1345
  async getFillSpotOrderIx(userAccountPublicKey, userAccount, order, fulfillmentConfig, makerInfo, referrerInfo) {
1342
- const userStatsPublicKey = pda_1.getUserStatsAccountPublicKey(this.program.programId, userAccount.authority);
1346
+ const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, userAccount.authority);
1343
1347
  const fillerPublicKey = await this.getUserAccountPublicKey();
1344
1348
  const fillerStatsPublicKey = this.getUserStatsAccountPublicKey();
1345
1349
  const marketIndex = order
@@ -1461,7 +1465,7 @@ class DriftClient {
1461
1465
  isSigner: false,
1462
1466
  });
1463
1467
  remainingAccounts.push({
1464
- pubkey: pda_1.getSerumSignerPublicKey(fulfillmentConfig.serumProgramId, fulfillmentConfig.serumMarket, fulfillmentConfig.serumSignerNonce),
1468
+ pubkey: (0, pda_1.getSerumSignerPublicKey)(fulfillmentConfig.serumProgramId, fulfillmentConfig.serumMarket, fulfillmentConfig.serumSignerNonce),
1465
1469
  isWritable: false,
1466
1470
  isSigner: false,
1467
1471
  });
@@ -1492,13 +1496,13 @@ class DriftClient {
1492
1496
  });
1493
1497
  }
1494
1498
  async triggerOrder(userAccountPublicKey, user, order, txParams) {
1495
- 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);
1499
+ 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);
1496
1500
  return txSig;
1497
1501
  }
1498
1502
  async getTriggerOrderIx(userAccountPublicKey, userAccount, order) {
1499
1503
  const fillerPublicKey = await this.getUserAccountPublicKey();
1500
1504
  let remainingAccountsParams;
1501
- if (types_1.isVariant(order.marketType, 'perp')) {
1505
+ if ((0, types_1.isVariant)(order.marketType, 'perp')) {
1502
1506
  remainingAccountsParams = {
1503
1507
  userAccounts: [userAccount],
1504
1508
  writablePerpMarketIndexes: [order.marketIndex],
@@ -1523,7 +1527,7 @@ class DriftClient {
1523
1527
  });
1524
1528
  }
1525
1529
  async forceCancelOrders(userAccountPublicKey, user, txParams) {
1526
- 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);
1530
+ 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);
1527
1531
  return txSig;
1528
1532
  }
1529
1533
  async getForceCancelOrdersIx(userAccountPublicKey, userAccount) {
@@ -1543,7 +1547,7 @@ class DriftClient {
1543
1547
  });
1544
1548
  }
1545
1549
  async placeAndTakePerpOrder(orderParams, makerInfo, referrerInfo, txParams) {
1546
- 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);
1550
+ 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);
1547
1551
  this.perpMarketLastSlotCache.set(orderParams.marketIndex, slot);
1548
1552
  return txSig;
1549
1553
  }
@@ -1597,7 +1601,7 @@ class DriftClient {
1597
1601
  });
1598
1602
  }
1599
1603
  async placeAndMakePerpOrder(orderParams, takerInfo, referrerInfo, txParams) {
1600
- 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);
1604
+ 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);
1601
1605
  this.perpMarketLastSlotCache.set(orderParams.marketIndex, slot);
1602
1606
  return txSig;
1603
1607
  }
@@ -1636,7 +1640,7 @@ class DriftClient {
1636
1640
  });
1637
1641
  }
1638
1642
  async placeAndTakeSpotOrder(orderParams, fulfillmentConfig, makerInfo, referrerInfo, txParams) {
1639
- 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);
1643
+ 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);
1640
1644
  this.spotMarketLastSlotCache.set(orderParams.marketIndex, slot);
1641
1645
  this.spotMarketLastSlotCache.set(numericConstants_1.QUOTE_SPOT_MARKET_INDEX, slot);
1642
1646
  return txSig;
@@ -1695,7 +1699,7 @@ class DriftClient {
1695
1699
  });
1696
1700
  }
1697
1701
  async placeAndMakeSpotOrder(orderParams, takerInfo, fulfillmentConfig, referrerInfo, txParams) {
1698
- 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);
1702
+ 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);
1699
1703
  this.spotMarketLastSlotCache.set(orderParams.marketIndex, slot);
1700
1704
  this.spotMarketLastSlotCache.set(numericConstants_1.QUOTE_SPOT_MARKET_INDEX, slot);
1701
1705
  return txSig;
@@ -1751,7 +1755,7 @@ class DriftClient {
1751
1755
  return await this.placeAndTakePerpOrder({
1752
1756
  orderType: types_1.OrderType.MARKET,
1753
1757
  marketIndex,
1754
- direction: position_1.findDirectionToClose(userPosition),
1758
+ direction: (0, position_1.findDirectionToClose)(userPosition),
1755
1759
  baseAssetAmount: userPosition.baseAssetAmount.abs(),
1756
1760
  reduceOnly: true,
1757
1761
  price: limitPrice,
@@ -1815,11 +1819,11 @@ class DriftClient {
1815
1819
  }
1816
1820
  const cancelOrderIx = await this.getCancelOrderIx(orderId);
1817
1821
  const orderTypeHasTrigger = newOrderType
1818
- ? types_1.isOneOfVariant(newOrderType, ['triggerlimit', 'triggerMarket'])
1819
- : types_1.isOneOfVariant(openOrder.orderType, ['triggerLimit', 'triggerMarket']);
1822
+ ? (0, types_1.isOneOfVariant)(newOrderType, ['triggerlimit', 'triggerMarket'])
1823
+ : (0, types_1.isOneOfVariant)(openOrder.orderType, ['triggerLimit', 'triggerMarket']);
1820
1824
  const orderTypeHasLimitPrice = newOrderType
1821
- ? types_1.isOneOfVariant(newOrderType, ['triggerLimit', 'limit'])
1822
- : types_1.isOneOfVariant(openOrder.orderType, ['triggerLimit', 'limit']);
1825
+ ? (0, types_1.isOneOfVariant)(newOrderType, ['triggerLimit', 'limit'])
1826
+ : (0, types_1.isOneOfVariant)(openOrder.orderType, ['triggerLimit', 'limit']);
1823
1827
  const newOrderParams = {
1824
1828
  orderType: newOrderType || openOrder.orderType,
1825
1829
  marketType: openOrder.marketType,
@@ -1890,11 +1894,11 @@ class DriftClient {
1890
1894
  }
1891
1895
  const cancelOrderIx = await this.getCancelOrderByUserIdIx(userOrderId);
1892
1896
  const orderTypeHasTrigger = newOrderType
1893
- ? types_1.isOneOfVariant(newOrderType, ['triggerlimit', 'triggerMarket'])
1894
- : types_1.isOneOfVariant(openOrder.orderType, ['triggerLimit', 'triggerMarket']);
1897
+ ? (0, types_1.isOneOfVariant)(newOrderType, ['triggerlimit', 'triggerMarket'])
1898
+ : (0, types_1.isOneOfVariant)(openOrder.orderType, ['triggerLimit', 'triggerMarket']);
1895
1899
  const orderTypeHasLimitPrice = newOrderType
1896
- ? types_1.isOneOfVariant(newOrderType, ['triggerLimit', 'limit'])
1897
- : types_1.isOneOfVariant(openOrder.orderType, ['triggerLimit', 'limit']);
1900
+ ? (0, types_1.isOneOfVariant)(newOrderType, ['triggerLimit', 'limit'])
1901
+ : (0, types_1.isOneOfVariant)(openOrder.orderType, ['triggerLimit', 'limit']);
1898
1902
  const newOrderParams = {
1899
1903
  orderType: newOrderType || openOrder.orderType,
1900
1904
  marketType: openOrder.marketType,
@@ -1955,7 +1959,7 @@ class DriftClient {
1955
1959
  return txSig;
1956
1960
  }
1957
1961
  async settlePNL(settleeUserAccountPublicKey, settleeUserAccount, marketIndex, txParams) {
1958
- 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);
1962
+ 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);
1959
1963
  return txSig;
1960
1964
  }
1961
1965
  async settlePNLIx(settleeUserAccountPublicKey, settleeUserAccount, marketIndex) {
@@ -1975,12 +1979,12 @@ class DriftClient {
1975
1979
  });
1976
1980
  }
1977
1981
  async liquidatePerp(userAccountPublicKey, userAccount, marketIndex, maxBaseAssetAmount, limitPrice, txParams) {
1978
- 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);
1982
+ 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);
1979
1983
  this.perpMarketLastSlotCache.set(marketIndex, slot);
1980
1984
  return txSig;
1981
1985
  }
1982
1986
  async getLiquidatePerpIx(userAccountPublicKey, userAccount, marketIndex, maxBaseAssetAmount, limitPrice) {
1983
- const userStatsPublicKey = pda_1.getUserStatsAccountPublicKey(this.program.programId, userAccount.authority);
1987
+ const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, userAccount.authority);
1984
1988
  const liquidatorPublicKey = await this.getUserAccountPublicKey();
1985
1989
  const liquidatorStatsPublicKey = this.getUserStatsAccountPublicKey();
1986
1990
  const remainingAccounts = this.getRemainingAccounts({
@@ -2001,13 +2005,13 @@ class DriftClient {
2001
2005
  });
2002
2006
  }
2003
2007
  async liquidateSpot(userAccountPublicKey, userAccount, assetMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice, txParams) {
2004
- 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);
2008
+ 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);
2005
2009
  this.spotMarketLastSlotCache.set(assetMarketIndex, slot);
2006
2010
  this.spotMarketLastSlotCache.set(liabilityMarketIndex, slot);
2007
2011
  return txSig;
2008
2012
  }
2009
2013
  async getLiquidateSpotIx(userAccountPublicKey, userAccount, assetMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice) {
2010
- const userStatsPublicKey = pda_1.getUserStatsAccountPublicKey(this.program.programId, userAccount.authority);
2014
+ const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, userAccount.authority);
2011
2015
  const liquidatorPublicKey = await this.getUserAccountPublicKey();
2012
2016
  const liquidatorStatsPublicKey = await this.getUserStatsAccountPublicKey();
2013
2017
  const remainingAccounts = this.getRemainingAccounts({
@@ -2028,13 +2032,13 @@ class DriftClient {
2028
2032
  });
2029
2033
  }
2030
2034
  async liquidateBorrowForPerpPnl(userAccountPublicKey, userAccount, perpMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice, txParams) {
2031
- 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);
2035
+ 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);
2032
2036
  this.perpMarketLastSlotCache.set(perpMarketIndex, slot);
2033
2037
  this.spotMarketLastSlotCache.set(liabilityMarketIndex, slot);
2034
2038
  return txSig;
2035
2039
  }
2036
2040
  async getLiquidateBorrowForPerpPnlIx(userAccountPublicKey, userAccount, perpMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice) {
2037
- const userStatsPublicKey = pda_1.getUserStatsAccountPublicKey(this.program.programId, userAccount.authority);
2041
+ const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, userAccount.authority);
2038
2042
  const liquidatorPublicKey = await this.getUserAccountPublicKey();
2039
2043
  const liquidatorStatsPublicKey = await this.getUserStatsAccountPublicKey();
2040
2044
  const remainingAccounts = this.getRemainingAccounts({
@@ -2055,13 +2059,13 @@ class DriftClient {
2055
2059
  });
2056
2060
  }
2057
2061
  async liquidatePerpPnlForDeposit(userAccountPublicKey, userAccount, perpMarketIndex, assetMarketIndex, maxPnlTransfer, limitPrice, txParams) {
2058
- 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);
2062
+ 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);
2059
2063
  this.perpMarketLastSlotCache.set(perpMarketIndex, slot);
2060
2064
  this.spotMarketLastSlotCache.set(assetMarketIndex, slot);
2061
2065
  return txSig;
2062
2066
  }
2063
2067
  async getLiquidatePerpPnlForDepositIx(userAccountPublicKey, userAccount, perpMarketIndex, assetMarketIndex, maxPnlTransfer, limitPrice) {
2064
- const userStatsPublicKey = pda_1.getUserStatsAccountPublicKey(this.program.programId, userAccount.authority);
2068
+ const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, userAccount.authority);
2065
2069
  const liquidatorPublicKey = await this.getUserAccountPublicKey();
2066
2070
  const liquidatorStatsPublicKey = await this.getUserStatsAccountPublicKey();
2067
2071
  const remainingAccounts = this.getRemainingAccounts({
@@ -2082,11 +2086,11 @@ class DriftClient {
2082
2086
  });
2083
2087
  }
2084
2088
  async resolvePerpBankruptcy(userAccountPublicKey, userAccount, marketIndex, txParams) {
2085
- 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);
2089
+ 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);
2086
2090
  return txSig;
2087
2091
  }
2088
2092
  async getResolvePerpBankruptcyIx(userAccountPublicKey, userAccount, marketIndex) {
2089
- const userStatsPublicKey = pda_1.getUserStatsAccountPublicKey(this.program.programId, userAccount.authority);
2093
+ const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, userAccount.authority);
2090
2094
  const liquidatorPublicKey = await this.getUserAccountPublicKey();
2091
2095
  const liquidatorStatsPublicKey = await this.getUserStatsAccountPublicKey();
2092
2096
  const remainingAccounts = this.getRemainingAccounts({
@@ -2112,11 +2116,11 @@ class DriftClient {
2112
2116
  });
2113
2117
  }
2114
2118
  async resolveSpotBankruptcy(userAccountPublicKey, userAccount, marketIndex, txParams) {
2115
- 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);
2119
+ 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);
2116
2120
  return txSig;
2117
2121
  }
2118
2122
  async getResolveSpotBankruptcyIx(userAccountPublicKey, userAccount, marketIndex) {
2119
- const userStatsPublicKey = pda_1.getUserStatsAccountPublicKey(this.program.programId, userAccount.authority);
2123
+ const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, userAccount.authority);
2120
2124
  const liquidatorPublicKey = await this.getUserAccountPublicKey();
2121
2125
  const liquidatorStatsPublicKey = await this.getUserStatsAccountPublicKey();
2122
2126
  const remainingAccounts = this.getRemainingAccounts({
@@ -2141,11 +2145,11 @@ class DriftClient {
2141
2145
  });
2142
2146
  }
2143
2147
  async updateFundingRate(perpMarketIndex, oracle, txParams) {
2144
- 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);
2148
+ 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);
2145
2149
  return txSig;
2146
2150
  }
2147
2151
  async getUpdateFundingRateIx(perpMarketIndex, oracle) {
2148
- const perpMarketPublicKey = await pda_1.getPerpMarketPublicKey(this.program.programId, perpMarketIndex);
2152
+ const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
2149
2153
  return await this.program.instruction.updateFundingRate(perpMarketIndex, {
2150
2154
  accounts: {
2151
2155
  state: await this.getStatePublicKey(),
@@ -2155,14 +2159,14 @@ class DriftClient {
2155
2159
  });
2156
2160
  }
2157
2161
  async settleFundingPayment(userAccountPublicKey, txParams) {
2158
- 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);
2162
+ 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);
2159
2163
  return txSig;
2160
2164
  }
2161
2165
  async getSettleFundingPaymentIx(userAccountPublicKey) {
2162
2166
  const userAccount = (await this.program.account.user.fetch(userAccountPublicKey));
2163
2167
  const writablePerpMarketIndexes = [];
2164
2168
  for (const position of userAccount.perpPositions) {
2165
- if (!position_1.positionIsAvailable(position)) {
2169
+ if (!(0, position_1.positionIsAvailable)(position)) {
2166
2170
  writablePerpMarketIndexes.push(position.marketIndex);
2167
2171
  }
2168
2172
  }
@@ -2192,11 +2196,11 @@ class DriftClient {
2192
2196
  return oracleData;
2193
2197
  }
2194
2198
  async initializeInsuranceFundStake(marketIndex, txParams) {
2195
- 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);
2199
+ 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);
2196
2200
  return txSig;
2197
2201
  }
2198
2202
  async getInitializeInsuranceFundStakeIx(marketIndex) {
2199
- const ifStakeAccountPublicKey = pda_1.getInsuranceFundStakeAccountPublicKey(this.program.programId, this.wallet.publicKey, marketIndex);
2203
+ const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, this.wallet.publicKey, marketIndex);
2200
2204
  return await this.program.instruction.initializeInsuranceFundStake(marketIndex, {
2201
2205
  accounts: {
2202
2206
  insuranceFundStake: ifStakeAccountPublicKey,
@@ -2212,7 +2216,7 @@ class DriftClient {
2212
2216
  }
2213
2217
  async addInsuranceFundStake(marketIndex, amount, collateralAccountPublicKey) {
2214
2218
  const spotMarket = this.getSpotMarketAccount(marketIndex);
2215
- const ifStakeAccountPublicKey = pda_1.getInsuranceFundStakeAccountPublicKey(this.program.programId, this.wallet.publicKey, marketIndex);
2219
+ const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, this.wallet.publicKey, marketIndex);
2216
2220
  const remainingAccounts = this.getRemainingAccounts({
2217
2221
  userAccounts: [this.getUserAccount()],
2218
2222
  useMarketLastSlotCache: true,
@@ -2238,7 +2242,7 @@ class DriftClient {
2238
2242
  }
2239
2243
  async requestRemoveInsuranceFundStake(marketIndex, amount) {
2240
2244
  const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
2241
- const ifStakeAccountPublicKey = pda_1.getInsuranceFundStakeAccountPublicKey(this.program.programId, this.wallet.publicKey, marketIndex);
2245
+ const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, this.wallet.publicKey, marketIndex);
2242
2246
  const remainingAccounts = this.getRemainingAccounts({
2243
2247
  userAccounts: [this.getUserAccount()],
2244
2248
  useMarketLastSlotCache: true,
@@ -2260,7 +2264,7 @@ class DriftClient {
2260
2264
  }
2261
2265
  async cancelRequestRemoveInsuranceFundStake(marketIndex) {
2262
2266
  const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
2263
- const ifStakeAccountPublicKey = pda_1.getInsuranceFundStakeAccountPublicKey(this.program.programId, this.wallet.publicKey, marketIndex);
2267
+ const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, this.wallet.publicKey, marketIndex);
2264
2268
  const remainingAccounts = this.getRemainingAccounts({
2265
2269
  userAccounts: [this.getUserAccount()],
2266
2270
  useMarketLastSlotCache: true,
@@ -2282,7 +2286,7 @@ class DriftClient {
2282
2286
  }
2283
2287
  async removeInsuranceFundStake(marketIndex, collateralAccountPublicKey) {
2284
2288
  const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
2285
- const ifStakeAccountPublicKey = pda_1.getInsuranceFundStakeAccountPublicKey(this.program.programId, this.wallet.publicKey, marketIndex);
2289
+ const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, this.wallet.publicKey, marketIndex);
2286
2290
  const remainingAccounts = this.getRemainingAccounts({
2287
2291
  userAccounts: [this.getUserAccount()],
2288
2292
  useMarketLastSlotCache: true,
@@ -2327,7 +2331,7 @@ class DriftClient {
2327
2331
  return txSig;
2328
2332
  }
2329
2333
  async resolvePerpPnlDeficit(spotMarketIndex, perpMarketIndex, txParams) {
2330
- 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);
2334
+ 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);
2331
2335
  return txSig;
2332
2336
  }
2333
2337
  async getResolvePerpPnlDeficitIx(spotMarketIndex, perpMarketIndex) {