@drift-labs/sdk 2.48.0-beta.5 → 2.48.0-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.48.0-beta.5
1
+ 2.48.0-beta.7
@@ -1150,7 +1150,7 @@ class DriftClient {
1150
1150
  withdrawIxs.push((0, spl_token_1.createCloseAccountInstruction)(associatedTokenAddress, authority, authority, []));
1151
1151
  }
1152
1152
  const tx = await this.buildTransaction(withdrawIxs, {
1153
- computeUnits: 600000,
1153
+ computeUnits: 1400000,
1154
1154
  });
1155
1155
  const { txSig, slot } = await this.sendTransaction(tx, additionalSigners, this.opts);
1156
1156
  this.spotMarketLastSlotCache.set(marketIndex, slot);
@@ -67,6 +67,7 @@ export declare class UserMap implements UserMapInterface {
67
67
  updateWithEventRecord(record: WrappedEvent<any>): Promise<void>;
68
68
  values(): IterableIterator<User>;
69
69
  size(): number;
70
+ getUniqueAuthorities(useSyncCallbackCriteria?: boolean): PublicKey[];
70
71
  sync(): Promise<void>;
71
72
  unsubscribe(): Promise<void>;
72
73
  }
@@ -148,6 +148,19 @@ class UserMap {
148
148
  size() {
149
149
  return this.userMap.size;
150
150
  }
151
+ getUniqueAuthorities(useSyncCallbackCriteria = true) {
152
+ const usersMeetingCriteria = Array.from(this.userMap.values()).filter((user) => {
153
+ let pass = true;
154
+ if (useSyncCallbackCriteria &&
155
+ this.syncCallbackCriteria.hasOpenOrders) {
156
+ pass = pass && user.getUserAccount().hasOpenOrder;
157
+ }
158
+ return pass;
159
+ });
160
+ const userAuths = new Set(usersMeetingCriteria.map((user) => user.getUserAccount().authority.toBase58()));
161
+ const userAuthKeys = Array.from(userAuths).map((userAuth) => new web3_js_1.PublicKey(userAuth));
162
+ return userAuthKeys;
163
+ }
151
164
  async sync() {
152
165
  if (this.syncPromise) {
153
166
  return this.syncPromise;
@@ -197,16 +210,7 @@ class UserMap {
197
210
  }
198
211
  }
199
212
  if (this.syncCallback) {
200
- const usersMeetingCriteria = Array.from(this.userMap.values()).filter((user) => {
201
- let pass = true;
202
- if (this.syncCallbackCriteria.hasOpenOrders) {
203
- pass = pass && user.getUserAccount().hasOpenOrder;
204
- }
205
- return pass;
206
- });
207
- const userAuths = new Set(usersMeetingCriteria.map((user) => user.getUserAccount().authority.toBase58()));
208
- const userAuthKeys = Array.from(userAuths).map((userAuth) => new web3_js_1.PublicKey(userAuth));
209
- await this.syncCallback(userAuthKeys);
213
+ await this.syncCallback(this.getUniqueAuthorities());
210
214
  }
211
215
  }
212
216
  catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.48.0-beta.5",
3
+ "version": "2.48.0-beta.7",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -2028,7 +2028,7 @@ export class DriftClient {
2028
2028
  }
2029
2029
 
2030
2030
  const tx = await this.buildTransaction(withdrawIxs, {
2031
- computeUnits: 600_000,
2031
+ computeUnits: 1_400_000,
2032
2032
  });
2033
2033
  const { txSig, slot } = await this.sendTransaction(
2034
2034
  tx,
@@ -216,6 +216,30 @@ export class UserMap implements UserMapInterface {
216
216
  return this.userMap.size;
217
217
  }
218
218
 
219
+ public getUniqueAuthorities(useSyncCallbackCriteria = true): PublicKey[] {
220
+ const usersMeetingCriteria = Array.from(this.userMap.values()).filter(
221
+ (user) => {
222
+ let pass = true;
223
+ if (
224
+ useSyncCallbackCriteria &&
225
+ this.syncCallbackCriteria.hasOpenOrders
226
+ ) {
227
+ pass = pass && user.getUserAccount().hasOpenOrder;
228
+ }
229
+ return pass;
230
+ }
231
+ );
232
+ const userAuths = new Set(
233
+ usersMeetingCriteria.map((user) =>
234
+ user.getUserAccount().authority.toBase58()
235
+ )
236
+ );
237
+ const userAuthKeys = Array.from(userAuths).map(
238
+ (userAuth) => new PublicKey(userAuth)
239
+ );
240
+ return userAuthKeys;
241
+ }
242
+
219
243
  public async sync() {
220
244
  if (this.syncPromise) {
221
245
  return this.syncPromise;
@@ -296,24 +320,7 @@ export class UserMap implements UserMapInterface {
296
320
  }
297
321
 
298
322
  if (this.syncCallback) {
299
- const usersMeetingCriteria = Array.from(this.userMap.values()).filter(
300
- (user) => {
301
- let pass = true;
302
- if (this.syncCallbackCriteria.hasOpenOrders) {
303
- pass = pass && user.getUserAccount().hasOpenOrder;
304
- }
305
- return pass;
306
- }
307
- );
308
- const userAuths = new Set(
309
- usersMeetingCriteria.map((user) =>
310
- user.getUserAccount().authority.toBase58()
311
- )
312
- );
313
- const userAuthKeys = Array.from(userAuths).map(
314
- (userAuth) => new PublicKey(userAuth)
315
- );
316
- await this.syncCallback(userAuthKeys);
323
+ await this.syncCallback(this.getUniqueAuthorities());
317
324
  }
318
325
  } catch (e) {
319
326
  console.error(`Error in UserMap.sync()`);