@haven-fi/solauto-sdk 1.0.275 → 1.0.277
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 +7 -4
- 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 +10 -4
- 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(),
|
@@ -216,7 +217,6 @@ class TransactionsManager {
|
|
216
217
|
this.txHandler.log(`${name} is ${status.toString().toLowerCase()}`);
|
217
218
|
this.statusCallback?.([...this.statuses]);
|
218
219
|
}
|
219
|
-
// TODO remove me
|
220
220
|
async debugAccounts(itemSet, tx) {
|
221
221
|
const lutInputs = await itemSet.lookupTables.getLutInputs([]);
|
222
222
|
const lutAccounts = lutInputs.map((x) => x.addresses).flat();
|
@@ -259,11 +259,14 @@ class TransactionsManager {
|
|
259
259
|
for (const item of items) {
|
260
260
|
await item.initialize();
|
261
261
|
}
|
262
|
-
|
262
|
+
let [choresBefore, choresAfter] = await (0, transactionUtils_1.getTransactionChores)(client, (0, umi_1.transactionBuilder)().add(items
|
263
263
|
.filter((x) => x.tx && x.tx.getInstructions().length > 0)
|
264
264
|
.map((x) => x.tx)));
|
265
265
|
if (updateLookupTable && !updateLookupTable?.new) {
|
266
|
-
choresBefore.prepend(updateLookupTable.tx);
|
266
|
+
choresBefore = choresBefore.prepend(updateLookupTable.tx);
|
267
|
+
this.txHandler.log(updateLookupTable.tx
|
268
|
+
.getInstructions()
|
269
|
+
.map((x) => x.programId.toString()));
|
267
270
|
}
|
268
271
|
if (choresBefore.getInstructions().length > 0) {
|
269
272
|
const chore = new TransactionItem(async () => ({ tx: choresBefore }), CHORES_TX_NAME);
|
@@ -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,U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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,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([
|
@@ -310,7 +312,6 @@ export class TransactionsManager {
|
|
310
312
|
this.statusCallback?.([...this.statuses]);
|
311
313
|
}
|
312
314
|
|
313
|
-
// TODO remove me
|
314
315
|
private async debugAccounts(itemSet: TransactionSet, tx: TransactionBuilder) {
|
315
316
|
const lutInputs = await itemSet.lookupTables.getLutInputs([]);
|
316
317
|
const lutAccounts = lutInputs.map((x) => x.addresses).flat();
|
@@ -380,7 +381,7 @@ export class TransactionsManager {
|
|
380
381
|
await item.initialize();
|
381
382
|
}
|
382
383
|
|
383
|
-
|
384
|
+
let [choresBefore, choresAfter] = await getTransactionChores(
|
384
385
|
client,
|
385
386
|
transactionBuilder().add(
|
386
387
|
items
|
@@ -389,7 +390,12 @@ export class TransactionsManager {
|
|
389
390
|
)
|
390
391
|
);
|
391
392
|
if (updateLookupTable && !updateLookupTable?.new) {
|
392
|
-
choresBefore.prepend(updateLookupTable.tx);
|
393
|
+
choresBefore = choresBefore.prepend(updateLookupTable.tx);
|
394
|
+
this.txHandler.log(
|
395
|
+
updateLookupTable.tx
|
396
|
+
.getInstructions()
|
397
|
+
.map((x) => x.programId.toString())
|
398
|
+
);
|
393
399
|
}
|
394
400
|
if (choresBefore.getInstructions().length > 0) {
|
395
401
|
const chore = new TransactionItem(
|
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();
|