@haven-fi/solauto-sdk 1.0.334 → 1.0.336
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 +4 -4
- package/dist/utils/jitoUtils.d.ts +3 -3
- package/dist/utils/jitoUtils.d.ts.map +1 -1
- package/dist/utils/jitoUtils.js +9 -4
- package/dist/utils/solauto/generalUtils.js +1 -1
- package/package.json +1 -1
- package/src/transactions/transactionsManager.ts +6 -4
- package/src/utils/jitoUtils.ts +19 -6
- package/src/utils/solauto/generalUtils.ts +2 -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;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;AAW7D,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,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;AAW7D,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;AA0FD,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,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,EAAE,CAAC;AAEJ,qBAAa,mBAAmB;IAK5B,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,cAAc,CAAC;IACvB,OAAO,CAAC,MAAM,CAAC;IACf,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,aAAa,CAAC;IACtB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,UAAU;IAXpB,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,YAAY,CAAe;gBAGzB,SAAS,EAAE,aAAa,GAAG,oBAAoB,EAC/C,cAAc,CAAC,GAAE,CAAC,QAAQ,EAAE,0BAA0B,KAAK,IAAI,aAAA,EAC/D,MAAM,CAAC,EAAE,kBAAkB,YAAA,EAC3B,kBAAkB,GAAE,kBAA2C,EAC/D,UAAU,GAAE,OAAe,EAC3B,aAAa,CAAC,EAAE,aAAa,YAAA,EAC7B,OAAO,GAAE,MAAU,EACnB,UAAU,GAAE,MAAY;YAQpB,uBAAuB;IAwCrC,OAAO,CAAC,YAAY;YA6CN,aAAa;IAoB3B,OAAO,CAAC,4BAA4B;IAgBpC,OAAO,CAAC,mBAAmB;YAoBb,SAAS;IAgBV,UAAU,CACrB,YAAY,EAAE,eAAe,EAAE,GAC9B,OAAO,CAAC,0BAA0B,CAAC;IA4FzB,IAAI,CACf,KAAK,EAAE,eAAe,EAAE,GACvB,OAAO,CAAC,0BAA0B,CAAC;YAmCxB,6BAA6B;YA+E7B,qBAAqB;YAuDrB,cAAc;YAqCd,eAAe;CAmD9B"}
|
@@ -86,13 +86,13 @@ class TransactionSet {
|
|
86
86
|
return false;
|
87
87
|
}
|
88
88
|
const singleTx = await this.getSingleTransaction();
|
89
|
-
|
89
|
+
const tx = (0, solanaUtils_1.addTxOptimizations)(this.txHandler.umi.identity, singleTx, 1, 1)
|
90
90
|
.add(item.tx)
|
91
91
|
.setAddressLookupTables(await this.lookupTables.getLutInputs([
|
92
92
|
...this.lutAddresses(),
|
93
93
|
...item.lookupTableAddresses,
|
94
|
-
]))
|
95
|
-
|
94
|
+
]));
|
95
|
+
return tx.fitsInOneTransaction(this.txHandler.umi);
|
96
96
|
}
|
97
97
|
add(...items) {
|
98
98
|
this.items.push(...items.filter((x) => x.tx && x.tx.getInstructions().length > 0));
|
@@ -352,7 +352,7 @@ class TransactionsManager {
|
|
352
352
|
let txSigs;
|
353
353
|
let error;
|
354
354
|
try {
|
355
|
-
txSigs = await (0, jitoUtils_1.sendJitoBundledTransactions)(this.txHandler.umi, this.txHandler.signer, transactions,
|
355
|
+
txSigs = await (0, jitoUtils_1.sendJitoBundledTransactions)(this.txHandler.umi, this.txHandler.connection, this.txHandler.signer, transactions, this.txType, this.priorityFeeSetting);
|
356
356
|
}
|
357
357
|
catch (e) {
|
358
358
|
error = e.message;
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { PublicKey } from "@solana/web3.js";
|
1
|
+
import { Connection, PublicKey } from "@solana/web3.js";
|
2
2
|
import { Signer, TransactionBuilder, Umi } from "@metaplex-foundation/umi";
|
3
|
-
import { PriorityFeeSetting } from "../types";
|
3
|
+
import { PriorityFeeSetting, TransactionRunType } from "../types";
|
4
4
|
export declare function getRandomTipAccount(): Promise<PublicKey>;
|
5
|
-
export declare function sendJitoBundledTransactions(umi: Umi, signer: Signer, txs: TransactionBuilder[],
|
5
|
+
export declare function sendJitoBundledTransactions(umi: Umi, connection: Connection, signer: Signer, txs: TransactionBuilder[], txType?: TransactionRunType, priorityFeeSetting?: PriorityFeeSetting): Promise<string[] | undefined>;
|
6
6
|
//# sourceMappingURL=jitoUtils.d.ts.map
|
@@ -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;
|
1
|
+
{"version":3,"file":"jitoUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jitoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAwB,MAAM,iBAAiB,CAAC;AAG9E,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAEJ,MAAM,0BAA0B,CAAC;AASlC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAKlE,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,SAAS,CAAC,CAa9D;AAwHD,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,kBAAkB,EAAE,EACzB,MAAM,CAAC,EAAE,kBAAkB,EAC3B,kBAAkB,GAAE,kBAA2C,GAC9D,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CAyD/B"}
|
package/dist/utils/jitoUtils.js
CHANGED
@@ -13,6 +13,7 @@ const generalUtils_1 = require("./generalUtils");
|
|
13
13
|
const types_1 = require("../types");
|
14
14
|
const axios_1 = __importDefault(require("axios"));
|
15
15
|
const bs58_1 = __importDefault(require("bs58"));
|
16
|
+
const bytes_1 = require("@coral-xyz/anchor/dist/cjs/utils/bytes");
|
16
17
|
async function getRandomTipAccount() {
|
17
18
|
const tipAccounts = [
|
18
19
|
"96gYZGLnJYVFmbjzopPSU6QiEV5fGqZNyN9nmNhvrZU5",
|
@@ -50,11 +51,11 @@ async function getTipInstruction(signer, tipLamports) {
|
|
50
51
|
// );
|
51
52
|
// }
|
52
53
|
async function umiToVersionedTransactions(umi, signer, txs, sign, feeEstimates, computeUnitLimits) {
|
53
|
-
|
54
|
+
let builtTxs = await Promise.all(txs.map(async (tx, i) => {
|
54
55
|
return (await (0, solanaUtils_1.assembleFinalTransaction)(signer, tx, feeEstimates ? feeEstimates[i] : undefined, computeUnitLimits ? computeUnitLimits[i] : undefined).setLatestBlockhash(umi)).build(umi);
|
55
56
|
}));
|
56
57
|
if (sign) {
|
57
|
-
await signer.signAllTransactions(builtTxs);
|
58
|
+
builtTxs = await signer.signAllTransactions(builtTxs);
|
58
59
|
}
|
59
60
|
return builtTxs.map((x) => (0, umi_web3js_adapters_1.toWeb3JsTransaction)(x));
|
60
61
|
}
|
@@ -107,7 +108,11 @@ async function sendJitoBundle(transactions) {
|
|
107
108
|
(0, generalUtils_1.consoleLog)("Bundle ID:", bundleId);
|
108
109
|
return bundleId ? await pollBundleStatus(bundleId) : [];
|
109
110
|
}
|
110
|
-
async function sendJitoBundledTransactions(umi, signer, txs,
|
111
|
+
async function sendJitoBundledTransactions(umi, connection, signer, txs, txType, priorityFeeSetting = types_1.PriorityFeeSetting.Min) {
|
112
|
+
if (txs.length === 1) {
|
113
|
+
const res = await (0, solanaUtils_1.sendSingleOptimizedTransaction)(umi, connection, txs[0], txType, priorityFeeSetting);
|
114
|
+
return res ? [bytes_1.bs58.encode(res)] : undefined;
|
115
|
+
}
|
111
116
|
(0, generalUtils_1.consoleLog)("Sending Jito bundle...");
|
112
117
|
(0, generalUtils_1.consoleLog)("Transactions: ", txs.length);
|
113
118
|
(0, generalUtils_1.consoleLog)("Transaction sizes: ", txs.map((x) => x.getTransactionSize(umi)));
|
@@ -119,7 +124,7 @@ async function sendJitoBundledTransactions(umi, signer, txs, simulateOnly, prior
|
|
119
124
|
let builtTxs = await umiToVersionedTransactions(umi, signer, txs, true, // false if simulating first and rebuilding later
|
120
125
|
feeEstimates);
|
121
126
|
// const simulationResults = await simulateJitoBundle(umi, builtTxs);
|
122
|
-
if (
|
127
|
+
if (txType !== "only-simulate") {
|
123
128
|
// let builtTxs = await umiToVersionedTransactions(
|
124
129
|
// client.signer,
|
125
130
|
// txs,
|
@@ -98,7 +98,7 @@ function eligibleForRebalance(positionState, positionSettings, positionDca, curr
|
|
98
98
|
0.95 >
|
99
99
|
values.debtAdjustmentUsd;
|
100
100
|
if (!sufficientLiquidity) {
|
101
|
-
|
101
|
+
(0, generalUtils_1.consoleLog)("Insufficient debt liquidity to further boost");
|
102
102
|
}
|
103
103
|
return sufficientLiquidity ? "boost" : undefined;
|
104
104
|
}
|
package/package.json
CHANGED
@@ -136,15 +136,16 @@ class TransactionSet {
|
|
136
136
|
}
|
137
137
|
|
138
138
|
const singleTx = await this.getSingleTransaction();
|
139
|
-
|
139
|
+
const tx = addTxOptimizations(this.txHandler.umi.identity, singleTx, 1, 1)
|
140
140
|
.add(item.tx)
|
141
141
|
.setAddressLookupTables(
|
142
142
|
await this.lookupTables.getLutInputs([
|
143
143
|
...this.lutAddresses(),
|
144
144
|
...item.lookupTableAddresses,
|
145
145
|
])
|
146
|
-
)
|
147
|
-
|
146
|
+
);
|
147
|
+
|
148
|
+
return tx.fitsInOneTransaction(this.txHandler.umi);
|
148
149
|
}
|
149
150
|
|
150
151
|
add(...items: TransactionItem[]) {
|
@@ -557,9 +558,10 @@ export class TransactionsManager {
|
|
557
558
|
try {
|
558
559
|
txSigs = await sendJitoBundledTransactions(
|
559
560
|
this.txHandler.umi,
|
561
|
+
this.txHandler.connection,
|
560
562
|
this.txHandler.signer,
|
561
563
|
transactions,
|
562
|
-
|
564
|
+
this.txType,
|
563
565
|
this.priorityFeeSetting
|
564
566
|
);
|
565
567
|
} catch (e: any) {
|
package/src/utils/jitoUtils.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { PublicKey, VersionedTransaction } from "@solana/web3.js";
|
1
|
+
import { Connection, PublicKey, VersionedTransaction } from "@solana/web3.js";
|
2
2
|
import { toWeb3JsTransaction } from "@metaplex-foundation/umi-web3js-adapters";
|
3
3
|
import { JITO_BLOCK_ENGINE } from "../constants/solautoConstants";
|
4
4
|
import {
|
@@ -11,10 +11,11 @@ import {
|
|
11
11
|
assembleFinalTransaction,
|
12
12
|
buildIronforgeApiUrl,
|
13
13
|
getComputeUnitPriceEstimate,
|
14
|
+
sendSingleOptimizedTransaction,
|
14
15
|
systemTransferUmiIx,
|
15
16
|
} from "./solanaUtils";
|
16
17
|
import { consoleLog } from "./generalUtils";
|
17
|
-
import { PriorityFeeSetting } from "../types";
|
18
|
+
import { PriorityFeeSetting, TransactionRunType } from "../types";
|
18
19
|
import axios from "axios";
|
19
20
|
import base58 from "bs58";
|
20
21
|
import { bs58 } from "@coral-xyz/anchor/dist/cjs/utils/bytes";
|
@@ -73,7 +74,7 @@ async function umiToVersionedTransactions(
|
|
73
74
|
feeEstimates?: number[],
|
74
75
|
computeUnitLimits?: number[]
|
75
76
|
): Promise<VersionedTransaction[]> {
|
76
|
-
|
77
|
+
let builtTxs = await Promise.all(
|
77
78
|
txs.map(async (tx, i) => {
|
78
79
|
return (
|
79
80
|
await assembleFinalTransaction(
|
@@ -87,7 +88,7 @@ async function umiToVersionedTransactions(
|
|
87
88
|
);
|
88
89
|
|
89
90
|
if (sign) {
|
90
|
-
await signer.signAllTransactions(builtTxs);
|
91
|
+
builtTxs = await signer.signAllTransactions(builtTxs);
|
91
92
|
}
|
92
93
|
|
93
94
|
return builtTxs.map((x) => toWeb3JsTransaction(x));
|
@@ -154,11 +155,23 @@ async function sendJitoBundle(transactions: string[]): Promise<string[]> {
|
|
154
155
|
|
155
156
|
export async function sendJitoBundledTransactions(
|
156
157
|
umi: Umi,
|
158
|
+
connection: Connection,
|
157
159
|
signer: Signer,
|
158
160
|
txs: TransactionBuilder[],
|
159
|
-
|
161
|
+
txType?: TransactionRunType,
|
160
162
|
priorityFeeSetting: PriorityFeeSetting = PriorityFeeSetting.Min
|
161
163
|
): Promise<string[] | undefined> {
|
164
|
+
if (txs.length === 1) {
|
165
|
+
const res = await sendSingleOptimizedTransaction(
|
166
|
+
umi,
|
167
|
+
connection,
|
168
|
+
txs[0],
|
169
|
+
txType,
|
170
|
+
priorityFeeSetting
|
171
|
+
);
|
172
|
+
return res ? [bs58.encode(res)] : undefined;
|
173
|
+
}
|
174
|
+
|
162
175
|
consoleLog("Sending Jito bundle...");
|
163
176
|
consoleLog("Transactions: ", txs.length);
|
164
177
|
consoleLog(
|
@@ -188,7 +201,7 @@ export async function sendJitoBundledTransactions(
|
|
188
201
|
|
189
202
|
// const simulationResults = await simulateJitoBundle(umi, builtTxs);
|
190
203
|
|
191
|
-
if (
|
204
|
+
if (txType !== "only-simulate") {
|
192
205
|
// let builtTxs = await umiToVersionedTransactions(
|
193
206
|
// client.signer,
|
194
207
|
// txs,
|
@@ -22,7 +22,7 @@ import {
|
|
22
22
|
getSolautoPositionAccountDataSerializer,
|
23
23
|
getSolautoPositionSize,
|
24
24
|
} from "../../generated";
|
25
|
-
import { currentUnixSeconds } from "../generalUtils";
|
25
|
+
import { consoleLog, currentUnixSeconds } from "../generalUtils";
|
26
26
|
import {
|
27
27
|
fromBaseUnit,
|
28
28
|
getLiqUtilzationRateBps,
|
@@ -184,7 +184,7 @@ export function eligibleForRebalance(
|
|
184
184
|
0.95 >
|
185
185
|
values.debtAdjustmentUsd;
|
186
186
|
if (!sufficientLiquidity) {
|
187
|
-
|
187
|
+
consoleLog("Insufficient debt liquidity to further boost");
|
188
188
|
}
|
189
189
|
return sufficientLiquidity ? "boost" : undefined;
|
190
190
|
}
|