@haven-fi/solauto-sdk 1.0.470 → 1.0.472

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.
@@ -97,7 +97,7 @@ exports.MARGINFI_ACCOUNTS = {
97
97
  bank: "Amtw3n7GZe5SWmyhMhaFhDTi39zbTkLeWErBsmZXwpDa",
98
98
  liquidityVault: "9xfyL8gxbV77VvhdgFmacHyLEG4h7d2eDWkSMfhXUPQ",
99
99
  vaultAuthority: "F4RSGd4BRXscCqAVG3rFLiPVpo7v6j1drVqnvSM3rBKH",
100
- priceOracle: "B1wxT1VK3i6DqCeXNdTHT5hBAJkLa3rxuTqBc7E7XRXV",
100
+ priceOracle: "2TTGSRSezqFzeLUH8JwRUbtN66XLLaymfYsWRTMjfiMw",
101
101
  },
102
102
  [tokens.WBTC]: {
103
103
  bank: "BKsfDJCMbYep6gr9pq8PsmJbb5XGLHbAJzUV8vmorz7a",
@@ -61,7 +61,7 @@ export declare class TransactionsManager {
61
61
  send(items: TransactionItem[]): Promise<TransactionManagerStatuses>;
62
62
  private processTransactionsAtomically;
63
63
  private processTransactionSet;
64
- private refreshItemSet;
64
+ private refreshItemSets;
65
65
  private sendTransaction;
66
66
  }
67
67
  export {};
@@ -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;AAMzD,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;AAW7D,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAK5B;AAqCD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AAkB,SAAmB;gBAG3B,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,UAAU,GAAE,OAAe,EAC3B,aAAa,CAAC,EAAE,aAAa,YAAA,EACrC,WAAW,CAAC,EAAE,WAAW;YAab,uBAAuB;IAwCrC,OAAO,CAAC,YAAY;YA6CN,aAAa;IAoB3B,OAAO,CAAC,4BAA4B;IAgBpC,OAAO,CAAC,mBAAmB;YAoBb,SAAS;IAiBV,UAAU,CACrB,YAAY,EAAE,eAAe,EAAE,GAC9B,OAAO,CAAC,0BAA0B,CAAC;IA+FzB,IAAI,CACf,KAAK,EAAE,eAAe,EAAE,GACvB,OAAO,CAAC,0BAA0B,CAAC;YA4BxB,6BAA6B;YAsI7B,qBAAqB;YAoDrB,eAAe;YAwDf,eAAe;CA4D9B"}
@@ -150,7 +150,7 @@ class TransactionsManager {
150
150
  this.atomically = atomically;
151
151
  this.errorsToThrow = errorsToThrow;
152
152
  this.statuses = [];
153
- this.updateOracleTxName = "Update oracle";
153
+ this.updateOracleTxName = "update oracle";
154
154
  this.lookupTables = new LookupTables(this.txHandler.defaultLookupTables(), this.txHandler.umi);
155
155
  this.signableRetries =
156
156
  retryConfig?.signableRetries ?? retryConfig?.totalRetries ?? 3;
@@ -346,10 +346,13 @@ class TransactionsManager {
346
346
  }
347
347
  num = attemptNum;
348
348
  if (attemptNum > 0) {
349
- for (let i = 0; i < itemSets.length; i++) {
350
- await itemSets[i].refetchAll(attemptNum);
349
+ const refreshedSets = await this.refreshItemSets(itemSets, attemptNum);
350
+ if (!refreshedSets || !refreshedSets.length) {
351
+ return;
352
+ }
353
+ else {
354
+ itemSets = refreshedSets;
351
355
  }
352
- itemSets = await this.assembleTransactionSets(itemSets.flatMap((x) => x.items));
353
356
  }
354
357
  transactions = [];
355
358
  for (const set of itemSets) {
@@ -402,7 +405,8 @@ class TransactionsManager {
402
405
  }
403
406
  num = attemptNum;
404
407
  if (currentIndex > 0 || attemptNum > 0) {
405
- itemSet = await this.refreshItemSet(itemSets, currentIndex, attemptNum);
408
+ const refreshedSets = await this.refreshItemSets(itemSets, attemptNum, currentIndex);
409
+ itemSet = refreshedSets ? refreshedSets[0] : undefined;
406
410
  }
407
411
  if (!itemSet)
408
412
  return;
@@ -416,18 +420,29 @@ class TransactionsManager {
416
420
  }
417
421
  }, this.totalRetries, this.retryDelay, this.errorsToThrow);
418
422
  }
419
- async refreshItemSet(itemSets, currentIndex, attemptNum) {
420
- const itemSet = itemSets[currentIndex];
421
- await itemSet.refetchAll(attemptNum);
422
- const newItemSets = await this.assembleTransactionSets([
423
- ...itemSet.items,
424
- ...itemSets.slice(currentIndex + 1).flatMap((set) => set.items),
425
- ]);
426
- const newItemSetNames = newItemSets.map(x => x.name());
427
- if (newItemSetNames.length === 1 && newItemSetNames[0] === this.updateOracleTxName) {
423
+ async refreshItemSets(itemSets, attemptNum, currentIndex) {
424
+ if (currentIndex !== undefined) {
425
+ const itemSet = itemSets[currentIndex];
426
+ await itemSet.refetchAll(attemptNum);
427
+ }
428
+ else {
429
+ for (const itemSet of itemSets) {
430
+ await itemSet.refetchAll(attemptNum);
431
+ }
432
+ }
433
+ const newItemSets = await this.assembleTransactionSets(currentIndex !== undefined
434
+ ? [
435
+ ...itemSets[currentIndex].items,
436
+ ...itemSets.slice(currentIndex + 1).flatMap((set) => set.items),
437
+ ]
438
+ : itemSets.flatMap((set) => set.items));
439
+ const newItemSetNames = newItemSets.map((x) => x.name());
440
+ if (newItemSetNames.length === 1 &&
441
+ newItemSetNames[0] === this.updateOracleTxName) {
442
+ (0, generalUtils_1.consoleLog)("Skipping unnecessary oracle update");
428
443
  return undefined;
429
444
  }
430
- if (newItemSets.length > 1) {
445
+ if (currentIndex !== undefined && newItemSets.length > 1) {
431
446
  itemSets.splice(currentIndex, itemSets.length - currentIndex, ...newItemSets);
432
447
  const startOfQueuedStatuses = this.statuses.findIndex((x) => x.status === TransactionStatus.Queued);
433
448
  this.statuses.splice(startOfQueuedStatuses, this.statuses.length - startOfQueuedStatuses, ...newItemSets.map((x, i) => ({
@@ -436,7 +451,7 @@ class TransactionsManager {
436
451
  status: i === 0 ? TransactionStatus.Processing : TransactionStatus.Queued,
437
452
  })));
438
453
  }
439
- return newItemSets[0];
454
+ return newItemSets;
440
455
  }
441
456
  async sendTransaction(tx, txName, attemptNum, priorityFeeSetting, txType) {
442
457
  this.updateStatus(txName, TransactionStatus.Processing, attemptNum);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.470",
3
+ "version": "1.0.472",
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",
@@ -79,7 +79,7 @@ export const MARGINFI_ACCOUNTS: {
79
79
  bank: "Amtw3n7GZe5SWmyhMhaFhDTi39zbTkLeWErBsmZXwpDa",
80
80
  liquidityVault: "9xfyL8gxbV77VvhdgFmacHyLEG4h7d2eDWkSMfhXUPQ",
81
81
  vaultAuthority: "F4RSGd4BRXscCqAVG3rFLiPVpo7v6j1drVqnvSM3rBKH",
82
- priceOracle: "B1wxT1VK3i6DqCeXNdTHT5hBAJkLa3rxuTqBc7E7XRXV",
82
+ priceOracle: "2TTGSRSezqFzeLUH8JwRUbtN66XLLaymfYsWRTMjfiMw",
83
83
  },
84
84
  [tokens.WBTC]: {
85
85
  bank: "BKsfDJCMbYep6gr9pq8PsmJbb5XGLHbAJzUV8vmorz7a",
@@ -12,6 +12,7 @@ import {
12
12
  sendSingleOptimizedTransaction,
13
13
  } from "../utils/solanaUtils";
14
14
  import {
15
+ consoleLog,
15
16
  ErrorsToThrow,
16
17
  retryWithExponentialBackoff,
17
18
  } from "../utils/generalUtils";
@@ -231,7 +232,7 @@ export class TransactionsManager {
231
232
  private totalRetries: number;
232
233
  private retryDelay: number;
233
234
 
234
- updateOracleTxName = "Update oracle";
235
+ updateOracleTxName = "update oracle";
235
236
 
236
237
  constructor(
237
238
  private txHandler: SolautoClient | ReferralStateManager,
@@ -555,12 +556,15 @@ export class TransactionsManager {
555
556
  num = attemptNum;
556
557
 
557
558
  if (attemptNum > 0) {
558
- for (let i = 0; i < itemSets.length; i++) {
559
- await itemSets[i].refetchAll(attemptNum);
560
- }
561
- itemSets = await this.assembleTransactionSets(
562
- itemSets.flatMap((x) => x.items)
559
+ const refreshedSets = await this.refreshItemSets(
560
+ itemSets,
561
+ attemptNum
563
562
  );
563
+ if (!refreshedSets || !refreshedSets.length) {
564
+ return;
565
+ } else {
566
+ itemSets = refreshedSets;
567
+ }
564
568
  }
565
569
 
566
570
  transactions = [];
@@ -689,11 +693,12 @@ export class TransactionsManager {
689
693
  num = attemptNum;
690
694
 
691
695
  if (currentIndex > 0 || attemptNum > 0) {
692
- itemSet = await this.refreshItemSet(
696
+ const refreshedSets = await this.refreshItemSets(
693
697
  itemSets,
694
- currentIndex,
695
- attemptNum
698
+ attemptNum,
699
+ currentIndex
696
700
  );
701
+ itemSet = refreshedSets ? refreshedSets[0] : undefined;
697
702
  }
698
703
  if (!itemSet) return;
699
704
 
@@ -720,25 +725,39 @@ export class TransactionsManager {
720
725
  );
721
726
  }
722
727
 
723
- private async refreshItemSet(
728
+ private async refreshItemSets(
724
729
  itemSets: TransactionSet[],
725
- currentIndex: number,
726
- attemptNum: number
727
- ): Promise<TransactionSet | undefined> {
728
- const itemSet = itemSets[currentIndex];
729
- await itemSet.refetchAll(attemptNum);
730
+ attemptNum: number,
731
+ currentIndex?: number
732
+ ): Promise<TransactionSet[] | undefined> {
733
+ if (currentIndex !== undefined) {
734
+ const itemSet = itemSets[currentIndex];
735
+ await itemSet.refetchAll(attemptNum);
736
+ } else {
737
+ for (const itemSet of itemSets) {
738
+ await itemSet.refetchAll(attemptNum);
739
+ }
740
+ }
730
741
 
731
- const newItemSets = await this.assembleTransactionSets([
732
- ...itemSet.items,
733
- ...itemSets.slice(currentIndex + 1).flatMap((set) => set.items),
734
- ]);
742
+ const newItemSets = await this.assembleTransactionSets(
743
+ currentIndex !== undefined
744
+ ? [
745
+ ...itemSets[currentIndex].items,
746
+ ...itemSets.slice(currentIndex + 1).flatMap((set) => set.items),
747
+ ]
748
+ : itemSets.flatMap((set) => set.items)
749
+ );
735
750
 
736
- const newItemSetNames = newItemSets.map(x => x.name());
737
- if (newItemSetNames.length === 1 && newItemSetNames[0] === this.updateOracleTxName) {
751
+ const newItemSetNames = newItemSets.map((x) => x.name());
752
+ if (
753
+ newItemSetNames.length === 1 &&
754
+ newItemSetNames[0] === this.updateOracleTxName
755
+ ) {
756
+ consoleLog("Skipping unnecessary oracle update");
738
757
  return undefined;
739
758
  }
740
759
 
741
- if (newItemSets.length > 1) {
760
+ if (currentIndex !== undefined && newItemSets.length > 1) {
742
761
  itemSets.splice(
743
762
  currentIndex,
744
763
  itemSets.length - currentIndex,
@@ -759,7 +778,7 @@ export class TransactionsManager {
759
778
  );
760
779
  }
761
780
 
762
- return newItemSets[0];
781
+ return newItemSets;
763
782
  }
764
783
 
765
784
  private async sendTransaction(