@haven-fi/solauto-sdk 1.0.274 → 1.0.276
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/transactions/transactionsManager.d.ts.map +1 -1
- package/dist/transactions/transactionsManager.js +11 -1
- package/dist/utils/solanaUtils.d.ts +1 -0
- package/dist/utils/solanaUtils.d.ts.map +1 -1
- package/dist/utils/solanaUtils.js +6 -2
- package/package.json +1 -1
- package/src/transactions/transactionsManager.ts +15 -1
- package/src/utils/solanaUtils.ts +16 -2
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;
|
1
|
+
{"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAMzD,OAAO,EACL,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,kBAAkB,EAElB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,oBAAoB,EAAa,MAAM,YAAY,CAAC;AAO7D,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAK5B;AAqCD,qBAAa,eAAe;IAMjB,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IACxC,IAAI,CAAC,EAAE,MAAM;IARtB,oBAAoB,EAAG,MAAM,EAAE,CAAC;IAChC,EAAE,CAAC,EAAE,kBAAkB,CAAC;IACjB,WAAW,EAAE,OAAO,CAAS;gBAG3B,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,O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AE,eAAe,EAAE,GAC9B,OAAO,CAAC,0BAA0B,CAAC;IAoEzB,IAAI,CACf,KAAK,EAAE,eAAe,EAAE,GACvB,OAAO,CAAC,0BAA0B,CAAC;YAsCxB,qBAAqB;YAuDrB,cAAc;YAqCd,eAAe;CAoD9B"}
|
@@ -83,7 +83,8 @@ class TransactionSet {
|
|
83
83
|
if (accountLocks > 128) {
|
84
84
|
return false;
|
85
85
|
}
|
86
|
-
|
86
|
+
const singleTx = await this.getSingleTransaction();
|
87
|
+
return (0, solanaUtils_1.addTxOptimizations)(this.txHandler.umi.identity, singleTx, 1, 1)
|
87
88
|
.add(item.tx)
|
88
89
|
.setAddressLookupTables(await this.lookupTables.getLutInputs([
|
89
90
|
...this.lutAddresses(),
|
@@ -264,6 +265,9 @@ class TransactionsManager {
|
|
264
265
|
.map((x) => x.tx)));
|
265
266
|
if (updateLookupTable && !updateLookupTable?.new) {
|
266
267
|
choresBefore.prepend(updateLookupTable.tx);
|
268
|
+
this.txHandler.log(updateLookupTable.tx
|
269
|
+
.getInstructions()
|
270
|
+
.map((x) => x.programId.toString()));
|
267
271
|
}
|
268
272
|
if (choresBefore.getInstructions().length > 0) {
|
269
273
|
const chore = new TransactionItem(async () => ({ tx: choresBefore }), CHORES_TX_NAME);
|
@@ -298,6 +302,12 @@ class TransactionsManager {
|
|
298
302
|
const itemSets = await this.assembleTransactionSets(items);
|
299
303
|
this.updateStatusForSets(itemSets);
|
300
304
|
this.txHandler.log("Initial item sets:", itemSets.length);
|
305
|
+
for (const itemSet of itemSets) {
|
306
|
+
const programs = (await itemSet.getSingleTransaction())
|
307
|
+
.getInstructions()
|
308
|
+
.map((x) => x.programId);
|
309
|
+
this.txHandler.log(programs.map((x) => x.toString()));
|
310
|
+
}
|
301
311
|
if (this.txType === "only-simulate" && itemSets.length > 1) {
|
302
312
|
this.txHandler.log("Only simulate and more than 1 transaction. Skipping...");
|
303
313
|
return [];
|
@@ -12,6 +12,7 @@ export declare function systemTransferUmiIx(signer: Signer, destination: PublicK
|
|
12
12
|
export declare function closeTokenAccountUmiIx(signer: Signer, tokenAccount: PublicKey, authority: PublicKey): WrappedInstruction;
|
13
13
|
export declare function splTokenTransferUmiIx(signer: Signer, fromTa: PublicKey, toTa: PublicKey, authority: PublicKey, amount: bigint): WrappedInstruction;
|
14
14
|
export declare function getAddressLookupInputs(umi: Umi, lookupTableAddresses: string[]): Promise<AddressLookupTableInput[]>;
|
15
|
+
export declare function addTxOptimizations(signer: Signer, transaction: TransactionBuilder, computeUnitPrice?: number, computeUnitLimit?: number): TransactionBuilder;
|
15
16
|
export declare function assembleFinalTransaction(signer: Signer, transaction: TransactionBuilder, computeUnitPrice?: number, computeUnitLimit?: number): TransactionBuilder;
|
16
17
|
export declare function getComputeUnitPriceEstimate(umi: Umi, tx: TransactionBuilder, prioritySetting: PriorityFeeSetting): Promise<number | undefined>;
|
17
18
|
export declare function sendSingleOptimizedTransaction(umi: Umi, connection: Connection, tx: TransactionBuilder, txType?: TransactionRunType, prioritySetting?: PriorityFeeSetting, onAwaitingSign?: () => void): Promise<Uint8Array | undefined>;
|
@@ -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,EAKL,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,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,QAAQ,EAAE,MAAM,GACf,kBAAkB,CAOpB;AAED,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,SAAS,GACd,kBAAkB,CAUpB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,SAAS,EACtB,QAAQ,EAAE,MAAM,GACf,kBAAkB,CASpB;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,SAAS,EACvB,SAAS,EAAE,SAAS,GACnB,kBAAkB,CAKpB;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,GACb,kBAAkB,CAKpB;AAED,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,GAAG,EACR,oBAAoB,EAAE,MAAM,EAAE,GAC7B,OAAO,CAAC,uBAAuB,EAAE,CAAC,CAkBpC;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,kBAAkB,EAC/B,gBAAgB,CAAC,EAAE,MAAM,EACzB,gBAAgB,CAAC,EAAE,MAAM,
|
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,M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,EAAE,GAC7B,OAAO,CAAC,uBAAuB,EAAE,CAAC,CAkBpC;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,kBAAkB,EAC/B,gBAAgB,CAAC,EAAE,MAAM,EACzB,gBAAgB,CAAC,EAAE,MAAM,sBAc1B;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,kBAAkB,EAC/B,gBAAgB,CAAC,EAAE,MAAM,EACzB,gBAAgB,CAAC,EAAE,MAAM,sBA2D1B;AAmBD,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,kBAAkB,EACtB,eAAe,EAAE,kBAAkB,GAClC,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAsB7B;AAiDD,wBAAsB,8BAA8B,CAClD,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,kBAAkB,EACtB,MAAM,CAAC,EAAE,kBAAkB,EAC3B,eAAe,GAAE,kBAA2C,EAC5D,cAAc,CAAC,EAAE,MAAM,IAAI,GAC1B,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CA6DjC"}
|
@@ -14,6 +14,7 @@ exports.systemTransferUmiIx = systemTransferUmiIx;
|
|
14
14
|
exports.closeTokenAccountUmiIx = closeTokenAccountUmiIx;
|
15
15
|
exports.splTokenTransferUmiIx = splTokenTransferUmiIx;
|
16
16
|
exports.getAddressLookupInputs = getAddressLookupInputs;
|
17
|
+
exports.addTxOptimizations = addTxOptimizations;
|
17
18
|
exports.assembleFinalTransaction = assembleFinalTransaction;
|
18
19
|
exports.getComputeUnitPriceEstimate = getComputeUnitPriceEstimate;
|
19
20
|
exports.sendSingleOptimizedTransaction = sendSingleOptimizedTransaction;
|
@@ -90,8 +91,8 @@ async function getAddressLookupInputs(umi, lookupTableAddresses) {
|
|
90
91
|
return acc;
|
91
92
|
}, new Array());
|
92
93
|
}
|
93
|
-
function
|
94
|
-
|
94
|
+
function addTxOptimizations(signer, transaction, computeUnitPrice, computeUnitLimit) {
|
95
|
+
return (0, umi_1.transactionBuilder)()
|
95
96
|
.prepend(computeUnitPrice !== undefined
|
96
97
|
? setComputeUnitPriceUmiIx(signer, computeUnitPrice)
|
97
98
|
: (0, umi_1.transactionBuilder)())
|
@@ -99,6 +100,9 @@ function assembleFinalTransaction(signer, transaction, computeUnitPrice, compute
|
|
99
100
|
? setComputeUnitLimitUmiIx(signer, computeUnitLimit)
|
100
101
|
: (0, umi_1.transactionBuilder)())
|
101
102
|
.add(transaction);
|
103
|
+
}
|
104
|
+
function assembleFinalTransaction(signer, transaction, computeUnitPrice, computeUnitLimit) {
|
105
|
+
const tx = addTxOptimizations(signer, transaction, computeUnitPrice, computeUnitLimit);
|
102
106
|
const marginfiStartFlSerializer = (0, marginfi_sdk_1.getLendingAccountStartFlashloanInstructionDataSerializer)();
|
103
107
|
const marginfiStartFlDiscriminator = marginfiStartFlSerializer
|
104
108
|
.serialize({
|
package/package.json
CHANGED
@@ -7,6 +7,7 @@ import {
|
|
7
7
|
} from "@metaplex-foundation/umi";
|
8
8
|
import { SolautoClient } from "../clients/solautoClient";
|
9
9
|
import {
|
10
|
+
addTxOptimizations,
|
10
11
|
getAddressLookupInputs,
|
11
12
|
sendSingleOptimizedTransaction,
|
12
13
|
} from "../utils/solanaUtils";
|
@@ -130,7 +131,8 @@ class TransactionSet {
|
|
130
131
|
return false;
|
131
132
|
}
|
132
133
|
|
133
|
-
|
134
|
+
const singleTx = await this.getSingleTransaction();
|
135
|
+
return addTxOptimizations(this.txHandler.umi.identity, singleTx, 1, 1)
|
134
136
|
.add(item.tx)
|
135
137
|
.setAddressLookupTables(
|
136
138
|
await this.lookupTables.getLutInputs([
|
@@ -390,6 +392,11 @@ export class TransactionsManager {
|
|
390
392
|
);
|
391
393
|
if (updateLookupTable && !updateLookupTable?.new) {
|
392
394
|
choresBefore.prepend(updateLookupTable.tx);
|
395
|
+
this.txHandler.log(
|
396
|
+
updateLookupTable.tx
|
397
|
+
.getInstructions()
|
398
|
+
.map((x) => x.programId.toString())
|
399
|
+
);
|
393
400
|
}
|
394
401
|
if (choresBefore.getInstructions().length > 0) {
|
395
402
|
const chore = new TransactionItem(
|
@@ -445,6 +452,13 @@ export class TransactionsManager {
|
|
445
452
|
this.updateStatusForSets(itemSets);
|
446
453
|
this.txHandler.log("Initial item sets:", itemSets.length);
|
447
454
|
|
455
|
+
for (const itemSet of itemSets) {
|
456
|
+
const programs = (await itemSet.getSingleTransaction())
|
457
|
+
.getInstructions()
|
458
|
+
.map((x) => x.programId);
|
459
|
+
this.txHandler.log(programs.map((x) => x.toString()));
|
460
|
+
}
|
461
|
+
|
448
462
|
if (this.txType === "only-simulate" && itemSets.length > 1) {
|
449
463
|
this.txHandler.log(
|
450
464
|
"Only simulate and more than 1 transaction. Skipping..."
|
package/src/utils/solanaUtils.ts
CHANGED
@@ -181,13 +181,13 @@ export async function getAddressLookupInputs(
|
|
181
181
|
}, new Array<AddressLookupTableInput>());
|
182
182
|
}
|
183
183
|
|
184
|
-
export function
|
184
|
+
export function addTxOptimizations(
|
185
185
|
signer: Signer,
|
186
186
|
transaction: TransactionBuilder,
|
187
187
|
computeUnitPrice?: number,
|
188
188
|
computeUnitLimit?: number
|
189
189
|
) {
|
190
|
-
|
190
|
+
return transactionBuilder()
|
191
191
|
.prepend(
|
192
192
|
computeUnitPrice !== undefined
|
193
193
|
? setComputeUnitPriceUmiIx(signer, computeUnitPrice)
|
@@ -199,6 +199,20 @@ export function assembleFinalTransaction(
|
|
199
199
|
: transactionBuilder()
|
200
200
|
)
|
201
201
|
.add(transaction);
|
202
|
+
}
|
203
|
+
|
204
|
+
export function assembleFinalTransaction(
|
205
|
+
signer: Signer,
|
206
|
+
transaction: TransactionBuilder,
|
207
|
+
computeUnitPrice?: number,
|
208
|
+
computeUnitLimit?: number
|
209
|
+
) {
|
210
|
+
const tx = addTxOptimizations(
|
211
|
+
signer,
|
212
|
+
transaction,
|
213
|
+
computeUnitPrice,
|
214
|
+
computeUnitLimit
|
215
|
+
);
|
202
216
|
|
203
217
|
const marginfiStartFlSerializer =
|
204
218
|
getLendingAccountStartFlashloanInstructionDataSerializer();
|