@haven-fi/solauto-sdk 1.0.296 → 1.0.298

Sign up to get free protection for your applications and to get access to all the features.
@@ -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;AAMrB,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;CACnB;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,CAkF7B"}
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;AAMrB,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;CACnB;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,CA0F7B"}
@@ -33,7 +33,7 @@ async function getJupSwapTransaction(signer, swapDetails, attemptNum) {
33
33
  : undefined,
34
34
  slippageBps: 50,
35
35
  maxAccounts: !swapDetails.exactOut ? 60 : undefined,
36
- }), 3);
36
+ }), 4, 200);
37
37
  const priceImpactBps = Math.round((0, numberUtils_1.toBps)(parseFloat(quoteResponse.priceImpactPct))) + 1;
38
38
  const finalPriceSlippageBps = Math.round(Math.max(50, quoteResponse.slippageBps, priceImpactBps) *
39
39
  (1 + (swapDetails.slippageIncFactor ?? 0)));
@@ -44,7 +44,7 @@ async function getJupSwapTransaction(signer, swapDetails, attemptNum) {
44
44
  Math.ceil(parseInt(quoteResponse.inAmount) * (0, numberUtils_1.fromBps)(finalPriceSlippageBps))).toString();
45
45
  }
46
46
  (0, generalUtils_1.consoleLog)("Getting jup instructions...");
47
- const instructions = await jupApi.swapInstructionsPost({
47
+ const instructions = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => await jupApi.swapInstructionsPost({
48
48
  swapRequest: {
49
49
  userPublicKey: signer.publicKey.toString(),
50
50
  quoteResponse,
@@ -52,7 +52,7 @@ async function getJupSwapTransaction(signer, swapDetails, attemptNum) {
52
52
  useTokenLedger: !swapDetails.exactOut && !swapDetails.exactIn,
53
53
  destinationTokenAccount: (0, accountUtils_1.getTokenAccount)(swapDetails.destinationWallet, swapDetails.outputMint).toString(),
54
54
  },
55
- });
55
+ }), 4, 200);
56
56
  if (!instructions.swapInstruction) {
57
57
  throw new Error("No swap instruction was returned by Jupiter");
58
58
  }
@@ -38,7 +38,7 @@ function marginfiMaxLtvAndLiqThresholdBps(supplyBank, debtBank, supplyPrice) {
38
38
  totalDepositedUsdValue > supplyBank.config.totalAssetValueInitLimit) {
39
39
  const discount = Number(supplyBank.config.totalAssetValueInitLimit) /
40
40
  totalDepositedUsdValue;
41
- maxLtv = Math.round(maxLtv * Number(discount));
41
+ maxLtv = maxLtv * Number(discount);
42
42
  }
43
43
  return [maxLtv, liqThreshold];
44
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.296",
3
+ "version": "1.0.298",
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",
@@ -69,7 +69,8 @@ export async function getJupSwapTransaction(
69
69
  slippageBps: 50,
70
70
  maxAccounts: !swapDetails.exactOut ? 60 : undefined,
71
71
  }),
72
- 3
72
+ 4,
73
+ 200
73
74
  );
74
75
 
75
76
  const priceImpactBps =
@@ -84,23 +85,30 @@ export async function getJupSwapTransaction(
84
85
  if (swapDetails.exactOut) {
85
86
  quoteResponse.inAmount = (
86
87
  parseInt(quoteResponse.inAmount) +
87
- Math.ceil(parseInt(quoteResponse.inAmount) * fromBps(finalPriceSlippageBps))
88
+ Math.ceil(
89
+ parseInt(quoteResponse.inAmount) * fromBps(finalPriceSlippageBps)
90
+ )
88
91
  ).toString();
89
92
  }
90
93
 
91
94
  consoleLog("Getting jup instructions...");
92
- const instructions = await jupApi.swapInstructionsPost({
93
- swapRequest: {
94
- userPublicKey: signer.publicKey.toString(),
95
- quoteResponse,
96
- wrapAndUnwrapSol: false,
97
- useTokenLedger: !swapDetails.exactOut && !swapDetails.exactIn,
98
- destinationTokenAccount: getTokenAccount(
99
- swapDetails.destinationWallet,
100
- swapDetails.outputMint
101
- ).toString(),
102
- },
103
- });
95
+ const instructions = await retryWithExponentialBackoff(
96
+ async () =>
97
+ await jupApi.swapInstructionsPost({
98
+ swapRequest: {
99
+ userPublicKey: signer.publicKey.toString(),
100
+ quoteResponse,
101
+ wrapAndUnwrapSol: false,
102
+ useTokenLedger: !swapDetails.exactOut && !swapDetails.exactIn,
103
+ destinationTokenAccount: getTokenAccount(
104
+ swapDetails.destinationWallet,
105
+ swapDetails.outputMint
106
+ ).toString(),
107
+ },
108
+ }),
109
+ 4,
110
+ 200
111
+ );
104
112
 
105
113
  if (!instructions.swapInstruction) {
106
114
  throw new Error("No swap instruction was returned by Jupiter");
@@ -78,7 +78,7 @@ export function marginfiMaxLtvAndLiqThresholdBps(
78
78
  const discount =
79
79
  Number(supplyBank.config.totalAssetValueInitLimit) /
80
80
  totalDepositedUsdValue;
81
- maxLtv = Math.round(maxLtv * Number(discount));
81
+ maxLtv = maxLtv * Number(discount);
82
82
  }
83
83
 
84
84
  return [maxLtv, liqThreshold];