@haven-fi/solauto-sdk 1.0.124 → 1.0.126

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.
@@ -417,15 +417,15 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
417
417
  }
418
418
  const freshState = await (0, marginfiUtils_1.getMarginfiAccountPositionState)(this.umi, this.marginfiAccountPk, this.supplyMint, this.debtMint, this.livePositionUpdates);
419
419
  if (freshState) {
420
+ this.log("Fresh state", freshState);
420
421
  const supplyPrice = constants_1.PRICES[(freshState?.supply.mint ?? web3_js_1.PublicKey.default).toString()].price;
421
422
  const debtPrice = constants_1.PRICES[(freshState?.debt.mint ?? web3_js_1.PublicKey.default).toString()].price;
422
- console.log("Supply price: ", supplyPrice);
423
- console.log("Debt price: ", debtPrice);
424
- console.log("Fresh state", freshState);
425
- console.log("Liq threshold bps:", freshState.liqUtilizationRateBps);
426
- console.log("Liq utilization rate bps:", freshState.liqUtilizationRateBps);
427
- console.log("Supply USD:", (0, numberUtils_1.fromBaseUnit)(freshState.supply.amountUsed.baseUnit, freshState.supply.decimals) * supplyPrice);
428
- console.log("Debt USD:", (0, numberUtils_1.fromBaseUnit)(freshState.debt.amountUsed.baseUnit, freshState.supply.decimals) * debtPrice);
423
+ this.log("Supply price: ", supplyPrice);
424
+ this.log("Debt price: ", debtPrice);
425
+ this.log("Liq threshold bps:", freshState.liqThresholdBps);
426
+ this.log("Liq utilization rate bps:", freshState.liqUtilizationRateBps);
427
+ this.log("Supply USD:", (0, numberUtils_1.fromBaseUnit)(freshState.supply.amountUsed.baseUnit, freshState.supply.decimals) * supplyPrice);
428
+ this.log("Debt USD:", (0, numberUtils_1.fromBaseUnit)(freshState.debt.amountUsed.baseUnit, freshState.debt.decimals) * debtPrice);
429
429
  }
430
430
  return freshState;
431
431
  }
@@ -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,yBAAyB,EAC1B,MAAM,iBAAiB,CAAC;AAOzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAkJjD,MAAM,WAAW,eAAe;IAC9B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;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,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,eAAe,CA0EjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,aAAa,GACtB,gBAAgB,GAAG,SAAS,CAmE9B;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,cAAc,CAkChB"}
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,yBAAyB,EAC1B,MAAM,iBAAiB,CAAC;AAOzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAkJjD,MAAM,WAAW,eAAe;IAC9B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;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,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,eAAe,CA0EjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,aAAa,GACtB,gBAAgB,GAAG,SAAS,CAoE9B;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,cAAc,CAkChB"}
@@ -131,9 +131,15 @@ function getFlashLoanDetails(client, values, jupQuote) {
131
131
  ? debtUsd + debtAdjustmentWithSlippage
132
132
  : debtUsd;
133
133
  const tempLiqUtilizationRateBps = (0, numberUtils_1.getLiqUtilzationRateBps)(supplyUsd, debtUsd, client.solautoPositionState.liqThresholdBps);
134
- const requiresFlashLoan = supplyUsd <= 0 ||
135
- tempLiqUtilizationRateBps >
136
- (0, numberUtils_1.getMaxLiqUtilizationRateBps)(client.solautoPositionState.maxLtvBps, client.solautoPositionState.liqThresholdBps, 0.01);
134
+ //TODO: revert me:
135
+ const requiresFlashLoan = true;
136
+ // supplyUsd <= 0 ||
137
+ // tempLiqUtilizationRateBps >
138
+ // getMaxLiqUtilizationRateBps(
139
+ // client.solautoPositionState!.maxLtvBps,
140
+ // client.solautoPositionState!.liqThresholdBps,
141
+ // 0.01
142
+ // );
137
143
  let flashLoanToken = undefined;
138
144
  let flashLoanTokenPrice = 0;
139
145
  if (values.increasingLeverage) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.124",
3
+ "version": "1.0.126",
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",
@@ -629,15 +629,15 @@ export class SolautoMarginfiClient extends SolautoClient {
629
629
  );
630
630
 
631
631
  if (freshState) {
632
+ this.log("Fresh state", freshState);
632
633
  const supplyPrice = PRICES[(freshState?.supply.mint ?? PublicKey.default).toString()].price;
633
634
  const debtPrice = PRICES[(freshState?.debt.mint ?? PublicKey.default).toString()].price;
634
- console.log("Supply price: ", supplyPrice);
635
- console.log("Debt price: ", debtPrice);
636
- console.log("Fresh state", freshState);
637
- console.log("Liq threshold bps:", freshState.liqUtilizationRateBps);
638
- console.log("Liq utilization rate bps:", freshState.liqUtilizationRateBps);
639
- console.log("Supply USD:", fromBaseUnit(freshState.supply.amountUsed.baseUnit, freshState.supply.decimals) * supplyPrice);
640
- console.log("Debt USD:", fromBaseUnit(freshState.debt.amountUsed.baseUnit, freshState.supply.decimals) * debtPrice);
635
+ this.log("Supply price: ", supplyPrice);
636
+ this.log("Debt price: ", debtPrice);
637
+ this.log("Liq threshold bps:", freshState.liqThresholdBps);
638
+ this.log("Liq utilization rate bps:", freshState.liqUtilizationRateBps);
639
+ this.log("Supply USD:", fromBaseUnit(freshState.supply.amountUsed.baseUnit, freshState.supply.decimals) * supplyPrice);
640
+ this.log("Debt USD:", fromBaseUnit(freshState.debt.amountUsed.baseUnit, freshState.debt.decimals) * debtPrice);
641
641
  }
642
642
 
643
643
  return freshState;
@@ -667,8 +667,8 @@ export async function buildSolautoRebalanceTransaction(
667
667
  "B",
668
668
  swapDetails,
669
669
  rebalanceType,
670
- jupQuote.slippageBps,
671
- undefined,
670
+ jupQuote.slippageBps,
671
+ undefined,
672
672
  targetLiqUtilizationRateBps
673
673
  ),
674
674
  ]);
@@ -287,14 +287,15 @@ export function getFlashLoanDetails(
287
287
  debtUsd,
288
288
  client.solautoPositionState!.liqThresholdBps
289
289
  );
290
- const requiresFlashLoan =
291
- supplyUsd <= 0 ||
292
- tempLiqUtilizationRateBps >
293
- getMaxLiqUtilizationRateBps(
294
- client.solautoPositionState!.maxLtvBps,
295
- client.solautoPositionState!.liqThresholdBps,
296
- 0.01
297
- );
290
+ //TODO: revert me:
291
+ const requiresFlashLoan = true;
292
+ // supplyUsd <= 0 ||
293
+ // tempLiqUtilizationRateBps >
294
+ // getMaxLiqUtilizationRateBps(
295
+ // client.solautoPositionState!.maxLtvBps,
296
+ // client.solautoPositionState!.liqThresholdBps,
297
+ // 0.01
298
+ // );
298
299
 
299
300
  let flashLoanToken: PositionTokenUsage | undefined = undefined;
300
301
  let flashLoanTokenPrice = 0;