@haven-fi/solauto-sdk 1.0.112 → 1.0.114
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/clients/solautoMarginfiClient.d.ts.map +1 -1
- package/dist/clients/solautoMarginfiClient.js +3 -0
- package/dist/transactions/transactionsManager.d.ts +5 -4
- package/dist/transactions/transactionsManager.d.ts.map +1 -1
- package/dist/transactions/transactionsManager.js +10 -8
- package/dist/utils/numberUtils.d.ts.map +1 -1
- package/dist/utils/solanaUtils.d.ts +1 -1
- package/dist/utils/solanaUtils.d.ts.map +1 -1
- package/dist/utils/solanaUtils.js +5 -3
- package/package.json +1 -1
- package/src/clients/solautoMarginfiClient.ts +3 -0
- package/src/transactions/transactionsManager.ts +13 -8
- package/src/utils/numberUtils.ts +0 -1
- package/src/utils/solanaUtils.ts +16 -6
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solautoMarginfiClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoMarginfiClient.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,MAAM,EACN,kBAAkB,EAMnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAM1D,OAAO,EACL,kBAAkB,EAElB,aAAa,EACb,iBAAiB,EACjB,wBAAwB,EACxB,gCAAgC,EAKjC,MAAM,cAAc,CAAC;AAGtB,OAAO,EAEL,eAAe,EAUhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAWnE,MAAM,WAAW,yBAA0B,SAAQ,iBAAiB;IAClE,eAAe,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACrC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,aA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qBAAqB,CAAC;IAE7C,iBAAiB,EAAG,SAAS,CAAC;IAC9B,eAAe,EAAG,SAAS,CAAC;IAG5B,iCAAiC,CAAC,EAAE,MAAM,CAAC;IAC3C,6BAA6B,EAAG,SAAS,CAAC;IAC1C,2BAA2B,CAAC,EAAE,eAAe,CAAC;IAE/C,UAAU,CAAC,IAAI,EAAE,yBAAyB;IAkE1C,8BAA8B;IA0CpC,eAAe,IAAI,SAAS;IAI5B,mBAAmB,IAAI,MAAM,EAAE;IAI/B,gBAAgB,IAAI,SAAS,EAAE;IAU/B,yBAAyB,IAAI,kBAAkB;IAS/C,YAAY,CACV,aAAa,CAAC,EAAE,gCAAgC,EAChD,GAAG,CAAC,EAAE,kBAAkB,GACvB,kBAAkB;IAMrB,OAAO,CAAC,sBAAsB;IA6C9B,OAAO,IAAI,kBAAkB;IAc7B,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB;IAUhE,OAAO,CAAC,6BAA6B;IAmErC,OAAO,CAAC,oCAAoC;IA0D5C,SAAS,CACP,aAAa,EAAE,GAAG,GAAG,GAAG,EACxB,WAAW,EAAE,cAAc,EAC3B,aAAa,EAAE,wBAAwB,EACvC,SAAS,CAAC,EAAE,gBAAgB,EAC5B,2BAA2B,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,kBAAkB;IA2DrB,WAAW,CACT,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,SAAS,GACjC,kBAAkB;IA2BrB,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,kBAAkB;IAoFlE,iCAAiC,IAAI,kBAAkB;IASjD,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAoBlE"}
|
@@ -413,7 +413,10 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
413
413
|
if (state) {
|
414
414
|
return state;
|
415
415
|
}
|
416
|
+
this.log("Live position updates:");
|
417
|
+
this.log(this.livePositionUpdates);
|
416
418
|
const freshState = await (0, marginfiUtils_1.getMarginfiAccountPositionState)(this.umi, this.marginfiAccountPk, this.supplyMint, this.debtMint, this.livePositionUpdates);
|
419
|
+
this.log("Fresh state:");
|
417
420
|
this.log(freshState);
|
418
421
|
return freshState;
|
419
422
|
}
|
@@ -39,10 +39,11 @@ declare class TransactionSet {
|
|
39
39
|
name(): string;
|
40
40
|
}
|
41
41
|
export declare enum TransactionStatus {
|
42
|
-
Skipped =
|
43
|
-
Processing =
|
44
|
-
|
45
|
-
|
42
|
+
Skipped = 0,
|
43
|
+
Processing = 1,
|
44
|
+
AwaitingSignature = 2,
|
45
|
+
Queued = 3,
|
46
|
+
Successful = 4
|
46
47
|
}
|
47
48
|
export type TransactionManagerStatuses = {
|
48
49
|
name: string;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EAEvB,kBAAkB,EAClB,GAAG,EACJ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAKzD,OAAO,EACL,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG7D,cAAM,YAAY;IAGG,WAAW,EAAE,MAAM,EAAE;IAAE,OAAO,CAAC,GAAG;IAFrD,KAAK,EAAE,uBAAuB,EAAE,CAAM;gBAEnB,WAAW,EAAE,MAAM,EAAE,EAAU,GAAG,EAAE,GAAG;IAGpD,YAAY,CAChB,mBAAmB,EAAE,MAAM,EAAE,GAC5B,OAAO,CAAC,uBAAuB,EAAE,CAAC;CAoBtC;AAED,qBAAa,eAAe;IAKjB,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CACV;QA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;CA0GjG"}
|
@@ -112,10 +112,11 @@ class TransactionSet {
|
|
112
112
|
}
|
113
113
|
var TransactionStatus;
|
114
114
|
(function (TransactionStatus) {
|
115
|
-
TransactionStatus["Skipped"] = "Skipped";
|
116
|
-
TransactionStatus["Processing"] = "Processing";
|
117
|
-
TransactionStatus["
|
118
|
-
TransactionStatus["
|
115
|
+
TransactionStatus[TransactionStatus["Skipped"] = 0] = "Skipped";
|
116
|
+
TransactionStatus[TransactionStatus["Processing"] = 1] = "Processing";
|
117
|
+
TransactionStatus[TransactionStatus["AwaitingSignature"] = 2] = "AwaitingSignature";
|
118
|
+
TransactionStatus[TransactionStatus["Queued"] = 3] = "Queued";
|
119
|
+
TransactionStatus[TransactionStatus["Successful"] = 4] = "Successful";
|
119
120
|
})(TransactionStatus || (exports.TransactionStatus = TransactionStatus = {}));
|
120
121
|
class TransactionsManager {
|
121
122
|
constructor(txHandler, statusCallback, simulateOnly, mustBeAtomic, errorsToThrow) {
|
@@ -192,12 +193,13 @@ class TransactionsManager {
|
|
192
193
|
async clientSend(items, prioritySetting) {
|
193
194
|
const client = this.txHandler;
|
194
195
|
const updateLookupTable = await client.updateLookupTable();
|
196
|
+
const updateLutTxName = "update lookup table";
|
195
197
|
if (updateLookupTable &&
|
196
198
|
updateLookupTable.updateLutTx.getInstructions().length > 0 &&
|
197
199
|
updateLookupTable?.needsToBeIsolated) {
|
198
|
-
this.updateStatus(
|
199
|
-
await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum) => await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.txHandler.umi, this.txHandler.connection, updateLookupTable.updateLutTx, this.simulateOnly, attemptNum), 3, 150, this.errorsToThrow);
|
200
|
-
this.updateStatus(
|
200
|
+
this.updateStatus(updateLutTxName, TransactionStatus.Processing);
|
201
|
+
await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum) => await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.txHandler.umi, this.txHandler.connection, updateLookupTable.updateLutTx, this.simulateOnly, attemptNum, prioritySetting, () => this.updateStatus(updateLutTxName, TransactionStatus.AwaitingSignature)), 3, 150, this.errorsToThrow);
|
202
|
+
this.updateStatus(updateLutTxName, TransactionStatus.Successful);
|
201
203
|
}
|
202
204
|
this.lookupTables.defaultLuts = client.defaultLookupTables();
|
203
205
|
for (const item of items) {
|
@@ -291,7 +293,7 @@ class TransactionsManager {
|
|
291
293
|
if (this.txHandler.localTest) {
|
292
294
|
await this.debugAccounts(itemSet, tx);
|
293
295
|
}
|
294
|
-
const txSig = await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.txHandler.umi, this.txHandler.connection, tx, this.simulateOnly, attemptNum, prioritySetting);
|
296
|
+
const txSig = await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.txHandler.umi, this.txHandler.connection, tx, this.simulateOnly, attemptNum, prioritySetting, () => this.updateStatus(itemSet.name(), TransactionStatus.AwaitingSignature));
|
295
297
|
this.updateStatus(itemSet.name(), TransactionStatus.Successful, txSig ? bs58_1.default.encode(txSig) : undefined);
|
296
298
|
}
|
297
299
|
}, 4, 150, this.errorsToThrow);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"numberUtils.d.ts","sourceRoot":"","sources":["../../src/utils/numberUtils.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"numberUtils.d.ts","sourceRoot":"","sources":["../../src/utils/numberUtils.ts"],"names":[],"mappings":"AAEA,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,MAAM,GACtB,MAAM,CAMR;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAqBrD;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAejE;AAED,wBAAgB,oBAAoB,CAClC,eAAe,EAAE,MAAM,EACvB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,2BAA2B,EAAE,MAAM,EACnC,gBAAgB,CAAC,EAAE,MAAM,UAW1B;AAED,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,OAAO,EACnB,2BAA2B,EAAE,MAAM,GAAG,SAAS,EAC/C,mBAAmB,EAAE,MAAM,GAC1B;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf,CAgCA;AAED,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,gBAAgB,EAAE,MAAM,GACvB,MAAM,CAER;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAKzE;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAKvE;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAKvE"}
|
@@ -13,5 +13,5 @@ export declare function splTokenTransferUmiIx(signer: Signer, fromTa: PublicKey,
|
|
13
13
|
export declare function getAdressLookupInputs(umi: Umi, lookupTableAddresses: string[]): Promise<AddressLookupTableInput[]>;
|
14
14
|
export declare function assembleFinalTransaction(signer: Signer, tx: TransactionBuilder, computeUnitPrice: number, computeUnitLimit?: number): TransactionBuilder;
|
15
15
|
export declare function getComputeUnitPriceEstimate(umi: Umi, tx: TransactionBuilder, prioritySetting: PriorityFeeSetting): Promise<number>;
|
16
|
-
export declare function sendSingleOptimizedTransaction(umi: Umi, connection: Connection, tx: TransactionBuilder, simulateOnly?: boolean, attemptNum?: number, prioritySetting?: PriorityFeeSetting): Promise<Uint8Array | undefined>;
|
16
|
+
export declare function sendSingleOptimizedTransaction(umi: Umi, connection: Connection, tx: TransactionBuilder, simulateOnly?: boolean, attemptNum?: number, prioritySetting?: PriorityFeeSetting, onAwaitingSign?: () => void): Promise<Uint8Array | undefined>;
|
17
17
|
//# 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,EAGL,UAAU,EACV,SAAS,EAIT,sBAAsB,EAEvB,MAAM,iBAAiB,CAAC;AAYzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C,wBAAgB,sBAAsB,
|
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,EAGL,UAAU,EACV,SAAS,EAIT,sBAAsB,EAEvB,MAAM,iBAAiB,CAAC;AAYzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,MAAM,GACnB,CAAC,UAAU,EAAE,GAAG,CAAC,CAOnB;AAED,wBAAsB,wBAAwB,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAQxE;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAA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ACtB,YAAY,CAAC,EAAE,OAAO,EACtB,UAAU,CAAC,EAAE,MAAM,EACnB,eAAe,GAAE,kBAA+C,EAChE,cAAc,CAAC,EAAE,MAAM,IAAI,GAC1B,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CA0DjC"}
|
@@ -130,7 +130,7 @@ function assembleFinalTransaction(signer, tx, computeUnitPrice, computeUnitLimit
|
|
130
130
|
async function simulateTransaction(connection, transaction) {
|
131
131
|
const simulationResult = await connection.simulateTransaction(transaction, {
|
132
132
|
sigVerify: false,
|
133
|
-
commitment: "processed"
|
133
|
+
commitment: "processed",
|
134
134
|
});
|
135
135
|
if (simulationResult.value.err) {
|
136
136
|
simulationResult.value.logs?.forEach((x) => {
|
@@ -154,16 +154,18 @@ async function getComputeUnitPriceEstimate(umi, tx, prioritySetting) {
|
|
154
154
|
const feeEstimate = Math.round(resp.priorityFeeEstimate);
|
155
155
|
return feeEstimate;
|
156
156
|
}
|
157
|
-
async function sendSingleOptimizedTransaction(umi, connection, tx, simulateOnly, attemptNum, prioritySetting = types_1.PriorityFeeSetting.Default) {
|
157
|
+
async function sendSingleOptimizedTransaction(umi, connection, tx, simulateOnly, attemptNum, prioritySetting = types_1.PriorityFeeSetting.Default, onAwaitingSign) {
|
158
158
|
console.log("Sending single optimized transaction...");
|
159
159
|
console.log("Instructions: ", tx.getInstructions().length);
|
160
160
|
console.log("Serialized transaction size: ", tx.getTransactionSize(umi));
|
161
161
|
const feeEstimate = await getComputeUnitPriceEstimate(umi, tx, prioritySetting);
|
162
162
|
console.log("Compute unit price: ", feeEstimate);
|
163
|
-
|
163
|
+
// TODO: we should only retry simulation if it's not a solauto error
|
164
|
+
const simulationResult = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => await simulateTransaction(connection, (0, umi_web3js_adapters_1.toWeb3JsTransaction)(await (await assembleFinalTransaction(umi.identity, tx, feeEstimate, 1400000).setLatestBlockhash(umi)).build(umi))), 3);
|
164
165
|
const computeUnitLimit = Math.round(simulationResult.value.unitsConsumed * 1.1);
|
165
166
|
console.log("Compute unit limit: ", computeUnitLimit);
|
166
167
|
if (!simulateOnly) {
|
168
|
+
onAwaitingSign?.();
|
167
169
|
const result = await assembleFinalTransaction(umi.identity, tx, feeEstimate, 800000).sendAndConfirm(umi, {
|
168
170
|
send: {
|
169
171
|
skipPreflight: true,
|
package/package.json
CHANGED
@@ -618,6 +618,8 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
618
618
|
return state;
|
619
619
|
}
|
620
620
|
|
621
|
+
this.log("Live position updates:");
|
622
|
+
this.log(this.livePositionUpdates);
|
621
623
|
const freshState = await getMarginfiAccountPositionState(
|
622
624
|
this.umi,
|
623
625
|
this.marginfiAccountPk,
|
@@ -625,6 +627,7 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
625
627
|
this.debtMint,
|
626
628
|
this.livePositionUpdates
|
627
629
|
);
|
630
|
+
this.log("Fresh state:");
|
628
631
|
this.log(freshState);
|
629
632
|
|
630
633
|
return freshState;
|
@@ -165,10 +165,11 @@ class TransactionSet {
|
|
165
165
|
}
|
166
166
|
|
167
167
|
export enum TransactionStatus {
|
168
|
-
Skipped
|
169
|
-
Processing
|
170
|
-
|
171
|
-
|
168
|
+
Skipped,
|
169
|
+
Processing,
|
170
|
+
AwaitingSignature,
|
171
|
+
Queued,
|
172
|
+
Successful,
|
172
173
|
}
|
173
174
|
|
174
175
|
export type TransactionManagerStatuses = {
|
@@ -268,12 +269,13 @@ export class TransactionsManager {
|
|
268
269
|
const client = this.txHandler as SolautoClient;
|
269
270
|
|
270
271
|
const updateLookupTable = await client.updateLookupTable();
|
272
|
+
const updateLutTxName = "update lookup table";
|
271
273
|
if (
|
272
274
|
updateLookupTable &&
|
273
275
|
updateLookupTable.updateLutTx.getInstructions().length > 0 &&
|
274
276
|
updateLookupTable?.needsToBeIsolated
|
275
277
|
) {
|
276
|
-
this.updateStatus(
|
278
|
+
this.updateStatus(updateLutTxName, TransactionStatus.Processing);
|
277
279
|
await retryWithExponentialBackoff(
|
278
280
|
async (attemptNum) =>
|
279
281
|
await sendSingleOptimizedTransaction(
|
@@ -281,13 +283,15 @@ export class TransactionsManager {
|
|
281
283
|
this.txHandler.connection,
|
282
284
|
updateLookupTable.updateLutTx,
|
283
285
|
this.simulateOnly,
|
284
|
-
attemptNum
|
286
|
+
attemptNum,
|
287
|
+
prioritySetting,
|
288
|
+
() => this.updateStatus(updateLutTxName, TransactionStatus.AwaitingSignature)
|
285
289
|
),
|
286
290
|
3,
|
287
291
|
150,
|
288
292
|
this.errorsToThrow
|
289
293
|
);
|
290
|
-
this.updateStatus(
|
294
|
+
this.updateStatus(updateLutTxName, TransactionStatus.Successful);
|
291
295
|
}
|
292
296
|
|
293
297
|
this.lookupTables.defaultLuts = client.defaultLookupTables();
|
@@ -419,7 +423,8 @@ export class TransactionsManager {
|
|
419
423
|
tx,
|
420
424
|
this.simulateOnly,
|
421
425
|
attemptNum,
|
422
|
-
prioritySetting
|
426
|
+
prioritySetting,
|
427
|
+
() => this.updateStatus(itemSet!.name(), TransactionStatus.AwaitingSignature)
|
423
428
|
);
|
424
429
|
this.updateStatus(
|
425
430
|
itemSet.name(),
|
package/src/utils/numberUtils.ts
CHANGED
package/src/utils/solanaUtils.ts
CHANGED
@@ -38,7 +38,9 @@ import {
|
|
38
38
|
} from "../marginfi-sdk";
|
39
39
|
import { PriorityFeeSetting } from "../types";
|
40
40
|
|
41
|
-
export function getSolanaRpcConnection(
|
41
|
+
export function getSolanaRpcConnection(
|
42
|
+
heliusApiKey: string
|
43
|
+
): [Connection, Umi] {
|
42
44
|
const connection = new Connection(
|
43
45
|
`https://mainnet.helius-rpc.com/?api-key=${heliusApiKey}`,
|
44
46
|
"finalized"
|
@@ -242,7 +244,7 @@ async function simulateTransaction(
|
|
242
244
|
): Promise<RpcResponseAndContext<SimulatedTransactionResponse>> {
|
243
245
|
const simulationResult = await connection.simulateTransaction(transaction, {
|
244
246
|
sigVerify: false,
|
245
|
-
commitment: "processed"
|
247
|
+
commitment: "processed",
|
246
248
|
});
|
247
249
|
if (simulationResult.value.err) {
|
248
250
|
simulationResult.value.logs?.forEach((x: any) => {
|
@@ -256,7 +258,7 @@ async function simulateTransaction(
|
|
256
258
|
export async function getComputeUnitPriceEstimate(
|
257
259
|
umi: Umi,
|
258
260
|
tx: TransactionBuilder,
|
259
|
-
prioritySetting: PriorityFeeSetting
|
261
|
+
prioritySetting: PriorityFeeSetting
|
260
262
|
): Promise<number> {
|
261
263
|
const web3Transaction = toWeb3JsTransaction(
|
262
264
|
(await tx.setLatestBlockhash(umi, { commitment: "finalized" })).build(umi)
|
@@ -281,15 +283,21 @@ export async function sendSingleOptimizedTransaction(
|
|
281
283
|
tx: TransactionBuilder,
|
282
284
|
simulateOnly?: boolean,
|
283
285
|
attemptNum?: number,
|
284
|
-
prioritySetting: PriorityFeeSetting = PriorityFeeSetting.Default
|
286
|
+
prioritySetting: PriorityFeeSetting = PriorityFeeSetting.Default,
|
287
|
+
onAwaitingSign?: () => void
|
285
288
|
): Promise<Uint8Array | undefined> {
|
286
289
|
console.log("Sending single optimized transaction...");
|
287
290
|
console.log("Instructions: ", tx.getInstructions().length);
|
288
291
|
console.log("Serialized transaction size: ", tx.getTransactionSize(umi));
|
289
292
|
|
290
|
-
const feeEstimate = await getComputeUnitPriceEstimate(
|
293
|
+
const feeEstimate = await getComputeUnitPriceEstimate(
|
294
|
+
umi,
|
295
|
+
tx,
|
296
|
+
prioritySetting
|
297
|
+
);
|
291
298
|
console.log("Compute unit price: ", feeEstimate);
|
292
299
|
|
300
|
+
// TODO: we should only retry simulation if it's not a solauto error
|
293
301
|
const simulationResult = await retryWithExponentialBackoff(
|
294
302
|
async () =>
|
295
303
|
await simulateTransaction(
|
@@ -304,7 +312,8 @@ export async function sendSingleOptimizedTransaction(
|
|
304
312
|
).setLatestBlockhash(umi)
|
305
313
|
).build(umi)
|
306
314
|
)
|
307
|
-
)
|
315
|
+
),
|
316
|
+
3
|
308
317
|
);
|
309
318
|
|
310
319
|
const computeUnitLimit = Math.round(
|
@@ -313,6 +322,7 @@ export async function sendSingleOptimizedTransaction(
|
|
313
322
|
console.log("Compute unit limit: ", computeUnitLimit);
|
314
323
|
|
315
324
|
if (!simulateOnly) {
|
325
|
+
onAwaitingSign?.();
|
316
326
|
const result = await assembleFinalTransaction(
|
317
327
|
umi.identity,
|
318
328
|
tx,
|