@haven-fi/solauto-sdk 1.0.516 → 1.0.518
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.
- package/dist/transactions/transactionsManager.d.ts.map +1 -1
- package/dist/transactions/transactionsManager.js +6 -3
- package/dist/utils/jitoUtils.d.ts +2 -2
- package/dist/utils/jitoUtils.d.ts.map +1 -1
- package/dist/utils/jitoUtils.js +5 -4
- package/dist/utils/solauto/rebalanceUtils.js +1 -1
- package/package.json +1 -1
- package/src/transactions/transactionsManager.ts +9 -2
- package/src/utils/jitoUtils.ts +10 -1
- package/src/utils/solauto/rebalanceUtils.ts +1 -1
@@ -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;AAMzD,OAAO,EAEL,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;AAa7D,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,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,EACxC,IAAI,CAAC,EAAE,MAAM,YAAA;IAGhB,UAAU;IAKV,OAAO,CAAC,UAAU,EAAE,MAAM;IAMhC,cAAc,IAAI,MAAM,EAAE;CAY3B;
|
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,EAEL,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;AAa7D,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,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,EACxC,IAAI,CAAC,EAAE,MAAM,YAAA;IAGhB,UAAU;IAKV,OAAO,CAAC,UAAU,EAAE,MAAM;IAMhC,cAAc,IAAI,MAAM,EAAE;CAY3B;AA6FD,oBAAY,iBAAiB;IAC3B,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,UAAU,eAAe;IACzB,MAAM,WAAW;CAClB;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,iBAAiB,CAA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;YA0Df,eAAe;CA4D9B"}
|
@@ -76,6 +76,9 @@ class TransactionSet {
|
|
76
76
|
this.lookupTables = lookupTables;
|
77
77
|
this.items = items;
|
78
78
|
}
|
79
|
+
async lutInputs() {
|
80
|
+
return await this.lookupTables.getLutInputs(this.lutAddresses());
|
81
|
+
}
|
79
82
|
async fitsWith(item) {
|
80
83
|
if (!item.tx) {
|
81
84
|
return true;
|
@@ -112,10 +115,9 @@ class TransactionSet {
|
|
112
115
|
const transactions = this.items
|
113
116
|
.filter((x) => x.tx && x.tx.getInstructions().length > 0)
|
114
117
|
.map((x) => x.tx);
|
115
|
-
const lutInputs = await this.lookupTables.getLutInputs(this.lutAddresses());
|
116
118
|
return (0, umi_1.transactionBuilder)()
|
117
119
|
.add(transactions)
|
118
|
-
.setAddressLookupTables(lutInputs);
|
120
|
+
.setAddressLookupTables(await this.lutInputs());
|
119
121
|
}
|
120
122
|
lutAddresses() {
|
121
123
|
return Array.from(new Set(this.items.map((x) => x.lookupTableAddresses).flat()));
|
@@ -386,8 +388,9 @@ class TransactionsManager {
|
|
386
388
|
}
|
387
389
|
let txSigs;
|
388
390
|
let error;
|
391
|
+
const lutInputs = await Promise.all(itemSets.map(async (x) => await x.lutInputs()));
|
389
392
|
try {
|
390
|
-
txSigs = await (0, jitoUtils_1.sendJitoBundledTransactions)(this.txHandler.umi, this.txHandler.connection, this.txHandler.signer, this.txHandler.otherSigners, transactions, this.txType, this.getUpdatedPriorityFeeSetting(prevError, attemptNum), () => this.updateStatusForSets(itemSets, TransactionStatus.Processing, attemptNum, undefined, true));
|
393
|
+
txSigs = await (0, jitoUtils_1.sendJitoBundledTransactions)(this.txHandler.umi, this.txHandler.connection, this.txHandler.signer, this.txHandler.otherSigners, transactions, lutInputs.flat(), this.txType, this.getUpdatedPriorityFeeSetting(prevError, attemptNum), () => this.updateStatusForSets(itemSets, TransactionStatus.Processing, attemptNum, undefined, true));
|
391
394
|
}
|
392
395
|
catch (e) {
|
393
396
|
error = e;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Connection, PublicKey } from "@solana/web3.js";
|
2
|
-
import { Signer, TransactionBuilder, Umi, TransactionMessage } from "@metaplex-foundation/umi";
|
2
|
+
import { Signer, TransactionBuilder, Umi, TransactionMessage, AddressLookupTableInput } from "@metaplex-foundation/umi";
|
3
3
|
import { PriorityFeeSetting, TransactionRunType } from "../types";
|
4
4
|
export declare function getRandomTipAccount(): PublicKey;
|
5
5
|
export declare function getRequiredSigners(message: TransactionMessage): {
|
@@ -7,5 +7,5 @@ export declare function getRequiredSigners(message: TransactionMessage): {
|
|
7
7
|
publicKey: string;
|
8
8
|
isWritable: boolean;
|
9
9
|
}[];
|
10
|
-
export declare function sendJitoBundledTransactions(umi: Umi, connection: Connection, userSigner: Signer, otherSigners: Signer[], txs: TransactionBuilder[], txType?: TransactionRunType, priorityFeeSetting?: PriorityFeeSetting, onAwaitingSign?: () => void): Promise<string[] | undefined>;
|
10
|
+
export declare function sendJitoBundledTransactions(umi: Umi, connection: Connection, userSigner: Signer, otherSigners: Signer[], txs: TransactionBuilder[], lutInputs: AddressLookupTableInput[], txType?: TransactionRunType, priorityFeeSetting?: PriorityFeeSetting, onAwaitingSign?: () => void): Promise<string[] | undefined>;
|
11
11
|
//# sourceMappingURL=jitoUtils.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"jitoUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jitoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EAKV,MAAM,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"jitoUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jitoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EAKV,MAAM,iBAAiB,CAAC;AAMzB,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAEH,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,0BAA0B,CAAC;AAQlC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAMlE,wBAAgB,mBAAmB,IAAI,SAAS,CAG/C;AAiOD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,kBAAkB;;;;IAkB7D;AAED,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EAAE,EACtB,GAAG,EAAE,kBAAkB,EAAE,EACzB,SAAS,EAAE,uBAAuB,EAAE,EACpC,MAAM,CAAC,EAAE,kBAAkB,EAC3B,kBAAkB,GAAE,kBAA2C,EAC/D,cAAc,CAAC,EAAE,MAAM,IAAI,GAC1B,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CAsG/B"}
|
package/dist/utils/jitoUtils.js
CHANGED
@@ -98,9 +98,10 @@ async function simulateJitoBundle(umi, txs) {
|
|
98
98
|
const transactionResults = simulationResult.transactionResults;
|
99
99
|
return transactionResults;
|
100
100
|
}
|
101
|
-
async function umiToVersionedTransactions(umi, blockhash, userSigner, otherSigners, txs, sign, feeEstimates, computeUnitLimits) {
|
101
|
+
async function umiToVersionedTransactions(umi, blockhash, userSigner, otherSigners, txs, lutInputs, sign, feeEstimates, computeUnitLimits) {
|
102
102
|
let builtTxs = await Promise.all(txs.map(async (tx, i) => {
|
103
103
|
return (0, solanaUtils_1.assembleFinalTransaction)(userSigner, tx, feeEstimates ? feeEstimates[i] : undefined, computeUnitLimits ? computeUnitLimits[i] : undefined)
|
104
|
+
.setAddressLookupTables(lutInputs)
|
104
105
|
.setBlockhash(blockhash)
|
105
106
|
.build(umi);
|
106
107
|
}));
|
@@ -189,7 +190,7 @@ function getRequiredSigners(message) {
|
|
189
190
|
}
|
190
191
|
return signersInfo;
|
191
192
|
}
|
192
|
-
async function sendJitoBundledTransactions(umi, connection, userSigner, otherSigners, txs, txType, priorityFeeSetting = types_1.PriorityFeeSetting.Min, onAwaitingSign) {
|
193
|
+
async function sendJitoBundledTransactions(umi, connection, userSigner, otherSigners, txs, lutInputs, txType, priorityFeeSetting = types_1.PriorityFeeSetting.Min, onAwaitingSign) {
|
193
194
|
if (txs.length === 1) {
|
194
195
|
const resp = await (0, solanaUtils_1.sendSingleOptimizedTransaction)(umi, connection, txs[0], txType, priorityFeeSetting, onAwaitingSign);
|
195
196
|
return resp ? [bytes_1.bs58.encode(resp)] : undefined;
|
@@ -207,13 +208,13 @@ async function sendJitoBundledTransactions(umi, connection, userSigner, otherSig
|
|
207
208
|
let builtTxs = [];
|
208
209
|
let simulationResults;
|
209
210
|
if (txType !== "skip-simulation") {
|
210
|
-
builtTxs = await umiToVersionedTransactions(umi, latestBlockhash, userSigner, otherSigners, txs, false, feeEstimates);
|
211
|
+
builtTxs = await umiToVersionedTransactions(umi, latestBlockhash, userSigner, otherSigners, txs, lutInputs, false, feeEstimates);
|
211
212
|
(0, generalUtils_1.consoleLog)(builtTxs.map((x) => x.message.compiledInstructions.map((y) => x.message.staticAccountKeys[y.programIdIndex].toString())));
|
212
213
|
simulationResults = await simulateJitoBundle(umi, builtTxs);
|
213
214
|
}
|
214
215
|
if (txType !== "only-simulate") {
|
215
216
|
onAwaitingSign?.();
|
216
|
-
builtTxs = await umiToVersionedTransactions(umi, latestBlockhash, userSigner, otherSigners, txs, true, feeEstimates, simulationResults
|
217
|
+
builtTxs = await umiToVersionedTransactions(umi, latestBlockhash, userSigner, otherSigners, txs, lutInputs, true, feeEstimates, simulationResults
|
217
218
|
? simulationResults.map((x) => x.unitsConsumed * 1.15)
|
218
219
|
: undefined);
|
219
220
|
const serializedTxs = builtTxs.map((x) => x.serialize());
|
@@ -153,7 +153,7 @@ function getFlashLoanRequirements(client, values, attemptNum) {
|
|
153
153
|
(0, generalUtils_2.tokenInfo)(client.debtMint).isStableCoin;
|
154
154
|
const sufficientSignerSupplyLiquidity = false; // TODO
|
155
155
|
const sufficientSignerDebtLiquidity = isJupLong; // TODO
|
156
|
-
const signerFlashLoan = Boolean(((attemptNum ?? 0) >
|
156
|
+
const signerFlashLoan = Boolean(((attemptNum ?? 0) > 3 ||
|
157
157
|
(insufficientDebtLiquidity && insufficientDebtLiquidity)) &&
|
158
158
|
(sufficientSignerSupplyLiquidity || sufficientSignerDebtLiquidity));
|
159
159
|
if (signerFlashLoan) {
|
package/package.json
CHANGED
@@ -123,6 +123,10 @@ class TransactionSet {
|
|
123
123
|
public items: TransactionItem[] = []
|
124
124
|
) {}
|
125
125
|
|
126
|
+
async lutInputs(): Promise<AddressLookupTableInput[]> {
|
127
|
+
return await this.lookupTables.getLutInputs(this.lutAddresses());
|
128
|
+
}
|
129
|
+
|
126
130
|
async fitsWith(item: TransactionItem): Promise<boolean> {
|
127
131
|
if (!item.tx) {
|
128
132
|
return true;
|
@@ -175,10 +179,9 @@ class TransactionSet {
|
|
175
179
|
.filter((x) => x.tx && x.tx.getInstructions().length > 0)
|
176
180
|
.map((x) => x.tx!);
|
177
181
|
|
178
|
-
const lutInputs = await this.lookupTables.getLutInputs(this.lutAddresses());
|
179
182
|
return transactionBuilder()
|
180
183
|
.add(transactions)
|
181
|
-
.setAddressLookupTables(lutInputs);
|
184
|
+
.setAddressLookupTables(await this.lutInputs());
|
182
185
|
}
|
183
186
|
|
184
187
|
lutAddresses(): string[] {
|
@@ -616,6 +619,9 @@ export class TransactionsManager {
|
|
616
619
|
|
617
620
|
let txSigs: string[] | undefined;
|
618
621
|
let error: Error | undefined;
|
622
|
+
const lutInputs = await Promise.all(
|
623
|
+
itemSets.map(async (x) => await x.lutInputs())
|
624
|
+
);
|
619
625
|
try {
|
620
626
|
txSigs = await sendJitoBundledTransactions(
|
621
627
|
this.txHandler.umi,
|
@@ -623,6 +629,7 @@ export class TransactionsManager {
|
|
623
629
|
this.txHandler.signer,
|
624
630
|
this.txHandler.otherSigners,
|
625
631
|
transactions,
|
632
|
+
lutInputs.flat(),
|
626
633
|
this.txType,
|
627
634
|
this.getUpdatedPriorityFeeSetting(prevError, attemptNum),
|
628
635
|
() =>
|
package/src/utils/jitoUtils.ts
CHANGED
@@ -7,13 +7,17 @@ import {
|
|
7
7
|
VersionedTransaction,
|
8
8
|
} from "@solana/web3.js";
|
9
9
|
import { toWeb3JsTransaction } from "@metaplex-foundation/umi-web3js-adapters";
|
10
|
-
import {
|
10
|
+
import {
|
11
|
+
JITO_BLOCK_ENGINE,
|
12
|
+
JITO_TIP_ACCOUNTS,
|
13
|
+
} from "../constants/solautoConstants";
|
11
14
|
import {
|
12
15
|
Signer,
|
13
16
|
TransactionBuilder,
|
14
17
|
Umi,
|
15
18
|
WrappedInstruction,
|
16
19
|
TransactionMessage,
|
20
|
+
AddressLookupTableInput,
|
17
21
|
} from "@metaplex-foundation/umi";
|
18
22
|
import {
|
19
23
|
assembleFinalTransaction,
|
@@ -150,6 +154,7 @@ async function umiToVersionedTransactions(
|
|
150
154
|
userSigner: Signer,
|
151
155
|
otherSigners: Signer[],
|
152
156
|
txs: TransactionBuilder[],
|
157
|
+
lutInputs: AddressLookupTableInput[],
|
153
158
|
sign: boolean,
|
154
159
|
feeEstimates?: number[],
|
155
160
|
computeUnitLimits?: number[]
|
@@ -162,6 +167,7 @@ async function umiToVersionedTransactions(
|
|
162
167
|
feeEstimates ? feeEstimates[i] : undefined,
|
163
168
|
computeUnitLimits ? computeUnitLimits[i] : undefined
|
164
169
|
)
|
170
|
+
.setAddressLookupTables(lutInputs)
|
165
171
|
.setBlockhash(blockhash)
|
166
172
|
.build(umi);
|
167
173
|
})
|
@@ -280,6 +286,7 @@ export async function sendJitoBundledTransactions(
|
|
280
286
|
userSigner: Signer,
|
281
287
|
otherSigners: Signer[],
|
282
288
|
txs: TransactionBuilder[],
|
289
|
+
lutInputs: AddressLookupTableInput[],
|
283
290
|
txType?: TransactionRunType,
|
284
291
|
priorityFeeSetting: PriorityFeeSetting = PriorityFeeSetting.Min,
|
285
292
|
onAwaitingSign?: () => void
|
@@ -341,6 +348,7 @@ export async function sendJitoBundledTransactions(
|
|
341
348
|
userSigner,
|
342
349
|
otherSigners,
|
343
350
|
txs,
|
351
|
+
lutInputs,
|
344
352
|
false,
|
345
353
|
feeEstimates
|
346
354
|
);
|
@@ -363,6 +371,7 @@ export async function sendJitoBundledTransactions(
|
|
363
371
|
userSigner,
|
364
372
|
otherSigners,
|
365
373
|
txs,
|
374
|
+
lutInputs,
|
366
375
|
true,
|
367
376
|
feeEstimates,
|
368
377
|
simulationResults
|
@@ -322,7 +322,7 @@ export function getFlashLoanRequirements(
|
|
322
322
|
const sufficientSignerSupplyLiquidity = false; // TODO
|
323
323
|
const sufficientSignerDebtLiquidity = isJupLong; // TODO
|
324
324
|
const signerFlashLoan = Boolean(
|
325
|
-
((attemptNum ?? 0) >
|
325
|
+
((attemptNum ?? 0) > 3 ||
|
326
326
|
(insufficientDebtLiquidity && insufficientDebtLiquidity)) &&
|
327
327
|
(sufficientSignerSupplyLiquidity || sufficientSignerDebtLiquidity)
|
328
328
|
);
|