@haven-fi/solauto-sdk 1.0.53 → 1.0.55

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../src/utils/generalUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAa,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAM3E,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAO1C;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,SAAS,GACZ,OAAO,CAAC,OAAO,CAAC,CAGlB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAEnE;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAU1E;AAED,wBAAsB,cAAc,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CA+C1E;AAED,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,KAAK,CAAC,CAAC;AAEjE,wBAAgB,2BAA2B,CAAC,CAAC,EAC3C,EAAE,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,EACtC,OAAO,GAAE,MAAU,EACnB,KAAK,GAAE,MAAY,EACnB,aAAa,CAAC,EAAE,aAAa,GAC5B,OAAO,CAAC,CAAC,CAAC,CA8BZ"}
1
+ {"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../src/utils/generalUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO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;CAC5B;AAED,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,cAAc,EAC3B,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,kBAAkB,CAAC,CAuE7B"}
@@ -34,7 +34,7 @@ async function getJupSwapTransaction(signer, swapDetails, attemptNum) {
34
34
  slippageBps: 10,
35
35
  maxAccounts: 60,
36
36
  }), 3);
37
- const finalPriceSlippageBps = Math.round(Math.max(quoteResponse.slippageBps, Math.round((0, numberUtils_1.toBps)(parseFloat(quoteResponse.priceImpactPct))) + 1) *
37
+ const finalPriceSlippageBps = Math.round(Math.max(100, quoteResponse.slippageBps, Math.round((0, numberUtils_1.toBps)(parseFloat(quoteResponse.priceImpactPct))) + 1) *
38
38
  (1 + (swapDetails.slippageBpsIncFactor ?? 0)));
39
39
  quoteResponse.slippageBps = finalPriceSlippageBps;
40
40
  console.log(quoteResponse);
@@ -1 +1 @@
1
- {"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/solauto/generalUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAoB,GAAG,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAClB,OAAO,EACP,eAAe,EACf,aAAa,EAEb,yBAAyB,EACzB,gCAAgC,EAIjC,MAAM,iBAAiB,CAAC;AAczB,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAgB9E,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,kBAAkB,GAC7B,MAAM,CAKR;AAED,wBAAgB,+BAA+B,CAC7C,UAAU,EAAE,kBAAkB,GAC7B,OAAO,CAET;AAED,wBAAgB,6BAA6B,CAC3C,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,kBAAkB,EAC9B,oBAAoB,E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;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,gCAAgC,CAAA;CAAE,GAC7D;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAE/C,qBAAa,mBAAmB;IACvB,gBAAgB,EAAE,MAAM,CAAa;IACrC,cAAc,EAAE,MAAM,CAAa;IACnC,uBAAuB,EAAE,MAAM,CAAa;IAC5C,QAAQ,EAAE,yBAAyB,GAAG,SAAS,CAAa;IAC5D,SAAS,EAAE,WAAW,GAAG,SAAS,CAAa;IAEtD,GAAG,CAAC,MAAM,EAAE,kBAAkB;IAyD9B,KAAK;IAQL,UAAU,IAAI,OAAO;CAQtB"}
@@ -13,6 +13,7 @@ exports.getAllReferralStates = getAllReferralStates;
13
13
  exports.getReferralsByUser = getReferralsByUser;
14
14
  exports.getAllPositionsByAuthority = getAllPositionsByAuthority;
15
15
  exports.positionStateWithLatestPrices = positionStateWithLatestPrices;
16
+ const web3_js_1 = require("@solana/web3.js");
16
17
  const umi_1 = require("@metaplex-foundation/umi");
17
18
  const generated_1 = require("../../generated");
18
19
  const generalUtils_1 = require("../generalUtils");
@@ -68,7 +69,7 @@ function getSolautoFeesBps(isReferred, feeType) {
68
69
  function eligibleForRebalance(positionState, positionSettings, positionDca) {
69
70
  if (positionDca.automation.targetPeriods > 0 &&
70
71
  eligibleForNextAutomationPeriod(positionDca.automation)) {
71
- return 'dca';
72
+ return "dca";
72
73
  }
73
74
  if (positionState.supply.amountUsed.baseUnit === BigInt(0)) {
74
75
  return undefined;
@@ -80,10 +81,10 @@ function eligibleForRebalance(positionState, positionSettings, positionDca) {
80
81
  const repayFrom = positionSettings.repayToBps + positionSettings.repayGap;
81
82
  const boostFrom = boostToBps - positionSettings.boostGap;
82
83
  if (positionState.liqUtilizationRateBps <= boostFrom) {
83
- return 'boost';
84
+ return "boost";
84
85
  }
85
86
  else if (positionState.liqUtilizationRateBps >= repayFrom) {
86
- return 'repay';
87
+ return "repay";
87
88
  }
88
89
  return undefined;
89
90
  }
@@ -194,7 +195,10 @@ async function getAllPositionsByAuthority(umi, user) {
194
195
  positionId: x.positionId,
195
196
  lendingPlatform: x.lendingPlatform,
196
197
  })));
197
- const marginfiPositions = await (0, marginfiUtils_1.getAllMarginfiAccountsByAuthority)(umi, user, true);
198
+ let marginfiPositions = await (0, marginfiUtils_1.getAllMarginfiAccountsByAuthority)(umi, user, true);
199
+ marginfiPositions = marginfiPositions.filter((x) => x.supplyMint &&
200
+ (x.debtMint.equals(web3_js_1.PublicKey.default) ||
201
+ constants_1.ALL_SUPPORTED_TOKENS.includes(x.debtMint.toString())));
198
202
  allPositions.push(...marginfiPositions.map((x) => ({
199
203
  publicKey: x.marginfiAccount,
200
204
  authority: user,
@@ -186,7 +186,7 @@ function getJupSwapRebalanceDetails(client, values, targetLiqUtilizationRateBps,
186
186
  inputMint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(input.mint),
187
187
  outputMint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(output.mint),
188
188
  destinationWallet: client.solautoPosition,
189
- slippageBpsIncFactor: 0.1 + ((attemptNum ?? 0) * 0.2),
189
+ slippageBpsIncFactor: 0.25 + ((attemptNum ?? 0) * 0.2),
190
190
  amount: rebalancingToZero
191
191
  ? client.solautoPositionState.debt.amountUsed.baseUnit +
192
192
  BigInt(Math.round(Number(client.solautoPositionState.debt.amountUsed.baseUnit) *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.53",
3
+ "version": "1.0.55",
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",
@@ -3,7 +3,6 @@ import { MaybeRpcAccount, publicKey, Umi } from "@metaplex-foundation/umi";
3
3
  import { PYTH_PRICE_FEED_IDS } from "../constants/pythConstants";
4
4
  import { fromBaseUnit, toBaseUnit } from "./numberUtils";
5
5
  import { PRICES } from "../constants/solautoConstants";
6
- import { ResponseError } from "@jup-ag/api";
7
6
 
8
7
  export function generateRandomU8(): number {
9
8
  return Math.floor(Math.random() * 255 + 1);
@@ -73,6 +73,7 @@ export async function getJupSwapTransaction(
73
73
 
74
74
  const finalPriceSlippageBps = Math.round(
75
75
  Math.max(
76
+ 100,
76
77
  quoteResponse.slippageBps,
77
78
  Math.round(toBps(parseFloat(quoteResponse.priceImpactPct))) + 1
78
79
  ) *
@@ -22,7 +22,7 @@ import {
22
22
  } from "../numberUtils";
23
23
  import { getReferralState } from "../accountUtils";
24
24
  import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
25
- import { USD_DECIMALS } from "../../constants";
25
+ import { ALL_SUPPORTED_TOKENS, USD_DECIMALS } from "../../constants";
26
26
  import {
27
27
  getAllMarginfiAccountsByAuthority,
28
28
  getMarginfiAccountPositionState,
@@ -127,7 +127,7 @@ export function eligibleForRebalance(
127
127
  positionDca.automation.targetPeriods > 0 &&
128
128
  eligibleForNextAutomationPeriod(positionDca.automation)
129
129
  ) {
130
- return 'dca';
130
+ return "dca";
131
131
  }
132
132
 
133
133
  if (positionState.supply.amountUsed.baseUnit === BigInt(0)) {
@@ -148,11 +148,9 @@ export function eligibleForRebalance(
148
148
  const boostFrom = boostToBps - positionSettings.boostGap;
149
149
 
150
150
  if (positionState.liqUtilizationRateBps <= boostFrom) {
151
- return 'boost';
152
- } else if (
153
- positionState.liqUtilizationRateBps >= repayFrom
154
- ) {
155
- return 'repay';
151
+ return "boost";
152
+ } else if (positionState.liqUtilizationRateBps >= repayFrom) {
153
+ return "repay";
156
154
  }
157
155
 
158
156
  return undefined;
@@ -293,11 +291,17 @@ export async function getAllPositionsByAuthority(
293
291
  }))
294
292
  );
295
293
 
296
- const marginfiPositions = await getAllMarginfiAccountsByAuthority(
294
+ let marginfiPositions = await getAllMarginfiAccountsByAuthority(
297
295
  umi,
298
296
  user,
299
297
  true
300
298
  );
299
+ marginfiPositions = marginfiPositions.filter(
300
+ (x) =>
301
+ x.supplyMint &&
302
+ (x.debtMint!.equals(PublicKey.default) ||
303
+ ALL_SUPPORTED_TOKENS.includes(x.debtMint!.toString()))
304
+ );
301
305
  allPositions.push(
302
306
  ...marginfiPositions.map((x) => ({
303
307
  publicKey: x.marginfiAccount,
@@ -327,7 +331,7 @@ export async function positionStateWithLatestPrices(
327
331
  umi,
328
332
  protocolAccount,
329
333
  toWeb3JsPublicKey(state.supply.mint),
330
- toWeb3JsPublicKey(state.debt.mint),
334
+ toWeb3JsPublicKey(state.debt.mint)
331
335
  );
332
336
  } else {
333
337
  throw new Error("Lending platorm not yet supported");
@@ -342,7 +342,7 @@ export function getJupSwapRebalanceDetails(
342
342
  inputMint: toWeb3JsPublicKey(input.mint),
343
343
  outputMint: toWeb3JsPublicKey(output.mint),
344
344
  destinationWallet: client.solautoPosition,
345
- slippageBpsIncFactor: 0.1 + ((attemptNum ?? 0) * 0.2),
345
+ slippageBpsIncFactor: 0.25 + ((attemptNum ?? 0) * 0.2),
346
346
  amount: rebalancingToZero
347
347
  ? client.solautoPositionState!.debt.amountUsed.baseUnit +
348
348
  BigInt(