@haven-fi/solauto-sdk 1.0.218 → 1.0.219

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,4 @@
1
+ import { RebalanceDirection } from "../generated";
1
2
  export declare function getLiqUtilzationRateBps(supplyUsd: number, debtUsd: number, liqThresholdBps: number): number;
2
3
  export declare function toBaseUnit(value: number, decimals: number): bigint;
3
4
  export declare function fromBaseUnit(value: bigint, decimals: number): number;
@@ -6,7 +7,7 @@ export declare function toBps(value: number): number;
6
7
  export declare function bytesToI80F48(bytes: number[]): number;
7
8
  export declare function uint8ArrayToBigInt(uint8Array: Uint8Array): bigint;
8
9
  export declare function getDebtAdjustmentUsd(liqThresholdBps: number, supplyUsd: number, debtUsd: number, targetLiqUtilizationRateBps: number, adjustmentFeeBps?: number): number;
9
- export declare function getSolautoFeesBps(isReferred: boolean, targetLiqUtilizationRateBps: number | undefined, positionNetWorthUsd: number, rebalanceDirection: "boost" | "repay"): {
10
+ export declare function getSolautoFeesBps(isReferred: boolean, targetLiqUtilizationRateBps: number | undefined, positionNetWorthUsd: number, rebalanceDirection: RebalanceDirection): {
10
11
  solauto: number;
11
12
  referrer: number;
12
13
  total: number;
@@ -1 +1 @@
1
- {"version":3,"file":"numberUtils.d.ts","sourceRoot":"","sources":["../../src/utils/numberUtils.ts"],"names":[],"mappings":"AAEA,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,MAAM,GACtB,MAAM,CAMR;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED,wBAAgB,aA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AK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAqBrD;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAejE;AAED,wBAAgB,oBAAoB,CAClC,eAAe,EAAE,MAAM,EACvB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,2BAA2B,EAAE,MAAM,EACnC,gBAAgB,CAAC,EAAE,MAAM,UAW1B;AAED,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,OAAO,EACnB,2BAA2B,EAAE,MAAM,GAAG,SAAS,EAC/C,mBAAmB,EAAE,MAAM,EAC3B,kBAAkB,EAAE,kBAAkB,GACrC;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf,CAgCA;AAED,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,gBAAgB,EAAE,MAAM,GACvB,MAAM,CAER;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAKzE;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAKvE;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAKvE"}
@@ -14,6 +14,7 @@ exports.maxRepayFromBps = maxRepayFromBps;
14
14
  exports.maxRepayToBps = maxRepayToBps;
15
15
  exports.maxBoostToBps = maxBoostToBps;
16
16
  const constants_1 = require("../constants");
17
+ const generated_1 = require("../generated");
17
18
  function getLiqUtilzationRateBps(supplyUsd, debtUsd, liqThresholdBps) {
18
19
  if (supplyUsd === 0) {
19
20
  return 0;
@@ -73,7 +74,7 @@ function getSolautoFeesBps(isReferred, targetLiqUtilizationRateBps, positionNetW
73
74
  const minFeeBps = 50; // Fee in basis points for maxSize (0.5%)
74
75
  const k = 1.5;
75
76
  let feeBps = 0;
76
- if (targetLiqUtilizationRateBps !== undefined || rebalanceDirection === "repay") {
77
+ if (targetLiqUtilizationRateBps !== undefined || rebalanceDirection === generated_1.RebalanceDirection.Repay) {
77
78
  feeBps = 25;
78
79
  }
79
80
  else if (positionNetWorthUsd <= minSize) {
@@ -1,17 +1,17 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
2
  import { SolautoClient } from "../../clients/solautoClient";
3
- import { DCASettings, PositionState, SolautoSettingsParameters, TokenType } from "../../generated";
3
+ import { DCASettings, PositionState, RebalanceDirection, SolautoSettingsParameters, TokenType } from "../../generated";
4
4
  import { QuoteResponse } from "@jup-ag/api";
5
5
  import { JupSwapDetails } from "../jupiterUtils";
6
6
  import { RebalanceAction } from "../../types";
7
7
  export interface RebalanceValues {
8
- increasingLeverage: boolean;
9
8
  debtAdjustmentUsd: number;
10
9
  repayingCloseToMaxLtv: boolean;
11
10
  amountToDcaIn: number;
12
11
  amountUsdToDcaIn: number;
13
12
  dcaTokenType?: TokenType;
14
13
  rebalanceAction: RebalanceAction;
14
+ rebalanceDirection: RebalanceDirection;
15
15
  }
16
16
  export declare function getRebalanceValues(state: PositionState, settings: SolautoSettingsParameters | undefined, dca: DCASettings | undefined, currentUnixTime: number, supplyPrice: number, debtPrice: number, targetLiqUtilizationRateBps?: number): RebalanceValues;
17
17
  export interface FlashLoanDetails {
@@ -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,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,EAAE,MAAM,GAClB,cAAc,CAyChB"}
@@ -83,21 +83,21 @@ function getRebalanceValues(state, settings, dca, currentUnixTime, supplyPrice,
83
83
  const { targetRateBps, amountToDcaIn } = getTargetRateAndDcaAmount(state, settings, dca, currentUnixTime, targetLiqUtilizationRateBps);
84
84
  const amountUsdToDcaIn = (0, numberUtils_1.fromBaseUnit)(BigInt(Math.round(amountToDcaIn ?? 0)), state.debt.decimals) *
85
85
  (dca?.tokenType === generated_1.TokenType.Debt ? debtPrice : supplyPrice);
86
- const increasingLeverage = amountUsdToDcaIn > 0 || state.liqUtilizationRateBps < targetRateBps;
87
- const adjustmentFeeBps = (0, numberUtils_1.getSolautoFeesBps)(false, targetLiqUtilizationRateBps, (0, numberUtils_1.fromBaseUnit)(state.netWorth.baseAmountUsdValue, generalAccounts_1.USD_DECIMALS), increasingLeverage ? "boost" : "repay").total;
86
+ const rebalanceDirection = amountUsdToDcaIn > 0 || state.liqUtilizationRateBps < targetRateBps ? generated_1.RebalanceDirection.Boost : generated_1.RebalanceDirection.Repay;
87
+ const adjustmentFeeBps = (0, numberUtils_1.getSolautoFeesBps)(false, targetLiqUtilizationRateBps, (0, numberUtils_1.fromBaseUnit)(state.netWorth.baseAmountUsdValue, generalAccounts_1.USD_DECIMALS), rebalanceDirection).total;
88
88
  const supplyUsd = (0, numberUtils_1.fromBaseUnit)(state.supply.amountUsed.baseAmountUsdValue, generalAccounts_1.USD_DECIMALS) +
89
89
  amountUsdToDcaIn;
90
90
  const debtUsd = (0, numberUtils_1.fromBaseUnit)(state.debt.amountUsed.baseAmountUsdValue, generalAccounts_1.USD_DECIMALS);
91
91
  let debtAdjustmentUsd = (0, numberUtils_1.getDebtAdjustmentUsd)(state.liqThresholdBps, supplyUsd, debtUsd, targetRateBps, adjustmentFeeBps);
92
92
  const maxRepayTo = (0, numberUtils_1.maxRepayToBps)(state.maxLtvBps, state.liqThresholdBps);
93
93
  return {
94
- increasingLeverage,
95
94
  debtAdjustmentUsd,
96
95
  repayingCloseToMaxLtv: state.liqUtilizationRateBps > maxRepayTo && targetRateBps >= maxRepayTo,
97
96
  amountToDcaIn: amountToDcaIn ?? 0,
98
97
  amountUsdToDcaIn,
99
98
  dcaTokenType: dca?.tokenType,
100
- rebalanceAction: (amountToDcaIn ?? 0) > 0 ? "dca" : increasingLeverage ? "boost" : "repay",
99
+ rebalanceAction: (amountToDcaIn ?? 0) > 0 ? "dca" : rebalanceDirection === generated_1.RebalanceDirection.Boost ? "boost" : "repay",
100
+ rebalanceDirection,
101
101
  };
102
102
  }
103
103
  function getFlashLoanDetails(client, values, jupQuote) {
@@ -115,7 +115,7 @@ function getFlashLoanDetails(client, values, jupQuote) {
115
115
  (0, numberUtils_1.getMaxLiqUtilizationRateBps)(client.solautoPositionState.maxLtvBps, client.solautoPositionState.liqThresholdBps, 0.01);
116
116
  let flashLoanToken = undefined;
117
117
  let flashLoanTokenPrice = 0;
118
- if (values.increasingLeverage) {
118
+ if (values.rebalanceDirection === generated_1.RebalanceDirection.Boost) {
119
119
  flashLoanToken = client.solautoPositionState.debt;
120
120
  flashLoanTokenPrice = (0, generalUtils_2.safeGetPrice)(client.debtMint);
121
121
  }
@@ -136,10 +136,10 @@ function getFlashLoanDetails(client, values, jupQuote) {
136
136
  : undefined;
137
137
  }
138
138
  function getJupSwapRebalanceDetails(client, values, targetLiqUtilizationRateBps, attemptNum) {
139
- const input = values.increasingLeverage
139
+ const input = values.rebalanceDirection === generated_1.RebalanceDirection.Boost
140
140
  ? client.solautoPositionState.debt
141
141
  : client.solautoPositionState.supply;
142
- const output = values.increasingLeverage
142
+ const output = values.rebalanceDirection === generated_1.RebalanceDirection.Boost
143
143
  ? client.solautoPositionState.supply
144
144
  : client.solautoPositionState.debt;
145
145
  const usdToSwap = Math.abs(values.debtAdjustmentUsd) +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.218",
3
+ "version": "1.0.219",
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,4 +1,5 @@
1
1
  import { BASIS_POINTS, MIN_REPAY_GAP_BPS } from "../constants";
2
+ import { RebalanceDirection } from "../generated";
2
3
 
3
4
  export function getLiqUtilzationRateBps(
4
5
  supplyUsd: number,
@@ -90,7 +91,7 @@ export function getSolautoFeesBps(
90
91
  isReferred: boolean,
91
92
  targetLiqUtilizationRateBps: number | undefined,
92
93
  positionNetWorthUsd: number,
93
- rebalanceDirection: "boost" | "repay"
94
+ rebalanceDirection: RebalanceDirection
94
95
  ): {
95
96
  solauto: number;
96
97
  referrer: number;
@@ -104,7 +105,7 @@ export function getSolautoFeesBps(
104
105
 
105
106
  let feeBps: number = 0;
106
107
 
107
- if (targetLiqUtilizationRateBps !== undefined || rebalanceDirection === "repay") {
108
+ if (targetLiqUtilizationRateBps !== undefined || rebalanceDirection === RebalanceDirection.Repay) {
108
109
  feeBps = 25;
109
110
  } else if (positionNetWorthUsd <= minSize) {
110
111
  feeBps = maxFeeBps;
@@ -4,6 +4,7 @@ import {
4
4
  DCASettings,
5
5
  PositionState,
6
6
  PositionTokenUsage,
7
+ RebalanceDirection,
7
8
  SolautoSettingsParameters,
8
9
  TokenType,
9
10
  } from "../../generated";
@@ -158,13 +159,13 @@ function getTargetRateAndDcaAmount(
158
159
  }
159
160
 
160
161
  export interface RebalanceValues {
161
- increasingLeverage: boolean;
162
162
  debtAdjustmentUsd: number;
163
163
  repayingCloseToMaxLtv: boolean;
164
164
  amountToDcaIn: number;
165
165
  amountUsdToDcaIn: number;
166
166
  dcaTokenType?: TokenType;
167
167
  rebalanceAction: RebalanceAction;
168
+ rebalanceDirection: RebalanceDirection
168
169
  }
169
170
 
170
171
  export function getRebalanceValues(
@@ -188,13 +189,12 @@ export function getRebalanceValues(
188
189
  fromBaseUnit(BigInt(Math.round(amountToDcaIn ?? 0)), state.debt.decimals) *
189
190
  (dca?.tokenType === TokenType.Debt ? debtPrice : supplyPrice);
190
191
 
191
- const increasingLeverage =
192
- amountUsdToDcaIn > 0 || state.liqUtilizationRateBps < targetRateBps;
192
+ const rebalanceDirection = amountUsdToDcaIn > 0 || state.liqUtilizationRateBps < targetRateBps ? RebalanceDirection.Boost : RebalanceDirection.Repay;
193
193
  const adjustmentFeeBps = getSolautoFeesBps(
194
194
  false,
195
195
  targetLiqUtilizationRateBps,
196
196
  fromBaseUnit(state.netWorth.baseAmountUsdValue, USD_DECIMALS),
197
- increasingLeverage ? "boost" : "repay"
197
+ rebalanceDirection
198
198
  ).total;
199
199
 
200
200
  const supplyUsd =
@@ -214,7 +214,6 @@ export function getRebalanceValues(
214
214
 
215
215
  const maxRepayTo = maxRepayToBps(state.maxLtvBps, state.liqThresholdBps);
216
216
  return {
217
- increasingLeverage,
218
217
  debtAdjustmentUsd,
219
218
  repayingCloseToMaxLtv:
220
219
  state.liqUtilizationRateBps > maxRepayTo && targetRateBps >= maxRepayTo,
@@ -222,7 +221,8 @@ export function getRebalanceValues(
222
221
  amountUsdToDcaIn,
223
222
  dcaTokenType: dca?.tokenType,
224
223
  rebalanceAction:
225
- (amountToDcaIn ?? 0) > 0 ? "dca" : increasingLeverage ? "boost" : "repay",
224
+ (amountToDcaIn ?? 0) > 0 ? "dca" : rebalanceDirection === RebalanceDirection.Boost ? "boost" : "repay",
225
+ rebalanceDirection,
226
226
  };
227
227
  }
228
228
 
@@ -269,7 +269,7 @@ export function getFlashLoanDetails(
269
269
 
270
270
  let flashLoanToken: PositionTokenUsage | undefined = undefined;
271
271
  let flashLoanTokenPrice = 0;
272
- if (values.increasingLeverage) {
272
+ if (values.rebalanceDirection === RebalanceDirection.Boost) {
273
273
  flashLoanToken = client.solautoPositionState!.debt;
274
274
  flashLoanTokenPrice = safeGetPrice(client.debtMint)!;
275
275
  } else {
@@ -301,10 +301,10 @@ export function getJupSwapRebalanceDetails(
301
301
  targetLiqUtilizationRateBps?: number,
302
302
  attemptNum?: number
303
303
  ): JupSwapDetails {
304
- const input = values.increasingLeverage
304
+ const input = values.rebalanceDirection === RebalanceDirection.Boost
305
305
  ? client.solautoPositionState!.debt
306
306
  : client.solautoPositionState!.supply;
307
- const output = values.increasingLeverage
307
+ const output = values.rebalanceDirection === RebalanceDirection.Boost
308
308
  ? client.solautoPositionState!.supply
309
309
  : client.solautoPositionState!.debt;
310
310
 
@@ -46,7 +46,7 @@ function assertAccurateRebalance(
46
46
  targetLiqUtilizationRateBps?: number,
47
47
  expectedUsdToDcaIn?: number
48
48
  ) {
49
- const { increasingLeverage, debtAdjustmentUsd, amountUsdToDcaIn } =
49
+ const { rebalanceDirection, debtAdjustmentUsd, amountUsdToDcaIn } =
50
50
  getRebalanceValues(
51
51
  client.solautoPositionState!,
52
52
  client.solautoPositionSettings(),
@@ -58,17 +58,15 @@ function assertAccurateRebalance(
58
58
  );
59
59
 
60
60
  let adjustmentFeeBps = 0;
61
- if (increasingLeverage) {
62
- adjustmentFeeBps = getSolautoFeesBps(
63
- client.referredBy !== undefined,
64
- targetLiqUtilizationRateBps,
65
- fromBaseUnit(
66
- client.solautoPositionState?.netWorth.baseAmountUsdValue ?? BigInt(0),
67
- USD_DECIMALS
68
- ),
69
- increasingLeverage ? "boost" : "repay"
70
- ).total;
71
- }
61
+ adjustmentFeeBps = getSolautoFeesBps(
62
+ client.referredBy !== undefined,
63
+ targetLiqUtilizationRateBps,
64
+ fromBaseUnit(
65
+ client.solautoPositionState?.netWorth.baseAmountUsdValue ?? BigInt(0),
66
+ USD_DECIMALS
67
+ ),
68
+ rebalanceDirection
69
+ ).total;
72
70
 
73
71
  assert(
74
72
  Math.round(amountUsdToDcaIn) === Math.round(expectedUsdToDcaIn ?? 0),