@haven-fi/solauto-sdk 1.0.494 → 1.0.496

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":"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;AAcjD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AA4I9C,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;IAChB,aAAa,EAAE,MAAM,CAAC;CACvB;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,CA6EjB;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe;;;EAsDxB;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B,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,CA6EjB;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,CAgC9B;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,cAAc,CA2EhB"}
@@ -182,15 +182,20 @@ function getJupSwapRebalanceDetails(client, values, targetLiqUtilizationRateBps,
182
182
  : client.solautoPositionState.debt;
183
183
  const usdToSwap = Math.abs(values.debtAdjustmentUsd) +
184
184
  (values.dcaTokenType === generated_1.TokenType.Debt ? values.amountUsdToDcaIn : 0);
185
- const inputAmount = (0, numberUtils_1.toBaseUnit)(usdToSwap / (0, priceUtils_1.safeGetPrice)(input.mint), input.decimals);
185
+ let inputAmount = (0, numberUtils_1.toBaseUnit)(usdToSwap / (0, priceUtils_1.safeGetPrice)(input.mint), input.decimals);
186
186
  const highLiquidity = (0, numberUtils_1.fromBaseUnit)(client.solautoPositionState?.netWorth.baseAmountUsdValue ?? BigInt(0), generalAccounts_1.USD_DECIMALS) > 10000;
187
187
  const usingMajor = (0, generalUtils_2.tokenInfo)(client.supplyMint).isMajor || (0, generalUtils_2.tokenInfo)(client.debtMint).isMajor;
188
- const debtPadding = !usingMajor && highLiquidity ? 0.001 : 0.0001;
188
+ const inputPadding = targetLiqUtilizationRateBps === 0 && !usingMajor && highLiquidity
189
+ ? 0.0001
190
+ : 0;
191
+ if (inputPadding) {
192
+ inputAmount += BigInt(Math.round(Number(inputAmount) * inputPadding));
193
+ }
189
194
  const outputAmount = targetLiqUtilizationRateBps === 0
190
195
  ? output.amountUsed.baseUnit +
191
196
  BigInt(Math.round(Number(output.amountUsed.baseUnit) *
192
197
  // Add this small percentage to account for the APR on the debt between now and the transaction
193
- debtPadding))
198
+ 0.0001))
194
199
  : (0, numberUtils_1.toBaseUnit)(usdToSwap / (0, priceUtils_1.safeGetPrice)(output.mint), output.decimals);
195
200
  const repaying = values.rebalanceDirection === generated_1.RebalanceDirection.Repay;
196
201
  const { requiresFlashLoan, useDebtLiquidity } = rebalanceRequiresFlashLoan(client, values);
@@ -199,7 +204,7 @@ function getJupSwapRebalanceDetails(client, values, targetLiqUtilizationRateBps,
199
204
  // values.repayingCloseToMaxLtv ||
200
205
  flashLoanRepayFromDebt;
201
206
  const exactIn = !exactOut;
202
- const addPadding = exactOut;
207
+ const addPadding = exactOut || targetLiqUtilizationRateBps === 0;
203
208
  return {
204
209
  inputMint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(input.mint),
205
210
  outputMint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(output.mint),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.494",
3
+ "version": "1.0.496",
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",
@@ -389,7 +389,7 @@ export function getJupSwapRebalanceDetails(
389
389
  Math.abs(values.debtAdjustmentUsd) +
390
390
  (values.dcaTokenType === TokenType.Debt ? values.amountUsdToDcaIn : 0);
391
391
 
392
- const inputAmount = toBaseUnit(
392
+ let inputAmount = toBaseUnit(
393
393
  usdToSwap / safeGetPrice(input.mint)!,
394
394
  input.decimals
395
395
  );
@@ -401,7 +401,14 @@ export function getJupSwapRebalanceDetails(
401
401
  ) > 10_000;
402
402
  const usingMajor =
403
403
  tokenInfo(client.supplyMint).isMajor || tokenInfo(client.debtMint).isMajor;
404
- const debtPadding = !usingMajor && highLiquidity ? 0.001 : 0.0001;
404
+ const inputPadding =
405
+ targetLiqUtilizationRateBps === 0 && !usingMajor && highLiquidity
406
+ ? 0.0001
407
+ : 0;
408
+ if (inputPadding) {
409
+ inputAmount += BigInt(Math.round(Number(inputAmount) * inputPadding));
410
+ }
411
+
405
412
  const outputAmount =
406
413
  targetLiqUtilizationRateBps === 0
407
414
  ? output.amountUsed.baseUnit +
@@ -409,7 +416,7 @@ export function getJupSwapRebalanceDetails(
409
416
  Math.round(
410
417
  Number(output.amountUsed.baseUnit) *
411
418
  // Add this small percentage to account for the APR on the debt between now and the transaction
412
- debtPadding
419
+ 0.0001
413
420
  )
414
421
  )
415
422
  : toBaseUnit(usdToSwap / safeGetPrice(output.mint)!, output.decimals);
@@ -429,7 +436,7 @@ export function getJupSwapRebalanceDetails(
429
436
  flashLoanRepayFromDebt;
430
437
  const exactIn = !exactOut;
431
438
 
432
- const addPadding = exactOut;
439
+ const addPadding = exactOut || targetLiqUtilizationRateBps === 0;
433
440
 
434
441
  return {
435
442
  inputMint: toWeb3JsPublicKey(input.mint),