@haven-fi/solauto-sdk 1.0.114 → 1.0.116
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/clients/referralStateManager.d.ts +1 -1
- package/dist/clients/referralStateManager.d.ts.map +1 -1
- package/dist/clients/referralStateManager.js +1 -1
- package/dist/clients/solautoClient.d.ts +1 -1
- package/dist/clients/solautoClient.d.ts.map +1 -1
- package/dist/clients/solautoClient.js +14 -12
- package/dist/clients/solautoMarginfiClient.d.ts.map +1 -1
- package/dist/clients/solautoMarginfiClient.js +1 -4
- package/dist/clients/txHandler.d.ts +1 -1
- package/dist/clients/txHandler.d.ts.map +1 -1
- package/dist/transactions/transactionUtils.d.ts.map +1 -1
- package/dist/transactions/transactionUtils.js +1 -0
- package/dist/transactions/transactionsManager.d.ts +8 -8
- package/dist/transactions/transactionsManager.d.ts.map +1 -1
- package/dist/transactions/transactionsManager.js +19 -17
- package/dist/types/solauto.d.ts +1 -0
- package/dist/types/solauto.d.ts.map +1 -1
- package/dist/utils/solanaUtils.d.ts +2 -2
- package/dist/utils/solanaUtils.d.ts.map +1 -1
- package/dist/utils/solanaUtils.js +8 -6
- package/dist/utils/solauto/rebalanceUtils.d.ts.map +1 -1
- package/local/updateSolautoLUT.ts +3 -1
- package/package.json +1 -1
- package/src/clients/referralStateManager.ts +1 -1
- package/src/clients/solautoClient.ts +17 -15
- package/src/clients/solautoMarginfiClient.ts +1 -4
- package/src/clients/txHandler.ts +1 -1
- package/src/transactions/transactionUtils.ts +1 -0
- package/src/transactions/transactionsManager.ts +60 -30
- package/src/types/solauto.ts +3 -1
- package/src/utils/solanaUtils.ts +28 -26
- package/src/utils/solauto/rebalanceUtils.ts +0 -1
- package/tests/transactions/solautoMarginfi.ts +10 -6
@@ -20,7 +20,7 @@ export declare class ReferralStateManager extends TxHandler {
|
|
20
20
|
defaultLookupTables(): string[];
|
21
21
|
updateReferralStatesIx(destFeesMint?: PublicKey, referredBy?: PublicKey, lookupTable?: PublicKey): TransactionBuilder;
|
22
22
|
claimReferralFeesIx(destFeesMint?: PublicKey): TransactionBuilder;
|
23
|
-
resetLiveTxUpdates(): Promise<void>;
|
23
|
+
resetLiveTxUpdates(success?: boolean): Promise<void>;
|
24
24
|
}
|
25
25
|
export {};
|
26
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;AAEpI,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,UAAU,wBAAwB;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,iBAAiB,CAAC,EAAE,SAAS,CAAC;CACjC;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,
|
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,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,iBAAiB,CAAC,EAAE,SAAS,CAAC;CACjC;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,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAC7D"}
|
@@ -43,7 +43,7 @@ export declare abstract class SolautoClient extends TxHandler {
|
|
43
43
|
livePositionUpdates: LivePositionUpdates;
|
44
44
|
constructor(heliusApiKey: string, localTest?: boolean | undefined);
|
45
45
|
initialize(args: SolautoClientArgs, lendingPlatform: LendingPlatform): Promise<void>;
|
46
|
-
resetLiveTxUpdates(): Promise<void>;
|
46
|
+
resetLiveTxUpdates(success?: boolean): Promise<void>;
|
47
47
|
abstract protocolAccount(): PublicKey;
|
48
48
|
defaultLookupTables(): string[];
|
49
49
|
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,SAAS,EACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,MAAM,EACN,kBAAkB,EAOnB,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,yBAAyB,EACzB,gCAAgC,EAChC,sBAAsB,EAMvB,MAAM,cAAc,CAAC;AAStB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAKvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAMnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,aAAa,CAAC;IAEvB,UAAU,CAAC,EAAE,SAAS,CAAC;I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,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;CAalE"}
|
@@ -87,20 +87,22 @@ class SolautoClient extends txHandler_1.TxHandler {
|
|
87
87
|
? this.solautoPositionData?.position?.dca
|
88
88
|
: undefined);
|
89
89
|
}
|
90
|
-
async resetLiveTxUpdates() {
|
91
|
-
if (
|
92
|
-
this.solautoPositionData
|
93
|
-
|
94
|
-
else {
|
95
|
-
if (this.livePositionUpdates.activeDca) {
|
96
|
-
this.solautoPositionData.position.dca =
|
97
|
-
this.livePositionUpdates.activeDca;
|
90
|
+
async resetLiveTxUpdates(success) {
|
91
|
+
if (success) {
|
92
|
+
if (!this.solautoPositionData) {
|
93
|
+
this.solautoPositionData = await (0, generated_1.safeFetchSolautoPosition)(this.umi, (0, umi_1.publicKey)(this.solautoPosition));
|
98
94
|
}
|
99
|
-
|
100
|
-
this.
|
101
|
-
this.
|
95
|
+
else {
|
96
|
+
if (this.livePositionUpdates.activeDca) {
|
97
|
+
this.solautoPositionData.position.dca =
|
98
|
+
this.livePositionUpdates.activeDca;
|
99
|
+
}
|
100
|
+
if (this.livePositionUpdates.settings) {
|
101
|
+
this.solautoPositionData.position.settingParams =
|
102
|
+
this.livePositionUpdates.settings;
|
103
|
+
}
|
104
|
+
// All other live position updates can be derived by getting a fresh position state, so we don't need to do anything else form livePositionUpdates
|
102
105
|
}
|
103
|
-
// All other live position updates can be derived by getting a fresh position state, so we don't need to do anything else form livePositionUpdates
|
104
106
|
}
|
105
107
|
this.livePositionUpdates.reset();
|
106
108
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solautoMarginfiClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoMarginfiClient.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,MAAM,EACN,kBAAkB,EAMnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAM1D,OAAO,EACL,kBAAkB,EAElB,aAAa,EACb,iBAAiB,EACjB,wBAAwB,EACxB,gCAAgC,EAKjC,MAAM,cAAc,CAAC;AAGtB,OAAO,EAEL,eAAe,EAUhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAWnE,MAAM,WAAW,yBAA0B,SAAQ,iBAAiB;IAClE,eAAe,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACrC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,aAAa,CAAC,EAAE,SAAS,CAAC;CAC3B;AAED,qBAAa,qBAAsB,SAAQ,aAAa;IACtD,OAAO,CAAC,WAAW,CAAkB;IAE9B,eAAe,EAAG,SAAS,CAAC;IAE5B,sBAAsB,EAAE,MAAM,CAAa;IAC3C,eAAe,EAAG,SAAS,GAAG,MAAM,CAAC;IACrC,iBAAiB,EAAG,SAAS,CAAC;IAC9B,aAAa,EAAG,SAAS,CAAC;IAE1B,sBAAsB,EAAG,qBAAqB,CAAC;IAC/C,oBAAoB,EAAG,qBAAqB,CAAC;IAE7C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yBAAyB,IAAI,kBAAkB;IAS/C,YAAY,CACV,aAAa,CAAC,EAAE,gCAAgC,EAChD,GAAG,CAAC,EAAE,kBAAkB,GACvB,kBAAkB;IAMrB,OAAO,CAAC,sBAAsB;IA6C9B,OAAO,IAAI,kBAAkB;IAc7B,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB;IAUhE,OAAO,CAAC,6BAA6B;IAmErC,OAAO,CAAC,oCAAoC;IA0D5C,SAAS,CACP,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;IA2DrB,WAAW,CACT,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,SAAS,GACjC,kBAAkB;IA2BrB,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,kBAAkB;IAoFlE,iCAAiC,IAAI,kBAAkB;IASjD,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAiBlE"}
|
@@ -413,11 +413,8 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
413
413
|
if (state) {
|
414
414
|
return state;
|
415
415
|
}
|
416
|
-
this.log("Live position updates:");
|
417
|
-
this.log(this.livePositionUpdates);
|
418
416
|
const freshState = await (0, marginfiUtils_1.getMarginfiAccountPositionState)(this.umi, this.marginfiAccountPk, this.supplyMint, this.debtMint, this.livePositionUpdates);
|
419
|
-
this.log("Fresh state:");
|
420
|
-
this.log(freshState);
|
417
|
+
this.log("Fresh state:", freshState);
|
421
418
|
return freshState;
|
422
419
|
}
|
423
420
|
}
|
@@ -8,6 +8,6 @@ export declare abstract class TxHandler {
|
|
8
8
|
constructor(heliusApiKey: string, localTest?: boolean | undefined);
|
9
9
|
log(...args: any[]): void;
|
10
10
|
abstract defaultLookupTables(): string[];
|
11
|
-
abstract resetLiveTxUpdates(): Promise<void>;
|
11
|
+
abstract resetLiveTxUpdates(success?: boolean): Promise<void>;
|
12
12
|
}
|
13
13
|
//# sourceMappingURL=txHandler.d.ts.map
|
@@ -1 +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,
|
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,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAC9D"}
|
@@ -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;AAElC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAKxE,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,
|
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;AAElC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAKxE,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,CA+G7B;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,CAAC;IACT,EAAE,EAAE,kBAAkB,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC,GACG,SAAS,CACZ,CAwHA;AAED,wBAAsB,gCAAgC,CACpD,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,SAAS,GACtB,OAAO,CAAC,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC,GAAG,SAAS,CAAC,CAmCrD"}
|
@@ -149,6 +149,7 @@ async function rebalanceChoresBefore(client, tx, accountsGettingCreated) {
|
|
149
149
|
}
|
150
150
|
if (checkIntermediaryMfiAccount &&
|
151
151
|
!(0, generalUtils_1.rpcAccountCreated)(intermediaryMarginfiAccount)) {
|
152
|
+
client.log("Creating intermediary marginfi account");
|
152
153
|
chores = chores.add(client.createIntermediaryMarginfiAccount());
|
153
154
|
}
|
154
155
|
if (checkSignerSupplyTa &&
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { AddressLookupTableInput, TransactionBuilder, Umi } from "@metaplex-foundation/umi";
|
2
2
|
import { SolautoClient } from "../clients/solautoClient";
|
3
3
|
import { ErrorsToThrow } from "../utils/generalUtils";
|
4
|
-
import { PriorityFeeSetting } from "../types";
|
4
|
+
import { PriorityFeeSetting, TransactionRunType } from "../types";
|
5
5
|
import { ReferralStateManager, TxHandler } from "../clients";
|
6
6
|
declare class LookupTables {
|
7
7
|
defaultLuts: string[];
|
@@ -39,11 +39,11 @@ declare class TransactionSet {
|
|
39
39
|
name(): string;
|
40
40
|
}
|
41
41
|
export declare enum TransactionStatus {
|
42
|
-
Skipped =
|
43
|
-
Processing =
|
44
|
-
AwaitingSignature =
|
45
|
-
Queued =
|
46
|
-
Successful =
|
42
|
+
Skipped = "Skipped",
|
43
|
+
Processing = "Processing",
|
44
|
+
AwaitingSignature = "Awaiting Signature",
|
45
|
+
Queued = "Queued",
|
46
|
+
Successful = "Successful"
|
47
47
|
}
|
48
48
|
export type TransactionManagerStatuses = {
|
49
49
|
name: string;
|
@@ -53,12 +53,12 @@ export type TransactionManagerStatuses = {
|
|
53
53
|
export declare class TransactionsManager {
|
54
54
|
private txHandler;
|
55
55
|
private statusCallback?;
|
56
|
-
private
|
56
|
+
private txType?;
|
57
57
|
private mustBeAtomic?;
|
58
58
|
private errorsToThrow?;
|
59
59
|
private statuses;
|
60
60
|
private lookupTables;
|
61
|
-
constructor(txHandler: SolautoClient | ReferralStateManager, statusCallback?: ((statuses: TransactionManagerStatuses) => void) | undefined,
|
61
|
+
constructor(txHandler: SolautoClient | ReferralStateManager, statusCallback?: ((statuses: TransactionManagerStatuses) => void) | undefined, txType?: TransactionRunType | undefined, mustBeAtomic?: boolean | undefined, errorsToThrow?: ErrorsToThrow | undefined);
|
62
62
|
private assembleTransactionSets;
|
63
63
|
updateStatus(name: string, status: TransactionStatus, txSig?: string): void;
|
64
64
|
debugAccounts(itemSet: TransactionSet, tx: TransactionBuilder): Promise<void>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EAEvB,kBAAkB,EAClB,GAAG,EACJ,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;
|
1
|
+
{"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EAEvB,kBAAkB,EAClB,GAAG,EACJ,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,kBA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 -17,10 +17,7 @@ class LookupTables {
|
|
17
17
|
this.cache = [];
|
18
18
|
}
|
19
19
|
async getLutInputs(additionalAddresses) {
|
20
|
-
const addresses = [
|
21
|
-
...this.defaultLuts,
|
22
|
-
...additionalAddresses,
|
23
|
-
];
|
20
|
+
const addresses = [...this.defaultLuts, ...additionalAddresses];
|
24
21
|
const currentCacheAddresses = this.cache.map((x) => x.publicKey.toString());
|
25
22
|
const missingAddresses = addresses.filter((x) => !currentCacheAddresses.includes(x));
|
26
23
|
if (missingAddresses) {
|
@@ -112,17 +109,17 @@ class TransactionSet {
|
|
112
109
|
}
|
113
110
|
var TransactionStatus;
|
114
111
|
(function (TransactionStatus) {
|
115
|
-
TransactionStatus[
|
116
|
-
TransactionStatus[
|
117
|
-
TransactionStatus[
|
118
|
-
TransactionStatus[
|
119
|
-
TransactionStatus[
|
112
|
+
TransactionStatus["Skipped"] = "Skipped";
|
113
|
+
TransactionStatus["Processing"] = "Processing";
|
114
|
+
TransactionStatus["AwaitingSignature"] = "Awaiting Signature";
|
115
|
+
TransactionStatus["Queued"] = "Queued";
|
116
|
+
TransactionStatus["Successful"] = "Successful";
|
120
117
|
})(TransactionStatus || (exports.TransactionStatus = TransactionStatus = {}));
|
121
118
|
class TransactionsManager {
|
122
|
-
constructor(txHandler, statusCallback,
|
119
|
+
constructor(txHandler, statusCallback, txType, mustBeAtomic, errorsToThrow) {
|
123
120
|
this.txHandler = txHandler;
|
124
121
|
this.statusCallback = statusCallback;
|
125
|
-
this.
|
122
|
+
this.txType = txType;
|
126
123
|
this.mustBeAtomic = mustBeAtomic;
|
127
124
|
this.errorsToThrow = errorsToThrow;
|
128
125
|
this.statuses = [];
|
@@ -142,7 +139,9 @@ class TransactionsManager {
|
|
142
139
|
throw new Error(`Transaction exceeds max transaction size (${transaction.getTransactionSize(this.txHandler.umi)})`);
|
143
140
|
}
|
144
141
|
else {
|
145
|
-
let newSet = new TransactionSet(this.txHandler, this.lookupTables, [
|
142
|
+
let newSet = new TransactionSet(this.txHandler, this.lookupTables, [
|
143
|
+
item,
|
144
|
+
]);
|
146
145
|
for (let j = i; j < items.length; j++) {
|
147
146
|
if (await newSet.fitsWith(items[j])) {
|
148
147
|
newSet.add(items[j]);
|
@@ -198,7 +197,7 @@ class TransactionsManager {
|
|
198
197
|
updateLookupTable.updateLutTx.getInstructions().length > 0 &&
|
199
198
|
updateLookupTable?.needsToBeIsolated) {
|
200
199
|
this.updateStatus(updateLutTxName, TransactionStatus.Processing);
|
201
|
-
await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum) => await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.txHandler.umi, this.txHandler.connection, updateLookupTable.updateLutTx, this.
|
200
|
+
await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum) => await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.txHandler.umi, this.txHandler.connection, updateLookupTable.updateLutTx, this.txType, attemptNum, prioritySetting, () => this.updateStatus(updateLutTxName, TransactionStatus.AwaitingSignature)), 3, 150, this.errorsToThrow);
|
202
201
|
this.updateStatus(updateLutTxName, TransactionStatus.Successful);
|
203
202
|
}
|
204
203
|
this.lookupTables.defaultLuts = client.defaultLookupTables();
|
@@ -223,8 +222,11 @@ class TransactionsManager {
|
|
223
222
|
items.push(chore);
|
224
223
|
this.txHandler.log("Chores after: ", choresAfter.getInstructions().length);
|
225
224
|
}
|
226
|
-
await this.send(items, prioritySetting, true)
|
227
|
-
|
225
|
+
await this.send(items, prioritySetting, true).catch((e) => {
|
226
|
+
client.resetLiveTxUpdates(false);
|
227
|
+
throw e;
|
228
|
+
});
|
229
|
+
if (this.txType !== "only-simulate") {
|
228
230
|
await client.resetLiveTxUpdates();
|
229
231
|
}
|
230
232
|
}
|
@@ -254,7 +256,7 @@ class TransactionsManager {
|
|
254
256
|
// this.updateStatus(set.name(), TransactionStatus.Successful);
|
255
257
|
// });
|
256
258
|
}
|
257
|
-
else if (
|
259
|
+
else if (this.txType !== "only-simulate" || itemSets.length === 1) {
|
258
260
|
for (let i = 0; i < itemSets.length; i++) {
|
259
261
|
const getFreshItemSet = async (itemSet, attemptNum) => {
|
260
262
|
await itemSet.refetchAll(attemptNum);
|
@@ -293,7 +295,7 @@ class TransactionsManager {
|
|
293
295
|
if (this.txHandler.localTest) {
|
294
296
|
await this.debugAccounts(itemSet, tx);
|
295
297
|
}
|
296
|
-
const txSig = await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.txHandler.umi, this.txHandler.connection, tx, this.
|
298
|
+
const txSig = await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.txHandler.umi, this.txHandler.connection, tx, this.txType, attemptNum, prioritySetting, () => this.updateStatus(itemSet.name(), TransactionStatus.AwaitingSignature));
|
297
299
|
this.updateStatus(itemSet.name(), TransactionStatus.Successful, txSig ? bs58_1.default.encode(txSig) : undefined);
|
298
300
|
}
|
299
301
|
}, 4, 150, this.errorsToThrow);
|
package/dist/types/solauto.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solauto.d.ts","sourceRoot":"","sources":["../../src/types/solauto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,WAAW,sBAAsB;IACrC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,eAAe,CAAC;IACjC,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,oBAAY,kBAAkB;IAC5B,OAAO,WAAW;IAClB,IAAI,SAAS;CACd;AAED,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC"}
|
1
|
+
{"version":3,"file":"solauto.d.ts","sourceRoot":"","sources":["../../src/types/solauto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,WAAW,sBAAsB;IACrC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,eAAe,CAAC;IACjC,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,oBAAY,kBAAkB;IAC5B,OAAO,WAAW;IAClB,IAAI,SAAS;CACd;AAED,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC;AAExD,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,GAAG,eAAe,GAAG,QAAQ,CAAC"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { AddressLookupTableInput, Signer, TransactionBuilder, Umi, WrappedInstruction } from "@metaplex-foundation/umi";
|
2
2
|
import { Connection, PublicKey, TransactionInstruction } from "@solana/web3.js";
|
3
|
-
import { PriorityFeeSetting } from "../types";
|
3
|
+
import { PriorityFeeSetting, TransactionRunType } from "../types";
|
4
4
|
export declare function getSolanaRpcConnection(heliusApiKey: string): [Connection, Umi];
|
5
5
|
export declare function currentUnixSecondsSolana(umi: Umi): Promise<number>;
|
6
6
|
export declare function getWrappedInstruction(signer: Signer, ix: TransactionInstruction): WrappedInstruction;
|
@@ -13,5 +13,5 @@ export declare function splTokenTransferUmiIx(signer: Signer, fromTa: PublicKey,
|
|
13
13
|
export declare function getAdressLookupInputs(umi: Umi, lookupTableAddresses: string[]): Promise<AddressLookupTableInput[]>;
|
14
14
|
export declare function assembleFinalTransaction(signer: Signer, tx: TransactionBuilder, computeUnitPrice: number, computeUnitLimit?: number): TransactionBuilder;
|
15
15
|
export declare function getComputeUnitPriceEstimate(umi: Umi, tx: TransactionBuilder, prioritySetting: PriorityFeeSetting): Promise<number>;
|
16
|
-
export declare function sendSingleOptimizedTransaction(umi: Umi, connection: Connection, tx: TransactionBuilder,
|
16
|
+
export declare function sendSingleOptimizedTransaction(umi: Umi, connection: Connection, tx: TransactionBuilder, txType?: TransactionRunType, attemptNum?: number, prioritySetting?: PriorityFeeSetting, onAwaitingSign?: () => void): Promise<Uint8Array | undefined>;
|
17
17
|
//# sourceMappingURL=solanaUtils.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solanaUtils.d.ts","sourceRoot":"","sources":["../../src/utils/solanaUtils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EACvB,MAAM,EACN,kBAAkB,EAClB,GAAG,EACH,kBAAkB,EAGnB,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAGL,UAAU,EACV,SAAS,EAIT,sBAAsB,EAEvB,MAAM,iBAAiB,CAAC;AAYzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;
|
1
|
+
{"version":3,"file":"solanaUtils.d.ts","sourceRoot":"","sources":["../../src/utils/solanaUtils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EACvB,MAAM,EACN,kBAAkB,EAClB,GAAG,EACH,kBAAkB,EAGnB,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAGL,UAAU,EACV,SAAS,EAIT,sBAAsB,EAEvB,MAAM,iBAAiB,CAAC;AAYzB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAElE,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,MAAM,GACnB,CAAC,UAAU,EAAE,GAAG,CAAC,CAOnB;AAED,wBAAsB,wBAAwB,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAQxE;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,M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,EACtB,MAAM,CAAC,EAAE,kBAAkB,EAC3B,UAAU,CAAC,EAAE,MAAM,EACnB,eAAe,GAAE,kBAA+C,EAChE,cAAc,CAAC,EAAE,MAAM,IAAI,GAC1B,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CA4DjC"}
|
@@ -154,17 +154,19 @@ async function getComputeUnitPriceEstimate(umi, tx, prioritySetting) {
|
|
154
154
|
const feeEstimate = Math.round(resp.priorityFeeEstimate);
|
155
155
|
return feeEstimate;
|
156
156
|
}
|
157
|
-
async function sendSingleOptimizedTransaction(umi, connection, tx,
|
157
|
+
async function sendSingleOptimizedTransaction(umi, connection, tx, txType, attemptNum, prioritySetting = types_1.PriorityFeeSetting.Default, onAwaitingSign) {
|
158
158
|
console.log("Sending single optimized transaction...");
|
159
159
|
console.log("Instructions: ", tx.getInstructions().length);
|
160
160
|
console.log("Serialized transaction size: ", tx.getTransactionSize(umi));
|
161
161
|
const feeEstimate = await getComputeUnitPriceEstimate(umi, tx, prioritySetting);
|
162
162
|
console.log("Compute unit price: ", feeEstimate);
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
163
|
+
if (txType !== "skip-simulation") {
|
164
|
+
// TODO: we should only retry simulation if it's not a solauto error
|
165
|
+
const simulationResult = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => await simulateTransaction(connection, (0, umi_web3js_adapters_1.toWeb3JsTransaction)(await (await assembleFinalTransaction(umi.identity, tx, feeEstimate, 1400000).setLatestBlockhash(umi)).build(umi))), 3);
|
166
|
+
const computeUnitLimit = Math.round(simulationResult.value.unitsConsumed * 1.1);
|
167
|
+
console.log("Compute unit limit: ", computeUnitLimit);
|
168
|
+
}
|
169
|
+
if (txType !== "only-simulate") {
|
168
170
|
onAwaitingSign?.();
|
169
171
|
const result = await assembleFinalTransaction(umi.identity, tx, feeEstimate, 800000).sendAndConfirm(umi, {
|
170
172
|
send: {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"rebalanceUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/solauto/rebalanceUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EACL,WAAW,
|
1
|
+
{"version":3,"file":"rebalanceUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/solauto/rebalanceUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EACL,WAAW,EACX,aAAa,EAEb,yBAAyB,EAC1B,MAAM,iBAAiB,CAAC;AAOzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAkJjD,MAAM,WAAW,eAAe;IAC9B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,yBAAyB,GAAG,SAAS,EAC/C,GAAG,EAAE,WAAW,GAAG,SAAS,EAC5B,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,2BAA2B,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,eAAe,CA0EjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,aAAa,GACtB,gBAAgB,GAAG,SAAS,CAmE9B;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,cAAc,CAkChB"}
|
@@ -1,18 +1,20 @@
|
|
1
1
|
import { PublicKey } from "@solana/web3.js";
|
2
2
|
import { getTokenAccounts } from "../src/utils/accountUtils";
|
3
|
-
import { SOLAUTO_MANAGER } from "../src/constants/generalAccounts";
|
3
|
+
import { SOLAUTO_FEES_WALLET, SOLAUTO_MANAGER } from "../src/constants/generalAccounts";
|
4
4
|
import { ALL_SUPPORTED_TOKENS } from "../src/constants/tokenConstants";
|
5
5
|
import { updateLookupTable } from "./shared";
|
6
6
|
import { SOLAUTO_LUT, STANDARD_LUT_ACCOUNTS } from "../src/constants/solautoConstants";
|
7
7
|
|
8
8
|
const LOOKUP_TABLE_ADDRESS = new PublicKey(SOLAUTO_LUT);
|
9
9
|
const solautoManagerTokenAccounts = getTokenAccounts(SOLAUTO_MANAGER, ALL_SUPPORTED_TOKENS.map((x) => new PublicKey(x)));
|
10
|
+
const solautoFeeWalletTokenAccounts = getTokenAccounts(SOLAUTO_FEES_WALLET, ALL_SUPPORTED_TOKENS.map((x) => new PublicKey(x)));
|
10
11
|
|
11
12
|
export async function updateSolautoLut(additionalAccounts?: string[]) {
|
12
13
|
return updateLookupTable(
|
13
14
|
[
|
14
15
|
...STANDARD_LUT_ACCOUNTS,
|
15
16
|
...solautoManagerTokenAccounts.map((x) => x.toString()),
|
17
|
+
...solautoFeeWalletTokenAccounts.map(x => x.toString()),
|
16
18
|
...(additionalAccounts ?? [])
|
17
19
|
],
|
18
20
|
LOOKUP_TABLE_ADDRESS
|
package/package.json
CHANGED
@@ -218,22 +218,24 @@ export abstract class SolautoClient extends TxHandler {
|
|
218
218
|
);
|
219
219
|
}
|
220
220
|
|
221
|
-
async resetLiveTxUpdates() {
|
222
|
-
if (
|
223
|
-
this.solautoPositionData
|
224
|
-
this.
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
this.
|
230
|
-
this.
|
231
|
-
|
232
|
-
|
233
|
-
this.
|
234
|
-
this.
|
221
|
+
async resetLiveTxUpdates(success?: boolean) {
|
222
|
+
if (success) {
|
223
|
+
if (!this.solautoPositionData) {
|
224
|
+
this.solautoPositionData = await safeFetchSolautoPosition(
|
225
|
+
this.umi,
|
226
|
+
publicKey(this.solautoPosition)
|
227
|
+
);
|
228
|
+
} else {
|
229
|
+
if (this.livePositionUpdates.activeDca) {
|
230
|
+
this.solautoPositionData.position.dca =
|
231
|
+
this.livePositionUpdates.activeDca;
|
232
|
+
}
|
233
|
+
if (this.livePositionUpdates.settings) {
|
234
|
+
this.solautoPositionData.position.settingParams =
|
235
|
+
this.livePositionUpdates.settings;
|
236
|
+
}
|
237
|
+
// All other live position updates can be derived by getting a fresh position state, so we don't need to do anything else form livePositionUpdates
|
235
238
|
}
|
236
|
-
// All other live position updates can be derived by getting a fresh position state, so we don't need to do anything else form livePositionUpdates
|
237
239
|
}
|
238
240
|
this.livePositionUpdates.reset();
|
239
241
|
}
|
@@ -618,8 +618,6 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
618
618
|
return state;
|
619
619
|
}
|
620
620
|
|
621
|
-
this.log("Live position updates:");
|
622
|
-
this.log(this.livePositionUpdates);
|
623
621
|
const freshState = await getMarginfiAccountPositionState(
|
624
622
|
this.umi,
|
625
623
|
this.marginfiAccountPk,
|
@@ -627,8 +625,7 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
627
625
|
this.debtMint,
|
628
626
|
this.livePositionUpdates
|
629
627
|
);
|
630
|
-
this.log("Fresh state:");
|
631
|
-
this.log(freshState);
|
628
|
+
this.log("Fresh state:", freshState);
|
632
629
|
|
633
630
|
return freshState;
|
634
631
|
}
|
package/src/clients/txHandler.ts
CHANGED
@@ -298,6 +298,7 @@ export async function rebalanceChoresBefore(
|
|
298
298
|
checkIntermediaryMfiAccount &&
|
299
299
|
!rpcAccountCreated(intermediaryMarginfiAccount)
|
300
300
|
) {
|
301
|
+
client.log("Creating intermediary marginfi account");
|
301
302
|
chores = chores.add(
|
302
303
|
(client as SolautoMarginfiClient).createIntermediaryMarginfiAccount()
|
303
304
|
);
|
@@ -15,23 +15,22 @@ import {
|
|
15
15
|
retryWithExponentialBackoff,
|
16
16
|
} from "../utils/generalUtils";
|
17
17
|
import { getTransactionChores } from "./transactionUtils";
|
18
|
-
import { PriorityFeeSetting } from "../types";
|
18
|
+
import { PriorityFeeSetting, TransactionRunType } from "../types";
|
19
19
|
import { ReferralStateManager, TxHandler } from "../clients";
|
20
20
|
// import { sendJitoBundledTransactions } from "../utils/jitoUtils";
|
21
21
|
|
22
22
|
class LookupTables {
|
23
23
|
cache: AddressLookupTableInput[] = [];
|
24
24
|
|
25
|
-
constructor(
|
26
|
-
|
25
|
+
constructor(
|
26
|
+
public defaultLuts: string[],
|
27
|
+
private umi: Umi
|
28
|
+
) {}
|
27
29
|
|
28
30
|
async getLutInputs(
|
29
31
|
additionalAddresses: string[]
|
30
32
|
): Promise<AddressLookupTableInput[]> {
|
31
|
-
const addresses = [
|
32
|
-
...this.defaultLuts,
|
33
|
-
...additionalAddresses,
|
34
|
-
];
|
33
|
+
const addresses = [...this.defaultLuts, ...additionalAddresses];
|
35
34
|
const currentCacheAddresses = this.cache.map((x) => x.publicKey.toString());
|
36
35
|
|
37
36
|
const missingAddresses = addresses.filter(
|
@@ -60,7 +59,7 @@ export class TransactionItem {
|
|
60
59
|
{ tx: TransactionBuilder; lookupTableAddresses?: string[] } | undefined
|
61
60
|
>,
|
62
61
|
public name?: string
|
63
|
-
) {
|
62
|
+
) {}
|
64
63
|
|
65
64
|
async initialize() {
|
66
65
|
await this.refetch(0);
|
@@ -91,7 +90,7 @@ class TransactionSet {
|
|
91
90
|
private txHandler: TxHandler,
|
92
91
|
public lookupTables: LookupTables,
|
93
92
|
public items: TransactionItem[] = []
|
94
|
-
) {
|
93
|
+
) {}
|
95
94
|
|
96
95
|
async fitsWith(item: TransactionItem): Promise<boolean> {
|
97
96
|
if (!item.tx) {
|
@@ -165,11 +164,11 @@ class TransactionSet {
|
|
165
164
|
}
|
166
165
|
|
167
166
|
export enum TransactionStatus {
|
168
|
-
Skipped,
|
169
|
-
Processing,
|
170
|
-
AwaitingSignature,
|
171
|
-
Queued,
|
172
|
-
Successful,
|
167
|
+
Skipped = "Skipped",
|
168
|
+
Processing = "Processing",
|
169
|
+
AwaitingSignature = "Awaiting Signature",
|
170
|
+
Queued = "Queued",
|
171
|
+
Successful = "Successful",
|
173
172
|
}
|
174
173
|
|
175
174
|
export type TransactionManagerStatuses = {
|
@@ -185,11 +184,14 @@ export class TransactionsManager {
|
|
185
184
|
constructor(
|
186
185
|
private txHandler: SolautoClient | ReferralStateManager,
|
187
186
|
private statusCallback?: (statuses: TransactionManagerStatuses) => void,
|
188
|
-
private
|
187
|
+
private txType?: TransactionRunType,
|
189
188
|
private mustBeAtomic?: boolean,
|
190
189
|
private errorsToThrow?: ErrorsToThrow
|
191
190
|
) {
|
192
|
-
this.lookupTables = new LookupTables(
|
191
|
+
this.lookupTables = new LookupTables(
|
192
|
+
this.txHandler.defaultLookupTables(),
|
193
|
+
this.txHandler.umi
|
194
|
+
);
|
193
195
|
}
|
194
196
|
|
195
197
|
private async assembleTransactionSets(
|
@@ -198,7 +200,7 @@ export class TransactionsManager {
|
|
198
200
|
let transactionSets: TransactionSet[] = [];
|
199
201
|
this.txHandler.log(`Reassembling ${items.length} items`);
|
200
202
|
|
201
|
-
for (let i = 0; i < items.length;) {
|
203
|
+
for (let i = 0; i < items.length; ) {
|
202
204
|
let item = items[i];
|
203
205
|
i++;
|
204
206
|
|
@@ -214,7 +216,9 @@ export class TransactionsManager {
|
|
214
216
|
`Transaction exceeds max transaction size (${transaction.getTransactionSize(this.txHandler.umi)})`
|
215
217
|
);
|
216
218
|
} else {
|
217
|
-
let newSet = new TransactionSet(this.txHandler, this.lookupTables, [
|
219
|
+
let newSet = new TransactionSet(this.txHandler, this.lookupTables, [
|
220
|
+
item,
|
221
|
+
]);
|
218
222
|
for (let j = i; j < items.length; j++) {
|
219
223
|
if (await newSet.fitsWith(items[j])) {
|
220
224
|
newSet.add(items[j]);
|
@@ -255,7 +259,9 @@ export class TransactionsManager {
|
|
255
259
|
const accountsNotInLut = ixAccounts.filter(
|
256
260
|
(x) => !lutAccounts.includes(x)
|
257
261
|
);
|
258
|
-
this.txHandler.log(
|
262
|
+
this.txHandler.log(
|
263
|
+
`Program ${ix.programId}, data len: ${ix.data.length}, LUT accounts data: ${ix.keys.filter((x) => lutAccounts.includes(x.pubkey)).length * 3}`
|
264
|
+
);
|
259
265
|
if (accountsNotInLut.length > 0) {
|
260
266
|
this.txHandler.log(`${accountsNotInLut.length} accounts not in LUT:`);
|
261
267
|
for (const key of accountsNotInLut) {
|
@@ -265,7 +271,10 @@ export class TransactionsManager {
|
|
265
271
|
}
|
266
272
|
}
|
267
273
|
|
268
|
-
async clientSend(
|
274
|
+
async clientSend(
|
275
|
+
items: TransactionItem[],
|
276
|
+
prioritySetting?: PriorityFeeSetting
|
277
|
+
) {
|
269
278
|
const client = this.txHandler as SolautoClient;
|
270
279
|
|
271
280
|
const updateLookupTable = await client.updateLookupTable();
|
@@ -282,10 +291,14 @@ export class TransactionsManager {
|
|
282
291
|
this.txHandler.umi,
|
283
292
|
this.txHandler.connection,
|
284
293
|
updateLookupTable.updateLutTx,
|
285
|
-
this.
|
294
|
+
this.txType,
|
286
295
|
attemptNum,
|
287
296
|
prioritySetting,
|
288
|
-
() =>
|
297
|
+
() =>
|
298
|
+
this.updateStatus(
|
299
|
+
updateLutTxName,
|
300
|
+
TransactionStatus.AwaitingSignature
|
301
|
+
)
|
289
302
|
),
|
290
303
|
3,
|
291
304
|
150,
|
@@ -318,23 +331,36 @@ export class TransactionsManager {
|
|
318
331
|
);
|
319
332
|
await chore.initialize();
|
320
333
|
items.unshift(chore);
|
321
|
-
this.txHandler.log(
|
334
|
+
this.txHandler.log(
|
335
|
+
"Chores before: ",
|
336
|
+
choresBefore.getInstructions().length
|
337
|
+
);
|
322
338
|
}
|
323
339
|
if (choresAfter.getInstructions().length > 0) {
|
324
340
|
const chore = new TransactionItem(async () => ({ tx: choresAfter }));
|
325
341
|
await chore.initialize();
|
326
342
|
items.push(chore);
|
327
|
-
this.txHandler.log(
|
343
|
+
this.txHandler.log(
|
344
|
+
"Chores after: ",
|
345
|
+
choresAfter.getInstructions().length
|
346
|
+
);
|
328
347
|
}
|
329
348
|
|
330
|
-
await this.send(items, prioritySetting, true)
|
349
|
+
await this.send(items, prioritySetting, true).catch((e) => {
|
350
|
+
client.resetLiveTxUpdates(false);
|
351
|
+
throw e;
|
352
|
+
});
|
331
353
|
|
332
|
-
if (
|
354
|
+
if (this.txType !== "only-simulate") {
|
333
355
|
await client.resetLiveTxUpdates();
|
334
356
|
}
|
335
357
|
}
|
336
358
|
|
337
|
-
async send(
|
359
|
+
async send(
|
360
|
+
items: TransactionItem[],
|
361
|
+
prioritySetting?: PriorityFeeSetting,
|
362
|
+
initialized?: boolean
|
363
|
+
) {
|
338
364
|
if (!initialized) {
|
339
365
|
for (const item of items) {
|
340
366
|
await item.initialize();
|
@@ -363,7 +389,7 @@ export class TransactionsManager {
|
|
363
389
|
// itemSets.forEach((set) => {
|
364
390
|
// this.updateStatus(set.name(), TransactionStatus.Successful);
|
365
391
|
// });
|
366
|
-
} else if (
|
392
|
+
} else if (this.txType !== "only-simulate" || itemSets.length === 1) {
|
367
393
|
for (let i = 0; i < itemSets.length; i++) {
|
368
394
|
const getFreshItemSet = async (
|
369
395
|
itemSet: TransactionSet,
|
@@ -421,10 +447,14 @@ export class TransactionsManager {
|
|
421
447
|
this.txHandler.umi,
|
422
448
|
this.txHandler.connection,
|
423
449
|
tx,
|
424
|
-
this.
|
450
|
+
this.txType,
|
425
451
|
attemptNum,
|
426
452
|
prioritySetting,
|
427
|
-
() =>
|
453
|
+
() =>
|
454
|
+
this.updateStatus(
|
455
|
+
itemSet!.name(),
|
456
|
+
TransactionStatus.AwaitingSignature
|
457
|
+
)
|
428
458
|
);
|
429
459
|
this.updateStatus(
|
430
460
|
itemSet.name(),
|
package/src/types/solauto.ts
CHANGED
package/src/utils/solanaUtils.ts
CHANGED
@@ -36,7 +36,7 @@ import {
|
|
36
36
|
getLendingAccountEndFlashloanInstructionDataSerializer,
|
37
37
|
getLendingAccountStartFlashloanInstructionDataSerializer,
|
38
38
|
} from "../marginfi-sdk";
|
39
|
-
import { PriorityFeeSetting } from "../types";
|
39
|
+
import { PriorityFeeSetting, TransactionRunType } from "../types";
|
40
40
|
|
41
41
|
export function getSolanaRpcConnection(
|
42
42
|
heliusApiKey: string
|
@@ -281,7 +281,7 @@ export async function sendSingleOptimizedTransaction(
|
|
281
281
|
umi: Umi,
|
282
282
|
connection: Connection,
|
283
283
|
tx: TransactionBuilder,
|
284
|
-
|
284
|
+
txType?: TransactionRunType,
|
285
285
|
attemptNum?: number,
|
286
286
|
prioritySetting: PriorityFeeSetting = PriorityFeeSetting.Default,
|
287
287
|
onAwaitingSign?: () => void
|
@@ -297,31 +297,33 @@ export async function sendSingleOptimizedTransaction(
|
|
297
297
|
);
|
298
298
|
console.log("Compute unit price: ", feeEstimate);
|
299
299
|
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
await
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
300
|
+
if (txType !== "skip-simulation") {
|
301
|
+
// TODO: we should only retry simulation if it's not a solauto error
|
302
|
+
const simulationResult = await retryWithExponentialBackoff(
|
303
|
+
async () =>
|
304
|
+
await simulateTransaction(
|
305
|
+
connection,
|
306
|
+
toWeb3JsTransaction(
|
307
|
+
await (
|
308
|
+
await assembleFinalTransaction(
|
309
|
+
umi.identity,
|
310
|
+
tx,
|
311
|
+
feeEstimate,
|
312
|
+
1_400_000
|
313
|
+
).setLatestBlockhash(umi)
|
314
|
+
).build(umi)
|
315
|
+
)
|
316
|
+
),
|
317
|
+
3
|
318
|
+
);
|
319
|
+
|
320
|
+
const computeUnitLimit = Math.round(
|
321
|
+
simulationResult.value.unitsConsumed! * 1.1
|
322
|
+
);
|
323
|
+
console.log("Compute unit limit: ", computeUnitLimit);
|
324
|
+
}
|
323
325
|
|
324
|
-
if (
|
326
|
+
if (txType !== "only-simulate") {
|
325
327
|
onAwaitingSign?.();
|
326
328
|
const result = await assembleFinalTransaction(
|
327
329
|
umi.identity,
|
@@ -18,6 +18,9 @@ import {
|
|
18
18
|
} from "../../src/transactions/transactionsManager";
|
19
19
|
import { PublicKey } from "@solana/web3.js";
|
20
20
|
import { USDC_MINT } from "../../src/constants";
|
21
|
+
import {
|
22
|
+
ACCOUNT_SIZE as TOKEN_ACCOUNT_SIZE,
|
23
|
+
} from "@solana/spl-token";
|
21
24
|
|
22
25
|
describe("Solauto Marginfi tests", async () => {
|
23
26
|
const signer = setupTest();
|
@@ -155,12 +158,13 @@ describe("Solauto Marginfi tests", async () => {
|
|
155
158
|
// )
|
156
159
|
// );
|
157
160
|
|
158
|
-
await new TransactionsManager(
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
).clientSend(transactionItems);
|
161
|
+
// await new TransactionsManager(
|
162
|
+
// client,
|
163
|
+
// undefined,
|
164
|
+
// !payForTransactions ? "only-simulate" : "normal",
|
165
|
+
// useJitoBundle
|
166
|
+
// ).clientSend(transactionItems);
|
164
167
|
|
168
|
+
console.log((await client.umi.rpc.getRent(TOKEN_ACCOUNT_SIZE)).basisPoints);
|
165
169
|
});
|
166
170
|
});
|