@haven-fi/solauto-sdk 1.0.175 → 1.0.176
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/transactions/transactionUtils.d.ts.map +1 -1
- package/dist/transactions/transactionUtils.js +3 -0
- package/dist/transactions/transactionsManager.d.ts.map +1 -1
- package/dist/transactions/transactionsManager.js +18 -0
- package/package.json +1 -1
- package/src/transactions/transactionUtils.ts +4 -0
- package/src/transactions/transactionsManager.ts +28 -0
- package/tests/transactions/solautoMarginfi.ts +2 -2
@@ -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,EAUd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAyNzD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CA+G7B;AAmLD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA0BnD;AAED,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,aAAa,
|
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,EAUd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAyNzD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CA+G7B;AAmLD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA0BnD;AAED,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,aAAa,WA6BnE;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CACN;IACE,EAAE,EAAE,kBAAkB,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC,GACD,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"}
|
@@ -329,6 +329,9 @@ function requiresRefreshBeforeRebalance(client) {
|
|
329
329
|
return true;
|
330
330
|
}
|
331
331
|
else if (client.solautoPositionData && !client.selfManaged) {
|
332
|
+
if (client.livePositionUpdates.supplyAdjustment > BigInt(0) || client.livePositionUpdates.debtAdjustment > BigInt(0)) {
|
333
|
+
return false;
|
334
|
+
}
|
332
335
|
const oldSupply = client.solautoPositionData.state.supply.amountUsed.baseUnit;
|
333
336
|
const oldDebt = client.solautoPositionData.state.debt.amountUsed.baseUnit;
|
334
337
|
const supplyDiff = (client.solautoPositionState?.supply.amountUsed.baseUnit ?? BigInt(0)) - oldSupply;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAKzD,OAAO,EACL,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAa,MAAM,YAAY,CAAC;
|
1
|
+
{"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAKzD,OAAO,EACL,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAa,MAAM,YAAY,CAAC;AA0C7D,qBAAa,eAAe;IAKjB,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CACV;QAAE,EAAE,EAAE,kBAAkB,CAAC;QAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,SAAS,CACxE;IACM,IAAI,CAAC,EAAE,MAAM;IATtB,oBAAoB,EAAG,MAAM,EAAE,CAAC;IAChC,EAAE,CAAC,EAAE,kBAAkB,CAAC;gBAGf,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CACV;QAAE,EAAE,EAAE,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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9B"}
|
@@ -9,6 +9,7 @@ const umi_1 = require("@metaplex-foundation/umi");
|
|
9
9
|
const solanaUtils_1 = require("../utils/solanaUtils");
|
10
10
|
const generalUtils_1 = require("../utils/generalUtils");
|
11
11
|
const transactionUtils_1 = require("./transactionUtils");
|
12
|
+
const generated_1 = require("../generated");
|
12
13
|
// import { sendJitoBundledTransactions } from "../utils/jitoUtils";
|
13
14
|
class LookupTables {
|
14
15
|
constructor(defaultLuts, umi) {
|
@@ -331,6 +332,23 @@ class TransactionsManager {
|
|
331
332
|
this.updateStatus(txName, TransactionStatus.Successful, attemptNum, txSig ? bs58_1.default.encode(txSig) : undefined);
|
332
333
|
}
|
333
334
|
catch (e) {
|
335
|
+
try {
|
336
|
+
if (typeof e === "object" && e["InstructionError"]) {
|
337
|
+
const err = e["InstructionError"];
|
338
|
+
const errIx = err[0];
|
339
|
+
const errCode = err[1]["Custom"];
|
340
|
+
const solautoProgram = this.txHandler.umi.programs.get(generated_1.SOLAUTO_PROGRAM_ID);
|
341
|
+
const invalidRebalanceError = new generated_1.InvalidRebalanceConditionError(solautoProgram);
|
342
|
+
if (tx.getInstructions()[Math.max(0, errIx - 2)].programId ===
|
343
|
+
generated_1.SOLAUTO_PROGRAM_ID &&
|
344
|
+
solautoProgram.getErrorFromCode(errCode)?.name ===
|
345
|
+
invalidRebalanceError.name) {
|
346
|
+
this.updateStatus(txName, TransactionStatus.Skipped, attemptNum);
|
347
|
+
return;
|
348
|
+
}
|
349
|
+
}
|
350
|
+
}
|
351
|
+
catch { }
|
334
352
|
this.updateStatus(txName, TransactionStatus.Failed, attemptNum);
|
335
353
|
throw e;
|
336
354
|
}
|
package/package.json
CHANGED
@@ -577,6 +577,10 @@ export function requiresRefreshBeforeRebalance(client: SolautoClient) {
|
|
577
577
|
) {
|
578
578
|
return true;
|
579
579
|
} else if (client.solautoPositionData && !client.selfManaged) {
|
580
|
+
if (client.livePositionUpdates.supplyAdjustment > BigInt(0) || client.livePositionUpdates.debtAdjustment > BigInt(0)) {
|
581
|
+
return false;
|
582
|
+
}
|
583
|
+
|
580
584
|
const oldSupply = client.solautoPositionData.state.supply.amountUsed.baseUnit;
|
581
585
|
const oldDebt = client.solautoPositionData.state.debt.amountUsed.baseUnit;
|
582
586
|
|
@@ -17,6 +17,10 @@ import {
|
|
17
17
|
import { getTransactionChores } from "./transactionUtils";
|
18
18
|
import { PriorityFeeSetting, TransactionRunType } from "../types";
|
19
19
|
import { ReferralStateManager, TxHandler } from "../clients";
|
20
|
+
import {
|
21
|
+
InvalidRebalanceConditionError,
|
22
|
+
SOLAUTO_PROGRAM_ID,
|
23
|
+
} from "../generated";
|
20
24
|
// import { sendJitoBundledTransactions } from "../utils/jitoUtils";
|
21
25
|
|
22
26
|
class LookupTables {
|
@@ -521,6 +525,30 @@ export class TransactionsManager {
|
|
521
525
|
txSig ? bs58.encode(txSig) : undefined
|
522
526
|
);
|
523
527
|
} catch (e) {
|
528
|
+
try {
|
529
|
+
if (typeof e === "object" && (e as any)["InstructionError"]) {
|
530
|
+
const err = (e as any)["InstructionError"];
|
531
|
+
const errIx = err[0];
|
532
|
+
const errCode = err[1]["Custom"];
|
533
|
+
|
534
|
+
const solautoProgram =
|
535
|
+
this.txHandler.umi.programs.get(SOLAUTO_PROGRAM_ID);
|
536
|
+
const invalidRebalanceError = new InvalidRebalanceConditionError(
|
537
|
+
solautoProgram
|
538
|
+
);
|
539
|
+
|
540
|
+
if (
|
541
|
+
tx.getInstructions()[Math.max(0, errIx - 2)].programId ===
|
542
|
+
SOLAUTO_PROGRAM_ID &&
|
543
|
+
solautoProgram.getErrorFromCode(errCode)?.name ===
|
544
|
+
invalidRebalanceError.name
|
545
|
+
) {
|
546
|
+
this.updateStatus(txName, TransactionStatus.Skipped, attemptNum);
|
547
|
+
return;
|
548
|
+
}
|
549
|
+
}
|
550
|
+
} catch {}
|
551
|
+
|
524
552
|
this.updateStatus(txName, TransactionStatus.Failed, attemptNum);
|
525
553
|
throw e;
|
526
554
|
}
|
@@ -24,7 +24,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
24
24
|
// const signer = setupTest();
|
25
25
|
const signer = setupTest("solauto-manager");
|
26
26
|
|
27
|
-
const payForTransactions =
|
27
|
+
const payForTransactions = false;
|
28
28
|
const useJitoBundle = false;
|
29
29
|
const positionId = 1;
|
30
30
|
|
@@ -40,7 +40,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
40
40
|
{
|
41
41
|
signer,
|
42
42
|
positionId,
|
43
|
-
authority: new PublicKey("
|
43
|
+
authority: new PublicKey("AprYCPiVeKMCgjQ2ZufwChMzvQ5kFjJo2ekTLSkXsQDm")
|
44
44
|
// marginfiAccount: new PublicKey(
|
45
45
|
// "4nNvUXF5YqHFcH2nGweSiuvy1ct7V5FXfoCLKFYUN36z"
|
46
46
|
// ),
|