@haven-fi/solauto-sdk 1.0.83 → 1.0.85
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.
- package/dist/clients/index.d.ts +1 -0
- package/dist/clients/index.d.ts.map +1 -1
- package/dist/clients/index.js +1 -0
- package/dist/clients/referralStateManager.d.ts +6 -2
- package/dist/clients/referralStateManager.d.ts.map +1 -1
- package/dist/clients/referralStateManager.js +10 -4
- package/dist/clients/solautoClient.d.ts +5 -8
- package/dist/clients/solautoClient.d.ts.map +1 -1
- package/dist/clients/solautoClient.js +6 -12
- package/dist/clients/txHandler.d.ts +13 -0
- package/dist/clients/txHandler.d.ts.map +1 -0
- package/dist/clients/txHandler.js +19 -0
- package/dist/transactions/transactionUtils.d.ts.map +1 -1
- package/dist/transactions/transactionUtils.js +1 -3
- package/dist/transactions/transactionsManager.d.ts +10 -9
- package/dist/transactions/transactionsManager.d.ts.map +1 -1
- package/dist/transactions/transactionsManager.js +45 -38
- package/package.json +1 -1
- package/src/clients/index.ts +2 -1
- package/src/clients/referralStateManager.ts +10 -4
- package/src/clients/solautoClient.ts +7 -16
- package/src/clients/txHandler.ts +28 -0
- package/src/transactions/transactionUtils.ts +2 -4
- package/src/transactions/transactionsManager.ts +55 -42
- package/tests/transactions/solautoMarginfi.ts +15 -16
package/dist/clients/index.d.ts
CHANGED
|
@@ -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"}
|
package/dist/clients/index.js
CHANGED
|
@@ -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;
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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 {
|
|
3
|
-
import { Signer, TransactionBuilder
|
|
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
|
-
|
|
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,
|
|
1
|
+
{"version":3,"file":"solautoClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoClient.ts"],"names":[],"mappings":"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"}
|
|
@@ -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
|
-
|
|
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.
|
|
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
|
-
|
|
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,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CA8G7B;AAkLD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,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,
|
|
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,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CA8G7B;AAkLD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,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.
|
|
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 { ReferralStateManager, TxHandler } from "../clients";
|
|
5
6
|
declare class LookupTables {
|
|
6
|
-
private client;
|
|
7
7
|
defaultLuts: string[];
|
|
8
|
+
private umi;
|
|
8
9
|
cache: AddressLookupTableInput[];
|
|
9
|
-
constructor(
|
|
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
|
|
30
|
+
private txHandler;
|
|
30
31
|
lookupTables: LookupTables;
|
|
31
32
|
items: TransactionItem[];
|
|
32
|
-
constructor(
|
|
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
|
|
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(
|
|
60
|
+
constructor(txHandler: SolautoClient | ReferralStateManager, 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
|
-
|
|
64
|
+
clientSend(items: TransactionItem[], 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,
|
|
1
|
+
{"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"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"}
|
|
@@ -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(
|
|
15
|
-
this.
|
|
16
|
-
this.
|
|
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.
|
|
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(
|
|
60
|
-
this.
|
|
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.
|
|
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.
|
|
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(
|
|
124
|
-
this.
|
|
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(
|
|
128
|
+
this.lookupTables = new LookupTables(this.txHandler.defaultLookupTables(), this.txHandler.umi);
|
|
132
129
|
}
|
|
133
130
|
async assembleTransactionSets(items) {
|
|
134
131
|
let transactionSets = [];
|
|
135
|
-
this.
|
|
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.
|
|
144
|
-
throw new Error(`Transaction exceeds max transaction size (${transaction.getTransactionSize(this.
|
|
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.
|
|
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.
|
|
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,30 @@ 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.
|
|
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.
|
|
185
|
+
this.txHandler.log(`${accountsNotInLut.length} accounts not in LUT:`);
|
|
189
186
|
for (const key of accountsNotInLut) {
|
|
190
|
-
this.
|
|
187
|
+
this.txHandler.log(key.toString());
|
|
191
188
|
}
|
|
192
189
|
}
|
|
193
190
|
}
|
|
194
191
|
}
|
|
195
|
-
async
|
|
196
|
-
const
|
|
192
|
+
async clientSend(items, prioritySetting) {
|
|
193
|
+
const client = this.txHandler;
|
|
194
|
+
const updateLookupTable = await client.updateLookupTable();
|
|
197
195
|
if (updateLookupTable &&
|
|
198
196
|
updateLookupTable.updateLutTx.getInstructions().length > 0 &&
|
|
199
197
|
updateLookupTable?.needsToBeIsolated) {
|
|
200
198
|
this.updateStatus("update lookup table", TransactionStatus.Processing);
|
|
201
|
-
await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum) => await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.
|
|
199
|
+
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
200
|
this.updateStatus("update lookup table", TransactionStatus.Successful);
|
|
203
201
|
}
|
|
204
|
-
|
|
202
|
+
this.lookupTables.defaultLuts = client.defaultLookupTables();
|
|
203
|
+
for (const item of items) {
|
|
205
204
|
await item.initialize();
|
|
206
205
|
}
|
|
207
|
-
const [choresBefore, choresAfter] = await (0, transactionUtils_1.getTransactionChores)(
|
|
206
|
+
const [choresBefore, choresAfter] = await (0, transactionUtils_1.getTransactionChores)(client, (0, umi_1.transactionBuilder)().add(items
|
|
208
207
|
.filter((x) => x.tx && x.tx.getInstructions().length > 0)
|
|
209
208
|
.map((x) => x.tx)));
|
|
210
209
|
if (updateLookupTable && !updateLookupTable.needsToBeIsolated) {
|
|
@@ -213,16 +212,27 @@ class TransactionsManager {
|
|
|
213
212
|
if (choresBefore.getInstructions().length > 0) {
|
|
214
213
|
const chore = new TransactionItem(async () => ({ tx: choresBefore }), "create account(s)");
|
|
215
214
|
await chore.initialize();
|
|
216
|
-
|
|
217
|
-
this.
|
|
215
|
+
items.unshift(chore);
|
|
216
|
+
this.txHandler.log("Chores before: ", choresBefore.getInstructions().length);
|
|
218
217
|
}
|
|
219
218
|
if (choresAfter.getInstructions().length > 0) {
|
|
220
219
|
const chore = new TransactionItem(async () => ({ tx: choresAfter }));
|
|
221
220
|
await chore.initialize();
|
|
222
|
-
|
|
223
|
-
this.
|
|
221
|
+
items.push(chore);
|
|
222
|
+
this.txHandler.log("Chores after: ", choresAfter.getInstructions().length);
|
|
224
223
|
}
|
|
225
|
-
|
|
224
|
+
await this.send(items, prioritySetting, true);
|
|
225
|
+
if (!this.simulateOnly) {
|
|
226
|
+
await client.resetLiveTxUpdates();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
async send(items, prioritySetting, initialized) {
|
|
230
|
+
if (!initialized) {
|
|
231
|
+
for (const item of items) {
|
|
232
|
+
await item.initialize();
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
const itemSets = await this.assembleTransactionSets(items);
|
|
226
236
|
const statusesStartIdx = this.statuses.length;
|
|
227
237
|
for (const itemSet of itemSets) {
|
|
228
238
|
this.updateStatus(itemSet.name(), TransactionStatus.Queued);
|
|
@@ -258,7 +268,7 @@ class TransactionsManager {
|
|
|
258
268
|
name: x.name(),
|
|
259
269
|
status: TransactionStatus.Queued,
|
|
260
270
|
})));
|
|
261
|
-
this.
|
|
271
|
+
this.txHandler.log(this.statuses);
|
|
262
272
|
itemSets.splice(i + 1, itemSets.length - i - 1, ...newItemSets.slice(1));
|
|
263
273
|
}
|
|
264
274
|
return newItemSets.length > 0 ? newItemSets[0] : undefined;
|
|
@@ -278,18 +288,15 @@ class TransactionsManager {
|
|
|
278
288
|
}
|
|
279
289
|
else {
|
|
280
290
|
this.updateStatus(itemSet.name(), TransactionStatus.Processing);
|
|
281
|
-
if (this.
|
|
291
|
+
if (this.txHandler.localTest) {
|
|
282
292
|
await this.debugAccounts(itemSet, tx);
|
|
283
293
|
}
|
|
284
|
-
const txSig = await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.
|
|
294
|
+
const txSig = await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.txHandler.umi, this.txHandler.connection, tx, this.simulateOnly, attemptNum, prioritySetting);
|
|
285
295
|
this.updateStatus(itemSet.name(), TransactionStatus.Successful, txSig ? bs58_1.default.encode(txSig) : undefined);
|
|
286
296
|
}
|
|
287
297
|
}, 4, 150, this.errorsToThrow);
|
|
288
298
|
}
|
|
289
299
|
}
|
|
290
|
-
if (!this.simulateOnly) {
|
|
291
|
-
await this.client.resetLivePositionUpdates();
|
|
292
|
-
}
|
|
293
300
|
}
|
|
294
301
|
}
|
|
295
302
|
exports.TransactionsManager = TransactionsManager;
|
package/package.json
CHANGED
package/src/clients/index.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
117
|
-
|
|
118
|
-
this.
|
|
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
|
-
|
|
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.
|
|
569
|
-
client.
|
|
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 { ReferralStateManager, 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
|
|
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.
|
|
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
|
|
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.
|
|
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.
|
|
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
|
|
187
|
-
private items: TransactionItem[],
|
|
186
|
+
private txHandler: SolautoClient | ReferralStateManager,
|
|
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(
|
|
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.
|
|
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.
|
|
212
|
+
if (!transaction.fitsInOneTransaction(this.txHandler.umi)) {
|
|
214
213
|
throw new Error(
|
|
215
|
-
`Transaction exceeds max transaction size (${transaction.getTransactionSize(this.
|
|
214
|
+
`Transaction exceeds max transaction size (${transaction.getTransactionSize(this.txHandler.umi)})`
|
|
216
215
|
);
|
|
217
216
|
} else {
|
|
218
|
-
let newSet = new TransactionSet(this.
|
|
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.
|
|
245
|
+
this.txHandler.log(`${name} is ${status.toString().toLowerCase()}`);
|
|
247
246
|
this.statusCallback?.(this.statuses);
|
|
248
247
|
}
|
|
249
248
|
|
|
@@ -256,18 +255,20 @@ export class TransactionsManager {
|
|
|
256
255
|
const accountsNotInLut = ixAccounts.filter(
|
|
257
256
|
(x) => !lutAccounts.includes(x)
|
|
258
257
|
);
|
|
259
|
-
this.
|
|
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.
|
|
260
|
+
this.txHandler.log(`${accountsNotInLut.length} accounts not in LUT:`);
|
|
262
261
|
for (const key of accountsNotInLut) {
|
|
263
|
-
this.
|
|
262
|
+
this.txHandler.log(key.toString());
|
|
264
263
|
}
|
|
265
264
|
}
|
|
266
265
|
}
|
|
267
266
|
}
|
|
268
267
|
|
|
269
|
-
async
|
|
270
|
-
const
|
|
268
|
+
async clientSend(items: TransactionItem[], prioritySetting?: PriorityFeeSetting) {
|
|
269
|
+
const client = this.txHandler as SolautoClient;
|
|
270
|
+
|
|
271
|
+
const updateLookupTable = await client.updateLookupTable();
|
|
271
272
|
if (
|
|
272
273
|
updateLookupTable &&
|
|
273
274
|
updateLookupTable.updateLutTx.getInstructions().length > 0 &&
|
|
@@ -277,8 +278,8 @@ export class TransactionsManager {
|
|
|
277
278
|
await retryWithExponentialBackoff(
|
|
278
279
|
async (attemptNum) =>
|
|
279
280
|
await sendSingleOptimizedTransaction(
|
|
280
|
-
this.
|
|
281
|
-
this.
|
|
281
|
+
this.txHandler.umi,
|
|
282
|
+
this.txHandler.connection,
|
|
282
283
|
updateLookupTable.updateLutTx,
|
|
283
284
|
this.simulateOnly,
|
|
284
285
|
attemptNum
|
|
@@ -290,14 +291,16 @@ export class TransactionsManager {
|
|
|
290
291
|
this.updateStatus("update lookup table", TransactionStatus.Successful);
|
|
291
292
|
}
|
|
292
293
|
|
|
293
|
-
|
|
294
|
+
this.lookupTables.defaultLuts = client.defaultLookupTables();
|
|
295
|
+
|
|
296
|
+
for (const item of items) {
|
|
294
297
|
await item.initialize();
|
|
295
298
|
}
|
|
296
299
|
|
|
297
300
|
const [choresBefore, choresAfter] = await getTransactionChores(
|
|
298
|
-
|
|
301
|
+
client,
|
|
299
302
|
transactionBuilder().add(
|
|
300
|
-
|
|
303
|
+
items
|
|
301
304
|
.filter((x) => x.tx && x.tx.getInstructions().length > 0)
|
|
302
305
|
.map((x) => x.tx!)
|
|
303
306
|
)
|
|
@@ -311,17 +314,31 @@ export class TransactionsManager {
|
|
|
311
314
|
"create account(s)"
|
|
312
315
|
);
|
|
313
316
|
await chore.initialize();
|
|
314
|
-
|
|
315
|
-
this.
|
|
317
|
+
items.unshift(chore);
|
|
318
|
+
this.txHandler.log("Chores before: ", choresBefore.getInstructions().length);
|
|
316
319
|
}
|
|
317
320
|
if (choresAfter.getInstructions().length > 0) {
|
|
318
321
|
const chore = new TransactionItem(async () => ({ tx: choresAfter }));
|
|
319
322
|
await chore.initialize();
|
|
320
|
-
|
|
321
|
-
this.
|
|
323
|
+
items.push(chore);
|
|
324
|
+
this.txHandler.log("Chores after: ", choresAfter.getInstructions().length);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
await this.send(items, prioritySetting, true);
|
|
328
|
+
|
|
329
|
+
if (!this.simulateOnly) {
|
|
330
|
+
await client.resetLiveTxUpdates();
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
async send(items: TransactionItem[], prioritySetting?: PriorityFeeSetting, initialized?: boolean) {
|
|
335
|
+
if (!initialized) {
|
|
336
|
+
for (const item of items) {
|
|
337
|
+
await item.initialize();
|
|
338
|
+
}
|
|
322
339
|
}
|
|
323
340
|
|
|
324
|
-
const itemSets = await this.assembleTransactionSets(
|
|
341
|
+
const itemSets = await this.assembleTransactionSets(items);
|
|
325
342
|
const statusesStartIdx = this.statuses.length;
|
|
326
343
|
for (const itemSet of itemSets) {
|
|
327
344
|
this.updateStatus(itemSet.name(), TransactionStatus.Queued);
|
|
@@ -366,7 +383,7 @@ export class TransactionsManager {
|
|
|
366
383
|
status: TransactionStatus.Queued,
|
|
367
384
|
}))
|
|
368
385
|
);
|
|
369
|
-
this.
|
|
386
|
+
this.txHandler.log(this.statuses);
|
|
370
387
|
itemSets.splice(
|
|
371
388
|
i + 1,
|
|
372
389
|
itemSets.length - i - 1,
|
|
@@ -393,13 +410,13 @@ export class TransactionsManager {
|
|
|
393
410
|
} else {
|
|
394
411
|
this.updateStatus(itemSet.name(), TransactionStatus.Processing);
|
|
395
412
|
|
|
396
|
-
if (this.
|
|
413
|
+
if (this.txHandler.localTest) {
|
|
397
414
|
await this.debugAccounts(itemSet, tx);
|
|
398
415
|
}
|
|
399
416
|
|
|
400
417
|
const txSig = await sendSingleOptimizedTransaction(
|
|
401
|
-
this.
|
|
402
|
-
this.
|
|
418
|
+
this.txHandler.umi,
|
|
419
|
+
this.txHandler.connection,
|
|
403
420
|
tx,
|
|
404
421
|
this.simulateOnly,
|
|
405
422
|
attemptNum,
|
|
@@ -418,9 +435,5 @@ export class TransactionsManager {
|
|
|
418
435
|
);
|
|
419
436
|
}
|
|
420
437
|
}
|
|
421
|
-
|
|
422
|
-
if (!this.simulateOnly) {
|
|
423
|
-
await this.client.resetLivePositionUpdates();
|
|
424
|
-
}
|
|
425
438
|
}
|
|
426
439
|
}
|
|
@@ -66,19 +66,19 @@ describe("Solauto Marginfi tests", async () => {
|
|
|
66
66
|
// }, "open position")
|
|
67
67
|
// );
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
).
|
|
162
|
+
).clientSend(transactionItems);
|
|
164
163
|
});
|
|
165
164
|
});
|