@haven-fi/solauto-sdk 1.0.83 → 1.0.84

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,5 @@
1
1
  export * from './solautoMarginfiClient';
2
2
  export * from './solautoClient';
3
3
  export * from './referralStateManager';
4
+ export * from './txHandler';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/clients/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/clients/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC"}
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./solautoMarginfiClient"), exports);
18
18
  __exportStar(require("./solautoClient"), exports);
19
19
  __exportStar(require("./referralStateManager"), exports);
20
+ __exportStar(require("./txHandler"), exports);
@@ -2,21 +2,25 @@ import { PublicKey } from "@solana/web3.js";
2
2
  import { Signer, TransactionBuilder, Umi } from "@metaplex-foundation/umi";
3
3
  import { WalletAdapter } from "@metaplex-foundation/umi-signer-wallet-adapters";
4
4
  import { ReferralState } from "../generated";
5
+ import { TxHandler } from "./txHandler";
5
6
  interface ReferralStateManagerArgs {
6
7
  referralAuthority?: PublicKey;
7
8
  signer?: Signer;
8
9
  wallet?: WalletAdapter;
9
10
  }
10
- export declare class ReferralStateManager {
11
+ export declare class ReferralStateManager extends TxHandler {
12
+ localTest?: boolean | undefined;
11
13
  umi: Umi;
12
14
  signer: Signer;
13
15
  referralAuthority: PublicKey;
14
16
  referralState: PublicKey;
15
17
  referralStateData: ReferralState | null;
16
- constructor(heliusApiKey: string);
18
+ constructor(heliusApiKey: string, localTest?: boolean | undefined);
17
19
  initialize(args: ReferralStateManagerArgs): Promise<void>;
20
+ defaultLookupTables(): string[];
18
21
  updateReferralStatesIx(destFeesMint?: PublicKey, referredBy?: PublicKey, lookupTable?: PublicKey): TransactionBuilder;
19
22
  claimReferralFeesIx(destFeesMint?: PublicKey): TransactionBuilder;
23
+ resetLiveTxUpdates(): Promise<void>;
20
24
  }
21
25
  export {};
22
26
  //# sourceMappingURL=referralStateManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"referralStateManager.d.ts","sourceRoot":"","sources":["../../src/clients/referralStateManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAa,MAAM,EAAkB,kBAAkB,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAEtG,OAAO,EAAE,aAAa,EAAyB,MAAM,iDAAiD,CAAC;AACvG,OAAO,EAA2C,aAAa,EAAgD,MAAM,cAAc,CAAC;AAGpI,UAAU,wBAAwB;IAC9B,iBAAiB,CAAC,EAAE,SAAS,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,aAAa,CAAC;CAC1B;AAED,qBAAa,oBAAoB;IACtB,GAAG,EAAG,GAAG,CAAC;IACV,MAAM,EAAG,MAAM,CAAC;IAEhB,iBAAiB,EAAG,SAAS,CAAC;IAC9B,aAAa,EAAG,SAAS,CAAC;IAC1B,iBAAiB,EAAG,aAAa,GAAG,IAAI,CAAC;gBAEpC,YAAY,EAAE,MAAM;IAS1B,UAAU,CAAC,IAAI,EAAE,wBAAwB;IAe/C,sBAAsB,CAAC,YAAY,CAAC,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,SAAS,EAAE,WAAW,CAAC,EAAE,SAAS,GAAG,kBAAkB;IAiBrH,mBAAmB,CAAC,YAAY,CAAC,EAAE,SAAS,GAAG,kBAAkB;CAwBpE"}
1
+ {"version":3,"file":"referralStateManager.d.ts","sourceRoot":"","sources":["../../src/clients/referralStateManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAa,MAAM,EAAkB,kBAAkB,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAEtG,OAAO,EAAE,aAAa,EAAyB,MAAM,iDAAiD,CAAC;AACvG,OAAO,EAA2C,aAAa,EAAgD,MAAM,cAAc,CAAC;AAEpI,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,UAAU,wBAAwB;IAC9B,iBAAiB,CAAC,EAAE,SAAS,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,aAAa,CAAC;CAC1B;AAED,qBAAa,oBAAqB,SAAQ,SAAS;IAQN,SAAS,CAAC,EAAE,OAAO;IAPrD,GAAG,EAAG,GAAG,CAAC;IACV,MAAM,EAAG,MAAM,CAAC;IAEhB,iBAAiB,EAAG,SAAS,CAAC;IAC9B,aAAa,EAAG,SAAS,CAAC;IAC1B,iBAAiB,EAAG,aAAa,GAAG,IAAI,CAAC;gBAEpC,YAAY,EAAE,MAAM,EAAS,SAAS,CAAC,EAAE,OAAO,YAAA;IAStD,UAAU,CAAC,IAAI,EAAE,wBAAwB;IAe/C,mBAAmB,IAAI,MAAM,EAAE;IAI/B,sBAAsB,CAAC,YAAY,CAAC,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,SAAS,EAAE,WAAW,CAAC,EAAE,SAAS,GAAG,kBAAkB;IAiBrH,mBAAmB,CAAC,YAAY,CAAC,EAAE,SAAS,GAAG,kBAAkB;IAwB3D,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;CAC5C"}
@@ -7,10 +7,12 @@ const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters"
7
7
  const umi_signer_wallet_adapters_1 = require("@metaplex-foundation/umi-signer-wallet-adapters");
8
8
  const generated_1 = require("../generated");
9
9
  const utils_1 = require("../utils");
10
- class ReferralStateManager {
11
- constructor(heliusApiKey) {
12
- const [_, umi] = (0, utils_1.getSolanaRpcConnection)(heliusApiKey);
13
- this.umi = umi.use({
10
+ const txHandler_1 = require("./txHandler");
11
+ class ReferralStateManager extends txHandler_1.TxHandler {
12
+ constructor(heliusApiKey, localTest) {
13
+ super(heliusApiKey, localTest);
14
+ this.localTest = localTest;
15
+ this.umi = this.umi.use({
14
16
  install(umi) {
15
17
  umi.programs.add((0, generated_1.createSolautoProgram)(), false);
16
18
  },
@@ -27,6 +29,9 @@ class ReferralStateManager {
27
29
  this.referralState = (0, utils_1.getReferralState)(args.referralAuthority ?? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey));
28
30
  this.referralStateData = await (0, generated_1.safeFetchReferralState)(this.umi, (0, umi_1.publicKey)(this.referralState));
29
31
  }
32
+ defaultLookupTables() {
33
+ return this.referralStateData?.lookupTable ? [this.referralStateData?.lookupTable.toString()] : [];
34
+ }
30
35
  updateReferralStatesIx(destFeesMint, referredBy, lookupTable) {
31
36
  return (0, generated_1.updateReferralStates)(this.umi, {
32
37
  signer: this.signer,
@@ -59,5 +64,6 @@ class ReferralStateManager {
59
64
  feesDestinationTa,
60
65
  });
61
66
  }
67
+ async resetLiveTxUpdates() { }
62
68
  }
63
69
  exports.ReferralStateManager = ReferralStateManager;
@@ -1,12 +1,13 @@
1
1
  import "rpc-websockets/dist/lib/client";
2
- import { Connection, PublicKey } from "@solana/web3.js";
3
- import { Signer, TransactionBuilder, Umi } from "@metaplex-foundation/umi";
2
+ import { PublicKey } from "@solana/web3.js";
3
+ import { Signer, TransactionBuilder } from "@metaplex-foundation/umi";
4
4
  import { WalletAdapter } from "@metaplex-foundation/umi-signer-wallet-adapters";
5
5
  import { DCASettings, DCASettingsInpArgs, LendingPlatform, PositionState, SolautoActionArgs, SolautoPosition, SolautoRebalanceTypeArgs, SolautoSettingsParameters, SolautoSettingsParametersInpArgs, UpdatePositionDataArgs } from "../generated";
6
6
  import { JupSwapDetails } from "../utils/jupiterUtils";
7
7
  import { FlashLoanDetails } from "../utils/solauto/rebalanceUtils";
8
8
  import { LivePositionUpdates } from "../utils/solauto/generalUtils";
9
9
  import { ReferralStateManager } from "./referralStateManager";
10
+ import { TxHandler } from "./txHandler";
10
11
  export interface SolautoClientArgs {
11
12
  authority?: PublicKey;
12
13
  positionId: number;
@@ -16,11 +17,8 @@ export interface SolautoClientArgs {
16
17
  debtMint?: PublicKey;
17
18
  referredByAuthority?: PublicKey;
18
19
  }
19
- export declare abstract class SolautoClient {
20
+ export declare abstract class SolautoClient extends TxHandler {
20
21
  localTest?: boolean | undefined;
21
- private heliusApiKey;
22
- umi: Umi;
23
- connection: Connection;
24
22
  lendingPlatform: LendingPlatform;
25
23
  authority: PublicKey;
26
24
  signer: Signer;
@@ -46,8 +44,7 @@ export declare abstract class SolautoClient {
46
44
  livePositionUpdates: LivePositionUpdates;
47
45
  constructor(heliusApiKey: string, localTest?: boolean | undefined);
48
46
  initialize(args: SolautoClientArgs, lendingPlatform: LendingPlatform): Promise<void>;
49
- log(...args: any[]): void;
50
- resetLivePositionUpdates(): Promise<void>;
47
+ resetLiveTxUpdates(): Promise<void>;
51
48
  abstract protocolAccount(): PublicKey;
52
49
  defaultLookupTables(): string[];
53
50
  lutAccountsToAdd(): PublicKey[];
@@ -1 +1 @@
1
- {"version":3,"file":"solautoClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoClient.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAEL,UAAU,EACV,SAAS,EACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAOJ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,aAAa,EAEd,MAAM,iDAAiD,CAAC;AACzD,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,y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AiC,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IAUzD,iBAAiB,IAAI,OAAO,CAChC;QAAE,WAAW,EAAE,kBAAkB,CAAC;QAAC,iBAAiB,EAAE,OAAO,CAAA;KAAE,GAAG,SAAS,CAC5E;IA2DD,uBAAuB,IAAI,yBAAyB,GAAG,SAAS;IAOhE,wBAAwB,IAAI,WAAW,GAAG,SAAS;IAOnD,YAAY,CACV,aAAa,CAAC,EAAE,gCAAgC,EAChD,GAAG,CAAC,EAAE,kBAAkB,GACvB,kBAAkB;IAuBrB,gBAAgB,CAAC,IAAI,EAAE,sBAAsB,GAAG,kBAAkB;IA2DlE,eAAe,IAAI,kBAAkB;IAWrC,WAAW,IAAI,kBAAkB;IA4BjC,QAAQ,CAAC,OAAO,IAAI,kBAAkB;IAEtC,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB;IAuFhE,QAAQ,CAAC,WAAW,CAClB,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,SAAS,GACjC,kBAAkB;IAErB,QAAQ,CAAC,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,kBAAkB;IAE3E,QAAQ,CAAC,SAAS,CAChB,aAAa,EAAE,GAAG,GAAG,GAAG,EACxB,WAAW,EAAE,cAAc,EAC3B,aAAa,EAAE,wBAAwB,EACvC,SAAS,CAAC,EAAE,gBAAgB,EAC5B,2BAA2B,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,kBAAkB;IAEf,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAYlE"}
@@ -14,14 +14,13 @@ const solautoConstants_1 = require("../constants/solautoConstants");
14
14
  const generalUtils_1 = require("../utils/generalUtils");
15
15
  const generalUtils_2 = require("../utils/solauto/generalUtils");
16
16
  const referralStateManager_1 = require("./referralStateManager");
17
- class SolautoClient {
17
+ const txHandler_1 = require("./txHandler");
18
+ class SolautoClient extends txHandler_1.TxHandler {
18
19
  constructor(heliusApiKey, localTest) {
20
+ super(heliusApiKey, localTest);
19
21
  this.localTest = localTest;
20
22
  this.livePositionUpdates = new generalUtils_2.LivePositionUpdates();
21
- this.heliusApiKey = heliusApiKey;
22
- const [connection, umi] = (0, solanaUtils_1.getSolanaRpcConnection)(this.heliusApiKey);
23
- this.connection = connection;
24
- this.umi = umi.use({
23
+ this.umi = this.umi.use({
25
24
  install(umi) {
26
25
  umi.programs.add((0, generated_1.createSolautoProgram)(), false);
27
26
  },
@@ -91,12 +90,7 @@ class SolautoClient {
91
90
  ? this.solautoPositionData?.position?.dca
92
91
  : undefined);
93
92
  }
94
- log(...args) {
95
- if (this.localTest) {
96
- console.log(...args);
97
- }
98
- }
99
- async resetLivePositionUpdates() {
93
+ async resetLiveTxUpdates() {
100
94
  if (!this.solautoPositionData) {
101
95
  this.solautoPositionData = await (0, generated_1.safeFetchSolautoPosition)(this.umi, (0, umi_1.publicKey)(this.solautoPosition));
102
96
  }
@@ -114,7 +108,7 @@ class SolautoClient {
114
108
  this.livePositionUpdates.reset();
115
109
  }
116
110
  defaultLookupTables() {
117
- return [solautoConstants_1.SOLAUTO_LUT];
111
+ return [solautoConstants_1.SOLAUTO_LUT, ...(this.authorityLutAddress ? [this.authorityLutAddress.toString()] : [])];
118
112
  }
119
113
  lutAccountsToAdd() {
120
114
  return [
@@ -0,0 +1,13 @@
1
+ import { Umi } from "@metaplex-foundation/umi";
2
+ import { Connection } from "@solana/web3.js";
3
+ export declare abstract class TxHandler {
4
+ localTest?: boolean | undefined;
5
+ heliusApiKey: string;
6
+ umi: Umi;
7
+ connection: Connection;
8
+ constructor(heliusApiKey: string, localTest?: boolean | undefined);
9
+ log(...args: any[]): void;
10
+ abstract defaultLookupTables(): string[];
11
+ abstract resetLiveTxUpdates(): Promise<void>;
12
+ }
13
+ //# sourceMappingURL=txHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"txHandler.d.ts","sourceRoot":"","sources":["../../src/clients/txHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAI7C,8BAAsB,SAAS;IAMpB,SAAS,CAAC,EAAE,OAAO;IALrB,YAAY,EAAG,MAAM,CAAC;IACtB,GAAG,EAAG,GAAG,CAAC;IACV,UAAU,EAAG,UAAU,CAAC;gBAEnB,YAAY,EAAE,MAAM,EACvB,SAAS,CAAC,EAAE,OAAO,YAAA;IAO5B,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAMzB,QAAQ,CAAC,mBAAmB,IAAI,MAAM,EAAE;IAExC,QAAQ,CAAC,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;CAC7C"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TxHandler = void 0;
4
+ const utils_1 = require("../utils");
5
+ class TxHandler {
6
+ constructor(heliusApiKey, localTest) {
7
+ this.localTest = localTest;
8
+ this.heliusApiKey = heliusApiKey;
9
+ const [connection, umi] = (0, utils_1.getSolanaRpcConnection)(this.heliusApiKey);
10
+ this.connection = connection;
11
+ this.umi = umi;
12
+ }
13
+ log(...args) {
14
+ if (this.localTest) {
15
+ console.log(...args);
16
+ }
17
+ }
18
+ }
19
+ exports.TxHandler = TxHandler;
@@ -1 +1 @@
1
- {"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAGL,OAAO,IAAI,eAAe,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,aAAa,EASd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAuMzD,wBAAsB,qBAAq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,EAAE,kBAAkB,CAAC,CAAC,CA4BnD;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CACN;IACA,EAAE,EAAE,kBAAkB,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC,GACC,SAAS,CACZ,CAyHA;AAED,wBAAsB,gCAAgC,CACpD,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,eAAe,GAC5B,OAAO,CAAC,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC,CAAC,CA8BzC"}
@@ -323,9 +323,7 @@ async function buildSolautoRebalanceTransaction(client, targetLiqUtilizationRate
323
323
  client.solautoPositionState = await client.getFreshPositionState();
324
324
  if (client.solautoPositionState?.supply.amountUsed.baseUnit === BigInt(0) ||
325
325
  (targetLiqUtilizationRateBps === undefined &&
326
- !(0, generalUtils_2.eligibleForRebalance)(client.solautoPositionState, client.livePositionUpdates.settings ??
327
- client.solautoPositionData?.position.settingParams, client.livePositionUpdates.activeDca ??
328
- client.solautoPositionData?.position.dca, (0, generalUtils_1.currentUnixSeconds)()))) {
326
+ !(0, generalUtils_2.eligibleForRebalance)(client.solautoPositionState, client.solautoPositionSettings(), client.solautoPositionActiveDca(), (0, generalUtils_1.currentUnixSeconds)()))) {
329
327
  client.log("Not eligible for a rebalance");
330
328
  return undefined;
331
329
  }
@@ -1,12 +1,13 @@
1
- import { AddressLookupTableInput, TransactionBuilder } from "@metaplex-foundation/umi";
1
+ import { AddressLookupTableInput, TransactionBuilder, Umi } from "@metaplex-foundation/umi";
2
2
  import { SolautoClient } from "../clients/solautoClient";
3
3
  import { ErrorsToThrow } from "../utils/generalUtils";
4
4
  import { PriorityFeeSetting } from "../types";
5
+ import { TxHandler } from "../clients";
5
6
  declare class LookupTables {
6
- private client;
7
7
  defaultLuts: string[];
8
+ private umi;
8
9
  cache: AddressLookupTableInput[];
9
- constructor(client: SolautoClient);
10
+ constructor(defaultLuts: string[], umi: Umi);
10
11
  getLutInputs(additionalAddresses: string[]): Promise<AddressLookupTableInput[]>;
11
12
  }
12
13
  export declare class TransactionItem {
@@ -26,10 +27,10 @@ export declare class TransactionItem {
26
27
  uniqueAccounts(): string[];
27
28
  }
28
29
  declare class TransactionSet {
29
- private client;
30
+ private txHandler;
30
31
  lookupTables: LookupTables;
31
32
  items: TransactionItem[];
32
- constructor(client: SolautoClient, lookupTables: LookupTables, items?: TransactionItem[]);
33
+ constructor(txHandler: TxHandler, lookupTables: LookupTables, items?: TransactionItem[]);
33
34
  fitsWith(item: TransactionItem): Promise<boolean>;
34
35
  add(...items: TransactionItem[]): void;
35
36
  refetchAll(attemptNum: number): Promise<void>;
@@ -49,19 +50,19 @@ export type TransactionManagerStatuses = {
49
50
  txSig?: string;
50
51
  }[];
51
52
  export declare class TransactionsManager {
52
- private client;
53
- private items;
53
+ private txHandler;
54
54
  private statusCallback?;
55
55
  private simulateOnly?;
56
56
  private mustBeAtomic?;
57
57
  private errorsToThrow?;
58
58
  private statuses;
59
59
  private lookupTables;
60
- constructor(client: SolautoClient, items: TransactionItem[], statusCallback?: ((statuses: TransactionManagerStatuses) => void) | undefined, simulateOnly?: boolean | undefined, mustBeAtomic?: boolean | undefined, errorsToThrow?: ErrorsToThrow | undefined);
60
+ constructor(txHandler: TxHandler, statusCallback?: ((statuses: TransactionManagerStatuses) => void) | undefined, simulateOnly?: boolean | undefined, mustBeAtomic?: boolean | undefined, errorsToThrow?: ErrorsToThrow | undefined);
61
61
  private assembleTransactionSets;
62
62
  updateStatus(name: string, status: TransactionStatus, txSig?: string): void;
63
63
  debugAccounts(itemSet: TransactionSet, tx: TransactionBuilder): Promise<void>;
64
- send(prioritySetting?: PriorityFeeSetting): Promise<void>;
64
+ sendWithClient(items: TransactionItem[], client: SolautoClient, prioritySetting?: PriorityFeeSetting): Promise<void>;
65
+ send(items: TransactionItem[], prioritySetting?: PriorityFeeSetting, initialized?: boolean): Promise<void>;
65
66
  }
66
67
  export {};
67
68
  //# sourceMappingURL=transactionsManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EAEvB,kBAAkB,EACnB,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,MAAM,UAAU,CAAC;AAG9C,cAAM,YAAY;IAIJ,OAAO,CAAC,MAAM;IAH1B,WAAW,EAAE,MAAM,EAAE,CAAM;IAC3B,KAAK,EAAE,uBAAuB,EAAE,CAAM;gBAElB,MAAM,EAAE,aAAa;IAInC,YAAY,CAChB,mBAAmB,EAAE,MAAM,EAAE,GAC5B,OAAO,CAAC,uBAAuB,EAAE,CAAC;CAqBtC;AAED,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,kBAAkB,CAAC;QAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,SAAS,CACxE,EACM,IAAI,CAAC,EAAE,MAAM,YAAA;IAGhB,UAAU;IAIV,OAAO,CAAC,UAAU,EAAE,MAAM;IAMhC,cAAc,IAAI,MAAM,EAAE;CAY3B;AAED,cAAM,cA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AAa,CAAC,EAAE,aAAa,YAAA;YAKzB,uBAAuB;IAsCrC,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,KAAK,CAAC,EAAE,MAAM;IAiB9D,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,EAAE,EAAE,kBAAkB;IAkB7D,cAAc,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,eAAe,CAAC,EAAE,kBAAkB;IAgEpG,IAAI,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,eAAe,CAAC,EAAE,kBAAkB,EAAE,WAAW,CAAC,EAAE,OAAO;CAyGjG"}
@@ -11,22 +11,20 @@ const generalUtils_1 = require("../utils/generalUtils");
11
11
  const transactionUtils_1 = require("./transactionUtils");
12
12
  // import { sendJitoBundledTransactions } from "../utils/jitoUtils";
13
13
  class LookupTables {
14
- constructor(client) {
15
- this.client = client;
16
- this.defaultLuts = [];
14
+ constructor(defaultLuts, umi) {
15
+ this.defaultLuts = defaultLuts;
16
+ this.umi = umi;
17
17
  this.cache = [];
18
- this.defaultLuts = [...client.defaultLookupTables()];
19
18
  }
20
19
  async getLutInputs(additionalAddresses) {
21
20
  const addresses = [
22
21
  ...this.defaultLuts,
23
- this.client.authorityLutAddress.toString(),
24
22
  ...additionalAddresses,
25
23
  ];
26
24
  const currentCacheAddresses = this.cache.map((x) => x.publicKey.toString());
27
25
  const missingAddresses = addresses.filter((x) => !currentCacheAddresses.includes(x));
28
26
  if (missingAddresses) {
29
- const additionalInputs = await (0, solanaUtils_1.getAdressLookupInputs)(this.client.umi, missingAddresses);
27
+ const additionalInputs = await (0, solanaUtils_1.getAdressLookupInputs)(this.umi, missingAddresses);
30
28
  this.cache.push(...additionalInputs);
31
29
  }
32
30
  return this.cache;
@@ -56,8 +54,8 @@ class TransactionItem {
56
54
  }
57
55
  exports.TransactionItem = TransactionItem;
58
56
  class TransactionSet {
59
- constructor(client, lookupTables, items = []) {
60
- this.client = client;
57
+ constructor(txHandler, lookupTables, items = []) {
58
+ this.txHandler = txHandler;
61
59
  this.lookupTables = lookupTables;
62
60
  this.items = items;
63
61
  }
@@ -78,13 +76,13 @@ class TransactionSet {
78
76
  ...this.lutAddresses(),
79
77
  ...item.lookupTableAddresses,
80
78
  ]))
81
- .fitsInOneTransaction(this.client.umi);
79
+ .fitsInOneTransaction(this.txHandler.umi);
82
80
  }
83
81
  add(...items) {
84
82
  this.items.push(...items.filter((x) => x.tx && x.tx.getInstructions().length > 0));
85
83
  }
86
84
  async refetchAll(attemptNum) {
87
- await this.client.resetLivePositionUpdates();
85
+ await this.txHandler.resetLiveTxUpdates();
88
86
  for (const item of this.items) {
89
87
  await item.refetch(attemptNum);
90
88
  }
@@ -120,19 +118,18 @@ var TransactionStatus;
120
118
  TransactionStatus["Successful"] = "Successful";
121
119
  })(TransactionStatus || (exports.TransactionStatus = TransactionStatus = {}));
122
120
  class TransactionsManager {
123
- constructor(client, items, statusCallback, simulateOnly, mustBeAtomic, errorsToThrow) {
124
- this.client = client;
125
- this.items = items;
121
+ constructor(txHandler, statusCallback, simulateOnly, mustBeAtomic, errorsToThrow) {
122
+ this.txHandler = txHandler;
126
123
  this.statusCallback = statusCallback;
127
124
  this.simulateOnly = simulateOnly;
128
125
  this.mustBeAtomic = mustBeAtomic;
129
126
  this.errorsToThrow = errorsToThrow;
130
127
  this.statuses = [];
131
- this.lookupTables = new LookupTables(client);
128
+ this.lookupTables = new LookupTables(this.txHandler.defaultLookupTables(), this.txHandler.umi);
132
129
  }
133
130
  async assembleTransactionSets(items) {
134
131
  let transactionSets = [];
135
- this.client.log(`Reassembling ${items.length} items`);
132
+ this.txHandler.log(`Reassembling ${items.length} items`);
136
133
  for (let i = 0; i < items.length;) {
137
134
  let item = items[i];
138
135
  i++;
@@ -140,11 +137,11 @@ class TransactionsManager {
140
137
  continue;
141
138
  }
142
139
  const transaction = item.tx.setAddressLookupTables(await this.lookupTables.getLutInputs(item.lookupTableAddresses));
143
- if (!transaction.fitsInOneTransaction(this.client.umi)) {
144
- throw new Error(`Transaction exceeds max transaction size (${transaction.getTransactionSize(this.client.umi)})`);
140
+ if (!transaction.fitsInOneTransaction(this.txHandler.umi)) {
141
+ throw new Error(`Transaction exceeds max transaction size (${transaction.getTransactionSize(this.txHandler.umi)})`);
145
142
  }
146
143
  else {
147
- let newSet = new TransactionSet(this.client, this.lookupTables, [item]);
144
+ let newSet = new TransactionSet(this.txHandler, this.lookupTables, [item]);
148
145
  for (let j = i; j < items.length; j++) {
149
146
  if (await newSet.fitsWith(items[j])) {
150
147
  newSet.add(items[j]);
@@ -173,7 +170,7 @@ class TransactionsManager {
173
170
  this.statuses.push({ name, status, txSig });
174
171
  }
175
172
  }
176
- this.client.log(`${name} is ${status.toString().toLowerCase()}`);
173
+ this.txHandler.log(`${name} is ${status.toString().toLowerCase()}`);
177
174
  this.statusCallback?.(this.statuses);
178
175
  }
179
176
  // TODO remove me
@@ -183,28 +180,29 @@ class TransactionsManager {
183
180
  for (const ix of tx.getInstructions()) {
184
181
  const ixAccounts = ix.keys.map((x) => x.pubkey);
185
182
  const accountsNotInLut = ixAccounts.filter((x) => !lutAccounts.includes(x));
186
- this.client.log(`Program ${ix.programId}, data len: ${ix.data.length}, LUT accounts data: ${ix.keys.filter((x) => lutAccounts.includes(x.pubkey)).length * 3}`);
183
+ this.txHandler.log(`Program ${ix.programId}, data len: ${ix.data.length}, LUT accounts data: ${ix.keys.filter((x) => lutAccounts.includes(x.pubkey)).length * 3}`);
187
184
  if (accountsNotInLut.length > 0) {
188
- this.client.log(`${accountsNotInLut.length} accounts not in LUT:`);
185
+ this.txHandler.log(`${accountsNotInLut.length} accounts not in LUT:`);
189
186
  for (const key of accountsNotInLut) {
190
- this.client.log(key.toString());
187
+ this.txHandler.log(key.toString());
191
188
  }
192
189
  }
193
190
  }
194
191
  }
195
- async send(prioritySetting) {
196
- const updateLookupTable = await this.client.updateLookupTable();
192
+ async sendWithClient(items, client, prioritySetting) {
193
+ const updateLookupTable = await client.updateLookupTable();
197
194
  if (updateLookupTable &&
198
195
  updateLookupTable.updateLutTx.getInstructions().length > 0 &&
199
196
  updateLookupTable?.needsToBeIsolated) {
200
197
  this.updateStatus("update lookup table", TransactionStatus.Processing);
201
- await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum) => await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.client.umi, this.client.connection, updateLookupTable.updateLutTx, this.simulateOnly, attemptNum), 3, 150, this.errorsToThrow);
198
+ await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum) => await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.txHandler.umi, this.txHandler.connection, updateLookupTable.updateLutTx, this.simulateOnly, attemptNum), 3, 150, this.errorsToThrow);
202
199
  this.updateStatus("update lookup table", TransactionStatus.Successful);
203
200
  }
204
- for (const item of this.items) {
201
+ this.lookupTables.defaultLuts = client.defaultLookupTables();
202
+ for (const item of items) {
205
203
  await item.initialize();
206
204
  }
207
- const [choresBefore, choresAfter] = await (0, transactionUtils_1.getTransactionChores)(this.client, (0, umi_1.transactionBuilder)().add(this.items
205
+ const [choresBefore, choresAfter] = await (0, transactionUtils_1.getTransactionChores)(client, (0, umi_1.transactionBuilder)().add(items
208
206
  .filter((x) => x.tx && x.tx.getInstructions().length > 0)
209
207
  .map((x) => x.tx)));
210
208
  if (updateLookupTable && !updateLookupTable.needsToBeIsolated) {
@@ -213,16 +211,27 @@ class TransactionsManager {
213
211
  if (choresBefore.getInstructions().length > 0) {
214
212
  const chore = new TransactionItem(async () => ({ tx: choresBefore }), "create account(s)");
215
213
  await chore.initialize();
216
- this.items.unshift(chore);
217
- this.client.log("Chores before: ", choresBefore.getInstructions().length);
214
+ items.unshift(chore);
215
+ this.txHandler.log("Chores before: ", choresBefore.getInstructions().length);
218
216
  }
219
217
  if (choresAfter.getInstructions().length > 0) {
220
218
  const chore = new TransactionItem(async () => ({ tx: choresAfter }));
221
219
  await chore.initialize();
222
- this.items.push(chore);
223
- this.client.log("Chores after: ", choresAfter.getInstructions().length);
220
+ items.push(chore);
221
+ this.txHandler.log("Chores after: ", choresAfter.getInstructions().length);
224
222
  }
225
- const itemSets = await this.assembleTransactionSets(this.items);
223
+ await this.send(items, prioritySetting, true);
224
+ if (!this.simulateOnly) {
225
+ await client.resetLiveTxUpdates();
226
+ }
227
+ }
228
+ async send(items, prioritySetting, initialized) {
229
+ if (!initialized) {
230
+ for (const item of items) {
231
+ await item.initialize();
232
+ }
233
+ }
234
+ const itemSets = await this.assembleTransactionSets(items);
226
235
  const statusesStartIdx = this.statuses.length;
227
236
  for (const itemSet of itemSets) {
228
237
  this.updateStatus(itemSet.name(), TransactionStatus.Queued);
@@ -258,7 +267,7 @@ class TransactionsManager {
258
267
  name: x.name(),
259
268
  status: TransactionStatus.Queued,
260
269
  })));
261
- this.client.log(this.statuses);
270
+ this.txHandler.log(this.statuses);
262
271
  itemSets.splice(i + 1, itemSets.length - i - 1, ...newItemSets.slice(1));
263
272
  }
264
273
  return newItemSets.length > 0 ? newItemSets[0] : undefined;
@@ -278,18 +287,15 @@ class TransactionsManager {
278
287
  }
279
288
  else {
280
289
  this.updateStatus(itemSet.name(), TransactionStatus.Processing);
281
- if (this.client.localTest) {
290
+ if (this.txHandler.localTest) {
282
291
  await this.debugAccounts(itemSet, tx);
283
292
  }
284
- const txSig = await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.client.umi, this.client.connection, tx, this.simulateOnly, attemptNum, prioritySetting);
293
+ const txSig = await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.txHandler.umi, this.txHandler.connection, tx, this.simulateOnly, attemptNum, prioritySetting);
285
294
  this.updateStatus(itemSet.name(), TransactionStatus.Successful, txSig ? bs58_1.default.encode(txSig) : undefined);
286
295
  }
287
296
  }, 4, 150, this.errorsToThrow);
288
297
  }
289
298
  }
290
- if (!this.simulateOnly) {
291
- await this.client.resetLivePositionUpdates();
292
- }
293
299
  }
294
300
  }
295
301
  exports.TransactionsManager = TransactionsManager;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.83",
3
+ "version": "1.0.84",
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",
@@ -1,3 +1,4 @@
1
1
  export * from './solautoMarginfiClient';
2
2
  export * from './solautoClient';
3
- export * from './referralStateManager';
3
+ export * from './referralStateManager';
4
+ export * from './txHandler';
@@ -5,6 +5,7 @@ import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
5
5
  import { WalletAdapter, walletAdapterIdentity } from "@metaplex-foundation/umi-signer-wallet-adapters";
6
6
  import { claimReferralFees, createSolautoProgram, ReferralState, safeFetchReferralState, updateReferralStates } from "../generated";
7
7
  import { getReferralState, getSolanaRpcConnection, getTokenAccount } from "../utils";
8
+ import { TxHandler } from "./txHandler";
8
9
 
9
10
  interface ReferralStateManagerArgs {
10
11
  referralAuthority?: PublicKey;
@@ -12,7 +13,7 @@ interface ReferralStateManagerArgs {
12
13
  wallet?: WalletAdapter;
13
14
  }
14
15
 
15
- export class ReferralStateManager {
16
+ export class ReferralStateManager extends TxHandler {
16
17
  public umi!: Umi;
17
18
  public signer!: Signer;
18
19
 
@@ -20,9 +21,9 @@ export class ReferralStateManager {
20
21
  public referralState!: PublicKey;
21
22
  public referralStateData!: ReferralState | null;
22
23
 
23
- constructor(heliusApiKey: string) {
24
- const [_, umi] = getSolanaRpcConnection(heliusApiKey);
25
- this.umi = umi.use({
24
+ constructor(heliusApiKey: string, public localTest?: boolean) {
25
+ super(heliusApiKey, localTest)
26
+ this.umi = this.umi.use({
26
27
  install(umi) {
27
28
  umi.programs.add(createSolautoProgram(), false);
28
29
  },
@@ -44,6 +45,10 @@ export class ReferralStateManager {
44
45
  this.referralStateData = await safeFetchReferralState(this.umi, publicKey(this.referralState));
45
46
  }
46
47
 
48
+ defaultLookupTables(): string[] {
49
+ return this.referralStateData?.lookupTable ? [this.referralStateData?.lookupTable.toString()] : [];
50
+ }
51
+
47
52
  updateReferralStatesIx(destFeesMint?: PublicKey, referredBy?: PublicKey, lookupTable?: PublicKey): TransactionBuilder {
48
53
  return updateReferralStates(this.umi, {
49
54
  signer: this.signer,
@@ -85,4 +90,5 @@ export class ReferralStateManager {
85
90
  });
86
91
  }
87
92
 
93
+ async resetLiveTxUpdates(): Promise<void> { }
88
94
  }
@@ -59,6 +59,7 @@ import {
59
59
  import { currentUnixSeconds } from "../utils/generalUtils";
60
60
  import { LivePositionUpdates } from "../utils/solauto/generalUtils";
61
61
  import { ReferralStateManager } from "./referralStateManager";
62
+ import { TxHandler } from "./txHandler";
62
63
 
63
64
  export interface SolautoClientArgs {
64
65
  authority?: PublicKey;
@@ -72,10 +73,7 @@ export interface SolautoClientArgs {
72
73
  referredByAuthority?: PublicKey;
73
74
  }
74
75
 
75
- export abstract class SolautoClient {
76
- private heliusApiKey!: string;
77
- public umi!: Umi;
78
- public connection!: Connection;
76
+ export abstract class SolautoClient extends TxHandler {
79
77
  public lendingPlatform!: LendingPlatform;
80
78
 
81
79
  public authority!: PublicKey;
@@ -113,10 +111,9 @@ export abstract class SolautoClient {
113
111
  heliusApiKey: string,
114
112
  public localTest?: boolean
115
113
  ) {
116
- this.heliusApiKey = heliusApiKey;
117
- const [connection, umi] = getSolanaRpcConnection(this.heliusApiKey);
118
- this.connection = connection;
119
- this.umi = umi.use({
114
+ super(heliusApiKey, localTest);
115
+
116
+ this.umi = this.umi.use({
120
117
  install(umi) {
121
118
  umi.programs.add(createSolautoProgram(), false);
122
119
  },
@@ -230,13 +227,7 @@ export abstract class SolautoClient {
230
227
  );
231
228
  }
232
229
 
233
- log(...args: any[]): void {
234
- if (this.localTest) {
235
- console.log(...args);
236
- }
237
- }
238
-
239
- async resetLivePositionUpdates() {
230
+ async resetLiveTxUpdates() {
240
231
  if (!this.solautoPositionData) {
241
232
  this.solautoPositionData = await safeFetchSolautoPosition(
242
233
  this.umi,
@@ -259,7 +250,7 @@ export abstract class SolautoClient {
259
250
  abstract protocolAccount(): PublicKey;
260
251
 
261
252
  defaultLookupTables(): string[] {
262
- return [SOLAUTO_LUT];
253
+ return [SOLAUTO_LUT, ...(this.authorityLutAddress ? [this.authorityLutAddress.toString()] : [])];
263
254
  }
264
255
 
265
256
  lutAccountsToAdd(): PublicKey[] {
@@ -0,0 +1,28 @@
1
+ import { Umi } from "@metaplex-foundation/umi";
2
+ import { Connection } from "@solana/web3.js";
3
+ import { getSolanaRpcConnection } from "../utils";
4
+
5
+
6
+ export abstract class TxHandler {
7
+ public heliusApiKey!: string;
8
+ public umi!: Umi;
9
+ public connection!: Connection;
10
+
11
+ constructor(heliusApiKey: string,
12
+ public localTest?: boolean) {
13
+ this.heliusApiKey = heliusApiKey;
14
+ const [connection, umi] = getSolanaRpcConnection(this.heliusApiKey);
15
+ this.connection = connection;
16
+ this.umi = umi;
17
+ }
18
+
19
+ log(...args: any[]): void {
20
+ if (this.localTest) {
21
+ console.log(...args);
22
+ }
23
+ }
24
+
25
+ abstract defaultLookupTables(): string[];
26
+
27
+ abstract resetLiveTxUpdates(): Promise<void>;
28
+ }
@@ -565,10 +565,8 @@ export async function buildSolautoRebalanceTransaction(
565
565
  (targetLiqUtilizationRateBps === undefined &&
566
566
  !eligibleForRebalance(
567
567
  client.solautoPositionState!,
568
- client.livePositionUpdates.settings ??
569
- client.solautoPositionData?.position.settingParams!,
570
- client.livePositionUpdates.activeDca ??
571
- client.solautoPositionData?.position.dca!,
568
+ client.solautoPositionSettings()!,
569
+ client.solautoPositionActiveDca()!,
572
570
  currentUnixSeconds()
573
571
  ))
574
572
  ) {
@@ -3,6 +3,7 @@ import {
3
3
  AddressLookupTableInput,
4
4
  transactionBuilder,
5
5
  TransactionBuilder,
6
+ Umi,
6
7
  } from "@metaplex-foundation/umi";
7
8
  import { SolautoClient } from "../clients/solautoClient";
8
9
  import {
@@ -15,14 +16,14 @@ import {
15
16
  } from "../utils/generalUtils";
16
17
  import { getTransactionChores } from "./transactionUtils";
17
18
  import { PriorityFeeSetting } from "../types";
19
+ import { Connection, PublicKey } from "@solana/web3.js";
20
+ import { TxHandler } from "../clients";
18
21
  // import { sendJitoBundledTransactions } from "../utils/jitoUtils";
19
22
 
20
23
  class LookupTables {
21
- defaultLuts: string[] = [];
22
24
  cache: AddressLookupTableInput[] = [];
23
25
 
24
- constructor(private client: SolautoClient) {
25
- this.defaultLuts = [...client.defaultLookupTables()];
26
+ constructor(public defaultLuts: string[], private umi: Umi) {
26
27
  }
27
28
 
28
29
  async getLutInputs(
@@ -30,7 +31,6 @@ class LookupTables {
30
31
  ): Promise<AddressLookupTableInput[]> {
31
32
  const addresses = [
32
33
  ...this.defaultLuts,
33
- this.client.authorityLutAddress!.toString(),
34
34
  ...additionalAddresses,
35
35
  ];
36
36
  const currentCacheAddresses = this.cache.map((x) => x.publicKey.toString());
@@ -40,7 +40,7 @@ class LookupTables {
40
40
  );
41
41
  if (missingAddresses) {
42
42
  const additionalInputs = await getAdressLookupInputs(
43
- this.client.umi,
43
+ this.umi,
44
44
  missingAddresses
45
45
  );
46
46
  this.cache.push(...additionalInputs);
@@ -61,7 +61,7 @@ export class TransactionItem {
61
61
  { tx: TransactionBuilder; lookupTableAddresses?: string[] } | undefined
62
62
  >,
63
63
  public name?: string
64
- ) {}
64
+ ) { }
65
65
 
66
66
  async initialize() {
67
67
  await this.refetch(0);
@@ -89,10 +89,10 @@ export class TransactionItem {
89
89
 
90
90
  class TransactionSet {
91
91
  constructor(
92
- private client: SolautoClient,
92
+ private txHandler: TxHandler,
93
93
  public lookupTables: LookupTables,
94
94
  public items: TransactionItem[] = []
95
- ) {}
95
+ ) { }
96
96
 
97
97
  async fitsWith(item: TransactionItem): Promise<boolean> {
98
98
  if (!item.tx) {
@@ -117,7 +117,7 @@ class TransactionSet {
117
117
  ...item.lookupTableAddresses,
118
118
  ])
119
119
  )
120
- .fitsInOneTransaction(this.client.umi);
120
+ .fitsInOneTransaction(this.txHandler.umi);
121
121
  }
122
122
 
123
123
  add(...items: TransactionItem[]) {
@@ -127,7 +127,7 @@ class TransactionSet {
127
127
  }
128
128
 
129
129
  async refetchAll(attemptNum: number) {
130
- await this.client.resetLivePositionUpdates();
130
+ await this.txHandler.resetLiveTxUpdates();
131
131
  for (const item of this.items) {
132
132
  await item.refetch(attemptNum);
133
133
  }
@@ -183,23 +183,22 @@ export class TransactionsManager {
183
183
  private lookupTables: LookupTables;
184
184
 
185
185
  constructor(
186
- private client: SolautoClient,
187
- private items: TransactionItem[],
186
+ private txHandler: TxHandler,
188
187
  private statusCallback?: (statuses: TransactionManagerStatuses) => void,
189
188
  private simulateOnly?: boolean,
190
189
  private mustBeAtomic?: boolean,
191
190
  private errorsToThrow?: ErrorsToThrow
192
191
  ) {
193
- this.lookupTables = new LookupTables(client);
192
+ this.lookupTables = new LookupTables(this.txHandler.defaultLookupTables(), this.txHandler.umi);
194
193
  }
195
194
 
196
195
  private async assembleTransactionSets(
197
196
  items: TransactionItem[]
198
197
  ): Promise<TransactionSet[]> {
199
198
  let transactionSets: TransactionSet[] = [];
200
- this.client.log(`Reassembling ${items.length} items`);
199
+ this.txHandler.log(`Reassembling ${items.length} items`);
201
200
 
202
- for (let i = 0; i < items.length; ) {
201
+ for (let i = 0; i < items.length;) {
203
202
  let item = items[i];
204
203
  i++;
205
204
 
@@ -210,12 +209,12 @@ export class TransactionsManager {
210
209
  const transaction = item.tx.setAddressLookupTables(
211
210
  await this.lookupTables.getLutInputs(item.lookupTableAddresses)
212
211
  );
213
- if (!transaction.fitsInOneTransaction(this.client.umi)) {
212
+ if (!transaction.fitsInOneTransaction(this.txHandler.umi)) {
214
213
  throw new Error(
215
- `Transaction exceeds max transaction size (${transaction.getTransactionSize(this.client.umi)})`
214
+ `Transaction exceeds max transaction size (${transaction.getTransactionSize(this.txHandler.umi)})`
216
215
  );
217
216
  } else {
218
- let newSet = new TransactionSet(this.client, this.lookupTables, [item]);
217
+ let newSet = new TransactionSet(this.txHandler, this.lookupTables, [item]);
219
218
  for (let j = i; j < items.length; j++) {
220
219
  if (await newSet.fitsWith(items[j])) {
221
220
  newSet.add(items[j]);
@@ -243,7 +242,7 @@ export class TransactionsManager {
243
242
  this.statuses.push({ name, status, txSig });
244
243
  }
245
244
  }
246
- this.client.log(`${name} is ${status.toString().toLowerCase()}`);
245
+ this.txHandler.log(`${name} is ${status.toString().toLowerCase()}`);
247
246
  this.statusCallback?.(this.statuses);
248
247
  }
249
248
 
@@ -256,18 +255,18 @@ export class TransactionsManager {
256
255
  const accountsNotInLut = ixAccounts.filter(
257
256
  (x) => !lutAccounts.includes(x)
258
257
  );
259
- this.client.log(`Program ${ix.programId}, data len: ${ix.data.length}, LUT accounts data: ${ix.keys.filter((x) => lutAccounts.includes(x.pubkey)).length * 3}`);
258
+ this.txHandler.log(`Program ${ix.programId}, data len: ${ix.data.length}, LUT accounts data: ${ix.keys.filter((x) => lutAccounts.includes(x.pubkey)).length * 3}`);
260
259
  if (accountsNotInLut.length > 0) {
261
- this.client.log(`${accountsNotInLut.length} accounts not in LUT:`);
260
+ this.txHandler.log(`${accountsNotInLut.length} accounts not in LUT:`);
262
261
  for (const key of accountsNotInLut) {
263
- this.client.log(key.toString());
262
+ this.txHandler.log(key.toString());
264
263
  }
265
264
  }
266
265
  }
267
266
  }
268
267
 
269
- async send(prioritySetting?: PriorityFeeSetting) {
270
- const updateLookupTable = await this.client.updateLookupTable();
268
+ async sendWithClient(items: TransactionItem[], client: SolautoClient, prioritySetting?: PriorityFeeSetting) {
269
+ const updateLookupTable = await client.updateLookupTable();
271
270
  if (
272
271
  updateLookupTable &&
273
272
  updateLookupTable.updateLutTx.getInstructions().length > 0 &&
@@ -277,8 +276,8 @@ export class TransactionsManager {
277
276
  await retryWithExponentialBackoff(
278
277
  async (attemptNum) =>
279
278
  await sendSingleOptimizedTransaction(
280
- this.client.umi,
281
- this.client.connection,
279
+ this.txHandler.umi,
280
+ this.txHandler.connection,
282
281
  updateLookupTable.updateLutTx,
283
282
  this.simulateOnly,
284
283
  attemptNum
@@ -290,14 +289,16 @@ export class TransactionsManager {
290
289
  this.updateStatus("update lookup table", TransactionStatus.Successful);
291
290
  }
292
291
 
293
- for (const item of this.items) {
292
+ this.lookupTables.defaultLuts = client.defaultLookupTables();
293
+
294
+ for (const item of items) {
294
295
  await item.initialize();
295
296
  }
296
297
 
297
298
  const [choresBefore, choresAfter] = await getTransactionChores(
298
- this.client,
299
+ client,
299
300
  transactionBuilder().add(
300
- this.items
301
+ items
301
302
  .filter((x) => x.tx && x.tx.getInstructions().length > 0)
302
303
  .map((x) => x.tx!)
303
304
  )
@@ -311,17 +312,31 @@ export class TransactionsManager {
311
312
  "create account(s)"
312
313
  );
313
314
  await chore.initialize();
314
- this.items.unshift(chore);
315
- this.client.log("Chores before: ", choresBefore.getInstructions().length);
315
+ items.unshift(chore);
316
+ this.txHandler.log("Chores before: ", choresBefore.getInstructions().length);
316
317
  }
317
318
  if (choresAfter.getInstructions().length > 0) {
318
319
  const chore = new TransactionItem(async () => ({ tx: choresAfter }));
319
320
  await chore.initialize();
320
- this.items.push(chore);
321
- this.client.log("Chores after: ", choresAfter.getInstructions().length);
321
+ items.push(chore);
322
+ this.txHandler.log("Chores after: ", choresAfter.getInstructions().length);
322
323
  }
323
324
 
324
- const itemSets = await this.assembleTransactionSets(this.items);
325
+ await this.send(items, prioritySetting, true);
326
+
327
+ if (!this.simulateOnly) {
328
+ await client.resetLiveTxUpdates();
329
+ }
330
+ }
331
+
332
+ async send(items: TransactionItem[], prioritySetting?: PriorityFeeSetting, initialized?: boolean) {
333
+ if (!initialized) {
334
+ for (const item of items) {
335
+ await item.initialize();
336
+ }
337
+ }
338
+
339
+ const itemSets = await this.assembleTransactionSets(items);
325
340
  const statusesStartIdx = this.statuses.length;
326
341
  for (const itemSet of itemSets) {
327
342
  this.updateStatus(itemSet.name(), TransactionStatus.Queued);
@@ -366,7 +381,7 @@ export class TransactionsManager {
366
381
  status: TransactionStatus.Queued,
367
382
  }))
368
383
  );
369
- this.client.log(this.statuses);
384
+ this.txHandler.log(this.statuses);
370
385
  itemSets.splice(
371
386
  i + 1,
372
387
  itemSets.length - i - 1,
@@ -393,13 +408,13 @@ export class TransactionsManager {
393
408
  } else {
394
409
  this.updateStatus(itemSet.name(), TransactionStatus.Processing);
395
410
 
396
- if (this.client.localTest) {
411
+ if (this.txHandler.localTest) {
397
412
  await this.debugAccounts(itemSet, tx);
398
413
  }
399
414
 
400
415
  const txSig = await sendSingleOptimizedTransaction(
401
- this.client.umi,
402
- this.client.connection,
416
+ this.txHandler.umi,
417
+ this.txHandler.connection,
403
418
  tx,
404
419
  this.simulateOnly,
405
420
  attemptNum,
@@ -418,9 +433,5 @@ export class TransactionsManager {
418
433
  );
419
434
  }
420
435
  }
421
-
422
- if (!this.simulateOnly) {
423
- await this.client.resetLivePositionUpdates();
424
- }
425
436
  }
426
437
  }
@@ -66,19 +66,19 @@ describe("Solauto Marginfi tests", async () => {
66
66
  // }, "open position")
67
67
  // );
68
68
 
69
- // const initialSupplyUsd = 150;
70
- // transactionItems.push(
71
- // new TransactionItem(async () => {
72
- // const [supplyPrice] = await getTokenPrices([supply]);
73
- // return {
74
- // tx: client.protocolInteraction(
75
- // solautoAction("Deposit", [
76
- // toBaseUnit(initialSupplyUsd / supplyPrice, supplyDecimals),
77
- // ])
78
- // ),
79
- // };
80
- // }, "deposit")
81
- // );
69
+ // const initialSupplyUsd = 150;
70
+ // transactionItems.push(
71
+ // new TransactionItem(async () => {
72
+ // const [supplyPrice] = await getTokenPrices([supply]);
73
+ // return {
74
+ // tx: client.protocolInteraction(
75
+ // solautoAction("Deposit", [
76
+ // toBaseUnit(initialSupplyUsd / supplyPrice, supplyDecimals),
77
+ // ])
78
+ // ),
79
+ // };
80
+ // }, "deposit")
81
+ // );
82
82
  // }
83
83
 
84
84
  // const maxLtvBps = client.solautoPositionState!.maxLtvBps;
@@ -118,7 +118,7 @@ describe("Solauto Marginfi tests", async () => {
118
118
  // };
119
119
  // }, "deposit")
120
120
  // );
121
-
121
+
122
122
  transactionItems.push(
123
123
  new TransactionItem(
124
124
  async (attemptNum) =>
@@ -156,10 +156,9 @@ describe("Solauto Marginfi tests", async () => {
156
156
 
157
157
  await new TransactionsManager(
158
158
  client,
159
- transactionItems,
160
159
  undefined,
161
160
  !payForTransactions,
162
161
  useJitoBundle
163
- ).send();
162
+ ).sendWithClient(transactionItems, client);
164
163
  });
165
164
  });