@haven-fi/solauto-sdk 1.0.559 → 1.0.560

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,CAClD,MAAM,EAAE,aAAa,oBAsDtB;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,KA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,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, } = await (0, jupiterUtils_1.getJupSwapTransaction)(client.signer, swapDetails, attemptNum);
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,14 @@ 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
- if (typeof error === "object" && error["InstructionError"]) {
461
+ if (error instanceof transactions_1.BundleSimulationError) {
462
+ console.log(error.details);
463
+ errTxIdx = error.details.transactionIdx;
464
+ errIxIdx = error.details.instructionIdx - computeIxs;
465
+ errCode = error.details.errorCode;
466
+ }
467
+ else if (typeof error === "object" &&
468
+ error["InstructionError"]) {
462
469
  const err = error["InstructionError"];
463
470
  errIxIdx = err[0] - computeIxs;
464
471
  errCode =
@@ -467,12 +474,6 @@ function getErrorInfo(umi, txs, error, simulationSuccessful) {
467
474
  : undefined;
468
475
  errName = errCode === undefined ? err[1] : undefined;
469
476
  }
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
477
  (0, generalUtils_1.consoleLog)("Transaction instructions:", txs.map((x) => x
477
478
  .getInstructions()
478
479
  .map((y) => y.programId.toString())
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.559",
3
+ "version": "1.0.560",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "Typescript SDK for the Solauto program on the Solana blockchain",
@@ -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(client, values, attemptNum);
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
- jupQuote,
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,15 @@ 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
- if (typeof error === "object" && (error as any)["InstructionError"]) {
859
+ if (error instanceof BundleSimulationError) {
860
+ console.log(error.details);
861
+ errTxIdx = error.details.transactionIdx;
862
+ errIxIdx = error.details.instructionIdx - computeIxs;
863
+ errCode = error.details.errorCode;
864
+ } else if (
865
+ typeof error === "object" &&
866
+ (error as any)["InstructionError"]
867
+ ) {
862
868
  const err = (error as any)["InstructionError"];
863
869
 
864
870
  errIxIdx = err[0] - computeIxs;
@@ -867,11 +873,6 @@ export function getErrorInfo(
867
873
  ? err[1]["Custom"]
868
874
  : undefined;
869
875
  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
876
  }
876
877
 
877
878
  consoleLog(