@haven-fi/solauto-sdk 1.0.592 → 1.0.594

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,3 +1,4 @@
1
1
  export * from "./rebalanceTxBuilder";
2
2
  export * from "./rebalanceValues";
3
+ export * from "./solautoFees";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/rebalance/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/rebalance/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC"}
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./rebalanceTxBuilder"), exports);
18
18
  __exportStar(require("./rebalanceValues"), exports);
19
+ __exportStar(require("./solautoFees"), exports);
@@ -20,7 +20,7 @@ class RebalanceTxBuilder {
20
20
  this.client.pos.eligibleForRebalance()));
21
21
  }
22
22
  getRebalanceValues(flFee) {
23
- return (0, rebalanceValues_1.getRebalanceValues)(this.client.pos, solautoFees_1.SolautoFeesBps.create(this.client.isReferred(), this.targetLiqUtilizationRateBps, this.client.pos.netWorthUsd()), flFee ?? 0, this.targetLiqUtilizationRateBps);
23
+ return (0, rebalanceValues_1.getRebalanceValues)(this.client.pos, this.targetLiqUtilizationRateBps, solautoFees_1.SolautoFeesBps.create(this.client.isReferred(), this.targetLiqUtilizationRateBps, this.client.pos.netWorthUsd()), flFee ?? 0);
24
24
  }
25
25
  getFlLiquiditySource(supplyLiquidityAvailable, debtLiquidityAvailable) {
26
26
  const debtAdjustmentUsd = Math.abs(this.values.debtAdjustmentUsd);
@@ -26,6 +26,6 @@ export interface RebalanceValues extends DebtAdjustment {
26
26
  tokenBalanceChange?: TokenBalanceChange;
27
27
  repayingCloseToMaxLtv: boolean;
28
28
  }
29
- export declare function getRebalanceValues(solautoPosition: SolautoPositionEx, solautoFeeBps: SolautoFeesBps | undefined, flFeeBps: number, targetLiqUtilizationRateBps?: number): RebalanceValues;
29
+ export declare function getRebalanceValues(solautoPosition: SolautoPositionEx, targetLiqUtilizationRateBps?: number, solautoFeeBps?: SolautoFeesBps, flFeeBps?: number): RebalanceValues;
30
30
  export {};
31
31
  //# sourceMappingURL=rebalanceValues.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rebalanceValues.d.ts","sourceRoot":"","sources":["../../../src/services/rebalance/rebalanceValues.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAEnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAO1D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,cAAc,CAAC;IAC1B,iCAAiC,EAAE,MAAM,CAAC;CAC3C;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,yBAAyB;IACjC,MAAM,EAAE,cAAc,CAAC;IACvB,iCAAiC,EAAE,MAAM,CAAC;CAC3C;AAED,wBAAgB,sBAAsB,CACpC,iBAAiB,EAAE,MAAM,EACzB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,gBAAgB,EACtB,YAAY,EAAE,MAAM,GACnB,yBAAyB,CA6B3B;AAED,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,gBAAgB,EACtB,2BAA2B,EAAE,MAAM,GAClC,cAAc,CA+BhB;AAqED,MAAM,WAAW,eAAgB,SAAQ,cAAc;IACrD,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,qBAAqB,EAAE,OAAO,CAAC;CAChC;AAED,wBAAgB,kBAAkB,CAChC,eAAe,EAAE,iBAAiB,EAClC,aAAa,EAAE,cAAc,GAAG,SAAS,EACzC,QAAQ,EAAE,MAAM,EAChB,2BAA2B,CAAC,EAAE,MAAM,GACnC,eAAe,CA6CjB"}
1
+ {"version":3,"file":"rebalanceValues.d.ts","sourceRoot":"","sources":["../../../src/services/rebalance/rebalanceValues.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAEnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAO1D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,cAAc,CAAC;IAC1B,iCAAiC,EAAE,MAAM,CAAC;CAC3C;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,yBAAyB;IACjC,MAAM,EAAE,cAAc,CAAC;IACvB,iCAAiC,EAAE,MAAM,CAAC;CAC3C;AAED,wBAAgB,sBAAsB,CACpC,iBAAiB,EAAE,MAAM,EACzB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,gBAAgB,EACtB,YAAY,EAAE,MAAM,GACnB,yBAAyB,CA6B3B;AAED,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,gBAAgB,EACtB,2BAA2B,EAAE,MAAM,GAClC,cAAc,CA+BhB;AAqED,MAAM,WAAW,eAAgB,SAAQ,cAAc;IACrD,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,qBAAqB,EAAE,OAAO,CAAC;CAChC;AAED,wBAAgB,kBAAkB,CAChC,eAAe,EAAE,iBAAiB,EAClC,2BAA2B,CAAC,EAAE,MAAM,EACpC,aAAa,CAAC,EAAE,cAAc,EAC9B,QAAQ,CAAC,EAAE,MAAM,GAChB,eAAe,CA6CjB"}
@@ -95,7 +95,7 @@ function getRebalanceDirection(solautoPosition, targetLtvBps) {
95
95
  ? generated_1.RebalanceDirection.Boost
96
96
  : generated_1.RebalanceDirection.Repay;
97
97
  }
98
- function getRebalanceValues(solautoPosition, solautoFeeBps, flFeeBps, targetLiqUtilizationRateBps) {
98
+ function getRebalanceValues(solautoPosition, targetLiqUtilizationRateBps, solautoFeeBps, flFeeBps) {
99
99
  const tokenBalanceChange = getTokenBalanceChange();
100
100
  const targetRate = getTargetLiqUtilizationRateBps(solautoPosition, targetLiqUtilizationRateBps, tokenBalanceChange);
101
101
  const rebalanceDirection = getRebalanceDirection(solautoPosition, targetRate);
@@ -105,7 +105,7 @@ function getRebalanceValues(solautoPosition, solautoFeeBps, flFeeBps, targetLiqU
105
105
  ? solautoFeeBps.getSolautoFeesBps(rebalanceDirection).total
106
106
  : 0,
107
107
  lpBorrow: solautoPosition.state().debt.borrowFeeBps,
108
- flashLoan: flFeeBps,
108
+ flashLoan: flFeeBps ?? 0,
109
109
  };
110
110
  const debtAdjustment = getDebtAdjustment((0, utils_1.fromBps)(solautoPosition.state().liqThresholdBps), position, fees, targetRate);
111
111
  const repayingCloseToMaxLtv = rebalanceDirection === generated_1.RebalanceDirection.Repay &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.592",
3
+ "version": "1.0.594",
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",
@@ -1,2 +1,3 @@
1
1
  export * from "./rebalanceTxBuilder";
2
2
  export * from "./rebalanceValues";
3
+ export * from "./solautoFees";
@@ -52,13 +52,13 @@ export class RebalanceTxBuilder {
52
52
  private getRebalanceValues(flFee?: number) {
53
53
  return getRebalanceValues(
54
54
  this.client.pos,
55
+ this.targetLiqUtilizationRateBps,
55
56
  SolautoFeesBps.create(
56
57
  this.client.isReferred(),
57
58
  this.targetLiqUtilizationRateBps,
58
59
  this.client.pos.netWorthUsd()
59
60
  ),
60
61
  flFee ?? 0,
61
- this.targetLiqUtilizationRateBps
62
62
  );
63
63
  }
64
64
 
@@ -183,9 +183,9 @@ export interface RebalanceValues extends DebtAdjustment {
183
183
 
184
184
  export function getRebalanceValues(
185
185
  solautoPosition: SolautoPositionEx,
186
- solautoFeeBps: SolautoFeesBps | undefined,
187
- flFeeBps: number,
188
- targetLiqUtilizationRateBps?: number
186
+ targetLiqUtilizationRateBps?: number,
187
+ solautoFeeBps?: SolautoFeesBps,
188
+ flFeeBps?: number,
189
189
  ): RebalanceValues {
190
190
  const tokenBalanceChange = getTokenBalanceChange();
191
191
 
@@ -207,7 +207,7 @@ export function getRebalanceValues(
207
207
  ? solautoFeeBps.getSolautoFeesBps(rebalanceDirection).total
208
208
  : 0,
209
209
  lpBorrow: solautoPosition.state().debt.borrowFeeBps,
210
- flashLoan: flFeeBps,
210
+ flashLoan: flFeeBps ?? 0,
211
211
  };
212
212
 
213
213
  const debtAdjustment = getDebtAdjustment(
@@ -11,12 +11,7 @@ import {
11
11
  import { fromBps, getLiqUtilzationRateBps } from "../../src/utils/numberUtils";
12
12
  import { getClient } from "../../src/utils/solautoUtils";
13
13
  import { USDC } from "../../src/constants/tokenConstants";
14
- import {
15
- buildHeliusApiUrl,
16
- fetchTokenPrices,
17
- getSolanaRpcConnection,
18
- safeGetPrice,
19
- } from "../../src/utils";
14
+ import { buildIronforgeApiUrl, fetchTokenPrices, safeGetPrice } from "../../src/utils";
20
15
  import {
21
16
  createFakePositionState,
22
17
  getRebalanceValues,
@@ -24,12 +19,8 @@ import {
24
19
  SolautoClient,
25
20
  } from "../../src";
26
21
  import { SolautoFeesBps } from "../../src/services/rebalance/solautoFees";
27
- import { buildIronforgeApiUrl } from "../../dist";
28
22
 
29
23
  const signer = setupTest(undefined, true);
30
- const [conn, _] = getSolanaRpcConnection(
31
- buildHeliusApiUrl(process.env.HELIUS_API_URL!)
32
- );
33
24
 
34
25
  function assertAccurateRebalance(
35
26
  client: SolautoClient,
@@ -38,13 +29,13 @@ function assertAccurateRebalance(
38
29
  ) {
39
30
  const { endResult } = getRebalanceValues(
40
31
  client.pos,
32
+ targetLiqUtilizationRateBps,
41
33
  SolautoFeesBps.create(
42
34
  false,
43
35
  targetLiqUtilizationRateBps,
44
36
  client.pos.netWorthUsd()
45
37
  ),
46
- 50,
47
- targetLiqUtilizationRateBps
38
+ 50
48
39
  );
49
40
 
50
41
  const newLiqUtilizationRateBps = getLiqUtilzationRateBps(