@haven-fi/solauto-sdk 1.0.295 → 1.0.297

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
  }
@@ -219,7 +219,7 @@ async function sendSingleOptimizedTransaction(umi, connection, tx, txType, prior
219
219
  if (txType !== "skip-simulation") {
220
220
  const simulationResult = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => await simulateTransaction(umi, connection, await assembleFinalTransaction(umi.identity, tx, cuPrice, 1400000).setLatestBlockhash(umi)), 3);
221
221
  simulationResult.value.err;
222
- computeUnitLimit = Math.round(simulationResult.value.unitsConsumed * 1.1);
222
+ computeUnitLimit = Math.round(simulationResult.value.unitsConsumed * 1.2);
223
223
  (0, generalUtils_1.consoleLog)("Compute unit limit: ", computeUnitLimit);
224
224
  }
225
225
  if (txType !== "only-simulate") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.295",
3
+ "version": "1.0.297",
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");
@@ -400,7 +400,7 @@ export async function sendSingleOptimizedTransaction(
400
400
  3
401
401
  );
402
402
  simulationResult.value.err;
403
- computeUnitLimit = Math.round(simulationResult.value.unitsConsumed! * 1.1);
403
+ computeUnitLimit = Math.round(simulationResult.value.unitsConsumed! * 1.2);
404
404
  consoleLog("Compute unit limit: ", computeUnitLimit);
405
405
  }
406
406
 
@@ -54,8 +54,8 @@ describe("Solauto Marginfi tests", async () => {
54
54
  // marginfiAccount: new PublicKey(
55
55
  // "4nNvUXF5YqHFcH2nGweSiuvy1ct7V5FXfoCLKFYUN36z"
56
56
  // ),
57
- supplyMint: NATIVE_MINT,
58
- debtMint: new PublicKey(USDC),
57
+ // supplyMint: NATIVE_MINT,
58
+ // debtMint: new PublicKey(USDC),
59
59
  });
60
60
 
61
61
  const transactionItems: TransactionItem[] = [];
@@ -9,6 +9,9 @@ import {
9
9
  } from "../../src/utils/solanaUtils";
10
10
  import { publicKey } from "@metaplex-foundation/umi";
11
11
  import { assert } from "chai";
12
+ import { getTokenAccount } from "../../src/utils";
13
+ import { SOLAUTO_FEES_WALLET } from "../../src/constants";
14
+ import { PublicKey } from "@solana/web3.js";
12
15
 
13
16
  describe("Assert Solauto fee token accounts are created", async () => {
14
17
  it("all Solauto fee token accounts created", async () => {
@@ -17,9 +20,12 @@ describe("Assert Solauto fee token accounts are created", async () => {
17
20
  );
18
21
 
19
22
  const tokenAccounts = await umi.rpc.getAccounts(
20
- ALL_SUPPORTED_TOKENS.map((x) => publicKey(x))
23
+ ALL_SUPPORTED_TOKENS.map((x) =>
24
+ publicKey(getTokenAccount(SOLAUTO_FEES_WALLET, new PublicKey(x)))
25
+ )
21
26
  );
22
27
  for (let i = 0; i < tokenAccounts.length; i++) {
28
+ console.log(tokenAccounts[i].publicKey.toString());
23
29
  if (!tokenAccounts[i].exists) {
24
30
  console.log(
25
31
  "Missing Solauto fees TA for ",