@haven-fi/solauto-sdk 1.0.559 → 1.0.561
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.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAoBxE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAsCzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAOlD,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AA4LjD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CAoH7B;AA2LD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA0BnD;AAED,wBAAsB,8BAA8B,
|
1
|
+
{"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAoBxE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAsCzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAOlD,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AA4LjD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CAoH7B;AA2LD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA0BnD;AAED,wBAAsB,8BAA8B,CAAC,MAAM,EAAE,aAAa,oBAqDzE;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAsI5C;AAED,wBAAsB,gCAAgC,CACpD,eAAe,EAAE,oBAAoB,EACrC,YAAY,EAAE,SAAS,EACvB,eAAe,EAAE,SAAS,GACzB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAsC5C;AAED,wBAAgB,YAAY,CAC1B,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,kBAAkB,EAAE,EACzB,KAAK,EAAE,KAAK,EACZ,oBAAoB,CAAC,EAAE,OAAO;;;;EA+G/B"}
|
@@ -375,7 +375,7 @@ async function buildSolautoRebalanceTransaction(client, targetLiqUtilizationRate
|
|
375
375
|
client.log("Rebalance values: ", values);
|
376
376
|
const flRequirements = await (0, rebalanceUtils_1.getFlashLoanRequirements)(client, values, attemptNum);
|
377
377
|
const swapDetails = await (0, rebalanceUtils_1.getJupSwapRebalanceDetails)(client, values, flRequirements, targetLiqUtilizationRateBps, attemptNum);
|
378
|
-
const { jupQuote, lookupTableAddresses, setupInstructions, swapIx
|
378
|
+
const { jupQuote, lookupTableAddresses, setupInstructions, swapIx } = await (0, jupiterUtils_1.getJupSwapTransaction)(client.signer, swapDetails, attemptNum);
|
379
379
|
const flashLoan = flRequirements
|
380
380
|
? (0, rebalanceUtils_1.getFlashLoanDetails)(client, flRequirements, values, jupQuote)
|
381
381
|
: undefined;
|
@@ -458,7 +458,15 @@ function getErrorInfo(umi, txs, error, simulationSuccessful) {
|
|
458
458
|
let errName;
|
459
459
|
const computeIxs = simulationSuccessful ? 2 : 1; // sub ixs to account for computeUnitLimit and computeUnitPrice that get added
|
460
460
|
try {
|
461
|
-
|
461
|
+
console.log(error instanceof transactions_1.BundleSimulationError);
|
462
|
+
if (error instanceof transactions_1.BundleSimulationError) {
|
463
|
+
console.log(error.details);
|
464
|
+
errTxIdx = error.details.transactionIdx;
|
465
|
+
errIxIdx = error.details.instructionIdx - computeIxs;
|
466
|
+
errCode = error.details.errorCode;
|
467
|
+
}
|
468
|
+
else if (typeof error === "object" &&
|
469
|
+
error["InstructionError"]) {
|
462
470
|
const err = error["InstructionError"];
|
463
471
|
errIxIdx = err[0] - computeIxs;
|
464
472
|
errCode =
|
@@ -467,12 +475,6 @@ function getErrorInfo(umi, txs, error, simulationSuccessful) {
|
|
467
475
|
: undefined;
|
468
476
|
errName = errCode === undefined ? err[1] : undefined;
|
469
477
|
}
|
470
|
-
else if (error instanceof transactions_1.BundleSimulationError) {
|
471
|
-
console.log(error.details);
|
472
|
-
errTxIdx = error.details.transactionIdx;
|
473
|
-
errIxIdx = error.details.instructionIdx - computeIxs;
|
474
|
-
errCode = error.details.errorCode;
|
475
|
-
}
|
476
478
|
(0, generalUtils_1.consoleLog)("Transaction instructions:", txs.map((x) => x
|
477
479
|
.getInstructions()
|
478
480
|
.map((y) => y.programId.toString())
|
package/package.json
CHANGED
@@ -599,9 +599,7 @@ export async function getTransactionChores(
|
|
599
599
|
return [choresBefore, choresAfter];
|
600
600
|
}
|
601
601
|
|
602
|
-
export async function requiresRefreshBeforeRebalance(
|
603
|
-
client: SolautoClient,
|
604
|
-
) {
|
602
|
+
export async function requiresRefreshBeforeRebalance(client: SolautoClient) {
|
605
603
|
const neverRefreshedBefore =
|
606
604
|
client.solautoPositionData &&
|
607
605
|
client.solautoPositionData.state.supply.amountCanBeUsed.baseUnit ===
|
@@ -693,7 +691,11 @@ export async function buildSolautoRebalanceTransaction(
|
|
693
691
|
);
|
694
692
|
client.log("Rebalance values: ", values);
|
695
693
|
|
696
|
-
const flRequirements = await getFlashLoanRequirements(
|
694
|
+
const flRequirements = await getFlashLoanRequirements(
|
695
|
+
client,
|
696
|
+
values,
|
697
|
+
attemptNum
|
698
|
+
);
|
697
699
|
const swapDetails = await getJupSwapRebalanceDetails(
|
698
700
|
client,
|
699
701
|
values,
|
@@ -701,12 +703,8 @@ export async function buildSolautoRebalanceTransaction(
|
|
701
703
|
targetLiqUtilizationRateBps,
|
702
704
|
attemptNum
|
703
705
|
);
|
704
|
-
const {
|
705
|
-
|
706
|
-
lookupTableAddresses,
|
707
|
-
setupInstructions,
|
708
|
-
swapIx,
|
709
|
-
} = await getJupSwapTransaction(client.signer, swapDetails, attemptNum);
|
706
|
+
const { jupQuote, lookupTableAddresses, setupInstructions, swapIx } =
|
707
|
+
await getJupSwapTransaction(client.signer, swapDetails, attemptNum);
|
710
708
|
|
711
709
|
const flashLoan = flRequirements
|
712
710
|
? getFlashLoanDetails(client, flRequirements, values, jupQuote)
|
@@ -858,7 +856,16 @@ export function getErrorInfo(
|
|
858
856
|
const computeIxs = simulationSuccessful ? 2 : 1; // sub ixs to account for computeUnitLimit and computeUnitPrice that get added
|
859
857
|
|
860
858
|
try {
|
861
|
-
|
859
|
+
console.log(error instanceof BundleSimulationError);
|
860
|
+
if (error instanceof BundleSimulationError) {
|
861
|
+
console.log(error.details);
|
862
|
+
errTxIdx = error.details.transactionIdx;
|
863
|
+
errIxIdx = error.details.instructionIdx - computeIxs;
|
864
|
+
errCode = error.details.errorCode;
|
865
|
+
} else if (
|
866
|
+
typeof error === "object" &&
|
867
|
+
(error as any)["InstructionError"]
|
868
|
+
) {
|
862
869
|
const err = (error as any)["InstructionError"];
|
863
870
|
|
864
871
|
errIxIdx = err[0] - computeIxs;
|
@@ -867,11 +874,6 @@ export function getErrorInfo(
|
|
867
874
|
? err[1]["Custom"]
|
868
875
|
: undefined;
|
869
876
|
errName = errCode === undefined ? (err[1] as string) : undefined;
|
870
|
-
} else if (error instanceof BundleSimulationError) {
|
871
|
-
console.log(error.details);
|
872
|
-
errTxIdx = error.details.transactionIdx;
|
873
|
-
errIxIdx = error.details.instructionIdx - computeIxs;
|
874
|
-
errCode = error.details.errorCode;
|
875
877
|
}
|
876
878
|
|
877
879
|
consoleLog(
|