@haven-fi/solauto-sdk 1.0.313 → 1.0.315

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":"jitoUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jitoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAwB,MAAM,iBAAiB,CAAC;AAGlE,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAEJ,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAI9C,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,SAAS,CAAC,CAa9D;AA2GD,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,kBAAkB,EAAE,EACzB,YAAY,CAAC,EAAE,OAAO,EACtB,kBAAkB,GAAE,kBAA2C,GAC9D,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CA0C/B"}
1
+ {"version":3,"file":"jitoUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jitoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAwB,MAAM,iBAAiB,CAAC;AAGlE,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAEJ,MAAM,0BAA0B,CAAC;AAQlC,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAK9C,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,SAAS,CAAC,CAa9D;AA8GD,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,kBAAkB,EAAE,EACzB,YAAY,CAAC,EAAE,OAAO,EACtB,kBAAkB,GAAE,kBAA2C,GAC9D,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CA2C/B"}
@@ -30,29 +30,33 @@ async function getRandomTipAccount() {
30
30
  async function getTipInstruction(signer, tipLamports) {
31
31
  return (0, solanaUtils_1.systemTransferUmiIx)(signer, await getRandomTipAccount(), BigInt(tipLamports));
32
32
  }
33
- // async function simulateJitoBundle(
34
- // txs: VersionedTransaction[]
35
- // ): Promise<SimulatedBundleTransactionResult[]> {
36
- // const simulationResult = await JITO_CONNECTION.simulateBundle(txs, {
37
- // preExecutionAccountsConfigs: txs.map((x) => null),
38
- // postExecutionAccountsConfigs: txs.map((x) => null),
39
- // skipSigVerify: true,
40
- // });
41
- // simulationResult.value.transactionResults.forEach((tx) => {
42
- // if (tx.err) {
43
- // tx.logs?.forEach((x) => {
44
- // consoleLog(x);
45
- // });
46
- // throw tx.err;
33
+ // TODO: fix
34
+ // async function simulateJitoBundle(umi: Umi, txs: VersionedTransaction[]) {
35
+ // const simulationResult = await axios.post(
36
+ // `${JITO_BLOCK_ENGINE}/api/v1/bundles`,
37
+ // {
38
+ // method: "simulateBundle",
39
+ // id: 1,
40
+ // jsonrpc: "2.0",
41
+ // params: [
42
+ // {
43
+ // encodedTransactions: txs.map((x) => bs58.encode(x.serialize())),
44
+ // preExecutionAccountsConfigs: txs.map((_) => ""),
45
+ // postExecutionAccountsConfigs: txs.map((_) => ""),
46
+ // skipSigVerify: true,
47
+ // },
48
+ // ],
47
49
  // }
48
- // });
49
- // return simulationResult.value.transactionResults;
50
+ // );
50
51
  // }
51
- async function umiToVersionedTransactions(umi, signer, txs, feeEstimates, computeUnitLimits) {
52
- return await Promise.all(txs.map(async (tx, i) => {
53
- const versionedTx = (0, umi_web3js_adapters_1.toWeb3JsTransaction)(await (await (0, solanaUtils_1.assembleFinalTransaction)(signer, tx, feeEstimates[i], computeUnitLimits ? computeUnitLimits[i] : undefined).setLatestBlockhash(umi)).buildAndSign(umi));
54
- return versionedTx;
52
+ async function umiToVersionedTransactions(umi, signer, txs, sign, feeEstimates, computeUnitLimits) {
53
+ const builtTxs = await Promise.all(txs.map(async (tx, i) => {
54
+ return (await (0, solanaUtils_1.assembleFinalTransaction)(signer, tx, feeEstimates[i], computeUnitLimits ? computeUnitLimits[i] : undefined).setLatestBlockhash(umi)).build(umi);
55
55
  }));
56
+ if (sign) {
57
+ signer.signAllTransactions(builtTxs);
58
+ }
59
+ return builtTxs.map((x) => (0, umi_web3js_adapters_1.toWeb3JsTransaction)(x));
56
60
  }
57
61
  async function getBundleStatus(bundleId) {
58
62
  const res = await axios_1.default.post(`${solautoConstants_1.JITO_BLOCK_ENGINE}/api/v1/bundles`, {
@@ -96,17 +100,16 @@ async function sendJitoBundledTransactions(umi, signer, txs, simulateOnly, prior
96
100
  (0, generalUtils_1.consoleLog)("Transactions: ", txs.length);
97
101
  (0, generalUtils_1.consoleLog)("Transaction sizes: ", txs.map((x) => x.getTransactionSize(umi)));
98
102
  txs[0] = txs[0].prepend(await getTipInstruction(signer, 150000));
99
- const feeEstimates = await Promise.all(txs.map(async (x) => (await (0, solanaUtils_1.getComputeUnitPriceEstimate)(umi, x, priorityFeeSetting, true)) ??
103
+ const feeEstimates = await Promise.all(txs.map(async (x) => (await (0, solanaUtils_1.getComputeUnitPriceEstimate)(umi, x, priorityFeeSetting)) ??
100
104
  1000000));
101
- let builtTxs = await umiToVersionedTransactions(umi, signer, txs, feeEstimates
102
- // Array(txs.length).fill(1_400_000)
103
- );
104
- // // TODO: Skip over this for now, and instead don't specify a compute unit limit in the final bundle transactions
105
- // const simulationResults = await simulateJitoBundle(builtTxs);
105
+ let builtTxs = await umiToVersionedTransactions(umi, signer, txs, true, // false if simulating first and rebuilding later
106
+ feeEstimates);
107
+ // const simulationResults = await simulateJitoBundle(umi, builtTxs);
106
108
  if (!simulateOnly) {
107
109
  // let builtTxs = await umiToVersionedTransactions(
108
110
  // client.signer,
109
111
  // txs,
112
+ // true,
110
113
  // feeEstimates,
111
114
  // simulationResults.map((x) => x.unitsConsumed! * 1.15)
112
115
  // );
@@ -14,6 +14,6 @@ export declare function splTokenTransferUmiIx(signer: Signer, fromTa: PublicKey,
14
14
  export declare function getAddressLookupInputs(umi: Umi, lookupTableAddresses: string[]): Promise<AddressLookupTableInput[]>;
15
15
  export declare function addTxOptimizations(signer: Signer, transaction: TransactionBuilder, computeUnitPrice?: number, computeUnitLimit?: number): TransactionBuilder;
16
16
  export declare function assembleFinalTransaction(signer: Signer, transaction: TransactionBuilder, computeUnitPrice?: number, computeUnitLimit?: number): TransactionBuilder;
17
- export declare function getComputeUnitPriceEstimate(umi: Umi, tx: TransactionBuilder, prioritySetting: PriorityFeeSetting, simMayFail: boolean): Promise<number | undefined>;
17
+ export declare function getComputeUnitPriceEstimate(umi: Umi, tx: TransactionBuilder, prioritySetting: PriorityFeeSetting): Promise<number | undefined>;
18
18
  export declare function sendSingleOptimizedTransaction(umi: Umi, connection: Connection, tx: TransactionBuilder, txType?: TransactionRunType, prioritySetting?: PriorityFeeSetting, onAwaitingSign?: () => void): Promise<Uint8Array | undefined>;
19
19
  //# sourceMappingURL=solanaUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"solanaUtils.d.ts","sourceRoot":"","sources":["../../src/utils/solanaUtils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EACvB,MAAM,EACN,kBAAkB,EAClB,GAAG,EACH,kBAAkB,EAGnB,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAIL,UAAU,EACV,SAAS,EAKT,sBAAsB,EAEvB,MAAM,iBAAiB,CAAC;AAgBzB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAIlE,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,UAErD;AAED,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,MAAM,UAE3D;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,SAAgC,GAC1C,CAAC,UAAU,EAAE,GAAG,CAAC,CAQnB;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EAC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S,CAAC,CA+DjC"}
@@ -150,22 +150,13 @@ async function simulateTransaction(umi, connection, transaction) {
150
150
  }
151
151
  return simulationResult;
152
152
  }
153
- async function getComputeUnitPriceEstimate(umi, tx, prioritySetting, simMayFail) {
153
+ async function getComputeUnitPriceEstimate(umi, tx, prioritySetting) {
154
154
  const web3Transaction = (0, umi_web3js_adapters_1.toWeb3JsTransaction)((await tx.setLatestBlockhash(umi, { commitment: "finalized" })).build(umi));
155
- const transaction = simMayFail
156
- ? undefined
157
- : bs58_1.default.encode(web3Transaction.serialize());
158
- const accountKeys = simMayFail
159
- ? tx
160
- .getInstructions()
161
- .flatMap((x) => x.keys.flatMap((x) => x.pubkey.toString()))
162
- : undefined;
163
155
  let feeEstimate;
164
156
  try {
165
157
  const resp = await umi.rpc.call("getPriorityFeeEstimate", [
166
158
  {
167
- transaction,
168
- accountKeys,
159
+ transaction: bs58_1.default.encode(web3Transaction.serialize()),
169
160
  options: {
170
161
  priorityLevel: prioritySetting.toString(),
171
162
  },
@@ -174,7 +165,22 @@ async function getComputeUnitPriceEstimate(umi, tx, prioritySetting, simMayFail)
174
165
  feeEstimate = Math.round(resp.priorityFeeEstimate);
175
166
  }
176
167
  catch (e) {
177
- console.error(e);
168
+ try {
169
+ const resp = await umi.rpc.call("getPriorityFeeEstimate", [
170
+ {
171
+ accountKeys: tx
172
+ .getInstructions()
173
+ .flatMap((x) => x.keys.flatMap((x) => x.pubkey.toString())),
174
+ options: {
175
+ priorityLevel: prioritySetting.toString(),
176
+ },
177
+ },
178
+ ]);
179
+ feeEstimate = Math.round(resp.priorityFeeEstimate);
180
+ }
181
+ catch (e) {
182
+ console.error(e);
183
+ }
178
184
  }
179
185
  return feeEstimate;
180
186
  }
@@ -216,7 +222,7 @@ async function sendSingleOptimizedTransaction(umi, connection, tx, txType, prior
216
222
  (0, generalUtils_1.consoleLog)("Serialized transaction size: ", tx.getTransactionSize(umi));
217
223
  let cuPrice;
218
224
  if (prioritySetting !== types_1.PriorityFeeSetting.None) {
219
- cuPrice = await getComputeUnitPriceEstimate(umi, tx, prioritySetting, false);
225
+ cuPrice = await getComputeUnitPriceEstimate(umi, tx, prioritySetting);
220
226
  if (!cuPrice) {
221
227
  cuPrice = 1000000;
222
228
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.313",
3
+ "version": "1.0.315",
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",
@@ -9,6 +9,7 @@ import {
9
9
  } from "@metaplex-foundation/umi";
10
10
  import {
11
11
  assembleFinalTransaction,
12
+ buildIronforgeApiUrl,
12
13
  getComputeUnitPriceEstimate,
13
14
  systemTransferUmiIx,
14
15
  } from "./solanaUtils";
@@ -16,6 +17,7 @@ import { consoleLog } from "./generalUtils";
16
17
  import { PriorityFeeSetting } from "../types";
17
18
  import axios from "axios";
18
19
  import base58 from "bs58";
20
+ import { bs58 } from "@coral-xyz/anchor/dist/cjs/utils/bytes";
19
21
 
20
22
  export async function getRandomTipAccount(): Promise<PublicKey> {
21
23
  const tipAccounts = [
@@ -43,49 +45,52 @@ async function getTipInstruction(
43
45
  );
44
46
  }
45
47
 
46
- // async function simulateJitoBundle(
47
- // txs: VersionedTransaction[]
48
- // ): Promise<SimulatedBundleTransactionResult[]> {
49
- // const simulationResult = await JITO_CONNECTION.simulateBundle(txs, {
50
- // preExecutionAccountsConfigs: txs.map((x) => null),
51
- // postExecutionAccountsConfigs: txs.map((x) => null),
52
- // skipSigVerify: true,
53
- // });
54
-
55
- // simulationResult.value.transactionResults.forEach((tx) => {
56
- // if (tx.err) {
57
- // tx.logs?.forEach((x) => {
58
- // consoleLog(x);
59
- // });
60
- // throw tx.err;
48
+ // TODO: fix
49
+ // async function simulateJitoBundle(umi: Umi, txs: VersionedTransaction[]) {
50
+ // const simulationResult = await axios.post(
51
+ // `${JITO_BLOCK_ENGINE}/api/v1/bundles`,
52
+ // {
53
+ // method: "simulateBundle",
54
+ // id: 1,
55
+ // jsonrpc: "2.0",
56
+ // params: [
57
+ // {
58
+ // encodedTransactions: txs.map((x) => bs58.encode(x.serialize())),
59
+ // preExecutionAccountsConfigs: txs.map((_) => ""),
60
+ // postExecutionAccountsConfigs: txs.map((_) => ""),
61
+ // skipSigVerify: true,
62
+ // },
63
+ // ],
61
64
  // }
62
- // });
63
-
64
- // return simulationResult.value.transactionResults;
65
+ // );
65
66
  // }
66
67
 
67
68
  async function umiToVersionedTransactions(
68
69
  umi: Umi,
69
70
  signer: Signer,
70
71
  txs: TransactionBuilder[],
72
+ sign: boolean,
71
73
  feeEstimates: number[],
72
74
  computeUnitLimits?: number[]
73
75
  ): Promise<VersionedTransaction[]> {
74
- return await Promise.all(
76
+ const builtTxs = await Promise.all(
75
77
  txs.map(async (tx, i) => {
76
- const versionedTx = toWeb3JsTransaction(
77
- await (
78
- await assembleFinalTransaction(
79
- signer,
80
- tx,
81
- feeEstimates[i],
82
- computeUnitLimits ? computeUnitLimits[i] : undefined
83
- ).setLatestBlockhash(umi)
84
- ).buildAndSign(umi)
85
- );
86
- return versionedTx;
78
+ return (
79
+ await assembleFinalTransaction(
80
+ signer,
81
+ tx,
82
+ feeEstimates[i],
83
+ computeUnitLimits ? computeUnitLimits[i] : undefined
84
+ ).setLatestBlockhash(umi)
85
+ ).build(umi);
87
86
  })
88
87
  );
88
+
89
+ if (sign) {
90
+ signer.signAllTransactions(builtTxs);
91
+ }
92
+
93
+ return builtTxs.map((x) => toWeb3JsTransaction(x));
89
94
  }
90
95
 
91
96
  async function getBundleStatus(bundleId: string) {
@@ -155,7 +160,7 @@ export async function sendJitoBundledTransactions(
155
160
  const feeEstimates = await Promise.all(
156
161
  txs.map(
157
162
  async (x) =>
158
- (await getComputeUnitPriceEstimate(umi, x, priorityFeeSetting, true)) ??
163
+ (await getComputeUnitPriceEstimate(umi, x, priorityFeeSetting)) ??
159
164
  1000000
160
165
  )
161
166
  );
@@ -164,16 +169,17 @@ export async function sendJitoBundledTransactions(
164
169
  umi,
165
170
  signer,
166
171
  txs,
172
+ true, // false if simulating first and rebuilding later
167
173
  feeEstimates
168
- // Array(txs.length).fill(1_400_000)
169
174
  );
170
- // // TODO: Skip over this for now, and instead don't specify a compute unit limit in the final bundle transactions
171
- // const simulationResults = await simulateJitoBundle(builtTxs);
175
+
176
+ // const simulationResults = await simulateJitoBundle(umi, builtTxs);
172
177
 
173
178
  if (!simulateOnly) {
174
179
  // let builtTxs = await umiToVersionedTransactions(
175
180
  // client.signer,
176
181
  // txs,
182
+ // true,
177
183
  // feeEstimates,
178
184
  // simulationResults.map((x) => x.unitsConsumed! * 1.15)
179
185
  // );
@@ -288,27 +288,17 @@ async function simulateTransaction(
288
288
  export async function getComputeUnitPriceEstimate(
289
289
  umi: Umi,
290
290
  tx: TransactionBuilder,
291
- prioritySetting: PriorityFeeSetting,
292
- simMayFail: boolean
291
+ prioritySetting: PriorityFeeSetting
293
292
  ): Promise<number | undefined> {
294
293
  const web3Transaction = toWeb3JsTransaction(
295
294
  (await tx.setLatestBlockhash(umi, { commitment: "finalized" })).build(umi)
296
295
  );
297
- const transaction = simMayFail
298
- ? undefined
299
- : bs58.encode(web3Transaction.serialize());
300
- const accountKeys = simMayFail
301
- ? tx
302
- .getInstructions()
303
- .flatMap((x) => x.keys.flatMap((x) => x.pubkey.toString()))
304
- : undefined;
305
296
 
306
297
  let feeEstimate: number | undefined;
307
298
  try {
308
299
  const resp = await umi.rpc.call("getPriorityFeeEstimate", [
309
300
  {
310
- transaction,
311
- accountKeys,
301
+ transaction: bs58.encode(web3Transaction.serialize()),
312
302
  options: {
313
303
  priorityLevel: prioritySetting.toString(),
314
304
  },
@@ -316,7 +306,21 @@ export async function getComputeUnitPriceEstimate(
316
306
  ]);
317
307
  feeEstimate = Math.round((resp as any).priorityFeeEstimate as number);
318
308
  } catch (e) {
319
- console.error(e);
309
+ try {
310
+ const resp = await umi.rpc.call("getPriorityFeeEstimate", [
311
+ {
312
+ accountKeys: tx
313
+ .getInstructions()
314
+ .flatMap((x) => x.keys.flatMap((x) => x.pubkey.toString())),
315
+ options: {
316
+ priorityLevel: prioritySetting.toString(),
317
+ },
318
+ },
319
+ ]);
320
+ feeEstimate = Math.round((resp as any).priorityFeeEstimate as number);
321
+ } catch (e) {
322
+ console.error(e);
323
+ }
320
324
  }
321
325
 
322
326
  return feeEstimate;
@@ -383,7 +387,11 @@ export async function sendSingleOptimizedTransaction(
383
387
 
384
388
  let cuPrice: number | undefined;
385
389
  if (prioritySetting !== PriorityFeeSetting.None) {
386
- cuPrice = await getComputeUnitPriceEstimate(umi, tx, prioritySetting, false);
390
+ cuPrice = await getComputeUnitPriceEstimate(
391
+ umi,
392
+ tx,
393
+ prioritySetting,
394
+ );
387
395
  if (!cuPrice) {
388
396
  cuPrice = 1000000;
389
397
  }