@haven-fi/solauto-sdk 1.0.244 → 1.0.246

Sign up to get free protection for your applications and to get access to all the features.
@@ -42,8 +42,9 @@ export declare abstract class SolautoClient extends ReferralStateManager {
42
42
  lutAccountsToAdd(): PublicKey[];
43
43
  fetchExistingAuthorityLutAccounts(): Promise<PublicKey[]>;
44
44
  updateLookupTable(): Promise<{
45
- updateLutTx: TransactionBuilder;
46
- needsToBeIsolated: boolean;
45
+ tx: TransactionBuilder;
46
+ new: boolean;
47
+ accountsToAdd: PublicKey[];
47
48
  } | undefined>;
48
49
  solautoPositionSettings(): SolautoSettingsParameters | undefined;
49
50
  solautoPositionActiveDca(): DCASettings | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"solautoClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoClient.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAA6B,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EACL,MAAM,EACN,kBAAkB,EAMnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC,EAEhC,sBAAsB,EAKvB,MAAM,cAAc,CAAC;AAUtB,OAAO,EACL,gBAAgB,EAChB,eAAe,EAChB,MAAM,iCAAiC,CAAC;AAMzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,WAAW,iBAAkB,SAAQ,wBAAwB;IACjE,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACt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C,EAAE,MAAM,GACnC,kBAAkB;IAEf,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAalE"}
@@ -145,18 +145,21 @@ class SolautoClient extends referralStateManager_1.ReferralStateManager {
145
145
  const accountsToAdd = this.lutAccountsToAdd().filter((x) => !existingLutAccounts
146
146
  .map((x) => x.toString().toLowerCase())
147
147
  .includes(x.toString().toLowerCase()));
148
- if (accountsToAdd.length > 0) {
149
- tx = tx.add((0, solanaUtils_1.getWrappedInstruction)(this.signer, web3_js_1.AddressLookupTableProgram.extendLookupTable({
150
- payer: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey),
151
- authority: this.authority,
152
- lookupTable: this.authorityLutAddress,
153
- addresses: accountsToAdd,
154
- })));
155
- }
156
- if (tx.getInstructions().length > 0) {
157
- this.log("Updating authority lookup table...");
148
+ if (accountsToAdd.length === 0) {
149
+ return undefined;
158
150
  }
159
- return { updateLutTx: tx, needsToBeIsolated: true };
151
+ tx = tx.add((0, solanaUtils_1.getWrappedInstruction)(this.signer, web3_js_1.AddressLookupTableProgram.extendLookupTable({
152
+ payer: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey),
153
+ authority: this.authority,
154
+ lookupTable: this.authorityLutAddress,
155
+ addresses: accountsToAdd,
156
+ })));
157
+ this.log("Requires authority LUT update...");
158
+ return {
159
+ tx,
160
+ new: existingLutAccounts.length === 0,
161
+ accountsToAdd,
162
+ };
160
163
  }
161
164
  solautoPositionSettings() {
162
165
  return (this.livePositionUpdates.settings ??
@@ -11,6 +11,7 @@ export declare class TransactionItem {
11
11
  name?: string | undefined;
12
12
  lookupTableAddresses: string[];
13
13
  tx?: TransactionBuilder;
14
+ initialized: boolean;
14
15
  constructor(fetchTx: (attemptNum: number) => Promise<TransactionItemInputs | undefined>, name?: string | undefined);
15
16
  initialize(): Promise<void>;
16
17
  refetch(attemptNum: number): Promise<void>;
@@ -47,8 +48,9 @@ export declare class TransactionsManager {
47
48
  private debugAccounts;
48
49
  private getUpdatedPriorityFeeSetting;
49
50
  private updateStatusForSets;
51
+ private updateLut;
50
52
  clientSend(transactions: TransactionItem[]): Promise<TransactionManagerStatuses>;
51
- send(items: TransactionItem[], initialized?: boolean): Promise<TransactionManagerStatuses>;
53
+ send(items: TransactionItem[]): Promise<TransactionManagerStatuses>;
52
54
  private processTransactionSet;
53
55
  private refreshItemSet;
54
56
  private sendTransaction;
@@ -1 +1 @@
1
- {"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAKzD,OAAO,EACL,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,kBAAkB,EAElB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,oBAAoB,EAAa,MAAM,YAAY,CAAC;AAI7D,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAK5B;AAqCD,qBAAa,eAAe;IAKjB,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IACxC,IAAI,CAAC,EAAE,MAAM;IAPtB,oBAAoB,EAAG,MAAM,EAAE,CAAC;IAChC,EAAE,CAAC,EAAE,kBAAkB,CAAC;gBAGf,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,EACxC,IAAI,CAAC,EAAE,MAAM,YAAA;IAGhB,UAAU;IAIV,OAAO,CAAC,UAAU,EAAE,MAAM;IAMhC,cAAc,IAAI,MAAM,EAAE;CAY3B;AAgFD,oBAAY,iBAAiB;IAC3B,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB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mBAAmB;IAK5B,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,cAAc,CAAC;IACvB,OAAO,CAAC,MAAM,CAAC;IACf,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,aAAa,CAAC;IACtB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,UAAU;IAVpB,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,YAAY,CAAe;gBAGzB,SAAS,EAAE,aAAa,GAAG,oBAAoB,EAC/C,cAAc,CAAC,GAAE,CAAC,QAAQ,EAAE,0BAA0B,KAAK,IAAI,aAAA,EAC/D,MAAM,CAAC,EAAE,kBAAkB,YAAA,EAC3B,kBAAkB,GAAE,kBAA2C,EAC/D,aAAa,CAAC,EAAE,aAAa,YAAA,EAC7B,OAAO,GAAE,MAAU,EACnB,UAAU,GAAE,MAAY;YAQpB,uBAAuB;IAwCrC,OAAO,CAAC,YAAY;YA8CN,aAAa;IAoB3B,OAAO,CAAC,4BAA4B;IAUpC,OAAO,CAAC,mBAAmB;YAMb,SAAS;IAgBV,UAAU,CACrB,YAAY,EAAE,eAAe,EAAE,GAC9B,OAAO,CAAC,0BAA0B,CAAC;IAgFzB,IAAI,CACf,KAAK,EAAE,eAAe,EAAE,GACvB,OAAO,CAAC,0BAA0B,CAAC;YA6BxB,qBAAqB;YAiDrB,cAAc;YAyBd,eAAe;CAkD9B"}
@@ -11,6 +11,7 @@ const generalUtils_1 = require("../utils/generalUtils");
11
11
  const transactionUtils_1 = require("./transactionUtils");
12
12
  const types_1 = require("../types");
13
13
  const web3_js_1 = require("@solana/web3.js");
14
+ const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
14
15
  // import { sendJitoBundledTransactions } from "../utils/jitoUtils";
15
16
  class TransactionTooLargeError extends Error {
16
17
  constructor(message) {
@@ -44,9 +45,11 @@ class TransactionItem {
44
45
  constructor(fetchTx, name) {
45
46
  this.fetchTx = fetchTx;
46
47
  this.name = name;
48
+ this.initialized = false;
47
49
  }
48
50
  async initialize() {
49
51
  await this.refetch(0);
52
+ this.initialized = true;
50
53
  }
51
54
  async refetch(attemptNum) {
52
55
  const resp = await this.fetchTx(attemptNum);
@@ -236,25 +239,45 @@ class TransactionsManager {
236
239
  this.updateStatus(itemSet.name(), TransactionStatus.Queued, 0);
237
240
  });
238
241
  }
242
+ async updateLut(tx) {
243
+ const updateLutTxName = "create lookup table";
244
+ await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum, prevError) => await this.sendTransaction(tx, updateLutTxName, attemptNum, this.getUpdatedPriorityFeeSetting(prevError)), 3, 150, this.errorsToThrow);
245
+ }
239
246
  async clientSend(transactions) {
240
247
  const items = [...transactions];
241
248
  const client = this.txHandler;
242
249
  const updateLookupTable = await client.updateLookupTable();
243
- const updateLutTxName = "create lookup table";
244
- if (updateLookupTable &&
245
- updateLookupTable.updateLutTx.getInstructions().length > 0 &&
246
- updateLookupTable?.needsToBeIsolated) {
247
- await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum, prevError) => await this.sendTransaction(updateLookupTable.updateLutTx, updateLutTxName, attemptNum, this.getUpdatedPriorityFeeSetting(prevError)), 3, 150, this.errorsToThrow);
250
+ let isolatedLutTx = updateLookupTable?.new;
251
+ if (updateLookupTable && !isolatedLutTx) {
252
+ for (const item of items) {
253
+ await item.initialize();
254
+ }
255
+ const txAccounts = items.flatMap((x) => x.tx.getInstructions().flatMap((x) => x.keys.map((x) => x.pubkey)));
256
+ console.log(Array.from(new Set(txAccounts)).map(x => x.toString()));
257
+ const newAccountsUsage = Array.from(new Set(txAccounts)).reduce((count, pk) => {
258
+ return updateLookupTable.accountsToAdd.find((x) => x.equals((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(pk)))
259
+ ? count + 1
260
+ : count;
261
+ }, 0);
262
+ console.log(updateLookupTable.accountsToAdd.map(x => x.toString()));
263
+ isolatedLutTx = newAccountsUsage > 1;
264
+ console.log(newAccountsUsage);
265
+ }
266
+ console.log(isolatedLutTx);
267
+ if (updateLookupTable && isolatedLutTx) {
268
+ await this.updateLut(updateLookupTable.tx);
248
269
  }
249
270
  this.lookupTables.defaultLuts = client.defaultLookupTables();
250
- for (const item of items) {
251
- await item.initialize();
271
+ if (!items[0].initialized || (updateLookupTable && isolatedLutTx)) {
272
+ for (const item of items) {
273
+ await item.initialize();
274
+ }
252
275
  }
253
276
  const [choresBefore, choresAfter] = await (0, transactionUtils_1.getTransactionChores)(client, (0, umi_1.transactionBuilder)().add(items
254
277
  .filter((x) => x.tx && x.tx.getInstructions().length > 0)
255
278
  .map((x) => x.tx)));
256
- if (updateLookupTable && !updateLookupTable.needsToBeIsolated) {
257
- choresBefore.prepend(updateLookupTable.updateLutTx);
279
+ if (updateLookupTable && !isolatedLutTx) {
280
+ choresBefore.prepend(updateLookupTable.tx);
258
281
  }
259
282
  if (choresBefore.getInstructions().length > 0) {
260
283
  const chore = new TransactionItem(async () => ({ tx: choresBefore }));
@@ -268,7 +291,7 @@ class TransactionsManager {
268
291
  items.push(chore);
269
292
  this.txHandler.log("Chores after: ", choresAfter.getInstructions().length);
270
293
  }
271
- const result = await this.send(items, true).catch((e) => {
294
+ const result = await this.send(items).catch((e) => {
272
295
  client.resetLiveTxUpdates(false);
273
296
  throw e;
274
297
  });
@@ -277,10 +300,10 @@ class TransactionsManager {
277
300
  }
278
301
  return result;
279
302
  }
280
- async send(items, initialized) {
303
+ async send(items) {
281
304
  this.statuses = [];
282
305
  this.lookupTables.reset();
283
- if (!initialized) {
306
+ if (!items[0].initialized) {
284
307
  for (const item of items) {
285
308
  await item.initialize();
286
309
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.244",
3
+ "version": "1.0.246",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "Typescript SDK for the Solauto program on the Solana blockchain",
@@ -247,7 +247,12 @@ export abstract class SolautoClient extends ReferralStateManager {
247
247
  }
248
248
 
249
249
  async updateLookupTable(): Promise<
250
- { updateLutTx: TransactionBuilder; needsToBeIsolated: boolean } | undefined
250
+ | {
251
+ tx: TransactionBuilder;
252
+ new: boolean;
253
+ accountsToAdd: PublicKey[];
254
+ }
255
+ | undefined
251
256
  > {
252
257
  const existingLutAccounts = await this.fetchExistingAuthorityLutAccounts();
253
258
  if (
@@ -279,25 +284,28 @@ export abstract class SolautoClient extends ReferralStateManager {
279
284
  .map((x) => x.toString().toLowerCase())
280
285
  .includes(x.toString().toLowerCase())
281
286
  );
282
- if (accountsToAdd.length > 0) {
283
- tx = tx.add(
284
- getWrappedInstruction(
285
- this.signer,
286
- AddressLookupTableProgram.extendLookupTable({
287
- payer: toWeb3JsPublicKey(this.signer.publicKey),
288
- authority: this.authority,
289
- lookupTable: this.authorityLutAddress,
290
- addresses: accountsToAdd,
291
- })
292
- )
293
- );
287
+ if (accountsToAdd.length === 0) {
288
+ return undefined;
294
289
  }
295
290
 
296
- if (tx.getInstructions().length > 0) {
297
- this.log("Updating authority lookup table...");
298
- }
291
+ tx = tx.add(
292
+ getWrappedInstruction(
293
+ this.signer,
294
+ AddressLookupTableProgram.extendLookupTable({
295
+ payer: toWeb3JsPublicKey(this.signer.publicKey),
296
+ authority: this.authority,
297
+ lookupTable: this.authorityLutAddress,
298
+ addresses: accountsToAdd,
299
+ })
300
+ )
301
+ );
299
302
 
300
- return { updateLutTx: tx, needsToBeIsolated: true };
303
+ this.log("Requires authority LUT update...");
304
+ return {
305
+ tx,
306
+ new: existingLutAccounts.length === 0,
307
+ accountsToAdd,
308
+ };
301
309
  }
302
310
 
303
311
  solautoPositionSettings(): SolautoSettingsParameters | undefined {
@@ -23,6 +23,7 @@ import {
23
23
  } from "../types";
24
24
  import { ReferralStateManager, TxHandler } from "../clients";
25
25
  import { TransactionExpiredBlockheightExceededError } from "@solana/web3.js";
26
+ import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
26
27
  // import { sendJitoBundledTransactions } from "../utils/jitoUtils";
27
28
 
28
29
  export class TransactionTooLargeError extends Error {
@@ -71,6 +72,7 @@ class LookupTables {
71
72
  export class TransactionItem {
72
73
  lookupTableAddresses!: string[];
73
74
  tx?: TransactionBuilder;
75
+ public initialized: boolean = false;
74
76
 
75
77
  constructor(
76
78
  public fetchTx: (
@@ -81,6 +83,7 @@ export class TransactionItem {
81
83
 
82
84
  async initialize() {
83
85
  await this.refetch(0);
86
+ this.initialized = true;
84
87
  }
85
88
 
86
89
  async refetch(attemptNum: number) {
@@ -339,6 +342,22 @@ export class TransactionsManager {
339
342
  });
340
343
  }
341
344
 
345
+ private async updateLut(tx: TransactionBuilder) {
346
+ const updateLutTxName = "create lookup table";
347
+ await retryWithExponentialBackoff(
348
+ async (attemptNum, prevError) =>
349
+ await this.sendTransaction(
350
+ tx,
351
+ updateLutTxName,
352
+ attemptNum,
353
+ this.getUpdatedPriorityFeeSetting(prevError)
354
+ ),
355
+ 3,
356
+ 150,
357
+ this.errorsToThrow
358
+ );
359
+ }
360
+
342
361
  public async clientSend(
343
362
  transactions: TransactionItem[]
344
363
  ): Promise<TransactionManagerStatuses> {
@@ -346,30 +365,37 @@ export class TransactionsManager {
346
365
  const client = this.txHandler as SolautoClient;
347
366
 
348
367
  const updateLookupTable = await client.updateLookupTable();
349
- const updateLutTxName = "create lookup table";
350
- if (
351
- updateLookupTable &&
352
- updateLookupTable.updateLutTx.getInstructions().length > 0 &&
353
- updateLookupTable?.needsToBeIsolated
354
- ) {
355
- await retryWithExponentialBackoff(
356
- async (attemptNum, prevError) =>
357
- await this.sendTransaction(
358
- updateLookupTable.updateLutTx,
359
- updateLutTxName,
360
- attemptNum,
361
- this.getUpdatedPriorityFeeSetting(prevError)
362
- ),
363
- 3,
364
- 150,
365
- this.errorsToThrow
368
+
369
+ let isolatedLutTx = updateLookupTable?.new;
370
+ if (updateLookupTable && !isolatedLutTx) {
371
+ for (const item of items) {
372
+ await item.initialize();
373
+ }
374
+ const txAccounts = items.flatMap((x) =>
375
+ x.tx!.getInstructions().flatMap((x) => x.keys.map((x) => x.pubkey))
366
376
  );
377
+ console.log(Array.from(new Set(txAccounts)).map(x => x.toString()));
378
+ const newAccountsUsage = Array.from(new Set(txAccounts)).reduce((count, pk) => {
379
+ return updateLookupTable.accountsToAdd.find((x) =>
380
+ x.equals(toWeb3JsPublicKey(pk))
381
+ )
382
+ ? count + 1
383
+ : count;
384
+ }, 0);
385
+ console.log(updateLookupTable.accountsToAdd.map(x => x.toString()));
386
+ isolatedLutTx = newAccountsUsage > 1;
387
+ console.log(newAccountsUsage);
388
+ }
389
+ console.log(isolatedLutTx);
390
+ if (updateLookupTable && isolatedLutTx) {
391
+ await this.updateLut(updateLookupTable.tx);
367
392
  }
368
-
369
393
  this.lookupTables.defaultLuts = client.defaultLookupTables();
370
394
 
371
- for (const item of items) {
372
- await item.initialize();
395
+ if (!items[0].initialized || (updateLookupTable && isolatedLutTx)) {
396
+ for (const item of items) {
397
+ await item.initialize();
398
+ }
373
399
  }
374
400
 
375
401
  const [choresBefore, choresAfter] = await getTransactionChores(
@@ -380,8 +406,8 @@ export class TransactionsManager {
380
406
  .map((x) => x.tx!)
381
407
  )
382
408
  );
383
- if (updateLookupTable && !updateLookupTable.needsToBeIsolated) {
384
- choresBefore.prepend(updateLookupTable.updateLutTx);
409
+ if (updateLookupTable && !isolatedLutTx) {
410
+ choresBefore.prepend(updateLookupTable.tx);
385
411
  }
386
412
  if (choresBefore.getInstructions().length > 0) {
387
413
  const chore = new TransactionItem(async () => ({ tx: choresBefore }));
@@ -402,7 +428,7 @@ export class TransactionsManager {
402
428
  );
403
429
  }
404
430
 
405
- const result = await this.send(items, true).catch((e) => {
431
+ const result = await this.send(items).catch((e) => {
406
432
  client.resetLiveTxUpdates(false);
407
433
  throw e;
408
434
  });
@@ -415,13 +441,12 @@ export class TransactionsManager {
415
441
  }
416
442
 
417
443
  public async send(
418
- items: TransactionItem[],
419
- initialized?: boolean
444
+ items: TransactionItem[]
420
445
  ): Promise<TransactionManagerStatuses> {
421
446
  this.statuses = [];
422
447
  this.lookupTables.reset();
423
448
 
424
- if (!initialized) {
449
+ if (!items[0].initialized) {
425
450
  for (const item of items) {
426
451
  await item.initialize();
427
452
  }