@drift-labs/sdk 2.31.1-beta.6 → 2.31.1-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/VERSION CHANGED
@@ -1 +1 @@
1
- 2.31.1-beta.6
1
+ 2.31.1-beta.7
@@ -51,6 +51,7 @@ export declare class DriftClient {
51
51
  authoritySubAccountMap?: Map<string, number[]>;
52
52
  skipLoadUsers?: boolean;
53
53
  txVersion: TransactionVersion;
54
+ txParams: TxParams;
54
55
  get isSubscribed(): boolean;
55
56
  set isSubscribed(val: boolean);
56
57
  constructor(config: DriftClientConfig);
@@ -64,7 +64,7 @@ class DriftClient {
64
64
  this._isSubscribed = val;
65
65
  }
66
66
  constructor(config) {
67
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
67
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
68
68
  this.users = new Map();
69
69
  this._isSubscribed = false;
70
70
  this.perpMarketLastSlotCache = new Map();
@@ -78,6 +78,10 @@ class DriftClient {
78
78
  this.activeSubAccountId = (_c = config.activeSubAccountId) !== null && _c !== void 0 ? _c : 0;
79
79
  this.skipLoadUsers = (_d = config.skipLoadUsers) !== null && _d !== void 0 ? _d : false;
80
80
  this.txVersion = (_e = config.txVersion) !== null && _e !== void 0 ? _e : 'legacy';
81
+ this.txParams = {
82
+ computeUnits: (_g = (_f = config.txParams) === null || _f === void 0 ? void 0 : _f.computeUnits) !== null && _g !== void 0 ? _g : 600000,
83
+ computeUnitsPrice: (_j = (_h = config.txParams) === null || _h === void 0 ? void 0 : _h.computeUnitsPrice) !== null && _j !== void 0 ? _j : 0,
84
+ };
81
85
  if (config.includeDelegates && config.subAccountIds) {
82
86
  throw new Error('Can only pass one of includeDelegates or subAccountIds. If you want to specify subaccount ids for multiple authorities, pass authoritySubaccountMap instead');
83
87
  }
@@ -92,8 +96,8 @@ class DriftClient {
92
96
  : config.subAccountIds
93
97
  ? new Map([[this.authority.toString(), config.subAccountIds]])
94
98
  : new Map();
95
- this.includeDelegates = (_f = config.includeDelegates) !== null && _f !== void 0 ? _f : false;
96
- if (((_g = config.accountSubscription) === null || _g === void 0 ? void 0 : _g.type) === 'polling') {
99
+ this.includeDelegates = (_k = config.includeDelegates) !== null && _k !== void 0 ? _k : false;
100
+ if (((_l = config.accountSubscription) === null || _l === void 0 ? void 0 : _l.type) === 'polling') {
97
101
  this.userAccountSubscriptionConfig = {
98
102
  type: 'polling',
99
103
  accountLoader: config.accountSubscription.accountLoader,
@@ -125,14 +129,14 @@ class DriftClient {
125
129
  const noMarketsAndOraclesSpecified = config.perpMarketIndexes === undefined &&
126
130
  config.spotMarketIndexes === undefined &&
127
131
  config.oracleInfos === undefined;
128
- if (((_h = config.accountSubscription) === null || _h === void 0 ? void 0 : _h.type) === 'polling') {
129
- this.accountSubscriber = new pollingDriftClientAccountSubscriber_1.PollingDriftClientAccountSubscriber(this.program, config.accountSubscription.accountLoader, (_j = config.perpMarketIndexes) !== null && _j !== void 0 ? _j : [], (_k = config.spotMarketIndexes) !== null && _k !== void 0 ? _k : [], (_l = config.oracleInfos) !== null && _l !== void 0 ? _l : [], noMarketsAndOraclesSpecified);
132
+ if (((_m = config.accountSubscription) === null || _m === void 0 ? void 0 : _m.type) === 'polling') {
133
+ this.accountSubscriber = new pollingDriftClientAccountSubscriber_1.PollingDriftClientAccountSubscriber(this.program, config.accountSubscription.accountLoader, (_o = config.perpMarketIndexes) !== null && _o !== void 0 ? _o : [], (_p = config.spotMarketIndexes) !== null && _p !== void 0 ? _p : [], (_q = config.oracleInfos) !== null && _q !== void 0 ? _q : [], noMarketsAndOraclesSpecified);
130
134
  }
131
135
  else {
132
- this.accountSubscriber = new webSocketDriftClientAccountSubscriber_1.WebSocketDriftClientAccountSubscriber(this.program, (_m = config.perpMarketIndexes) !== null && _m !== void 0 ? _m : [], (_o = config.spotMarketIndexes) !== null && _o !== void 0 ? _o : [], (_p = config.oracleInfos) !== null && _p !== void 0 ? _p : [], noMarketsAndOraclesSpecified);
136
+ this.accountSubscriber = new webSocketDriftClientAccountSubscriber_1.WebSocketDriftClientAccountSubscriber(this.program, (_r = config.perpMarketIndexes) !== null && _r !== void 0 ? _r : [], (_s = config.spotMarketIndexes) !== null && _s !== void 0 ? _s : [], (_t = config.oracleInfos) !== null && _t !== void 0 ? _t : [], noMarketsAndOraclesSpecified);
133
137
  }
134
138
  this.eventEmitter = this.accountSubscriber.eventEmitter;
135
- this.txSender = (_q = config.txSender) !== null && _q !== void 0 ? _q : new retryTxSender_1.RetryTxSender(this.provider);
139
+ this.txSender = (_u = config.txSender) !== null && _u !== void 0 ? _u : new retryTxSender_1.RetryTxSender(this.provider);
136
140
  }
137
141
  getUserMapKey(subAccountId, authority) {
138
142
  return `${subAccountId}_${authority.toString()}`;
@@ -3071,13 +3075,13 @@ class DriftClient {
3071
3075
  async buildTransaction(instructions, txParams, txVersion, lookupTables) {
3072
3076
  var _a, _b;
3073
3077
  const allIx = [];
3074
- const computeUnits = (_a = txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits) !== null && _a !== void 0 ? _a : 600000;
3078
+ const computeUnits = (_a = txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits) !== null && _a !== void 0 ? _a : this.txParams.computeUnits;
3075
3079
  if (computeUnits !== 200000) {
3076
3080
  allIx.push(web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
3077
3081
  units: computeUnits,
3078
3082
  }));
3079
3083
  }
3080
- const computeUnitsPrice = (_b = txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice) !== null && _b !== void 0 ? _b : 0;
3084
+ const computeUnitsPrice = (_b = txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice) !== null && _b !== void 0 ? _b : this.txParams.computeUnitsPrice;
3081
3085
  if (computeUnitsPrice !== 0) {
3082
3086
  allIx.push(web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
3083
3087
  microLamports: computeUnitsPrice,
@@ -1,5 +1,5 @@
1
1
  import { ConfirmOptions, Connection, PublicKey, TransactionVersion } from '@solana/web3.js';
2
- import { IWallet } from './types';
2
+ import { IWallet, TxParams } from './types';
3
3
  import { OracleInfo } from './oracles/types';
4
4
  import { BulkAccountLoader } from './accounts/bulkAccountLoader';
5
5
  import { DriftEnv } from './config';
@@ -24,6 +24,7 @@ export type DriftClientConfig = {
24
24
  authoritySubAccountMap?: Map<string, number[]>;
25
25
  skipLoadUsers?: boolean;
26
26
  txVersion?: TransactionVersion;
27
+ txParams?: TxParams;
27
28
  };
28
29
  export type DriftClientSubscriptionConfig = {
29
30
  type: 'websocket';
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.31.1-beta.5",
2
+ "version": "2.31.1-beta.6",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.31.1-beta.6",
3
+ "version": "2.31.1-beta.7",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -155,6 +155,7 @@ export class DriftClient {
155
155
  authoritySubAccountMap?: Map<string, number[]>;
156
156
  skipLoadUsers?: boolean;
157
157
  txVersion: TransactionVersion;
158
+ txParams: TxParams;
158
159
 
159
160
  public get isSubscribed() {
160
161
  return this._isSubscribed && this.accountSubscriber.isSubscribed;
@@ -183,6 +184,10 @@ export class DriftClient {
183
184
  this.activeSubAccountId = config.activeSubAccountId ?? 0;
184
185
  this.skipLoadUsers = config.skipLoadUsers ?? false;
185
186
  this.txVersion = config.txVersion ?? 'legacy';
187
+ this.txParams = {
188
+ computeUnits: config.txParams?.computeUnits ?? 600_000,
189
+ computeUnitsPrice: config.txParams?.computeUnitsPrice ?? 0,
190
+ };
186
191
 
187
192
  if (config.includeDelegates && config.subAccountIds) {
188
193
  throw new Error(
@@ -5401,7 +5406,7 @@ export class DriftClient {
5401
5406
  lookupTables?: AddressLookupTableAccount[]
5402
5407
  ): Promise<Transaction | VersionedTransaction> {
5403
5408
  const allIx = [];
5404
- const computeUnits = txParams?.computeUnits ?? 600_000;
5409
+ const computeUnits = txParams?.computeUnits ?? this.txParams.computeUnits;
5405
5410
  if (computeUnits !== 200_000) {
5406
5411
  allIx.push(
5407
5412
  ComputeBudgetProgram.setComputeUnitLimit({
@@ -5409,7 +5414,8 @@ export class DriftClient {
5409
5414
  })
5410
5415
  );
5411
5416
  }
5412
- const computeUnitsPrice = txParams?.computeUnitsPrice ?? 0;
5417
+ const computeUnitsPrice =
5418
+ txParams?.computeUnitsPrice ?? this.txParams.computeUnitsPrice;
5413
5419
  if (computeUnitsPrice !== 0) {
5414
5420
  allIx.push(
5415
5421
  ComputeBudgetProgram.setComputeUnitPrice({
@@ -4,7 +4,7 @@ import {
4
4
  PublicKey,
5
5
  TransactionVersion,
6
6
  } from '@solana/web3.js';
7
- import { IWallet } from './types';
7
+ import { IWallet, TxParams } from './types';
8
8
  import { OracleInfo } from './oracles/types';
9
9
  import { BulkAccountLoader } from './accounts/bulkAccountLoader';
10
10
  import { DriftEnv } from './config';
@@ -30,6 +30,7 @@ export type DriftClientConfig = {
30
30
  authoritySubAccountMap?: Map<string, number[]>; // if passed this will override subAccountIds and includeDelegates
31
31
  skipLoadUsers?: boolean; // if passed to constructor, no user accounts will be loaded. they will load if updateWallet is called afterwards.
32
32
  txVersion?: TransactionVersion; // which tx version to use
33
+ txParams?: TxParams; // default tx params to use
33
34
  };
34
35
 
35
36
  export type DriftClientSubscriptionConfig =
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.31.1-beta.6",
2
+ "version": "2.31.1-beta.7",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {