@haven-fi/solauto-sdk 1.0.425 → 1.0.427

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 +1 @@
1
- {"version":3,"file":"jupiterUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jupiterUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAA0B,MAAM,iBAAiB,CAAC;AAGpE,OAAO,EAGL,aAAa,EACd,MAAM,aAAa,CAAC;AAOrB,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,SAAS,CAAC;IACtB,iBAAiB,EAAE,SAAS,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAgBD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,aAAa,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,iBAAiB,EAAE,kBAAkB,CAAC;IACtC,aAAa,EAAE,kBAAkB,CAAC;IAClC,MAAM,EAAE,kBAAkB,CAAC;CAC5B;AAED,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,cAAc,EAC3B,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,kBAAkB,CAAC,CAmG7B;AAED,wBAAsB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,SAAS,CAAC,EAAE,OAAO;;GAiB5E"}
1
+ {"version":3,"file":"jupiterUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jupiterUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAA0B,MAAM,iBAAiB,CAAC;AAGpE,OAAO,EAGL,aAAa,EACd,MAAM,aAAa,CAAC;AAOrB,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,SAAS,CAAC;IACtB,iBAAiB,EAAE,SAAS,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAgBD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,aAAa,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,iBAAiB,EAAE,kBAAkB,CAAC;IACtC,aAAa,EAAE,kBAAkB,CAAC;IAClC,MAAM,EAAE,kBAAkB,CAAC;CAC5B;AAED,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,cAAc,EAC3B,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,kBAAkB,CAAC,CAiG7B;AAED,wBAAsB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,SAAS,CAAC,EAAE,OAAO;;GAiB5E"}
@@ -34,15 +34,13 @@ async function getJupSwapTransaction(signer, swapDetails, attemptNum) {
34
34
  : swapDetails.exactIn
35
35
  ? "ExactIn"
36
36
  : undefined,
37
- slippageBps: memecoinSwap ? 500 : 200,
37
+ slippageBps: memecoinSwap ? 500 : 300,
38
38
  maxAccounts: !swapDetails.exactOut ? 45 : undefined,
39
39
  }), 4, 200);
40
40
  const priceImpactBps = Math.round((0, numberUtils_1.toBps)(parseFloat(quoteResponse.priceImpactPct))) + 1;
41
41
  const finalPriceSlippageBps = Math.round(Math.max(50, quoteResponse.slippageBps, priceImpactBps) *
42
42
  (1 + (swapDetails.slippageIncFactor ?? 0)));
43
- if (!swapDetails.exactOut) {
44
- quoteResponse.slippageBps = finalPriceSlippageBps;
45
- }
43
+ quoteResponse.slippageBps = finalPriceSlippageBps;
46
44
  (0, generalUtils_1.consoleLog)(quoteResponse);
47
45
  (0, generalUtils_1.consoleLog)("Getting jup instructions...");
48
46
  const instructions = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => await jupApi.swapInstructionsPost({
@@ -62,9 +60,9 @@ async function getJupSwapTransaction(signer, swapDetails, attemptNum) {
62
60
  (0, generalUtils_1.consoleLog)("Increased price impact bps:", finalPriceImpactBps);
63
61
  if (swapDetails.addPadding) {
64
62
  (0, generalUtils_1.consoleLog)("Raw inAmount:", quoteResponse.inAmount);
65
- quoteResponse.inAmount = Math.round(parseInt(quoteResponse.inAmount) +
66
- parseInt(quoteResponse.inAmount) *
67
- Math.max((0, numberUtils_1.fromBps)(finalPriceImpactBps), (0, numberUtils_1.fromBps)(finalPriceImpactBps) / 2)).toString();
63
+ const inc = Math.max((0, numberUtils_1.fromBps)(finalPriceImpactBps), (0, numberUtils_1.fromBps)(finalPriceImpactBps) / 2);
64
+ (0, generalUtils_1.consoleLog)("Inc:", inc);
65
+ quoteResponse.inAmount = Math.round(parseInt(quoteResponse.inAmount) + parseInt(quoteResponse.inAmount) * inc).toString();
68
66
  (0, generalUtils_1.consoleLog)("Increased inAmount:", quoteResponse.inAmount);
69
67
  }
70
68
  return {
@@ -171,7 +171,7 @@ function getJupSwapRebalanceDetails(client, values, targetLiqUtilizationRateBps,
171
171
  inputMint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(input.mint),
172
172
  outputMint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(output.mint),
173
173
  destinationWallet: client.solautoPosition,
174
- slippageIncFactor: 1 + (attemptNum ?? 0) * 0.25,
174
+ slippageIncFactor: 0.5 + (attemptNum ?? 0) * 0.25,
175
175
  amount: exactOut ? outputAmount : inputAmount,
176
176
  exactIn: exactIn,
177
177
  exactOut: exactOut,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.425",
3
+ "version": "1.0.427",
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",
@@ -71,7 +71,7 @@ export async function getJupSwapTransaction(
71
71
  : swapDetails.exactIn
72
72
  ? "ExactIn"
73
73
  : undefined,
74
- slippageBps: memecoinSwap ? 500 : 200,
74
+ slippageBps: memecoinSwap ? 500 : 300,
75
75
  maxAccounts: !swapDetails.exactOut ? 45 : undefined,
76
76
  }),
77
77
  4,
@@ -84,9 +84,7 @@ export async function getJupSwapTransaction(
84
84
  Math.max(50, quoteResponse.slippageBps, priceImpactBps) *
85
85
  (1 + (swapDetails.slippageIncFactor ?? 0))
86
86
  );
87
- if (!swapDetails.exactOut) {
88
- quoteResponse.slippageBps = finalPriceSlippageBps;
89
- }
87
+ quoteResponse.slippageBps = finalPriceSlippageBps;
90
88
  consoleLog(quoteResponse);
91
89
 
92
90
  consoleLog("Getting jup instructions...");
@@ -119,13 +117,13 @@ export async function getJupSwapTransaction(
119
117
 
120
118
  if (swapDetails.addPadding) {
121
119
  consoleLog("Raw inAmount:", quoteResponse.inAmount);
120
+ const inc = Math.max(
121
+ fromBps(finalPriceImpactBps),
122
+ fromBps(finalPriceImpactBps) / 2
123
+ );
124
+ consoleLog("Inc:", inc);
122
125
  quoteResponse.inAmount = Math.round(
123
- parseInt(quoteResponse.inAmount) +
124
- parseInt(quoteResponse.inAmount) *
125
- Math.max(
126
- fromBps(finalPriceImpactBps),
127
- fromBps(finalPriceImpactBps) / 2
128
- )
126
+ parseInt(quoteResponse.inAmount) + parseInt(quoteResponse.inAmount) * inc
129
127
  ).toString();
130
128
  consoleLog("Increased inAmount:", quoteResponse.inAmount);
131
129
  }
@@ -363,7 +363,7 @@ export function getJupSwapRebalanceDetails(
363
363
  inputMint: toWeb3JsPublicKey(input.mint),
364
364
  outputMint: toWeb3JsPublicKey(output.mint),
365
365
  destinationWallet: client.solautoPosition,
366
- slippageIncFactor: 1 + (attemptNum ?? 0) * 0.25,
366
+ slippageIncFactor: 0.5 + (attemptNum ?? 0) * 0.25,
367
367
  amount: exactOut ? outputAmount : inputAmount,
368
368
  exactIn: exactIn,
369
369
  exactOut: exactOut,