@haven-fi/solauto-sdk 1.0.163 → 1.0.165

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.
@@ -53,8 +53,8 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
53
53
  this.supplyPriceOracle = new web3_js_1.PublicKey(this.marginfiSupplyAccounts.priceOracle);
54
54
  this.debtPriceOracle = new web3_js_1.PublicKey(this.marginfiDebtAccounts.priceOracle);
55
55
  if (!this.solautoPositionState) {
56
- const [maxLtv, liqThreshold] = (await this.maxLtvAndLiqThreshold());
57
- this.solautoPositionState = (0, utils_1.createFakePositionState)({ mint: this.supplyMint }, { mint: this.debtMint }, (0, numberUtils_1.toBps)(maxLtv), (0, numberUtils_1.toBps)(liqThreshold));
56
+ const result = await this.maxLtvAndLiqThreshold();
57
+ this.solautoPositionState = (0, utils_1.createFakePositionState)({ mint: this.supplyMint }, { mint: this.debtMint }, result ? (0, numberUtils_1.toBps)(result[0]) : 0, result ? (0, numberUtils_1.toBps)(result[1]) : 0);
58
58
  }
59
59
  if (!this.initialized) {
60
60
  await this.setIntermediaryMarginfiDetails();
@@ -101,10 +101,10 @@ function getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, offsetFromMaxLt
101
101
  return toBps((fromBps(maxLtvBps) - offsetFromMaxLtv) / fromBps(liqThresholdBps)) - 1; // -1 to account for any rounding issues
102
102
  }
103
103
  function maxRepayFromBps(maxLtvBps, liqThresholdBps) {
104
- return Math.min(9000, getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps - 1000, 0.0075));
104
+ return Math.min(9000, getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps - 1000, 0.01));
105
105
  }
106
106
  function maxRepayToBps(maxLtvBps, liqThresholdBps) {
107
- return Math.min(maxRepayFromBps(maxLtvBps, liqThresholdBps) - constants_1.MIN_REPAY_GAP_BPS, getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.0075));
107
+ return Math.min(maxRepayFromBps(maxLtvBps, liqThresholdBps) - constants_1.MIN_REPAY_GAP_BPS, getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.01));
108
108
  }
109
109
  function maxBoostToBps(maxLtvBps, liqThresholdBps) {
110
110
  return Math.min(maxRepayToBps(maxLtvBps, liqThresholdBps), getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.01));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.163",
3
+ "version": "1.0.165",
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",
@@ -133,12 +133,12 @@ export class SolautoMarginfiClient extends SolautoClient {
133
133
  this.debtPriceOracle = new PublicKey(this.marginfiDebtAccounts.priceOracle);
134
134
 
135
135
  if (!this.solautoPositionState) {
136
- const [maxLtv, liqThreshold] = (await this.maxLtvAndLiqThreshold())!;
136
+ const result = await this.maxLtvAndLiqThreshold()!;
137
137
  this.solautoPositionState = createFakePositionState(
138
138
  { mint: this.supplyMint },
139
139
  { mint: this.debtMint },
140
- toBps(maxLtv),
141
- toBps(liqThreshold)
140
+ result ? toBps(result[0]) : 0,
141
+ result ? toBps(result[1]) : 0
142
142
  );
143
143
  }
144
144
 
@@ -139,14 +139,14 @@ export function getMaxLiqUtilizationRateBps(
139
139
  export function maxRepayFromBps(maxLtvBps: number, liqThresholdBps: number) {
140
140
  return Math.min(
141
141
  9000,
142
- getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps - 1000, 0.0075)
142
+ getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps - 1000, 0.01)
143
143
  );
144
144
  }
145
145
 
146
146
  export function maxRepayToBps(maxLtvBps: number, liqThresholdBps: number) {
147
147
  return Math.min(
148
148
  maxRepayFromBps(maxLtvBps, liqThresholdBps) - MIN_REPAY_GAP_BPS,
149
- getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.0075)
149
+ getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.01)
150
150
  );
151
151
  }
152
152
 
@@ -21,10 +21,10 @@ import { USDC_MINT } from "../../src/constants";
21
21
  import { buildHeliusApiUrl } from "../../src/utils";
22
22
 
23
23
  describe("Solauto Marginfi tests", async () => {
24
- const signer = setupTest();
25
- // const signer = setupTest("solauto-manager");
24
+ // const signer = setupTest();
25
+ const signer = setupTest("solauto-manager");
26
26
 
27
- const payForTransactions = true;
27
+ const payForTransactions = false;
28
28
  const useJitoBundle = false;
29
29
  const positionId = 1;
30
30
 
@@ -124,7 +124,7 @@ describe("Solauto Marginfi tests", async () => {
124
124
  transactionItems.push(
125
125
  new TransactionItem(
126
126
  async (attemptNum) =>
127
- await buildSolautoRebalanceTransaction(client, 7200, attemptNum),
127
+ await buildSolautoRebalanceTransaction(client, undefined, attemptNum),
128
128
  "rebalance"
129
129
  )
130
130
  );