@haven-fi/solauto-sdk 1.0.207 → 1.0.209

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,15 +1,13 @@
1
- import { TransactionBuilder, Umi } from "@metaplex-foundation/umi";
1
+ import { TransactionBuilder } from "@metaplex-foundation/umi";
2
2
  import { PublicKey } from "@solana/web3.js";
3
- import { ReferralState } from "../generated";
4
3
  import { SolautoClient } from "../clients/solautoClient";
4
+ import { ReferralStateManager } from "../clients";
5
+ import { TransactionItemInputs } from "../types";
5
6
  export declare function rebalanceChoresBefore(client: SolautoClient, tx: TransactionBuilder, accountsGettingCreated: string[]): Promise<TransactionBuilder>;
6
7
  export declare function getTransactionChores(client: SolautoClient, tx: TransactionBuilder): Promise<[TransactionBuilder, TransactionBuilder]>;
7
8
  export declare function requiresRefreshBeforeRebalance(client: SolautoClient): Promise<boolean>;
8
- export declare function buildSolautoRebalanceTransaction(client: SolautoClient, targetLiqUtilizationRateBps?: number, attemptNum?: number): Promise<{
9
- tx: TransactionBuilder;
10
- lookupTableAddresses: string[];
11
- } | undefined>;
12
- export declare function convertReferralFeesToDestination(umi: Umi, referralState: ReferralState, tokenAccount: PublicKey): Promise<[TransactionBuilder, string[]] | undefined>;
9
+ export declare function buildSolautoRebalanceTransaction(client: SolautoClient, targetLiqUtilizationRateBps?: number, attemptNum?: number): Promise<TransactionItemInputs | undefined>;
10
+ export declare function convertReferralFeesToDestination(referralManager: ReferralStateManager, tokenAccount: PublicKey, destinationMint: PublicKey): Promise<TransactionItemInputs | undefined>;
13
11
  export declare function getErrorInfo(tx: TransactionBuilder, error: any): {
14
12
  errorName: string | undefined;
15
13
  errorInfo: undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAKxE,OAA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AE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AA0LjD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CA+G7B;AAkLD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA0BnD;AAED,wBAAsB,8BAA8B,CAAC,MAAM,EAAE,aAAa,oBAwCzE;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAkH5C;AAED,wBAAsB,gCAAgC,CACpD,eAAe,EAAE,oBAAoB,EACrC,YAAY,EAAE,SAAS,EACvB,eAAe,EAAE,SAAS,GACzB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAsC5C;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG;;;;EAwC9D"}
@@ -400,30 +400,30 @@ async function buildSolautoRebalanceTransaction(client, targetLiqUtilizationRate
400
400
  lookupTableAddresses,
401
401
  };
402
402
  }
403
- async function convertReferralFeesToDestination(umi, referralState, tokenAccount) {
404
- const tokenAccountData = await (0, accountUtils_1.getTokenAccountData)(umi, tokenAccount);
403
+ async function convertReferralFeesToDestination(referralManager, tokenAccount, destinationMint) {
404
+ const tokenAccountData = await (0, accountUtils_1.getTokenAccountData)(referralManager.umi, tokenAccount);
405
405
  if (!tokenAccountData || tokenAccountData.amount === BigInt(0)) {
406
406
  return undefined;
407
407
  }
408
- const { lookupTableAddresses, setupInstructions, swapIx } = await (0, jupiterUtils_1.getJupSwapTransaction)(umi.identity, {
408
+ const { lookupTableAddresses, setupInstructions, swapIx } = await (0, jupiterUtils_1.getJupSwapTransaction)(referralManager.umi.identity, {
409
409
  amount: tokenAccountData.amount,
410
- destinationWallet: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(referralState.publicKey),
410
+ destinationWallet: referralManager.referralState,
411
411
  inputMint: tokenAccountData.mint,
412
- outputMint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(referralState.destFeesMint),
412
+ outputMint: destinationMint,
413
413
  exactIn: true,
414
414
  slippageIncFactor: 0.25,
415
415
  });
416
416
  let tx = (0, umi_1.transactionBuilder)()
417
417
  .add(setupInstructions)
418
- .add((0, generated_1.convertReferralFees)(umi, {
419
- signer: umi.identity,
420
- intermediaryTa: (0, umi_1.publicKey)((0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(umi.identity.publicKey), tokenAccountData.mint)),
418
+ .add((0, generated_1.convertReferralFees)(referralManager.umi, {
419
+ signer: referralManager.umi.identity,
420
+ intermediaryTa: (0, umi_1.publicKey)((0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(referralManager.umi.identity.publicKey), tokenAccountData.mint)),
421
421
  ixsSysvar: (0, umi_1.publicKey)(web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY),
422
- referralState: referralState.publicKey,
422
+ referralState: (0, umi_1.publicKey)(referralManager.referralState),
423
423
  referralFeesTa: (0, umi_1.publicKey)(tokenAccount),
424
424
  }))
425
425
  .add(swapIx);
426
- return [tx, lookupTableAddresses];
426
+ return { tx, lookupTableAddresses };
427
427
  }
428
428
  function getErrorInfo(tx, error) {
429
429
  let canBeIgnored = false;
@@ -1,20 +1,14 @@
1
1
  import { TransactionBuilder } from "@metaplex-foundation/umi";
2
2
  import { SolautoClient } from "../clients/solautoClient";
3
3
  import { ErrorsToThrow } from "../utils/generalUtils";
4
- import { PriorityFeeSetting, TransactionRunType } from "../types";
4
+ import { PriorityFeeSetting, TransactionItemInputs, TransactionRunType } from "../types";
5
5
  import { ReferralStateManager } from "../clients";
6
6
  export declare class TransactionItem {
7
- fetchTx: (attemptNum: number) => Promise<{
8
- tx: TransactionBuilder;
9
- lookupTableAddresses?: string[];
10
- } | undefined>;
7
+ fetchTx: (attemptNum: number) => Promise<TransactionItemInputs | undefined>;
11
8
  name?: string | undefined;
12
9
  lookupTableAddresses: string[];
13
10
  tx?: TransactionBuilder;
14
- constructor(fetchTx: (attemptNum: number) => Promise<{
15
- tx: TransactionBuilder;
16
- lookupTableAddresses?: string[];
17
- } | undefined>, name?: string | undefined);
11
+ constructor(fetchTx: (attemptNum: number) => Promise<TransactionItemInputs | undefined>, name?: string | undefined);
18
12
  initialize(): Promise<void>;
19
13
  refetch(attemptNum: number): Promise<void>;
20
14
  uniqueAccounts(): string[];
@@ -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,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAa,MAAM,YAAY,CAAC;AA0C7D,qBAAa,eAAe;IAKjB,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CACV;QAAE,EAAE,EAAE,kBAAkB,CAAC;QAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,SAAS,CACxE;IACM,IAAI,CAAC,EAAE,MAAM;IATtB,oBAAoB,EAAG,MAAM,EAAE,CAAC;IAChC,EAAE,CAAC,EAAE,kBAAkB,CAAC;gBAGf,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CACV;QAAE,EAAE,EAAE,kBAAk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,eAAe,CAAC,EAAE,kBAAkB,GACnC,OAAO,CAAC,0BAA0B,CAAC;IAyEzB,IAAI,CACf,KAAK,EAAE,eAAe,EAAE,EACxB,eAAe,CAAC,EAAE,kBAAkB,EACpC,WAAW,CAAC,EAAE,OAAO,GACpB,OAAO,CAAC,0BAA0B,CAAC;YAwGxB,eAAe;CAkD9B"}
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,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACzF,OAAO,EAAE,oBAAoB,EAAa,MAAM,YAAY,CAAC;AAwC7D,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,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,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,EAAE,CAAC;AAEJ,qBAAa,mBAAmB;IAK5B,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,cAAc,CAAC;IACvB,OAAO,CAAC,MAAM,CAAC;IACf,OAAO,CAAC,YAAY,CAAC;IACrB,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,YAAY,CAAC,EAAE,OAAO,YAAA,EACtB,aAAa,CAAC,EAAE,aAAa,YAAA,EAC7B,OAAO,GAAE,MAAU,EACnB,UAAU,GAAE,MAAY;YAQpB,uBAAuB;IAwCrC,OAAO,CAAC,YAAY;YA8CN,aAAa;IAoBd,UAAU,CACrB,YAAY,EAAE,eAAe,EAAE,EAC/B,eAAe,CAAC,EAAE,kBAAkB,GACnC,OAAO,CAAC,0BAA0B,CAAC;IAyEzB,IAAI,CACf,KAAK,EAAE,eAAe,EAAE,EACxB,eAAe,CAAC,EAAE,kBAAkB,EACpC,WAAW,CAAC,EAAE,OAAO,GACpB,OAAO,CAAC,0BAA0B,CAAC;YAwGxB,eAAe;CAoD9B"}
@@ -1,5 +1,6 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
2
  import { LendingPlatform, PositionType } from "../generated";
3
+ import { TransactionBuilder } from "@metaplex-foundation/umi";
3
4
  export interface SolautoPositionDetails {
4
5
  publicKey?: PublicKey;
5
6
  authority: PublicKey;
@@ -16,4 +17,8 @@ export declare enum PriorityFeeSetting {
16
17
  }
17
18
  export type RebalanceAction = "boost" | "repay" | "dca";
18
19
  export type TransactionRunType = "skip-simulation" | "only-simulate" | "normal";
20
+ export interface TransactionItemInputs {
21
+ tx: TransactionBuilder;
22
+ lookupTableAddresses?: string[];
23
+ }
19
24
  //# sourceMappingURL=solauto.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"solauto.d.ts","sourceRoot":"","sources":["../../src/types/solauto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE7D,MAAM,WAAW,sBAAsB;IACrC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,YAAY,CAAC;IAC3B,eAAe,EAAE,eAAe,CAAC;IACjC,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,oBAAY,kBAAkB;IAC5B,OAAO,WAAW;IAClB,IAAI,SAAS;CACd;AAED,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC;AAExD,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,GAAG,eAAe,GAAG,QAAQ,CAAC"}
1
+ {"version":3,"file":"solauto.d.ts","sourceRoot":"","sources":["../../src/types/solauto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,MAAM,WAAW,sBAAsB;IACrC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,YAAY,CAAC;IAC3B,eAAe,EAAE,eAAe,CAAC;IACjC,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,oBAAY,kBAAkB;IAC5B,OAAO,WAAW;IAClB,IAAI,SAAS;CACd;AAED,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC;AAExD,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,GAAG,eAAe,GAAG,QAAQ,CAAC;AAEhF,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,kBAAkB,CAAC;IACvB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;CACjC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.207",
3
+ "version": "1.0.209",
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",
@@ -22,7 +22,6 @@
22
22
  "@metaplex-foundation/umi-web3js-adapters": "^0.9.1",
23
23
  "@solana/spl-token": "^0.4.0",
24
24
  "@solana/web3.js": "^1.92.1",
25
- "@sqds/multisig": "^2.1.3",
26
25
  "bs58": "^5.0.0",
27
26
  "cross-fetch": "^4.0.0",
28
27
  "rpc-websockets": "7.11.0"
@@ -26,6 +26,7 @@ import {
26
26
  getMarginfiRebalanceInstructionDataSerializer,
27
27
  getSolautoErrorFromCode,
28
28
  isSolautoAction,
29
+ safeFetchReferralState,
29
30
  solautoAction,
30
31
  } from "../generated";
31
32
  import { SolautoClient } from "../clients/solautoClient";
@@ -65,13 +66,14 @@ import {
65
66
  getMarginfiErrorFromName,
66
67
  MARGINFI_PROGRAM_ID,
67
68
  } from "../marginfi-sdk";
68
- import { TxHandler } from "../clients";
69
+ import { ReferralStateManager, TxHandler } from "../clients";
69
70
  import {
70
71
  createJupiterProgram,
71
72
  getJupiterErrorFromName,
72
73
  JUPITER_PROGRAM_ID,
73
74
  } from "../jupiter-sdk";
74
75
  import { PRICES } from "../constants";
76
+ import { TransactionItemInputs } from "../types";
75
77
 
76
78
  interface wSolTokenUsage {
77
79
  wSolTokenAccount: PublicKey;
@@ -627,13 +629,7 @@ export async function buildSolautoRebalanceTransaction(
627
629
  client: SolautoClient,
628
630
  targetLiqUtilizationRateBps?: number,
629
631
  attemptNum?: number
630
- ): Promise<
631
- | {
632
- tx: TransactionBuilder;
633
- lookupTableAddresses: string[];
634
- }
635
- | undefined
636
- > {
632
+ ): Promise<TransactionItemInputs | undefined> {
637
633
  client.solautoPositionState = await client.getFreshPositionState();
638
634
  if (
639
635
  (client.solautoPositionState?.supply.amountUsed.baseUnit === BigInt(0) &&
@@ -750,21 +746,24 @@ export async function buildSolautoRebalanceTransaction(
750
746
  }
751
747
 
752
748
  export async function convertReferralFeesToDestination(
753
- umi: Umi,
754
- referralState: ReferralState,
755
- tokenAccount: PublicKey
756
- ): Promise<[TransactionBuilder, string[]] | undefined> {
757
- const tokenAccountData = await getTokenAccountData(umi, tokenAccount);
749
+ referralManager: ReferralStateManager,
750
+ tokenAccount: PublicKey,
751
+ destinationMint: PublicKey
752
+ ): Promise<TransactionItemInputs | undefined> {
753
+ const tokenAccountData = await getTokenAccountData(
754
+ referralManager.umi,
755
+ tokenAccount
756
+ );
758
757
  if (!tokenAccountData || tokenAccountData.amount === BigInt(0)) {
759
758
  return undefined;
760
759
  }
761
760
 
762
761
  const { lookupTableAddresses, setupInstructions, swapIx } =
763
- await getJupSwapTransaction(umi.identity, {
762
+ await getJupSwapTransaction(referralManager.umi.identity, {
764
763
  amount: tokenAccountData.amount,
765
- destinationWallet: toWeb3JsPublicKey(referralState.publicKey),
764
+ destinationWallet: referralManager.referralState,
766
765
  inputMint: tokenAccountData.mint,
767
- outputMint: toWeb3JsPublicKey(referralState.destFeesMint),
766
+ outputMint: destinationMint,
768
767
  exactIn: true,
769
768
  slippageIncFactor: 0.25,
770
769
  });
@@ -772,22 +771,22 @@ export async function convertReferralFeesToDestination(
772
771
  let tx = transactionBuilder()
773
772
  .add(setupInstructions)
774
773
  .add(
775
- convertReferralFees(umi, {
776
- signer: umi.identity,
774
+ convertReferralFees(referralManager.umi, {
775
+ signer: referralManager.umi.identity,
777
776
  intermediaryTa: publicKey(
778
777
  getTokenAccount(
779
- toWeb3JsPublicKey(umi.identity.publicKey),
778
+ toWeb3JsPublicKey(referralManager.umi.identity.publicKey),
780
779
  tokenAccountData.mint
781
780
  )
782
781
  ),
783
782
  ixsSysvar: publicKey(SYSVAR_INSTRUCTIONS_PUBKEY),
784
- referralState: referralState.publicKey,
783
+ referralState: publicKey(referralManager.referralState),
785
784
  referralFeesTa: publicKey(tokenAccount),
786
785
  })
787
786
  )
788
787
  .add(swapIx);
789
788
 
790
- return [tx, lookupTableAddresses];
789
+ return { tx, lookupTableAddresses };
791
790
  }
792
791
 
793
792
  export function getErrorInfo(tx: TransactionBuilder, error: any) {
@@ -15,12 +15,8 @@ import {
15
15
  retryWithExponentialBackoff,
16
16
  } from "../utils/generalUtils";
17
17
  import { getErrorInfo, getTransactionChores } from "./transactionUtils";
18
- import { PriorityFeeSetting, TransactionRunType } from "../types";
18
+ import { PriorityFeeSetting, TransactionItemInputs, TransactionRunType } from "../types";
19
19
  import { ReferralStateManager, TxHandler } from "../clients";
20
- import {
21
- InvalidRebalanceConditionError,
22
- SOLAUTO_PROGRAM_ID,
23
- } from "../generated";
24
20
  // import { sendJitoBundledTransactions } from "../utils/jitoUtils";
25
21
 
26
22
  class LookupTables {
@@ -58,6 +54,8 @@ class LookupTables {
58
54
  }
59
55
  }
60
56
 
57
+
58
+
61
59
  export class TransactionItem {
62
60
  lookupTableAddresses!: string[];
63
61
  tx?: TransactionBuilder;
@@ -65,9 +63,7 @@ export class TransactionItem {
65
63
  constructor(
66
64
  public fetchTx: (
67
65
  attemptNum: number
68
- ) => Promise<
69
- { tx: TransactionBuilder; lookupTableAddresses?: string[] } | undefined
70
- >,
66
+ ) => Promise<TransactionItemInputs | undefined>,
71
67
  public name?: string
72
68
  ) {}
73
69
 
@@ -542,7 +538,9 @@ export class TransactionsManager {
542
538
  undefined,
543
539
  errorDetails.errorInfo ?? errorDetails.errorName ?? "Unknown error"
544
540
  );
545
- this.txHandler.log(`${errorDetails.errorName ?? "Unknown error"}: ${errorDetails.errorInfo ?? "unknown"}`);
541
+ this.txHandler.log(
542
+ `${errorDetails.errorName ?? "Unknown error"}: ${errorDetails.errorInfo ?? "unknown"}`
543
+ );
546
544
 
547
545
  if (!errorDetails.canBeIgnored) {
548
546
  throw e;
@@ -1,5 +1,6 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
2
  import { LendingPlatform, PositionType } from "../generated";
3
+ import { TransactionBuilder } from "@metaplex-foundation/umi";
3
4
 
4
5
  export interface SolautoPositionDetails {
5
6
  publicKey?: PublicKey;
@@ -14,9 +15,14 @@ export interface SolautoPositionDetails {
14
15
 
15
16
  export enum PriorityFeeSetting {
16
17
  Default = "Medium",
17
- High = "High"
18
+ High = "High",
18
19
  }
19
20
 
20
21
  export type RebalanceAction = "boost" | "repay" | "dca";
21
22
 
22
- export type TransactionRunType = "skip-simulation" | "only-simulate" | "normal";
23
+ export type TransactionRunType = "skip-simulation" | "only-simulate" | "normal";
24
+
25
+ export interface TransactionItemInputs {
26
+ tx: TransactionBuilder;
27
+ lookupTableAddresses?: string[];
28
+ }