@haven-fi/solauto-sdk 1.0.3 → 1.0.4
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;
|
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;AAKrB,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,SAAS,CAAC;IACtB,iBAAiB,EAAE,SAAS,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAgBD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,aAAa,CAAC;IACxB,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,GAC1B,OAAO,CAAC,kBAAkB,CAAC,CA+D7B"}
|
@@ -5,7 +5,6 @@ const umi_1 = require("@metaplex-foundation/umi");
|
|
5
5
|
const web3_js_1 = require("@solana/web3.js");
|
6
6
|
const solanaUtils_1 = require("./solanaUtils");
|
7
7
|
const numberUtils_1 = require("./numberUtils");
|
8
|
-
const console_1 = require("console");
|
9
8
|
const api_1 = require("@jup-ag/api");
|
10
9
|
const accountUtils_1 = require("./accountUtils");
|
11
10
|
const jupApi = (0, api_1.createJupiterApiClient)();
|
@@ -47,7 +46,9 @@ async function getJupSwapTransaction(signer, swapDetails) {
|
|
47
46
|
destinationTokenAccount: (0, accountUtils_1.getTokenAccount)(swapDetails.destinationWallet, swapDetails.outputMint).toString(),
|
48
47
|
},
|
49
48
|
});
|
50
|
-
|
49
|
+
if (!instructions.swapInstruction) {
|
50
|
+
throw new Error("No swap instruction was returned by Jupiter");
|
51
|
+
}
|
51
52
|
return {
|
52
53
|
jupQuote: quoteResponse,
|
53
54
|
lookupTableAddresses: instructions.addressLookupTableAddresses,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solanaUtils.d.ts","sourceRoot":"","sources":["../../src/utils/solanaUtils.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,uBAAuB,EACvB,MAAM,EACN,kBAAkB,EAClB,kBAAkB,EAGnB,MAAM,0BAA0B,CAAC;AAMlC,OAAO,EAGL,SAAS,EAIT,sBAAsB,EAGvB,MAAM,iBAAiB,CAAC;AAOzB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAQzD,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,cAGhD;AAED,wBAAgB,YAAY,CAAC,eAAe,GAAE,MAAa,GAAG,UAAU,CAIvE;AAED,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,MAAM,CAAC,CAQhE;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,sBAAsB,GACzB,kBAAkB,CAMpB;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,GACtB,kBAAkB,CAOpB;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,QA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,GAClB,OAAO,CAAC,MAAM,CAAC,CAcjB;AAED,wBAAsB,8BAA8B,CAClD,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,YAAY,CAAC,EAAE,OAAO,EACtB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAqDjC"}
|
@@ -152,7 +152,6 @@ async function getComputeUnitPriceEstimate(tx, attemptNum) {
|
|
152
152
|
},
|
153
153
|
]);
|
154
154
|
const feeEstimate = Math.round(resp.priorityFeeEstimate);
|
155
|
-
console.log("Compute unit price: ", feeEstimate);
|
156
155
|
return feeEstimate;
|
157
156
|
}
|
158
157
|
exports.getComputeUnitPriceEstimate = getComputeUnitPriceEstimate;
|
@@ -161,9 +160,10 @@ async function sendSingleOptimizedTransaction(client, tx, simulateOnly, attemptN
|
|
161
160
|
client.log("Instructions: ", tx.getInstructions().length);
|
162
161
|
client.log("Serialized transaction size: ", tx.getTransactionSize(solautoConstants_1.UMI));
|
163
162
|
const feeEstimate = await getComputeUnitPriceEstimate(tx, attemptNum);
|
163
|
+
client.log("Compute unit price: ", feeEstimate);
|
164
164
|
const simulationResult = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => await simulateTransaction((0, umi_web3js_adapters_1.toWeb3JsTransaction)(await (await assembleFinalTransaction(client.signer, tx, feeEstimate, 1400000).setLatestBlockhash(solautoConstants_1.UMI)).buildAndSign(solautoConstants_1.UMI))));
|
165
165
|
const computeUnitLimit = Math.round(simulationResult.value.unitsConsumed * 1.15);
|
166
|
-
|
166
|
+
client.log("Compute unit limit: ", computeUnitLimit);
|
167
167
|
if (!simulateOnly) {
|
168
168
|
const result = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => await assembleFinalTransaction(client.signer, tx, feeEstimate, computeUnitLimit).sendAndConfirm(solautoConstants_1.UMI, {
|
169
169
|
send: {
|
package/package.json
CHANGED
@@ -6,7 +6,6 @@ import {
|
|
6
6
|
import { PublicKey, TransactionInstruction } from "@solana/web3.js";
|
7
7
|
import { getWrappedInstruction } from "./solanaUtils";
|
8
8
|
import { toBps } from "./numberUtils";
|
9
|
-
import { assert } from "console";
|
10
9
|
import {
|
11
10
|
createJupiterApiClient,
|
12
11
|
Instruction,
|
@@ -87,7 +86,10 @@ export async function getJupSwapTransaction(
|
|
87
86
|
},
|
88
87
|
});
|
89
88
|
|
90
|
-
|
89
|
+
if (!instructions.swapInstruction) {
|
90
|
+
throw new Error("No swap instruction was returned by Jupiter");
|
91
|
+
}
|
92
|
+
|
91
93
|
return {
|
92
94
|
jupQuote: quoteResponse,
|
93
95
|
lookupTableAddresses: instructions.addressLookupTableAddresses,
|
package/src/utils/solanaUtils.ts
CHANGED
@@ -268,7 +268,6 @@ export async function getComputeUnitPriceEstimate(
|
|
268
268
|
},
|
269
269
|
]);
|
270
270
|
const feeEstimate = Math.round((resp as any).priorityFeeEstimate as number);
|
271
|
-
console.log("Compute unit price: ", feeEstimate);
|
272
271
|
|
273
272
|
return feeEstimate;
|
274
273
|
}
|
@@ -284,6 +283,7 @@ export async function sendSingleOptimizedTransaction(
|
|
284
283
|
client.log("Serialized transaction size: ", tx.getTransactionSize(UMI));
|
285
284
|
|
286
285
|
const feeEstimate = await getComputeUnitPriceEstimate(tx, attemptNum);
|
286
|
+
client.log("Compute unit price: ", feeEstimate);
|
287
287
|
|
288
288
|
const simulationResult = await retryWithExponentialBackoff(
|
289
289
|
async () =>
|
@@ -304,7 +304,7 @@ export async function sendSingleOptimizedTransaction(
|
|
304
304
|
const computeUnitLimit = Math.round(
|
305
305
|
simulationResult.value.unitsConsumed! * 1.15
|
306
306
|
);
|
307
|
-
|
307
|
+
client.log("Compute unit limit: ", computeUnitLimit);
|
308
308
|
|
309
309
|
if (!simulateOnly) {
|
310
310
|
const result = await retryWithExponentialBackoff(
|