@haven-fi/solauto-sdk 1.0.446 → 1.0.448

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.
@@ -451,7 +451,7 @@ function getErrorInfo(umi, txs, error, simulationSuccessful) {
451
451
  let canBeIgnored = false;
452
452
  let errorName = undefined;
453
453
  let errorInfo = undefined;
454
- let errTxIdx;
454
+ let errTxIdx = 0;
455
455
  let errIxIdx;
456
456
  let errCode;
457
457
  let errName;
@@ -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,EACX,aAAa,EAEb,kBAAkB,EAClB,yBAAyB,EACzB,SAAS,EACV,MAAM,iBAAiB,CAAC;AAOzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAajD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAoI9C,MAAM,WAAW,eAAe;IAC9B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,eAAe,EAAE,eAAe,CAAC;IACjC,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC;CACjB;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,E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AAC;IACjC,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC;CACjB;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,GACnC,eAAe,CAwDjB;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe;;;EAsDxB;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,SAAS,CAAC;IAChB,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,aAAa,GACtB,gBAAgB,GAAG,SAAS,CAmC9B;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,cAAc,CA4DhB"}
@@ -127,14 +127,9 @@ function rebalanceRequiresFlashLoan(client, values) {
127
127
  const requiresFlashLoan = supplyUsd <= 0 || tempLiqUtilizationRateBps > maxLiqUtilizationRateBps;
128
128
  (0, generalUtils_2.consoleLog)("Requires flash loan:", requiresFlashLoan);
129
129
  (0, generalUtils_2.consoleLog)("Intermediary liq utilization rate:", tempLiqUtilizationRateBps, `$${supplyUsd}`, `$${debtUsd}`, "Max:", maxLiqUtilizationRateBps);
130
- // const useDebtLiquidity =
131
- // Math.abs(values.debtAdjustmentUsd) * 1.1 <=
132
- // fromBaseUnit(
133
- // client.solautoPositionState?.debt.amountCanBeUsed.baseAmountUsdValue ??
134
- // BigInt(0),
135
- // USD_DECIMALS
136
- // );
137
- const useDebtLiquidity = false;
130
+ const useDebtLiquidity = Math.abs(values.debtAdjustmentUsd) * 1.1 <=
131
+ (0, numberUtils_1.fromBaseUnit)(client.solautoPositionState?.debt.amountCanBeUsed.baseAmountUsdValue ??
132
+ BigInt(0), generalAccounts_1.USD_DECIMALS);
138
133
  return { requiresFlashLoan, useDebtLiquidity };
139
134
  }
140
135
  function getFlashLoanDetails(client, values, jupQuote) {
@@ -19,7 +19,6 @@ import { NATIVE_MINT } from "@solana/spl-token";
19
19
  import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
20
20
  import path from "path";
21
21
  import { config } from "dotenv";
22
- import { safeFetchMarginfiAccount } from "../src/marginfi-sdk";
23
22
 
24
23
  config({ path: path.join(__dirname, ".env") });
25
24
 
@@ -203,16 +202,17 @@ async function main(filterWhitelist: boolean) {
203
202
  );
204
203
 
205
204
  const repayFrom = pos.position.settingParams.repayToBps + pos.position.settingParams.repayGap;
206
- const unhealthy = pos.state.liqUtilizationRateBps > repayFrom;
207
- const healthText = unhealthy ? `(Unhealthy: ${pos.state.liqUtilizationRateBps - repayFrom}` : "";
205
+ const unhealthy = latestState.liqUtilizationRateBps > repayFrom;
206
+ const healthText = unhealthy ? `(Unhealthy: ${latestState.liqUtilizationRateBps - repayFrom}bps)` : "";
208
207
  if (unhealthy) {
209
208
  unhealthyPositions += 1;
210
209
  }
211
210
 
212
- console.log(pos.publicKey.toString(), `(${pos.authority.toString()})`);
211
+ console.log(pos.publicKey.toString(), `(${pos.authority.toString()} ${pos.positionId})`);
213
212
  console.log(
214
213
  `${strategy}: $${formatNumber(fromBaseUnit(latestState.netWorth.baseAmountUsdValue, USD_DECIMALS), 2, 10000, 2)} ${healthText}`
215
214
  );
215
+ // console.log(latestState.liqUtilizationRateBps, repayFrom);
216
216
  }
217
217
 
218
218
  console.log("\nTotal positions:", solautoPositionsData.length, unhealthyPositions ? ` (unhealthy: ${unhealthyPositions})` : "");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.446",
3
+ "version": "1.0.448",
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",
@@ -845,7 +845,7 @@ export function getErrorInfo(
845
845
  let errorName: string | undefined = undefined;
846
846
  let errorInfo: string | undefined = undefined;
847
847
 
848
- let errTxIdx: number | undefined;
848
+ let errTxIdx: number = 0;
849
849
  let errIxIdx: number | undefined;
850
850
  let errCode: number | undefined;
851
851
  let errName: string | undefined;
@@ -285,14 +285,13 @@ export function rebalanceRequiresFlashLoan(
285
285
  maxLiqUtilizationRateBps
286
286
  );
287
287
 
288
- // const useDebtLiquidity =
289
- // Math.abs(values.debtAdjustmentUsd) * 1.1 <=
290
- // fromBaseUnit(
291
- // client.solautoPositionState?.debt.amountCanBeUsed.baseAmountUsdValue ??
292
- // BigInt(0),
293
- // USD_DECIMALS
294
- // );
295
- const useDebtLiquidity = false;
288
+ const useDebtLiquidity =
289
+ Math.abs(values.debtAdjustmentUsd) * 1.1 <=
290
+ fromBaseUnit(
291
+ client.solautoPositionState?.debt.amountCanBeUsed.baseAmountUsdValue ??
292
+ BigInt(0),
293
+ USD_DECIMALS
294
+ );
296
295
  return { requiresFlashLoan, useDebtLiquidity };
297
296
  }
298
297
 
@@ -380,7 +379,10 @@ export function getJupSwapRebalanceDetails(
380
379
 
381
380
  const repaying = values.rebalanceDirection === RebalanceDirection.Repay;
382
381
 
383
- const { requiresFlashLoan, useDebtLiquidity } = rebalanceRequiresFlashLoan(client, values);
382
+ const { requiresFlashLoan, useDebtLiquidity } = rebalanceRequiresFlashLoan(
383
+ client,
384
+ values
385
+ );
384
386
  const flashLoanRepayFromDebt =
385
387
  repaying && requiresFlashLoan && useDebtLiquidity;
386
388
 
@@ -34,19 +34,19 @@ import {
34
34
  getSolautoManagedPositions,
35
35
  } from "../../src/utils";
36
36
  import { PriorityFeeSetting } from "../../src/types";
37
+ import { buildIronforgeApiUrl } from "../../dist";
37
38
 
38
39
  describe("Solauto Marginfi tests", async () => {
39
40
  // const signer = setupTest();
40
41
  const signer = setupTest("solauto-manager");
41
42
 
42
- const payForTransactions = true;
43
+ const payForTransactions = false;
43
44
  const testProgram = false;
44
45
  const positionId = 1;
45
46
 
46
47
  it("open - deposit - borrow - rebalance to 0 - withdraw - close", async () => {
47
48
  const client = new SolautoMarginfiClient(
48
- // buildHeliusApiUrl(process.env.HELIUS_API_KEY!),
49
- "https://staked.helius-rpc.com?api-key=6a7423cf-35ef-44ce-b02b-02567f57d181",
49
+ buildIronforgeApiUrl(process.env.IRONFORGE_API_KEY!),
50
50
  true,
51
51
  testProgram ? SOLAUTO_TEST_PROGRAM : SOLAUTO_PROD_PROGRAM
52
52
  );
@@ -58,13 +58,13 @@ describe("Solauto Marginfi tests", async () => {
58
58
  await client.initialize({
59
59
  signer,
60
60
  positionId,
61
- authority: new PublicKey("5bFfSCsGUgEzYH8kwwRtFnWkKZ1by8uD8RHvKQPnQReB"),
61
+ authority: new PublicKey("He4ka5Q3N1UvZikZvykdi47xyk5PoVP2tcQL5sVp31Sz"),
62
62
  // new: true,
63
63
  // marginfiAccount: new PublicKey(
64
- // "4nNvUXF5YqHFcH2nGweSiuvy1ct7V5FXfoCLKFYUN36z"
64
+ // ""
65
65
  // ),
66
- // marginfiGroup: new PublicKey("G1rt3EpQ43K3bY457rhukQGRAo2QxydFAGRKqnjKzyr5"),
67
- // supplyMint: new PublicKey("3B5wuUrMEi5yATD7on46hKfej3pfmd7t1RKgrsN3pump"),
66
+ // marginfiGroup: new PublicKey(""),
67
+ // supplyMint: new PublicKey(""),
68
68
  // debtMint: new PublicKey(USDC),
69
69
  });
70
70
 
@@ -168,7 +168,7 @@ describe("Solauto Marginfi tests", async () => {
168
168
  client,
169
169
  undefined,
170
170
  !payForTransactions ? "only-simulate" : "normal",
171
- PriorityFeeSetting.High,
171
+ PriorityFeeSetting.Min,
172
172
  true
173
173
  ).clientSend(transactionItems);
174
174