@drift-labs/sdk 2.105.0-beta.0 → 2.105.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.
package/VERSION CHANGED
@@ -1 +1 @@
1
- 2.105.0-beta.0
1
+ 2.105.0-beta.2
@@ -244,7 +244,6 @@ class PollingDriftClientAccountSubscriber {
244
244
  this.accountsToPoll.clear();
245
245
  this.oraclesToPoll.clear();
246
246
  this.isSubscribed = false;
247
- this.accountLoader.accountsToLoad = new Map();
248
247
  }
249
248
  async addSpotMarket(marketIndex) {
250
249
  const marketPublicKey = await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex);
@@ -41,6 +41,7 @@ export declare class DriftClient {
41
41
  wallet: IWallet;
42
42
  program: Program;
43
43
  provider: AnchorProvider;
44
+ env: DriftEnv;
44
45
  opts?: ConfirmOptions;
45
46
  useHotWalletAdmin?: boolean;
46
47
  users: Map<string, User>;
@@ -92,11 +92,12 @@ class DriftClient {
92
92
  this.mustIncludeSpotMarketIndexes = new Set();
93
93
  this.connection = config.connection;
94
94
  this.wallet = config.wallet;
95
+ this.env = (_a = config.env) !== null && _a !== void 0 ? _a : 'mainnet-beta';
95
96
  this.opts = config.opts || {
96
97
  ...config_1.DEFAULT_CONFIRMATION_OPTS,
97
98
  };
98
- this.useHotWalletAdmin = (_a = config.useHotWalletAdmin) !== null && _a !== void 0 ? _a : false;
99
- if ((_b = config === null || config === void 0 ? void 0 : config.connection) === null || _b === void 0 ? void 0 : _b.commitment) {
99
+ this.useHotWalletAdmin = (_b = config.useHotWalletAdmin) !== null && _b !== void 0 ? _b : false;
100
+ if ((_c = config === null || config === void 0 ? void 0 : config.connection) === null || _c === void 0 ? void 0 : _c.commitment) {
100
101
  // At the moment this ensures that our transaction simulations (which use Connection object) will use the same commitment level as our Transaction blockhashes (which use these opts)
101
102
  this.opts.commitment = config.connection.commitment;
102
103
  this.opts.preflightCommitment = config.connection.commitment;
@@ -104,17 +105,17 @@ class DriftClient {
104
105
  this.provider = new anchor_1.AnchorProvider(config.connection,
105
106
  // @ts-ignore
106
107
  config.wallet, this.opts);
107
- this.program = new anchor_1.Program(drift_json_1.default, (_c = config.programID) !== null && _c !== void 0 ? _c : new web3_js_1.PublicKey(config_1.DRIFT_PROGRAM_ID), this.provider);
108
- this.authority = (_d = config.authority) !== null && _d !== void 0 ? _d : this.wallet.publicKey;
109
- this.activeSubAccountId = (_e = config.activeSubAccountId) !== null && _e !== void 0 ? _e : 0;
110
- this.skipLoadUsers = (_f = config.skipLoadUsers) !== null && _f !== void 0 ? _f : false;
111
- this.txVersion = (_g = config.txVersion) !== null && _g !== void 0 ? _g : 0;
108
+ this.program = new anchor_1.Program(drift_json_1.default, (_d = config.programID) !== null && _d !== void 0 ? _d : new web3_js_1.PublicKey(config_1.DRIFT_PROGRAM_ID), this.provider);
109
+ this.authority = (_e = config.authority) !== null && _e !== void 0 ? _e : this.wallet.publicKey;
110
+ this.activeSubAccountId = (_f = config.activeSubAccountId) !== null && _f !== void 0 ? _f : 0;
111
+ this.skipLoadUsers = (_g = config.skipLoadUsers) !== null && _g !== void 0 ? _g : false;
112
+ this.txVersion = (_h = config.txVersion) !== null && _h !== void 0 ? _h : 0;
112
113
  this.txParams = {
113
- computeUnits: (_j = (_h = config.txParams) === null || _h === void 0 ? void 0 : _h.computeUnits) !== null && _j !== void 0 ? _j : 600000,
114
- computeUnitsPrice: (_l = (_k = config.txParams) === null || _k === void 0 ? void 0 : _k.computeUnitsPrice) !== null && _l !== void 0 ? _l : 0,
114
+ computeUnits: (_k = (_j = config.txParams) === null || _j === void 0 ? void 0 : _j.computeUnits) !== null && _k !== void 0 ? _k : 600000,
115
+ computeUnitsPrice: (_m = (_l = config.txParams) === null || _l === void 0 ? void 0 : _l.computeUnitsPrice) !== null && _m !== void 0 ? _m : 0,
115
116
  };
116
117
  this.txHandler =
117
- (_m = config === null || config === void 0 ? void 0 : config.txHandler) !== null && _m !== void 0 ? _m : new txHandler_1.TxHandler({
118
+ (_o = config === null || config === void 0 ? void 0 : config.txHandler) !== null && _o !== void 0 ? _o : new txHandler_1.TxHandler({
118
119
  connection: this.connection,
119
120
  // @ts-ignore
120
121
  wallet: this.provider.wallet,
@@ -140,8 +141,8 @@ class DriftClient {
140
141
  : config.subAccountIds
141
142
  ? new Map([[this.authority.toString(), config.subAccountIds]])
142
143
  : new Map();
143
- this.includeDelegates = (_o = config.includeDelegates) !== null && _o !== void 0 ? _o : false;
144
- if (((_p = config.accountSubscription) === null || _p === void 0 ? void 0 : _p.type) === 'polling') {
144
+ this.includeDelegates = (_p = config.includeDelegates) !== null && _p !== void 0 ? _p : false;
145
+ if (((_q = config.accountSubscription) === null || _q === void 0 ? void 0 : _q.type) === 'polling') {
145
146
  this.userAccountSubscriptionConfig = {
146
147
  type: 'polling',
147
148
  accountLoader: config.accountSubscription.accountLoader,
@@ -151,32 +152,32 @@ class DriftClient {
151
152
  accountLoader: config.accountSubscription.accountLoader,
152
153
  };
153
154
  }
154
- else if (((_q = config.accountSubscription) === null || _q === void 0 ? void 0 : _q.type) === 'grpc') {
155
+ else if (((_r = config.accountSubscription) === null || _r === void 0 ? void 0 : _r.type) === 'grpc') {
155
156
  this.userAccountSubscriptionConfig = {
156
157
  type: 'grpc',
157
- resubTimeoutMs: (_r = config.accountSubscription) === null || _r === void 0 ? void 0 : _r.resubTimeoutMs,
158
- logResubMessages: (_s = config.accountSubscription) === null || _s === void 0 ? void 0 : _s.logResubMessages,
159
- grpcConfigs: (_t = config.accountSubscription) === null || _t === void 0 ? void 0 : _t.grpcConfigs,
158
+ resubTimeoutMs: (_s = config.accountSubscription) === null || _s === void 0 ? void 0 : _s.resubTimeoutMs,
159
+ logResubMessages: (_t = config.accountSubscription) === null || _t === void 0 ? void 0 : _t.logResubMessages,
160
+ grpcConfigs: (_u = config.accountSubscription) === null || _u === void 0 ? void 0 : _u.grpcConfigs,
160
161
  };
161
162
  this.userStatsAccountSubscriptionConfig = {
162
163
  type: 'grpc',
163
- grpcConfigs: (_u = config.accountSubscription) === null || _u === void 0 ? void 0 : _u.grpcConfigs,
164
- resubTimeoutMs: (_v = config.accountSubscription) === null || _v === void 0 ? void 0 : _v.resubTimeoutMs,
165
- logResubMessages: (_w = config.accountSubscription) === null || _w === void 0 ? void 0 : _w.logResubMessages,
164
+ grpcConfigs: (_v = config.accountSubscription) === null || _v === void 0 ? void 0 : _v.grpcConfigs,
165
+ resubTimeoutMs: (_w = config.accountSubscription) === null || _w === void 0 ? void 0 : _w.resubTimeoutMs,
166
+ logResubMessages: (_x = config.accountSubscription) === null || _x === void 0 ? void 0 : _x.logResubMessages,
166
167
  };
167
168
  }
168
169
  else {
169
170
  this.userAccountSubscriptionConfig = {
170
171
  type: 'websocket',
171
- resubTimeoutMs: (_x = config.accountSubscription) === null || _x === void 0 ? void 0 : _x.resubTimeoutMs,
172
- logResubMessages: (_y = config.accountSubscription) === null || _y === void 0 ? void 0 : _y.logResubMessages,
173
- commitment: (_z = config.accountSubscription) === null || _z === void 0 ? void 0 : _z.commitment,
172
+ resubTimeoutMs: (_y = config.accountSubscription) === null || _y === void 0 ? void 0 : _y.resubTimeoutMs,
173
+ logResubMessages: (_z = config.accountSubscription) === null || _z === void 0 ? void 0 : _z.logResubMessages,
174
+ commitment: (_0 = config.accountSubscription) === null || _0 === void 0 ? void 0 : _0.commitment,
174
175
  };
175
176
  this.userStatsAccountSubscriptionConfig = {
176
177
  type: 'websocket',
177
- resubTimeoutMs: (_0 = config.accountSubscription) === null || _0 === void 0 ? void 0 : _0.resubTimeoutMs,
178
- logResubMessages: (_1 = config.accountSubscription) === null || _1 === void 0 ? void 0 : _1.logResubMessages,
179
- commitment: (_2 = config.accountSubscription) === null || _2 === void 0 ? void 0 : _2.commitment,
178
+ resubTimeoutMs: (_1 = config.accountSubscription) === null || _1 === void 0 ? void 0 : _1.resubTimeoutMs,
179
+ logResubMessages: (_2 = config.accountSubscription) === null || _2 === void 0 ? void 0 : _2.logResubMessages,
180
+ commitment: (_3 = config.accountSubscription) === null || _3 === void 0 ? void 0 : _3.commitment,
180
181
  };
181
182
  }
182
183
  if (config.userStats) {
@@ -187,27 +188,27 @@ class DriftClient {
187
188
  });
188
189
  }
189
190
  this.marketLookupTable = config.marketLookupTable;
190
- if (config.env && !this.marketLookupTable) {
191
- this.marketLookupTable = new web3_js_1.PublicKey(config_1.configs[config.env].MARKET_LOOKUP_TABLE);
191
+ if (!this.marketLookupTable) {
192
+ this.marketLookupTable = new web3_js_1.PublicKey(config_1.configs[this.env].MARKET_LOOKUP_TABLE);
192
193
  }
193
194
  const delistedMarketSetting = config.delistedMarketSetting || types_2.DelistedMarketSetting.Unsubscribe;
194
195
  const noMarketsAndOraclesSpecified = config.perpMarketIndexes === undefined &&
195
196
  config.spotMarketIndexes === undefined &&
196
197
  config.oracleInfos === undefined;
197
- if (((_3 = config.accountSubscription) === null || _3 === void 0 ? void 0 : _3.type) === 'polling') {
198
- this.accountSubscriber = new pollingDriftClientAccountSubscriber_1.PollingDriftClientAccountSubscriber(this.program, config.accountSubscription.accountLoader, (_4 = config.perpMarketIndexes) !== null && _4 !== void 0 ? _4 : [], (_5 = config.spotMarketIndexes) !== null && _5 !== void 0 ? _5 : [], (_6 = config.oracleInfos) !== null && _6 !== void 0 ? _6 : [], noMarketsAndOraclesSpecified, delistedMarketSetting);
198
+ if (((_4 = config.accountSubscription) === null || _4 === void 0 ? void 0 : _4.type) === 'polling') {
199
+ this.accountSubscriber = new pollingDriftClientAccountSubscriber_1.PollingDriftClientAccountSubscriber(this.program, config.accountSubscription.accountLoader, (_5 = config.perpMarketIndexes) !== null && _5 !== void 0 ? _5 : [], (_6 = config.spotMarketIndexes) !== null && _6 !== void 0 ? _6 : [], (_7 = config.oracleInfos) !== null && _7 !== void 0 ? _7 : [], noMarketsAndOraclesSpecified, delistedMarketSetting);
199
200
  }
200
- else if (((_7 = config.accountSubscription) === null || _7 === void 0 ? void 0 : _7.type) === 'grpc') {
201
- this.accountSubscriber = new grpcDriftClientAccountSubscriber_1.gprcDriftClientAccountSubscriber(config.accountSubscription.grpcConfigs, this.program, (_8 = config.perpMarketIndexes) !== null && _8 !== void 0 ? _8 : [], (_9 = config.spotMarketIndexes) !== null && _9 !== void 0 ? _9 : [], (_10 = config.oracleInfos) !== null && _10 !== void 0 ? _10 : [], noMarketsAndOraclesSpecified, delistedMarketSetting, {
202
- resubTimeoutMs: (_11 = config.accountSubscription) === null || _11 === void 0 ? void 0 : _11.resubTimeoutMs,
203
- logResubMessages: (_12 = config.accountSubscription) === null || _12 === void 0 ? void 0 : _12.logResubMessages,
201
+ else if (((_8 = config.accountSubscription) === null || _8 === void 0 ? void 0 : _8.type) === 'grpc') {
202
+ this.accountSubscriber = new grpcDriftClientAccountSubscriber_1.gprcDriftClientAccountSubscriber(config.accountSubscription.grpcConfigs, this.program, (_9 = config.perpMarketIndexes) !== null && _9 !== void 0 ? _9 : [], (_10 = config.spotMarketIndexes) !== null && _10 !== void 0 ? _10 : [], (_11 = config.oracleInfos) !== null && _11 !== void 0 ? _11 : [], noMarketsAndOraclesSpecified, delistedMarketSetting, {
203
+ resubTimeoutMs: (_12 = config.accountSubscription) === null || _12 === void 0 ? void 0 : _12.resubTimeoutMs,
204
+ logResubMessages: (_13 = config.accountSubscription) === null || _13 === void 0 ? void 0 : _13.logResubMessages,
204
205
  });
205
206
  }
206
207
  else {
207
- this.accountSubscriber = new webSocketDriftClientAccountSubscriber_1.WebSocketDriftClientAccountSubscriber(this.program, (_13 = config.perpMarketIndexes) !== null && _13 !== void 0 ? _13 : [], (_14 = config.spotMarketIndexes) !== null && _14 !== void 0 ? _14 : [], (_15 = config.oracleInfos) !== null && _15 !== void 0 ? _15 : [], noMarketsAndOraclesSpecified, delistedMarketSetting, {
208
- resubTimeoutMs: (_16 = config.accountSubscription) === null || _16 === void 0 ? void 0 : _16.resubTimeoutMs,
209
- logResubMessages: (_17 = config.accountSubscription) === null || _17 === void 0 ? void 0 : _17.logResubMessages,
210
- }, (_18 = config.accountSubscription) === null || _18 === void 0 ? void 0 : _18.commitment);
208
+ this.accountSubscriber = new webSocketDriftClientAccountSubscriber_1.WebSocketDriftClientAccountSubscriber(this.program, (_14 = config.perpMarketIndexes) !== null && _14 !== void 0 ? _14 : [], (_15 = config.spotMarketIndexes) !== null && _15 !== void 0 ? _15 : [], (_16 = config.oracleInfos) !== null && _16 !== void 0 ? _16 : [], noMarketsAndOraclesSpecified, delistedMarketSetting, {
209
+ resubTimeoutMs: (_17 = config.accountSubscription) === null || _17 === void 0 ? void 0 : _17.resubTimeoutMs,
210
+ logResubMessages: (_18 = config.accountSubscription) === null || _18 === void 0 ? void 0 : _18.logResubMessages,
211
+ }, (_19 = config.accountSubscription) === null || _19 === void 0 ? void 0 : _19.commitment);
211
212
  }
212
213
  this.eventEmitter = this.accountSubscriber.eventEmitter;
213
214
  this.metricsEventEmitter = new events_1.EventEmitter();
@@ -215,14 +216,13 @@ class DriftClient {
215
216
  this.enableMetricsEvents = true;
216
217
  }
217
218
  this.txSender =
218
- (_19 = config.txSender) !== null && _19 !== void 0 ? _19 : new retryTxSender_1.RetryTxSender({
219
+ (_20 = config.txSender) !== null && _20 !== void 0 ? _20 : new retryTxSender_1.RetryTxSender({
219
220
  connection: this.connection,
220
221
  wallet: this.wallet,
221
222
  opts: this.opts,
222
223
  txHandler: this.txHandler,
223
224
  });
224
- this.sbOnDemandProgramdId =
225
- config_1.configs[(_20 = config.env) !== null && _20 !== void 0 ? _20 : 'mainnet-beta'].SB_ON_DEMAND_PID;
225
+ this.sbOnDemandProgramdId = config_1.configs[this.env].SB_ON_DEMAND_PID;
226
226
  }
227
227
  getUserMapKey(subAccountId, authority) {
228
228
  return `${subAccountId}_${authority.toString()}`;
@@ -244,7 +244,6 @@ class PollingDriftClientAccountSubscriber {
244
244
  this.accountsToPoll.clear();
245
245
  this.oraclesToPoll.clear();
246
246
  this.isSubscribed = false;
247
- this.accountLoader.accountsToLoad = new Map();
248
247
  }
249
248
  async addSpotMarket(marketIndex) {
250
249
  const marketPublicKey = await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex);
@@ -41,6 +41,7 @@ export declare class DriftClient {
41
41
  wallet: IWallet;
42
42
  program: Program;
43
43
  provider: AnchorProvider;
44
+ env: DriftEnv;
44
45
  opts?: ConfirmOptions;
45
46
  useHotWalletAdmin?: boolean;
46
47
  users: Map<string, User>;
@@ -92,11 +92,12 @@ class DriftClient {
92
92
  this.mustIncludeSpotMarketIndexes = new Set();
93
93
  this.connection = config.connection;
94
94
  this.wallet = config.wallet;
95
+ this.env = (_a = config.env) !== null && _a !== void 0 ? _a : 'mainnet-beta';
95
96
  this.opts = config.opts || {
96
97
  ...config_1.DEFAULT_CONFIRMATION_OPTS,
97
98
  };
98
- this.useHotWalletAdmin = (_a = config.useHotWalletAdmin) !== null && _a !== void 0 ? _a : false;
99
- if ((_b = config === null || config === void 0 ? void 0 : config.connection) === null || _b === void 0 ? void 0 : _b.commitment) {
99
+ this.useHotWalletAdmin = (_b = config.useHotWalletAdmin) !== null && _b !== void 0 ? _b : false;
100
+ if ((_c = config === null || config === void 0 ? void 0 : config.connection) === null || _c === void 0 ? void 0 : _c.commitment) {
100
101
  // At the moment this ensures that our transaction simulations (which use Connection object) will use the same commitment level as our Transaction blockhashes (which use these opts)
101
102
  this.opts.commitment = config.connection.commitment;
102
103
  this.opts.preflightCommitment = config.connection.commitment;
@@ -104,17 +105,17 @@ class DriftClient {
104
105
  this.provider = new anchor_1.AnchorProvider(config.connection,
105
106
  // @ts-ignore
106
107
  config.wallet, this.opts);
107
- this.program = new anchor_1.Program(drift_json_1.default, (_c = config.programID) !== null && _c !== void 0 ? _c : new web3_js_1.PublicKey(config_1.DRIFT_PROGRAM_ID), this.provider);
108
- this.authority = (_d = config.authority) !== null && _d !== void 0 ? _d : this.wallet.publicKey;
109
- this.activeSubAccountId = (_e = config.activeSubAccountId) !== null && _e !== void 0 ? _e : 0;
110
- this.skipLoadUsers = (_f = config.skipLoadUsers) !== null && _f !== void 0 ? _f : false;
111
- this.txVersion = (_g = config.txVersion) !== null && _g !== void 0 ? _g : 0;
108
+ this.program = new anchor_1.Program(drift_json_1.default, (_d = config.programID) !== null && _d !== void 0 ? _d : new web3_js_1.PublicKey(config_1.DRIFT_PROGRAM_ID), this.provider);
109
+ this.authority = (_e = config.authority) !== null && _e !== void 0 ? _e : this.wallet.publicKey;
110
+ this.activeSubAccountId = (_f = config.activeSubAccountId) !== null && _f !== void 0 ? _f : 0;
111
+ this.skipLoadUsers = (_g = config.skipLoadUsers) !== null && _g !== void 0 ? _g : false;
112
+ this.txVersion = (_h = config.txVersion) !== null && _h !== void 0 ? _h : 0;
112
113
  this.txParams = {
113
- computeUnits: (_j = (_h = config.txParams) === null || _h === void 0 ? void 0 : _h.computeUnits) !== null && _j !== void 0 ? _j : 600000,
114
- computeUnitsPrice: (_l = (_k = config.txParams) === null || _k === void 0 ? void 0 : _k.computeUnitsPrice) !== null && _l !== void 0 ? _l : 0,
114
+ computeUnits: (_k = (_j = config.txParams) === null || _j === void 0 ? void 0 : _j.computeUnits) !== null && _k !== void 0 ? _k : 600000,
115
+ computeUnitsPrice: (_m = (_l = config.txParams) === null || _l === void 0 ? void 0 : _l.computeUnitsPrice) !== null && _m !== void 0 ? _m : 0,
115
116
  };
116
117
  this.txHandler =
117
- (_m = config === null || config === void 0 ? void 0 : config.txHandler) !== null && _m !== void 0 ? _m : new txHandler_1.TxHandler({
118
+ (_o = config === null || config === void 0 ? void 0 : config.txHandler) !== null && _o !== void 0 ? _o : new txHandler_1.TxHandler({
118
119
  connection: this.connection,
119
120
  // @ts-ignore
120
121
  wallet: this.provider.wallet,
@@ -140,8 +141,8 @@ class DriftClient {
140
141
  : config.subAccountIds
141
142
  ? new Map([[this.authority.toString(), config.subAccountIds]])
142
143
  : new Map();
143
- this.includeDelegates = (_o = config.includeDelegates) !== null && _o !== void 0 ? _o : false;
144
- if (((_p = config.accountSubscription) === null || _p === void 0 ? void 0 : _p.type) === 'polling') {
144
+ this.includeDelegates = (_p = config.includeDelegates) !== null && _p !== void 0 ? _p : false;
145
+ if (((_q = config.accountSubscription) === null || _q === void 0 ? void 0 : _q.type) === 'polling') {
145
146
  this.userAccountSubscriptionConfig = {
146
147
  type: 'polling',
147
148
  accountLoader: config.accountSubscription.accountLoader,
@@ -151,32 +152,32 @@ class DriftClient {
151
152
  accountLoader: config.accountSubscription.accountLoader,
152
153
  };
153
154
  }
154
- else if (((_q = config.accountSubscription) === null || _q === void 0 ? void 0 : _q.type) === 'grpc') {
155
+ else if (((_r = config.accountSubscription) === null || _r === void 0 ? void 0 : _r.type) === 'grpc') {
155
156
  this.userAccountSubscriptionConfig = {
156
157
  type: 'grpc',
157
- resubTimeoutMs: (_r = config.accountSubscription) === null || _r === void 0 ? void 0 : _r.resubTimeoutMs,
158
- logResubMessages: (_s = config.accountSubscription) === null || _s === void 0 ? void 0 : _s.logResubMessages,
159
- grpcConfigs: (_t = config.accountSubscription) === null || _t === void 0 ? void 0 : _t.grpcConfigs,
158
+ resubTimeoutMs: (_s = config.accountSubscription) === null || _s === void 0 ? void 0 : _s.resubTimeoutMs,
159
+ logResubMessages: (_t = config.accountSubscription) === null || _t === void 0 ? void 0 : _t.logResubMessages,
160
+ grpcConfigs: (_u = config.accountSubscription) === null || _u === void 0 ? void 0 : _u.grpcConfigs,
160
161
  };
161
162
  this.userStatsAccountSubscriptionConfig = {
162
163
  type: 'grpc',
163
- grpcConfigs: (_u = config.accountSubscription) === null || _u === void 0 ? void 0 : _u.grpcConfigs,
164
- resubTimeoutMs: (_v = config.accountSubscription) === null || _v === void 0 ? void 0 : _v.resubTimeoutMs,
165
- logResubMessages: (_w = config.accountSubscription) === null || _w === void 0 ? void 0 : _w.logResubMessages,
164
+ grpcConfigs: (_v = config.accountSubscription) === null || _v === void 0 ? void 0 : _v.grpcConfigs,
165
+ resubTimeoutMs: (_w = config.accountSubscription) === null || _w === void 0 ? void 0 : _w.resubTimeoutMs,
166
+ logResubMessages: (_x = config.accountSubscription) === null || _x === void 0 ? void 0 : _x.logResubMessages,
166
167
  };
167
168
  }
168
169
  else {
169
170
  this.userAccountSubscriptionConfig = {
170
171
  type: 'websocket',
171
- resubTimeoutMs: (_x = config.accountSubscription) === null || _x === void 0 ? void 0 : _x.resubTimeoutMs,
172
- logResubMessages: (_y = config.accountSubscription) === null || _y === void 0 ? void 0 : _y.logResubMessages,
173
- commitment: (_z = config.accountSubscription) === null || _z === void 0 ? void 0 : _z.commitment,
172
+ resubTimeoutMs: (_y = config.accountSubscription) === null || _y === void 0 ? void 0 : _y.resubTimeoutMs,
173
+ logResubMessages: (_z = config.accountSubscription) === null || _z === void 0 ? void 0 : _z.logResubMessages,
174
+ commitment: (_0 = config.accountSubscription) === null || _0 === void 0 ? void 0 : _0.commitment,
174
175
  };
175
176
  this.userStatsAccountSubscriptionConfig = {
176
177
  type: 'websocket',
177
- resubTimeoutMs: (_0 = config.accountSubscription) === null || _0 === void 0 ? void 0 : _0.resubTimeoutMs,
178
- logResubMessages: (_1 = config.accountSubscription) === null || _1 === void 0 ? void 0 : _1.logResubMessages,
179
- commitment: (_2 = config.accountSubscription) === null || _2 === void 0 ? void 0 : _2.commitment,
178
+ resubTimeoutMs: (_1 = config.accountSubscription) === null || _1 === void 0 ? void 0 : _1.resubTimeoutMs,
179
+ logResubMessages: (_2 = config.accountSubscription) === null || _2 === void 0 ? void 0 : _2.logResubMessages,
180
+ commitment: (_3 = config.accountSubscription) === null || _3 === void 0 ? void 0 : _3.commitment,
180
181
  };
181
182
  }
182
183
  if (config.userStats) {
@@ -187,27 +188,27 @@ class DriftClient {
187
188
  });
188
189
  }
189
190
  this.marketLookupTable = config.marketLookupTable;
190
- if (config.env && !this.marketLookupTable) {
191
- this.marketLookupTable = new web3_js_1.PublicKey(config_1.configs[config.env].MARKET_LOOKUP_TABLE);
191
+ if (!this.marketLookupTable) {
192
+ this.marketLookupTable = new web3_js_1.PublicKey(config_1.configs[this.env].MARKET_LOOKUP_TABLE);
192
193
  }
193
194
  const delistedMarketSetting = config.delistedMarketSetting || types_2.DelistedMarketSetting.Unsubscribe;
194
195
  const noMarketsAndOraclesSpecified = config.perpMarketIndexes === undefined &&
195
196
  config.spotMarketIndexes === undefined &&
196
197
  config.oracleInfos === undefined;
197
- if (((_3 = config.accountSubscription) === null || _3 === void 0 ? void 0 : _3.type) === 'polling') {
198
- this.accountSubscriber = new pollingDriftClientAccountSubscriber_1.PollingDriftClientAccountSubscriber(this.program, config.accountSubscription.accountLoader, (_4 = config.perpMarketIndexes) !== null && _4 !== void 0 ? _4 : [], (_5 = config.spotMarketIndexes) !== null && _5 !== void 0 ? _5 : [], (_6 = config.oracleInfos) !== null && _6 !== void 0 ? _6 : [], noMarketsAndOraclesSpecified, delistedMarketSetting);
198
+ if (((_4 = config.accountSubscription) === null || _4 === void 0 ? void 0 : _4.type) === 'polling') {
199
+ this.accountSubscriber = new pollingDriftClientAccountSubscriber_1.PollingDriftClientAccountSubscriber(this.program, config.accountSubscription.accountLoader, (_5 = config.perpMarketIndexes) !== null && _5 !== void 0 ? _5 : [], (_6 = config.spotMarketIndexes) !== null && _6 !== void 0 ? _6 : [], (_7 = config.oracleInfos) !== null && _7 !== void 0 ? _7 : [], noMarketsAndOraclesSpecified, delistedMarketSetting);
199
200
  }
200
- else if (((_7 = config.accountSubscription) === null || _7 === void 0 ? void 0 : _7.type) === 'grpc') {
201
- this.accountSubscriber = new grpcDriftClientAccountSubscriber_1.gprcDriftClientAccountSubscriber(config.accountSubscription.grpcConfigs, this.program, (_8 = config.perpMarketIndexes) !== null && _8 !== void 0 ? _8 : [], (_9 = config.spotMarketIndexes) !== null && _9 !== void 0 ? _9 : [], (_10 = config.oracleInfos) !== null && _10 !== void 0 ? _10 : [], noMarketsAndOraclesSpecified, delistedMarketSetting, {
202
- resubTimeoutMs: (_11 = config.accountSubscription) === null || _11 === void 0 ? void 0 : _11.resubTimeoutMs,
203
- logResubMessages: (_12 = config.accountSubscription) === null || _12 === void 0 ? void 0 : _12.logResubMessages,
201
+ else if (((_8 = config.accountSubscription) === null || _8 === void 0 ? void 0 : _8.type) === 'grpc') {
202
+ this.accountSubscriber = new grpcDriftClientAccountSubscriber_1.gprcDriftClientAccountSubscriber(config.accountSubscription.grpcConfigs, this.program, (_9 = config.perpMarketIndexes) !== null && _9 !== void 0 ? _9 : [], (_10 = config.spotMarketIndexes) !== null && _10 !== void 0 ? _10 : [], (_11 = config.oracleInfos) !== null && _11 !== void 0 ? _11 : [], noMarketsAndOraclesSpecified, delistedMarketSetting, {
203
+ resubTimeoutMs: (_12 = config.accountSubscription) === null || _12 === void 0 ? void 0 : _12.resubTimeoutMs,
204
+ logResubMessages: (_13 = config.accountSubscription) === null || _13 === void 0 ? void 0 : _13.logResubMessages,
204
205
  });
205
206
  }
206
207
  else {
207
- this.accountSubscriber = new webSocketDriftClientAccountSubscriber_1.WebSocketDriftClientAccountSubscriber(this.program, (_13 = config.perpMarketIndexes) !== null && _13 !== void 0 ? _13 : [], (_14 = config.spotMarketIndexes) !== null && _14 !== void 0 ? _14 : [], (_15 = config.oracleInfos) !== null && _15 !== void 0 ? _15 : [], noMarketsAndOraclesSpecified, delistedMarketSetting, {
208
- resubTimeoutMs: (_16 = config.accountSubscription) === null || _16 === void 0 ? void 0 : _16.resubTimeoutMs,
209
- logResubMessages: (_17 = config.accountSubscription) === null || _17 === void 0 ? void 0 : _17.logResubMessages,
210
- }, (_18 = config.accountSubscription) === null || _18 === void 0 ? void 0 : _18.commitment);
208
+ this.accountSubscriber = new webSocketDriftClientAccountSubscriber_1.WebSocketDriftClientAccountSubscriber(this.program, (_14 = config.perpMarketIndexes) !== null && _14 !== void 0 ? _14 : [], (_15 = config.spotMarketIndexes) !== null && _15 !== void 0 ? _15 : [], (_16 = config.oracleInfos) !== null && _16 !== void 0 ? _16 : [], noMarketsAndOraclesSpecified, delistedMarketSetting, {
209
+ resubTimeoutMs: (_17 = config.accountSubscription) === null || _17 === void 0 ? void 0 : _17.resubTimeoutMs,
210
+ logResubMessages: (_18 = config.accountSubscription) === null || _18 === void 0 ? void 0 : _18.logResubMessages,
211
+ }, (_19 = config.accountSubscription) === null || _19 === void 0 ? void 0 : _19.commitment);
211
212
  }
212
213
  this.eventEmitter = this.accountSubscriber.eventEmitter;
213
214
  this.metricsEventEmitter = new events_1.EventEmitter();
@@ -215,14 +216,13 @@ class DriftClient {
215
216
  this.enableMetricsEvents = true;
216
217
  }
217
218
  this.txSender =
218
- (_19 = config.txSender) !== null && _19 !== void 0 ? _19 : new retryTxSender_1.RetryTxSender({
219
+ (_20 = config.txSender) !== null && _20 !== void 0 ? _20 : new retryTxSender_1.RetryTxSender({
219
220
  connection: this.connection,
220
221
  wallet: this.wallet,
221
222
  opts: this.opts,
222
223
  txHandler: this.txHandler,
223
224
  });
224
- this.sbOnDemandProgramdId =
225
- config_1.configs[(_20 = config.env) !== null && _20 !== void 0 ? _20 : 'mainnet-beta'].SB_ON_DEMAND_PID;
225
+ this.sbOnDemandProgramdId = config_1.configs[this.env].SB_ON_DEMAND_PID;
226
226
  }
227
227
  getUserMapKey(subAccountId, authority) {
228
228
  return `${subAccountId}_${authority.toString()}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.105.0-beta.0",
3
+ "version": "2.105.0-beta.2",
4
4
  "main": "lib/node/index.js",
5
5
  "types": "lib/node/index.d.ts",
6
6
  "browser": "./lib/browser/index.js",
@@ -402,7 +402,6 @@ export class PollingDriftClientAccountSubscriber
402
402
  this.accountsToPoll.clear();
403
403
  this.oraclesToPoll.clear();
404
404
  this.isSubscribed = false;
405
- this.accountLoader.accountsToLoad = new Map();
406
405
  }
407
406
 
408
407
  async addSpotMarket(marketIndex: number): Promise<boolean> {
@@ -201,6 +201,7 @@ export class DriftClient {
201
201
  wallet: IWallet;
202
202
  public program: Program;
203
203
  provider: AnchorProvider;
204
+ env: DriftEnv;
204
205
  opts?: ConfirmOptions;
205
206
  useHotWalletAdmin?: boolean;
206
207
  users = new Map<string, User>();
@@ -249,6 +250,7 @@ export class DriftClient {
249
250
  public constructor(config: DriftClientConfig) {
250
251
  this.connection = config.connection;
251
252
  this.wallet = config.wallet;
253
+ this.env = config.env ?? 'mainnet-beta';
252
254
  this.opts = config.opts || {
253
255
  ...DEFAULT_CONFIRMATION_OPTS,
254
256
  };
@@ -369,9 +371,9 @@ export class DriftClient {
369
371
  }
370
372
 
371
373
  this.marketLookupTable = config.marketLookupTable;
372
- if (config.env && !this.marketLookupTable) {
374
+ if (!this.marketLookupTable) {
373
375
  this.marketLookupTable = new PublicKey(
374
- configs[config.env].MARKET_LOOKUP_TABLE
376
+ configs[this.env].MARKET_LOOKUP_TABLE
375
377
  );
376
378
  }
377
379
 
@@ -437,8 +439,7 @@ export class DriftClient {
437
439
  txHandler: this.txHandler,
438
440
  });
439
441
 
440
- this.sbOnDemandProgramdId =
441
- configs[config.env ?? 'mainnet-beta'].SB_ON_DEMAND_PID;
442
+ this.sbOnDemandProgramdId = configs[this.env].SB_ON_DEMAND_PID;
442
443
  }
443
444
 
444
445
  public getUserMapKey(subAccountId: number, authority: PublicKey): string {