@haven-fi/solauto-sdk 1.0.478 → 1.0.480

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.
@@ -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,EAEL,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,qBAAa,eAAe;IAMjB,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IACxC,IAAI,CAAC,EAAE,MAAM;IARtB,oBAAoB,EAAG,MAAM,EAAE,CAAC;IAChC,EAAE,CAAC,EAAE,kBAAkB,CAAC;IACjB,WAAW,EAAE,OAAO,CAAS;gBAG3B,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,EACxC,IAAI,CAAC,EAAE,MAAM,YAAA;IAGhB,UAAU;IAKV,OAAO,CAAC,UAAU,EAAE,MAAM;IAMhC,cAAc,IAAI,MAAM,EAAE;CAY3B;AA0FD,oBAAY,iBAAiB;IAC3B,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,UAAU,eAAe;IACzB,MAAM,WAAW;CAClB;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;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AsI7B,qBAAqB;YAoDrB,eAAe;YAwDf,eAAe;CA4D9B"}
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,EAEL,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,qBAAa,eAAe;IAMjB,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IACxC,IAAI,CAAC,EAAE,MAAM;IARtB,oBAAoB,EAAG,MAAM,EAAE,CAAC;IAChC,EAAE,CAAC,EAAE,kBAAkB,CAAC;IACjB,WAAW,EAAE,OAAO,CAAS;gBAG3B,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,EACxC,IAAI,CAAC,EAAE,MAAM,YAAA;IAGhB,UAAU;IAKV,OAAO,CAAC,UAAU,EAAE,MAAM;IAMhC,cAAc,IAAI,MAAM,EAAE;CAY3B;AA0FD,oBAAY,iBAAiB;IAC3B,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,UAAU,eAAe;IACzB,MAAM,WAAW;CAClB;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,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actionsManager {
314
314
  async send(items) {
315
315
  this.statuses = [];
316
316
  this.lookupTables.reset();
317
- if (!items[0].initialized) {
318
- for (const item of items) {
319
- await item.initialize();
317
+ const itemSets = await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum) => {
318
+ if (!items[0].initialized) {
319
+ for (const item of items) {
320
+ await item.initialize();
321
+ }
320
322
  }
321
- }
322
- this.txHandler.log("Transaction items:", items.length);
323
- const itemSets = await this.assembleTransactionSets(items);
323
+ else if (attemptNum > 0) {
324
+ for (const item of items) {
325
+ await item.refetch(0);
326
+ }
327
+ }
328
+ this.txHandler.log("Transaction items:", items.length);
329
+ return await this.assembleTransactionSets(items);
330
+ }, 2);
324
331
  this.updateStatusForSets(itemSets, TransactionStatus.Queued, 0);
325
332
  this.txHandler.log("Initial item sets:", itemSets.length);
326
333
  if (this.atomically) {
@@ -421,21 +428,23 @@ class TransactionsManager {
421
428
  }, this.totalRetries, this.retryDelay, this.errorsToThrow);
422
429
  }
423
430
  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) {
431
+ const newItemSets = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => {
432
+ if (currentIndex !== undefined) {
433
+ const itemSet = itemSets[currentIndex];
430
434
  await itemSet.refetchAll(attemptNum);
431
435
  }
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));
436
+ else {
437
+ for (const itemSet of itemSets) {
438
+ await itemSet.refetchAll(attemptNum);
439
+ }
440
+ }
441
+ return await this.assembleTransactionSets(currentIndex !== undefined
442
+ ? [
443
+ ...itemSets[currentIndex].items,
444
+ ...itemSets.slice(currentIndex + 1).flatMap((set) => set.items),
445
+ ]
446
+ : itemSets.flatMap((set) => set.items));
447
+ }, 2);
439
448
  const newItemSetNames = newItemSets.map((x) => x.name());
440
449
  if (newItemSetNames.length === 1 &&
441
450
  newItemSetNames[0] === this.updateOracleTxName) {
@@ -193,7 +193,7 @@ function getJupSwapRebalanceDetails(client, values, targetLiqUtilizationRateBps,
193
193
  const { requiresFlashLoan, useDebtLiquidity } = rebalanceRequiresFlashLoan(client, values);
194
194
  const flashLoanRepayFromDebt = repaying && requiresFlashLoan && useDebtLiquidity;
195
195
  const exactOut = targetLiqUtilizationRateBps === 0 ||
196
- values.repayingCloseToMaxLtv ||
196
+ // values.repayingCloseToMaxLtv ||
197
197
  flashLoanRepayFromDebt;
198
198
  const exactIn = !exactOut;
199
199
  const addPadding = exactOut;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.478",
3
+ "version": "1.0.480",
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",
@@ -515,14 +515,20 @@ export class TransactionsManager {
515
515
  this.statuses = [];
516
516
  this.lookupTables.reset();
517
517
 
518
- if (!items[0].initialized) {
519
- for (const item of items) {
520
- await item.initialize();
518
+ const itemSets = await retryWithExponentialBackoff(async (attemptNum) => {
519
+ if (!items[0].initialized) {
520
+ for (const item of items) {
521
+ await item.initialize();
522
+ }
523
+ } else if (attemptNum > 0) {
524
+ for (const item of items) {
525
+ await item.refetch(0);
526
+ }
521
527
  }
522
- }
528
+ this.txHandler.log("Transaction items:", items.length);
529
+ return await this.assembleTransactionSets(items);
530
+ }, 2);
523
531
 
524
- this.txHandler.log("Transaction items:", items.length);
525
- const itemSets = await this.assembleTransactionSets(items);
526
532
  this.updateStatusForSets(itemSets, TransactionStatus.Queued, 0);
527
533
  this.txHandler.log("Initial item sets:", itemSets.length);
528
534
 
@@ -730,23 +736,25 @@ export class TransactionsManager {
730
736
  attemptNum: number,
731
737
  currentIndex?: number
732
738
  ): 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) {
739
+ const newItemSets = await retryWithExponentialBackoff(async () => {
740
+ if (currentIndex !== undefined) {
741
+ const itemSet = itemSets[currentIndex];
738
742
  await itemSet.refetchAll(attemptNum);
743
+ } else {
744
+ for (const itemSet of itemSets) {
745
+ await itemSet.refetchAll(attemptNum);
746
+ }
739
747
  }
740
- }
741
748
 
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
- );
749
+ return await this.assembleTransactionSets(
750
+ currentIndex !== undefined
751
+ ? [
752
+ ...itemSets[currentIndex].items,
753
+ ...itemSets.slice(currentIndex + 1).flatMap((set) => set.items),
754
+ ]
755
+ : itemSets.flatMap((set) => set.items)
756
+ );
757
+ }, 2);
750
758
 
751
759
  const newItemSetNames = newItemSets.map((x) => x.name());
752
760
  if (
@@ -415,7 +415,7 @@ export function getJupSwapRebalanceDetails(
415
415
 
416
416
  const exactOut =
417
417
  targetLiqUtilizationRateBps === 0 ||
418
- values.repayingCloseToMaxLtv ||
418
+ // values.repayingCloseToMaxLtv ||
419
419
  flashLoanRepayFromDebt;
420
420
  const exactIn = !exactOut;
421
421