@haven-fi/solauto-sdk 1.0.639 → 1.0.641

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.
@@ -5,6 +5,7 @@ export declare const MIN_POSITION_STATE_FRESHNESS_SECS = 5;
5
5
  export declare const MIN_REPAY_GAP_BPS = 50;
6
6
  export declare const MIN_BOOST_GAP_BPS = 50;
7
7
  export declare const MIN_USD_SUPPORTED_POSITION = 1000;
8
+ export declare const OFFSET_FROM_MAX_LTV = 0.005;
8
9
  export declare const REFERRER_PERCENTAGE = 0.15;
9
10
  export declare const PRICES: {
10
11
  [key: string]: {
@@ -1 +1 @@
1
- {"version":3,"file":"solautoConstants.d.ts","sourceRoot":"","sources":["../../src/constants/solautoConstants.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,SAAS,EACV,MAAM,iBAAiB,CAAC;AAQzB,eAAO,MAAM,oBAAoB,WAEhC,CAAC;AACF,eAAO,MAAM,oBAAoB,WAEhC,CAAC;AAIF,eAAO,MAAM,iCAAiC,IAAI,CAAC;AACnD,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAE/C,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAExC,eAAO,MAAM,MAAM,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CAAO,CAAC;AAEvG,eAAO,MAAM,iBAAiB,UAS7B,CAAC;AAEF,eAAO,MAAM,WAAW,iDAAiD,CAAC;AAC1E,eAAO,MAAM,qBAAqB,UAYR,CAAC"}
1
+ {"version":3,"file":"solautoConstants.d.ts","sourceRoot":"","sources":["../../src/constants/solautoConstants.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,SAAS,EACV,MAAM,iBAAiB,CAAC;AAQzB,eAAO,MAAM,oBAAoB,WAEhC,CAAC;AACF,eAAO,MAAM,oBAAoB,WAEhC,CAAC;AAIF,eAAO,MAAM,iCAAiC,IAAI,CAAC;AACnD,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAE/C,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AAEzC,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAExC,eAAO,MAAM,MAAM,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CAAO,CAAC;AAEvG,eAAO,MAAM,iBAAiB,UAS7B,CAAC;AAEF,eAAO,MAAM,WAAW,iDAAiD,CAAC;AAC1E,eAAO,MAAM,qBAAqB,UAYR,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.STANDARD_LUT_ACCOUNTS = exports.SOLAUTO_LUT = exports.JITO_TIP_ACCOUNTS = exports.PRICES = exports.REFERRER_PERCENTAGE = exports.MIN_USD_SUPPORTED_POSITION = exports.MIN_BOOST_GAP_BPS = exports.MIN_REPAY_GAP_BPS = exports.MIN_POSITION_STATE_FRESHNESS_SECS = exports.SOLAUTO_TEST_PROGRAM = exports.SOLAUTO_PROD_PROGRAM = void 0;
3
+ exports.STANDARD_LUT_ACCOUNTS = exports.SOLAUTO_LUT = exports.JITO_TIP_ACCOUNTS = exports.PRICES = exports.REFERRER_PERCENTAGE = exports.OFFSET_FROM_MAX_LTV = exports.MIN_USD_SUPPORTED_POSITION = exports.MIN_BOOST_GAP_BPS = exports.MIN_REPAY_GAP_BPS = exports.MIN_POSITION_STATE_FRESHNESS_SECS = exports.SOLAUTO_TEST_PROGRAM = exports.SOLAUTO_PROD_PROGRAM = void 0;
4
4
  const web3_js_1 = require("@solana/web3.js");
5
5
  const spl_token_1 = require("@solana/spl-token");
6
6
  const generalConstants_1 = require("./generalConstants");
@@ -12,6 +12,7 @@ exports.MIN_POSITION_STATE_FRESHNESS_SECS = 5;
12
12
  exports.MIN_REPAY_GAP_BPS = 50;
13
13
  exports.MIN_BOOST_GAP_BPS = 50;
14
14
  exports.MIN_USD_SUPPORTED_POSITION = 1000;
15
+ exports.OFFSET_FROM_MAX_LTV = 0.005;
15
16
  exports.REFERRER_PERCENTAGE = 0.15;
16
17
  exports.PRICES = {};
17
18
  exports.JITO_TIP_ACCOUNTS = [
@@ -109,7 +109,7 @@ class RebalanceSwapManager {
109
109
  exactIn,
110
110
  exactOut,
111
111
  amount: swapAmount,
112
- slippageBps: swappingMeme ? 300 : 50,
112
+ slippageBps: swappingMeme ? 200 : 50,
113
113
  };
114
114
  (0, utils_1.consoleLog)("Swap input:", swapInput);
115
115
  if (exactIn && (rebalanceToZero || this.values.repayingCloseToMaxLtv)) {
@@ -1 +1 @@
1
- {"version":3,"file":"rebalanceTxBuilder.d.ts","sourceRoot":"","sources":["../../../src/services/rebalance/rebalanceTxBuilder.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAGL,qBAAqB,EACtB,MAAM,aAAa,CAAC;AA0BrB,qBAAa,kBAAkB;IAQ3B,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,2BAA2B,CAAC;IARtC,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,aAAa,CAAwB;IAC7C,OAAO,CAAC,WAAW,CAAwB;IAC3C,OAAO,CAAC,cAAc,CAAC,CAAwB;IAC/C,OAAO,CAAC,SAAS,CAAiC;gBAGxC,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,YAAA;IAG9C,OAAO,CAAC,0BAA0B;IAQlC,OAAO,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  const flashBorrowDest = exactOut
196
196
  ? (0, utils_1.getTokenAccount)(this.client.pos.publicKey, new web3_js_1.PublicKey(swapQuote.outputMint))
197
197
  : (0, utils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.client.signer.publicKey), new web3_js_1.PublicKey(swapQuote.inputMint));
198
+ (0, utils_1.consoleLog)("Flash borrow dest:", flashBorrowDest.toString());
198
199
  tx = tx.add([
199
200
  setupIx,
200
201
  this.client.flProvider.flashBorrow(flashLoanDetails, flashBorrowDest),
@@ -120,11 +120,11 @@ function getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, offsetFromMaxLt
120
120
  1); // -1 to account for any rounding issues
121
121
  }
122
122
  function maxRepayFromBps(maxLtvBps, liqThresholdBps) {
123
- return Math.min(8700, getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps - 1000, 0.01));
123
+ return Math.min(9000, getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps - 1000, constants_1.OFFSET_FROM_MAX_LTV));
124
124
  }
125
125
  function maxRepayToBps(maxLtvBps, liqThresholdBps) {
126
- return Math.min(maxRepayFromBps(maxLtvBps, liqThresholdBps) - constants_1.MIN_REPAY_GAP_BPS, getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.01));
126
+ return Math.min(maxRepayFromBps(maxLtvBps, liqThresholdBps) - constants_1.MIN_REPAY_GAP_BPS, getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, constants_1.OFFSET_FROM_MAX_LTV));
127
127
  }
128
128
  function maxBoostToBps(maxLtvBps, liqThresholdBps) {
129
- return Math.min(maxRepayToBps(maxLtvBps, liqThresholdBps), getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.01));
129
+ return Math.min(maxRepayToBps(maxLtvBps, liqThresholdBps), getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, constants_1.OFFSET_FROM_MAX_LTV));
130
130
  }
@@ -97,7 +97,7 @@ async function main(filterWhitelist: boolean) {
97
97
  umi,
98
98
  positions.map((x) => new PublicKey(x.publicKey!))
99
99
  )
100
- ).sort((a, b) => a.netWorthUsd - b.netWorthUsd);
100
+ ).sort((a, b) => a.netWorthUsd() - b.netWorthUsd());
101
101
 
102
102
  const tokensUsed = Array.from(
103
103
  new Set(
@@ -115,11 +115,6 @@ async function main(filterWhitelist: boolean) {
115
115
  let awaitingBoostPositions = 0;
116
116
 
117
117
  for (const pos of positionsEx) {
118
- await pos.updateWithLatestPrices({
119
- supplyPrice: safeGetPrice(pos.supplyMint),
120
- debtPrice: safeGetPrice(pos.debtMint),
121
- });
122
-
123
118
  const actionToTake = pos.eligibleForRebalance(0);
124
119
 
125
120
  const repayFrom = pos.settings!.repayToBps + pos.settings!.repayGap;
@@ -142,7 +137,7 @@ async function main(filterWhitelist: boolean) {
142
137
  `(${pos.authority.toString()} ${pos.positionId})`
143
138
  );
144
139
  console.log(
145
- `${pos.strategyName}: $${formatNumber(pos.netWorthUsd, 2, 10000, 2)} ${healthText} ${boostText}`
140
+ `${pos.strategyName}: $${formatNumber(pos.netWorthUsd(), 2, 10000, 2)} ${healthText} ${boostText}`
146
141
  );
147
142
  }
148
143
 
@@ -161,7 +156,7 @@ async function main(filterWhitelist: boolean) {
161
156
  .map((x) => x.supplyUsd())
162
157
  .reduce((acc, curr) => acc + curr, 0);
163
158
  const netWorth = positionsEx
164
- .map((x) => x.netWorthUsd)
159
+ .map((x) => x.netWorthUsd())
165
160
  .reduce((acc, curr) => acc + curr, 0);
166
161
 
167
162
  console.log(`TVL: $${formatNumber(tvl, 2, 10000, 2)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.639",
3
+ "version": "1.0.641",
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",
@@ -26,6 +26,8 @@ export const MIN_REPAY_GAP_BPS = 50;
26
26
  export const MIN_BOOST_GAP_BPS = 50;
27
27
  export const MIN_USD_SUPPORTED_POSITION = 1000;
28
28
 
29
+ export const OFFSET_FROM_MAX_LTV = 0.005;
30
+
29
31
  export const REFERRER_PERCENTAGE = 0.15;
30
32
 
31
33
  export const PRICES: { [key: string]: { realtimePrice: number; emaPrice: number; time: number } } = {};
@@ -174,7 +174,7 @@ export class RebalanceSwapManager {
174
174
  exactIn,
175
175
  exactOut,
176
176
  amount: swapAmount,
177
- slippageBps: swappingMeme ? 300 : 50,
177
+ slippageBps: swappingMeme ? 200 : 50,
178
178
  };
179
179
  consoleLog("Swap input:", swapInput);
180
180
 
@@ -337,6 +337,7 @@ export class RebalanceTxBuilder {
337
337
  new PublicKey(swapQuote.inputMint)
338
338
  );
339
339
 
340
+ consoleLog("Flash borrow dest:", flashBorrowDest.toString());
340
341
  tx = tx.add([
341
342
  setupIx,
342
343
  this.client.flProvider.flashBorrow(flashLoanDetails, flashBorrowDest),
@@ -1,4 +1,4 @@
1
- import { BASIS_POINTS, MIN_REPAY_GAP_BPS, USD_DECIMALS } from "../constants";
1
+ import { BASIS_POINTS, MIN_REPAY_GAP_BPS, OFFSET_FROM_MAX_LTV, USD_DECIMALS } from "../constants";
2
2
  import { PositionState } from "../generated";
3
3
 
4
4
  export function calcNetWorthUsd(state?: PositionState) {
@@ -168,21 +168,21 @@ export function getMaxLiqUtilizationRateBps(
168
168
 
169
169
  export function maxRepayFromBps(maxLtvBps: number, liqThresholdBps: number) {
170
170
  return Math.min(
171
- 8700,
172
- getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps - 1000, 0.01)
171
+ 9000,
172
+ getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps - 1000, OFFSET_FROM_MAX_LTV)
173
173
  );
174
174
  }
175
175
 
176
176
  export function maxRepayToBps(maxLtvBps: number, liqThresholdBps: number) {
177
177
  return Math.min(
178
178
  maxRepayFromBps(maxLtvBps, liqThresholdBps) - MIN_REPAY_GAP_BPS,
179
- getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.01)
179
+ getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, OFFSET_FROM_MAX_LTV)
180
180
  );
181
181
  }
182
182
 
183
183
  export function maxBoostToBps(maxLtvBps: number, liqThresholdBps: number) {
184
184
  return Math.min(
185
185
  maxRepayToBps(maxLtvBps, liqThresholdBps),
186
- getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.01)
186
+ getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, OFFSET_FROM_MAX_LTV)
187
187
  );
188
188
  }