@haven-fi/solauto-sdk 1.0.322 → 1.0.324

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.
@@ -91,18 +91,20 @@ function eligibleForRebalance(positionState, positionSettings, positionDca, curr
91
91
  : positionSettings.boostToBps;
92
92
  const repayFrom = positionSettings.repayToBps + positionSettings.repayGap;
93
93
  const boostFrom = boostToBps - positionSettings.boostGap;
94
- if (Math.max(0, positionState.liqUtilizationRateBps - boostFrom) <=
95
- bpsDistanceThreshold) {
96
- const values = (0, rebalanceUtils_1.getRebalanceValues)(positionState, positionSettings, positionDca, (0, generalUtils_1.currentUnixSeconds)(), supplyMintPrice, debtMintPrice);
97
- const sufficientLiquidity = (0, numberUtils_1.fromBaseUnit)(positionState.debt.amountCanBeUsed.baseAmountUsdValue, constants_1.USD_DECIMALS) *
98
- 0.95 >
99
- values.debtAdjustmentUsd;
100
- if (!sufficientLiquidity) {
101
- console.log("Insufficient debt liquidity to further boost");
94
+ if (positionState.liqUtilizationRateBps - boostFrom <= bpsDistanceThreshold) {
95
+ if (positionState.liqUtilizationRateBps < boostFrom) {
96
+ const values = (0, rebalanceUtils_1.getRebalanceValues)(positionState, positionSettings, positionDca, (0, generalUtils_1.currentUnixSeconds)(), supplyMintPrice, debtMintPrice);
97
+ const sufficientLiquidity = (0, numberUtils_1.fromBaseUnit)(positionState.debt.amountCanBeUsed.baseAmountUsdValue, constants_1.USD_DECIMALS) *
98
+ 0.95 >
99
+ values.debtAdjustmentUsd;
100
+ if (!sufficientLiquidity) {
101
+ console.log("Insufficient debt liquidity to further boost");
102
+ }
103
+ return sufficientLiquidity ? "boost" : undefined;
102
104
  }
103
- return sufficientLiquidity ? "boost" : undefined;
105
+ return "boost";
104
106
  }
105
- else if (Math.max(0, repayFrom - positionState.liqUtilizationRateBps) <=
107
+ else if (repayFrom - positionState.liqUtilizationRateBps <=
106
108
  bpsDistanceThreshold) {
107
109
  return "repay";
108
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.322",
3
+ "version": "1.0.324",
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",
@@ -166,32 +166,32 @@ export function eligibleForRebalance(
166
166
  const repayFrom = positionSettings.repayToBps + positionSettings.repayGap;
167
167
  const boostFrom = boostToBps - positionSettings.boostGap;
168
168
 
169
- if (
170
- Math.max(0, positionState.liqUtilizationRateBps - boostFrom) <=
171
- bpsDistanceThreshold
172
- ) {
173
- const values = getRebalanceValues(
174
- positionState!,
175
- positionSettings,
176
- positionDca,
177
- currentUnixSeconds(),
178
- supplyMintPrice,
179
- debtMintPrice
180
- );
181
- const sufficientLiquidity =
182
- fromBaseUnit(
183
- positionState.debt.amountCanBeUsed.baseAmountUsdValue,
184
- USD_DECIMALS
185
- ) *
186
- 0.95 >
187
- values.debtAdjustmentUsd;
188
- if (!sufficientLiquidity) {
189
- console.log("Insufficient debt liquidity to further boost");
169
+ if (positionState.liqUtilizationRateBps - boostFrom <= bpsDistanceThreshold) {
170
+ if (positionState.liqUtilizationRateBps < boostFrom) {
171
+ const values = getRebalanceValues(
172
+ positionState!,
173
+ positionSettings,
174
+ positionDca,
175
+ currentUnixSeconds(),
176
+ supplyMintPrice,
177
+ debtMintPrice
178
+ );
179
+ const sufficientLiquidity =
180
+ fromBaseUnit(
181
+ positionState.debt.amountCanBeUsed.baseAmountUsdValue,
182
+ USD_DECIMALS
183
+ ) *
184
+ 0.95 >
185
+ values.debtAdjustmentUsd;
186
+ if (!sufficientLiquidity) {
187
+ console.log("Insufficient debt liquidity to further boost");
188
+ }
189
+ return sufficientLiquidity ? "boost" : undefined;
190
190
  }
191
191
 
192
- return sufficientLiquidity ? "boost" : undefined;
192
+ return "boost";
193
193
  } else if (
194
- Math.max(0, repayFrom - positionState.liqUtilizationRateBps) <=
194
+ repayFrom - positionState.liqUtilizationRateBps <=
195
195
  bpsDistanceThreshold
196
196
  ) {
197
197
  return "repay";