@haven-fi/solauto-sdk 1.0.555 → 1.0.557
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/constants/solautoConstants.d.ts.map +1 -1
- package/dist/constants/solautoConstants.js +0 -4
- package/dist/utils/generalUtils.d.ts +1 -0
- package/dist/utils/generalUtils.d.ts.map +1 -1
- package/dist/utils/generalUtils.js +23 -0
- package/dist/utils/jitoUtils.d.ts.map +1 -1
- package/dist/utils/jitoUtils.js +17 -32
- package/dist/utils/solanaUtils.d.ts.map +1 -1
- package/dist/utils/solanaUtils.js +7 -13
- package/package.json +1 -1
- package/src/constants/solautoConstants.ts +0 -4
- package/src/utils/generalUtils.ts +26 -0
- package/src/utils/jitoUtils.ts +23 -40
- package/src/utils/solanaUtils.ts +11 -15
- package/tests/transactions/solautoMarginfi.ts +7 -7
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solautoConstants.d.ts","sourceRoot":"","sources":["../../src/constants/solautoConstants.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,SAAS,EACV,MAAM,iBAAiB,CAAC;AASzB,eAAO,MAAM,oBAAoB,WAEhC,CAAC;AACF,eAAO,MAAM,oBAAoB,WAEhC,CAAC;AAIF,eAAO,MAAM,YAAY,QAAQ,CAAC;AAElC,eAAO,MAAM,iCAAiC,IAAI,CAAC;AACnD,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAE/C,eAAO,MAAM,MAAM,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CAAO,CAAC;AAE7E,eAAO,MAAM,iBAAiB,0CAA0C,CAAC;AAEzE,eAAO,MAAM,iBAAiB,UAS7B,CAAC;
|
1
|
+
{"version":3,"file":"solautoConstants.d.ts","sourceRoot":"","sources":["../../src/constants/solautoConstants.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,SAAS,EACV,MAAM,iBAAiB,CAAC;AASzB,eAAO,MAAM,oBAAoB,WAEhC,CAAC;AACF,eAAO,MAAM,oBAAoB,WAEhC,CAAC;AAIF,eAAO,MAAM,YAAY,QAAQ,CAAC;AAElC,eAAO,MAAM,iCAAiC,IAAI,CAAC;AACnD,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAE/C,eAAO,MAAM,MAAM,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CAAO,CAAC;AAE7E,eAAO,MAAM,iBAAiB,0CAA0C,CAAC;AAEzE,eAAO,MAAM,iBAAiB,UAS7B,CAAC;AAEF,eAAO,MAAM,WAAW,iDAAiD,CAAC;AAC1E,eAAO,MAAM,qBAAqB,UAYR,CAAC;AAG3B,eAAO,MAAM,aAAa,UAOzB,CAAA"}
|
@@ -26,10 +26,6 @@ exports.JITO_TIP_ACCOUNTS = [
|
|
26
26
|
"DttWaMuVvTiduZRnguLF7jNxTgiMBZ1hyAumKUiL2KRL",
|
27
27
|
"3AVi9Tg9Uo68tJfuvoKvqKNWKkC5wPdSSdeBnizKZ6jT",
|
28
28
|
];
|
29
|
-
// "9D4xwZwDf46n9ft5gQxZzq3rBbdRXsXojKQLZbBdskPY";
|
30
|
-
// "J97FEQeJzChRnaAjNy3dRvm9FBavKqAdxo8jKXzw17ut"
|
31
|
-
// "ByhmNseaYZXBDcBm6xhbgarwixgjym6H4ddLsvgoL3BL"
|
32
|
-
// "2VJK8AHqtiaiJKYbBtFr3EHV4Hcy1FHCiEYQFmUvxot8"
|
33
29
|
exports.SOLAUTO_LUT = "8b7KefQDroVLGao71J5H3hFwABeyMCgCrLpXWssNFhk9";
|
34
30
|
exports.STANDARD_LUT_ACCOUNTS = [
|
35
31
|
web3_js_1.PublicKey.default,
|
@@ -15,4 +15,5 @@ export declare function zip<T, U>(list1: T[], list2: U[]): [T, U][];
|
|
15
15
|
export type ErrorsToThrow = Array<new (...args: any[]) => Error>;
|
16
16
|
export declare function retryWithExponentialBackoff<T>(fn: (attemptNum: number, prevErr?: Error) => Promise<T>, retries?: number, delay?: number, errorsToThrow?: ErrorsToThrow): Promise<T>;
|
17
17
|
export declare function toEnumValue<E extends object>(enumObj: E, value: number): E[keyof E] | undefined;
|
18
|
+
export declare function customRpcCall(umi: Umi, method: string, params?: any): Promise<any>;
|
18
19
|
//# sourceMappingURL=generalUtils.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../src/utils/generalUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAa,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAc,SAAS,EAAE,MAAM,cAAc,CAAC;
|
1
|
+
{"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../src/utils/generalUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAa,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAc,SAAS,EAAE,MAAM,cAAc,CAAC;AAGrD,wBAAgB,UAAU,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAI/C;AAED,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,CAErD;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAW1D;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,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efault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
6
|
exports.consoleLog = consoleLog;
|
4
7
|
exports.tokenInfo = tokenInfo;
|
@@ -13,9 +16,11 @@ exports.arraysAreEqual = arraysAreEqual;
|
|
13
16
|
exports.zip = zip;
|
14
17
|
exports.retryWithExponentialBackoff = retryWithExponentialBackoff;
|
15
18
|
exports.toEnumValue = toEnumValue;
|
19
|
+
exports.customRpcCall = customRpcCall;
|
16
20
|
const web3_js_1 = require("@solana/web3.js");
|
17
21
|
const umi_1 = require("@metaplex-foundation/umi");
|
18
22
|
const constants_1 = require("../constants");
|
23
|
+
const axios_1 = __importDefault(require("axios"));
|
19
24
|
function consoleLog(...args) {
|
20
25
|
if (globalThis.LOCAL_TEST) {
|
21
26
|
console.log(...args);
|
@@ -120,3 +125,21 @@ function toEnumValue(enumObj, value) {
|
|
120
125
|
}
|
121
126
|
return undefined;
|
122
127
|
}
|
128
|
+
async function customRpcCall(umi, method, params) {
|
129
|
+
const data = (await axios_1.default.post(umi.rpc.getEndpoint(), {
|
130
|
+
jsonrpc: "2.0",
|
131
|
+
id: 1,
|
132
|
+
method,
|
133
|
+
params,
|
134
|
+
}, {
|
135
|
+
headers: {
|
136
|
+
"Content-Type": "application/json",
|
137
|
+
},
|
138
|
+
})).data;
|
139
|
+
if ("result" in data) {
|
140
|
+
return data.result;
|
141
|
+
}
|
142
|
+
else {
|
143
|
+
return data;
|
144
|
+
}
|
145
|
+
}
|
@@ -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;AAMzB,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAEH,kBAAkB,EAEnB,MAAM,0BAA0B,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,EAEnB,MAAM,0BAA0B,CAAC;AAYlC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAMlE,wBAAgB,mBAAmB,IAAI,SAAS,CAG/C;AAgND,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,MAAM,CAAC,EAAE,kBAAkB,EAC3B,kBAAkB,GAAE,kBAA2C,EAC/D,cAAc,CAAC,EAAE,MAAM,IAAI,GAC1B,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CA+F/B"}
|
package/dist/utils/jitoUtils.js
CHANGED
@@ -46,29 +46,19 @@ function parseJitoErrorMessage(message) {
|
|
46
46
|
}
|
47
47
|
async function simulateJitoBundle(umi, txs) {
|
48
48
|
const simulationResult = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => {
|
49
|
-
const
|
50
|
-
|
51
|
-
|
52
|
-
method: "simulateBundle",
|
53
|
-
params: [
|
54
|
-
{
|
55
|
-
encodedTransactions: txs.map((x) => Buffer.from(x.serialize()).toString("base64")),
|
56
|
-
},
|
57
|
-
{
|
58
|
-
encoding: "base64",
|
59
|
-
commitment: "confirmed",
|
60
|
-
preExecutionAccountsConfigs: txs.map((_) => { }),
|
61
|
-
postExecutionAccountsConfigs: txs.map((_) => { }),
|
62
|
-
skipSigVerify: true,
|
63
|
-
},
|
64
|
-
],
|
65
|
-
}, {
|
66
|
-
headers: {
|
67
|
-
"Content-Type": "application/json",
|
49
|
+
const res = await (0, generalUtils_1.customRpcCall)(umi, "simulateBundle", [
|
50
|
+
{
|
51
|
+
encodedTransactions: txs.map((x) => Buffer.from(x.serialize()).toString("base64")),
|
68
52
|
},
|
69
|
-
|
70
|
-
|
71
|
-
|
53
|
+
{
|
54
|
+
encoding: "base64",
|
55
|
+
commitment: "confirmed",
|
56
|
+
preExecutionAccountsConfigs: txs.map((_) => { }),
|
57
|
+
postExecutionAccountsConfigs: txs.map((_) => { }),
|
58
|
+
skipSigVerify: true,
|
59
|
+
},
|
60
|
+
]);
|
61
|
+
if (res.value && res.value.summary.failed) {
|
72
62
|
const resValue = res.result.value;
|
73
63
|
const transactionResults = resValue.transactionResults;
|
74
64
|
transactionResults.forEach((x) => {
|
@@ -93,7 +83,7 @@ async function simulateJitoBundle(umi, txs) {
|
|
93
83
|
else if (res.error && res.error.message) {
|
94
84
|
throw new Error(res.error.message);
|
95
85
|
}
|
96
|
-
return res.
|
86
|
+
return res.value;
|
97
87
|
});
|
98
88
|
const transactionResults = simulationResult.transactionResults;
|
99
89
|
return transactionResults;
|
@@ -120,16 +110,11 @@ async function umiToVersionedTransactions(umi, blockhash, userSigner, otherSigne
|
|
120
110
|
return builtTxs.map((x) => (0, umi_web3js_adapters_1.toWeb3JsTransaction)(x));
|
121
111
|
}
|
122
112
|
async function getBundleStatus(umi, bundleId) {
|
123
|
-
const res = await
|
124
|
-
|
125
|
-
|
126
|
-
method: "getBundleStatuses",
|
127
|
-
params: [[bundleId]],
|
128
|
-
});
|
129
|
-
if (res.data.error) {
|
130
|
-
throw new Error(`Failed to get bundle status: ${res.data.error}`);
|
113
|
+
const res = await (0, generalUtils_1.customRpcCall)(umi, "getBundleStatuses", [[bundleId]]);
|
114
|
+
if (res.error) {
|
115
|
+
throw new Error(`Failed to get bundle status: ${res.error}`);
|
131
116
|
}
|
132
|
-
return res
|
117
|
+
return res;
|
133
118
|
}
|
134
119
|
async function pollBundleStatus(umi, bundleId, interval = 1000, timeout = 40000) {
|
135
120
|
const endTime = Date.now() + timeout;
|
@@ -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,EAIL,UAAU,EACV,SAAS,EAKT,sBAAsB,EAEvB,MAAM,iBAAiB,CAAC;
|
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,EAIL,UAAU,EACV,SAAS,EAKT,sBAAsB,EAEvB,MAAM,iBAAiB,CAAC;AAiBzB,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,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,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,CAuEjC"}
|
@@ -31,7 +31,6 @@ const marginfi_sdk_1 = require("../marginfi-sdk");
|
|
31
31
|
const types_1 = require("../types");
|
32
32
|
const solauto_1 = require("./solauto");
|
33
33
|
const constants_1 = require("../constants");
|
34
|
-
const axios_1 = __importDefault(require("axios"));
|
35
34
|
function buildHeliusApiUrl(heliusApiKey) {
|
36
35
|
return `https://mainnet.helius-rpc.com/?api-key=${heliusApiKey}`;
|
37
36
|
}
|
@@ -153,15 +152,10 @@ async function simulateTransaction(umi, connection, transaction) {
|
|
153
152
|
return simulationResult;
|
154
153
|
}
|
155
154
|
async function getQnComputeUnitPriceEstimate(umi, programId, blockheight = 50) {
|
156
|
-
return
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
params: {
|
161
|
-
last_n_blocks: blockheight,
|
162
|
-
account: programId.toString(),
|
163
|
-
},
|
164
|
-
})).data;
|
155
|
+
return await (0, generalUtils_1.customRpcCall)(umi, "qn_estimatePriorityFees", {
|
156
|
+
last_n_blocks: blockheight,
|
157
|
+
account: programId.toString(),
|
158
|
+
});
|
165
159
|
}
|
166
160
|
async function getComputeUnitPriceEstimate(umi, tx, prioritySetting, useAccounts) {
|
167
161
|
const web3Transaction = (0, umi_web3js_adapters_1.toWeb3JsTransaction)((await tx.setLatestBlockhash(umi, { commitment: "finalized" })).build(umi));
|
@@ -170,7 +164,7 @@ async function getComputeUnitPriceEstimate(umi, tx, prioritySetting, useAccounts
|
|
170
164
|
.flatMap((x) => x.keys.flatMap((x) => x.pubkey.toString()));
|
171
165
|
let feeEstimate;
|
172
166
|
try {
|
173
|
-
const resp = await
|
167
|
+
const resp = await (0, generalUtils_1.customRpcCall)(umi, "getPriorityFeeEstimate", [
|
174
168
|
{
|
175
169
|
transaction: !useAccounts
|
176
170
|
? bs58_1.default.encode(web3Transaction.serialize())
|
@@ -185,7 +179,7 @@ async function getComputeUnitPriceEstimate(umi, tx, prioritySetting, useAccounts
|
|
185
179
|
}
|
186
180
|
catch (e) {
|
187
181
|
try {
|
188
|
-
const resp = await
|
182
|
+
const resp = await (0, generalUtils_1.customRpcCall)(umi, "getPriorityFeeEstimate", [
|
189
183
|
{
|
190
184
|
accountKeys,
|
191
185
|
options: {
|
@@ -235,7 +229,7 @@ async function sendSingleOptimizedTransaction(umi, connection, tx, txType, prior
|
|
235
229
|
(0, generalUtils_1.consoleLog)("Sending single optimized transaction...");
|
236
230
|
(0, generalUtils_1.consoleLog)("Instructions: ", tx.getInstructions().length);
|
237
231
|
(0, generalUtils_1.consoleLog)("Serialized transaction size: ", tx.getTransactionSize(umi));
|
238
|
-
(0, generalUtils_1.consoleLog)("Programs: ", tx.getInstructions().map(x => x.programId));
|
232
|
+
(0, generalUtils_1.consoleLog)("Programs: ", tx.getInstructions().map((x) => x.programId));
|
239
233
|
const accounts = tx
|
240
234
|
.getInstructions()
|
241
235
|
.flatMap((x) => [
|
package/package.json
CHANGED
@@ -44,10 +44,6 @@ export const JITO_TIP_ACCOUNTS = [
|
|
44
44
|
"3AVi9Tg9Uo68tJfuvoKvqKNWKkC5wPdSSdeBnizKZ6jT",
|
45
45
|
];
|
46
46
|
|
47
|
-
// "9D4xwZwDf46n9ft5gQxZzq3rBbdRXsXojKQLZbBdskPY";
|
48
|
-
// "J97FEQeJzChRnaAjNy3dRvm9FBavKqAdxo8jKXzw17ut"
|
49
|
-
// "ByhmNseaYZXBDcBm6xhbgarwixgjym6H4ddLsvgoL3BL"
|
50
|
-
// "2VJK8AHqtiaiJKYbBtFr3EHV4Hcy1FHCiEYQFmUvxot8"
|
51
47
|
export const SOLAUTO_LUT = "8b7KefQDroVLGao71J5H3hFwABeyMCgCrLpXWssNFhk9";
|
52
48
|
export const STANDARD_LUT_ACCOUNTS = [
|
53
49
|
PublicKey.default,
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { PublicKey } from "@solana/web3.js";
|
2
2
|
import { MaybeRpcAccount, publicKey, Umi } from "@metaplex-foundation/umi";
|
3
3
|
import { TOKEN_INFO, TokenInfo } from "../constants";
|
4
|
+
import axios from "axios";
|
4
5
|
|
5
6
|
export function consoleLog(...args: any[]): void {
|
6
7
|
if ((globalThis as any).LOCAL_TEST) {
|
@@ -142,3 +143,28 @@ export function toEnumValue<E extends object>(
|
|
142
143
|
|
143
144
|
return undefined;
|
144
145
|
}
|
146
|
+
|
147
|
+
export async function customRpcCall(umi: Umi, method: string, params?: any) {
|
148
|
+
const data = (
|
149
|
+
await axios.post(
|
150
|
+
umi.rpc.getEndpoint(),
|
151
|
+
{
|
152
|
+
jsonrpc: "2.0",
|
153
|
+
id: 1,
|
154
|
+
method,
|
155
|
+
params,
|
156
|
+
},
|
157
|
+
{
|
158
|
+
headers: {
|
159
|
+
"Content-Type": "application/json",
|
160
|
+
},
|
161
|
+
}
|
162
|
+
)
|
163
|
+
).data;
|
164
|
+
|
165
|
+
if ("result" in data) {
|
166
|
+
return data.result;
|
167
|
+
} else {
|
168
|
+
return data;
|
169
|
+
}
|
170
|
+
}
|
package/src/utils/jitoUtils.ts
CHANGED
@@ -25,7 +25,11 @@ import {
|
|
25
25
|
sendSingleOptimizedTransaction,
|
26
26
|
systemTransferUmiIx,
|
27
27
|
} from "./solanaUtils";
|
28
|
-
import {
|
28
|
+
import {
|
29
|
+
consoleLog,
|
30
|
+
customRpcCall,
|
31
|
+
retryWithExponentialBackoff,
|
32
|
+
} from "./generalUtils";
|
29
33
|
import { PriorityFeeSetting, TransactionRunType } from "../types";
|
30
34
|
import axios from "axios";
|
31
35
|
import base58 from "bs58";
|
@@ -74,37 +78,22 @@ function parseJitoErrorMessage(message: string) {
|
|
74
78
|
|
75
79
|
async function simulateJitoBundle(umi: Umi, txs: VersionedTransaction[]) {
|
76
80
|
const simulationResult = await retryWithExponentialBackoff(async () => {
|
77
|
-
const
|
78
|
-
umi.rpc.getEndpoint(),
|
81
|
+
const res = await customRpcCall(umi, "simulateBundle", [
|
79
82
|
{
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
params: [
|
84
|
-
{
|
85
|
-
encodedTransactions: txs.map((x) =>
|
86
|
-
Buffer.from(x.serialize()).toString("base64")
|
87
|
-
),
|
88
|
-
},
|
89
|
-
{
|
90
|
-
encoding: "base64",
|
91
|
-
commitment: "confirmed",
|
92
|
-
preExecutionAccountsConfigs: txs.map((_) => {}),
|
93
|
-
postExecutionAccountsConfigs: txs.map((_) => {}),
|
94
|
-
skipSigVerify: true,
|
95
|
-
},
|
96
|
-
],
|
83
|
+
encodedTransactions: txs.map((x) =>
|
84
|
+
Buffer.from(x.serialize()).toString("base64")
|
85
|
+
),
|
97
86
|
},
|
98
87
|
{
|
99
|
-
|
100
|
-
|
101
|
-
},
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
88
|
+
encoding: "base64",
|
89
|
+
commitment: "confirmed",
|
90
|
+
preExecutionAccountsConfigs: txs.map((_) => {}),
|
91
|
+
postExecutionAccountsConfigs: txs.map((_) => {}),
|
92
|
+
skipSigVerify: true,
|
93
|
+
},
|
94
|
+
]);
|
106
95
|
|
107
|
-
if (res.
|
96
|
+
if (res.value && res.value.summary.failed) {
|
108
97
|
const resValue = res.result.value;
|
109
98
|
const transactionResults =
|
110
99
|
resValue.transactionResults as SimulatedTransactionResponse[];
|
@@ -139,7 +128,7 @@ async function simulateJitoBundle(umi: Umi, txs: VersionedTransaction[]) {
|
|
139
128
|
throw new Error(res.error.message);
|
140
129
|
}
|
141
130
|
|
142
|
-
return res.
|
131
|
+
return res.value;
|
143
132
|
});
|
144
133
|
|
145
134
|
const transactionResults =
|
@@ -191,17 +180,11 @@ async function umiToVersionedTransactions(
|
|
191
180
|
}
|
192
181
|
|
193
182
|
async function getBundleStatus(umi: Umi, bundleId: string) {
|
194
|
-
const res = await
|
195
|
-
|
196
|
-
|
197
|
-
method: "getBundleStatuses",
|
198
|
-
params: [[bundleId]],
|
199
|
-
});
|
200
|
-
if (res.data.error) {
|
201
|
-
throw new Error(`Failed to get bundle status: ${res.data.error}`);
|
183
|
+
const res = await customRpcCall(umi, "getBundleStatuses", [[bundleId]]);
|
184
|
+
if (res.error) {
|
185
|
+
throw new Error(`Failed to get bundle status: ${res.error}`);
|
202
186
|
}
|
203
|
-
|
204
|
-
return res.data.result;
|
187
|
+
return res;
|
205
188
|
}
|
206
189
|
|
207
190
|
async function pollBundleStatus(
|
@@ -317,7 +300,7 @@ export async function sendJitoBundledTransactions(
|
|
317
300
|
);
|
318
301
|
|
319
302
|
txs[0] = txs[0].prepend(getTipInstruction(userSigner, 150_000));
|
320
|
-
|
303
|
+
|
321
304
|
const feeEstimates =
|
322
305
|
priorityFeeSetting !== PriorityFeeSetting.None
|
323
306
|
? await Promise.all(
|
package/src/utils/solanaUtils.ts
CHANGED
@@ -36,6 +36,7 @@ import { getTokenAccount } from "./accountUtils";
|
|
36
36
|
import {
|
37
37
|
arraysAreEqual,
|
38
38
|
consoleLog,
|
39
|
+
customRpcCall,
|
39
40
|
retryWithExponentialBackoff,
|
40
41
|
} from "./generalUtils";
|
41
42
|
import {
|
@@ -45,7 +46,6 @@ import {
|
|
45
46
|
import { PriorityFeeSetting, TransactionRunType } from "../types";
|
46
47
|
import { createDynamicSolautoProgram } from "./solauto";
|
47
48
|
import { SOLAUTO_PROD_PROGRAM } from "../constants";
|
48
|
-
import axios from "axios";
|
49
49
|
|
50
50
|
export function buildHeliusApiUrl(heliusApiKey: string) {
|
51
51
|
return `https://mainnet.helius-rpc.com/?api-key=${heliusApiKey}`;
|
@@ -292,17 +292,10 @@ export async function getQnComputeUnitPriceEstimate(
|
|
292
292
|
programId: PublicKey,
|
293
293
|
blockheight: number = 50
|
294
294
|
): Promise<any> {
|
295
|
-
return (
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
id: 1,
|
300
|
-
params: {
|
301
|
-
last_n_blocks: blockheight,
|
302
|
-
account: programId.toString(),
|
303
|
-
},
|
304
|
-
})
|
305
|
-
).data;
|
295
|
+
return await customRpcCall(umi, "qn_estimatePriorityFees", {
|
296
|
+
last_n_blocks: blockheight,
|
297
|
+
account: programId.toString(),
|
298
|
+
});
|
306
299
|
}
|
307
300
|
|
308
301
|
export async function getComputeUnitPriceEstimate(
|
@@ -321,7 +314,7 @@ export async function getComputeUnitPriceEstimate(
|
|
321
314
|
|
322
315
|
let feeEstimate: number | undefined;
|
323
316
|
try {
|
324
|
-
const resp = await umi
|
317
|
+
const resp = await customRpcCall(umi, "getPriorityFeeEstimate", [
|
325
318
|
{
|
326
319
|
transaction: !useAccounts
|
327
320
|
? bs58.encode(web3Transaction.serialize())
|
@@ -335,7 +328,7 @@ export async function getComputeUnitPriceEstimate(
|
|
335
328
|
feeEstimate = Math.round((resp as any).priorityFeeEstimate as number);
|
336
329
|
} catch (e) {
|
337
330
|
try {
|
338
|
-
const resp = await umi
|
331
|
+
const resp = await customRpcCall(umi, "getPriorityFeeEstimate", [
|
339
332
|
{
|
340
333
|
accountKeys,
|
341
334
|
options: {
|
@@ -408,7 +401,10 @@ export async function sendSingleOptimizedTransaction(
|
|
408
401
|
consoleLog("Sending single optimized transaction...");
|
409
402
|
consoleLog("Instructions: ", tx.getInstructions().length);
|
410
403
|
consoleLog("Serialized transaction size: ", tx.getTransactionSize(umi));
|
411
|
-
consoleLog(
|
404
|
+
consoleLog(
|
405
|
+
"Programs: ",
|
406
|
+
tx.getInstructions().map((x) => x.programId)
|
407
|
+
);
|
412
408
|
|
413
409
|
const accounts = tx
|
414
410
|
.getInstructions()
|
@@ -44,12 +44,12 @@ import { PriorityFeeSetting } from "../../src/types";
|
|
44
44
|
import { buildIronforgeApiUrl, fromBaseUnit, tokenInfo, USD_DECIMALS } from "../../dist";
|
45
45
|
|
46
46
|
describe("Solauto Marginfi tests", async () => {
|
47
|
-
|
48
|
-
const signer = setupTest("solauto-manager");
|
47
|
+
const signer = setupTest();
|
48
|
+
// const signer = setupTest("solauto-manager");
|
49
49
|
|
50
|
-
const payForTransactions =
|
51
|
-
const testProgram =
|
52
|
-
const positionId =
|
50
|
+
const payForTransactions = false;
|
51
|
+
const testProgram = true;
|
52
|
+
const positionId = 1;
|
53
53
|
|
54
54
|
it("open - deposit - borrow - rebalance to 0 - withdraw - close", async () => {
|
55
55
|
const client = new SolautoMarginfiClient(
|
@@ -65,7 +65,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
65
65
|
await client.initialize({
|
66
66
|
signer,
|
67
67
|
positionId,
|
68
|
-
authority: new PublicKey("FKYQs7KgRvaKQHxXwb8HKfoBcFdSxLL3JvHWpPdVQ16v"),
|
68
|
+
// authority: new PublicKey("FKYQs7KgRvaKQHxXwb8HKfoBcFdSxLL3JvHWpPdVQ16v"),
|
69
69
|
// new: true,
|
70
70
|
// marginfiAccount: new PublicKey(
|
71
71
|
// ""
|
@@ -145,7 +145,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
145
145
|
transactionItems.push(
|
146
146
|
new TransactionItem(
|
147
147
|
async (attemptNum) =>
|
148
|
-
await buildSolautoRebalanceTransaction(client,
|
148
|
+
await buildSolautoRebalanceTransaction(client, 2000, attemptNum),
|
149
149
|
"rebalance"
|
150
150
|
)
|
151
151
|
);
|