@haven-fi/solauto-sdk 1.0.555 → 1.0.556
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 +42 -30
- package/dist/utils/solanaUtils.d.ts.map +1 -1
- package/dist/utils/solanaUtils.js +27 -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 +48 -37
- package/src/utils/solanaUtils.ts +31 -14
- 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;AA4OD,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,28 +46,45 @@ 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
|
-
|
53
|
+
{
|
54
|
+
encoding: "base64",
|
55
|
+
commitment: "confirmed",
|
56
|
+
preExecutionAccountsConfigs: txs.map((_) => { }),
|
57
|
+
postExecutionAccountsConfigs: txs.map((_) => { }),
|
58
|
+
skipSigVerify: true,
|
59
|
+
},
|
60
|
+
]);
|
61
|
+
// const resp = await axios.post(
|
62
|
+
// umi.rpc.getEndpoint(),
|
63
|
+
// {
|
64
|
+
// jsonrpc: "2.0",
|
65
|
+
// id: 1,
|
66
|
+
// method: "simulateBundle",
|
67
|
+
// params: [
|
68
|
+
// {
|
69
|
+
// encodedTransactions: txs.map((x) =>
|
70
|
+
// Buffer.from(x.serialize()).toString("base64")
|
71
|
+
// ),
|
72
|
+
// },
|
73
|
+
// {
|
74
|
+
// encoding: "base64",
|
75
|
+
// commitment: "confirmed",
|
76
|
+
// preExecutionAccountsConfigs: txs.map((_) => {}),
|
77
|
+
// postExecutionAccountsConfigs: txs.map((_) => {}),
|
78
|
+
// skipSigVerify: true,
|
79
|
+
// },
|
80
|
+
// ],
|
81
|
+
// },
|
82
|
+
// {
|
83
|
+
// headers: {
|
84
|
+
// "Content-Type": "application/json",
|
85
|
+
// },
|
86
|
+
// }
|
87
|
+
// );
|
71
88
|
if (res.result && res.result.value && res.result.value.summary.failed) {
|
72
89
|
const resValue = res.result.value;
|
73
90
|
const transactionResults = resValue.transactionResults;
|
@@ -120,16 +137,11 @@ async function umiToVersionedTransactions(umi, blockhash, userSigner, otherSigne
|
|
120
137
|
return builtTxs.map((x) => (0, umi_web3js_adapters_1.toWeb3JsTransaction)(x));
|
121
138
|
}
|
122
139
|
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}`);
|
140
|
+
const res = await (0, generalUtils_1.customRpcCall)(umi, "getBundleStatuses", [[bundleId]]);
|
141
|
+
if (res.error) {
|
142
|
+
throw new Error(`Failed to get bundle status: ${res.error}`);
|
131
143
|
}
|
132
|
-
return res.
|
144
|
+
return res.result;
|
133
145
|
}
|
134
146
|
async function pollBundleStatus(umi, bundleId, interval = 1000, timeout = 40000) {
|
135
147
|
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;AAKlE,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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AAuBD,wBAAsB,6BAA6B,CACjD,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,EACpB,WAAW,GAAE,MAAW,GACvB,OAAO,CAAC,GAAG,CAAC,CAKd;AAED,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,kBAAkB,EACtB,eAAe,EAAE,kBAAkB,EACnC,WAAW,CAAC,EAAE,OAAO,GACpB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CA4D7B;AA+CD,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,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())
|
@@ -181,11 +175,23 @@ async function getComputeUnitPriceEstimate(umi, tx, prioritySetting, useAccounts
|
|
181
175
|
},
|
182
176
|
},
|
183
177
|
]);
|
178
|
+
// const resp = await umi.rpc.call("getPriorityFeeEstimate", [
|
179
|
+
// {
|
180
|
+
// transaction: !useAccounts
|
181
|
+
// ? bs58.encode(web3Transaction.serialize())
|
182
|
+
// : undefined,
|
183
|
+
// accountKeys: useAccounts ? accountKeys : undefined,
|
184
|
+
// options: {
|
185
|
+
// priorityLevel: prioritySetting.toString(),
|
186
|
+
// },
|
187
|
+
// },
|
188
|
+
// ]);
|
184
189
|
feeEstimate = Math.round(resp.priorityFeeEstimate);
|
190
|
+
console.log(resp);
|
185
191
|
}
|
186
192
|
catch (e) {
|
187
193
|
try {
|
188
|
-
const resp = await
|
194
|
+
const resp = await (0, generalUtils_1.customRpcCall)(umi, "getPriorityFeeEstimate", [
|
189
195
|
{
|
190
196
|
accountKeys,
|
191
197
|
options: {
|
@@ -193,6 +199,14 @@ async function getComputeUnitPriceEstimate(umi, tx, prioritySetting, useAccounts
|
|
193
199
|
},
|
194
200
|
},
|
195
201
|
]);
|
202
|
+
// const resp = await umi.rpc.call("getPriorityFeeEstimate", [
|
203
|
+
// {
|
204
|
+
// accountKeys,
|
205
|
+
// options: {
|
206
|
+
// priorityLevel: prioritySetting.toString(),
|
207
|
+
// },
|
208
|
+
// },
|
209
|
+
// ]);
|
196
210
|
feeEstimate = Math.round(resp.priorityFeeEstimate);
|
197
211
|
}
|
198
212
|
catch (e) {
|
@@ -235,7 +249,7 @@ async function sendSingleOptimizedTransaction(umi, connection, tx, txType, prior
|
|
235
249
|
(0, generalUtils_1.consoleLog)("Sending single optimized transaction...");
|
236
250
|
(0, generalUtils_1.consoleLog)("Instructions: ", tx.getInstructions().length);
|
237
251
|
(0, generalUtils_1.consoleLog)("Serialized transaction size: ", tx.getTransactionSize(umi));
|
238
|
-
(0, generalUtils_1.consoleLog)("Programs: ", tx.getInstructions().map(x => x.programId));
|
252
|
+
(0, generalUtils_1.consoleLog)("Programs: ", tx.getInstructions().map((x) => x.programId));
|
239
253
|
const accounts = tx
|
240
254
|
.getInstructions()
|
241
255
|
.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,35 +78,47 @@ 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
|
+
]);
|
95
|
+
// const resp = await axios.post(
|
96
|
+
// umi.rpc.getEndpoint(),
|
97
|
+
// {
|
98
|
+
// jsonrpc: "2.0",
|
99
|
+
// id: 1,
|
100
|
+
// method: "simulateBundle",
|
101
|
+
// params: [
|
102
|
+
// {
|
103
|
+
// encodedTransactions: txs.map((x) =>
|
104
|
+
// Buffer.from(x.serialize()).toString("base64")
|
105
|
+
// ),
|
106
|
+
// },
|
107
|
+
// {
|
108
|
+
// encoding: "base64",
|
109
|
+
// commitment: "confirmed",
|
110
|
+
// preExecutionAccountsConfigs: txs.map((_) => {}),
|
111
|
+
// postExecutionAccountsConfigs: txs.map((_) => {}),
|
112
|
+
// skipSigVerify: true,
|
113
|
+
// },
|
114
|
+
// ],
|
115
|
+
// },
|
116
|
+
// {
|
117
|
+
// headers: {
|
118
|
+
// "Content-Type": "application/json",
|
119
|
+
// },
|
120
|
+
// }
|
121
|
+
// );
|
106
122
|
|
107
123
|
if (res.result && res.result.value && res.result.value.summary.failed) {
|
108
124
|
const resValue = res.result.value;
|
@@ -191,17 +207,12 @@ async function umiToVersionedTransactions(
|
|
191
207
|
}
|
192
208
|
|
193
209
|
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}`);
|
210
|
+
const res = await customRpcCall(umi, "getBundleStatuses", [[bundleId]]);
|
211
|
+
if (res.error) {
|
212
|
+
throw new Error(`Failed to get bundle status: ${res.error}`);
|
202
213
|
}
|
203
214
|
|
204
|
-
return res.
|
215
|
+
return res.result;
|
205
216
|
}
|
206
217
|
|
207
218
|
async function pollBundleStatus(
|
@@ -317,7 +328,7 @@ export async function sendJitoBundledTransactions(
|
|
317
328
|
);
|
318
329
|
|
319
330
|
txs[0] = txs[0].prepend(getTipInstruction(userSigner, 150_000));
|
320
|
-
|
331
|
+
|
321
332
|
const feeEstimates =
|
322
333
|
priorityFeeSetting !== PriorityFeeSetting.None
|
323
334
|
? 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 {
|
@@ -292,17 +293,10 @@ export async function getQnComputeUnitPriceEstimate(
|
|
292
293
|
programId: PublicKey,
|
293
294
|
blockheight: number = 50
|
294
295
|
): 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;
|
296
|
+
return await customRpcCall(umi, "qn_estimatePriorityFees", {
|
297
|
+
last_n_blocks: blockheight,
|
298
|
+
account: programId.toString(),
|
299
|
+
});
|
306
300
|
}
|
307
301
|
|
308
302
|
export async function getComputeUnitPriceEstimate(
|
@@ -321,7 +315,7 @@ export async function getComputeUnitPriceEstimate(
|
|
321
315
|
|
322
316
|
let feeEstimate: number | undefined;
|
323
317
|
try {
|
324
|
-
const resp = await umi
|
318
|
+
const resp = await customRpcCall(umi, "getPriorityFeeEstimate", [
|
325
319
|
{
|
326
320
|
transaction: !useAccounts
|
327
321
|
? bs58.encode(web3Transaction.serialize())
|
@@ -332,10 +326,22 @@ export async function getComputeUnitPriceEstimate(
|
|
332
326
|
},
|
333
327
|
},
|
334
328
|
]);
|
329
|
+
// const resp = await umi.rpc.call("getPriorityFeeEstimate", [
|
330
|
+
// {
|
331
|
+
// transaction: !useAccounts
|
332
|
+
// ? bs58.encode(web3Transaction.serialize())
|
333
|
+
// : undefined,
|
334
|
+
// accountKeys: useAccounts ? accountKeys : undefined,
|
335
|
+
// options: {
|
336
|
+
// priorityLevel: prioritySetting.toString(),
|
337
|
+
// },
|
338
|
+
// },
|
339
|
+
// ]);
|
335
340
|
feeEstimate = Math.round((resp as any).priorityFeeEstimate as number);
|
341
|
+
console.log(resp);
|
336
342
|
} catch (e) {
|
337
343
|
try {
|
338
|
-
const resp = await umi
|
344
|
+
const resp = await customRpcCall(umi, "getPriorityFeeEstimate", [
|
339
345
|
{
|
340
346
|
accountKeys,
|
341
347
|
options: {
|
@@ -343,6 +349,14 @@ export async function getComputeUnitPriceEstimate(
|
|
343
349
|
},
|
344
350
|
},
|
345
351
|
]);
|
352
|
+
// const resp = await umi.rpc.call("getPriorityFeeEstimate", [
|
353
|
+
// {
|
354
|
+
// accountKeys,
|
355
|
+
// options: {
|
356
|
+
// priorityLevel: prioritySetting.toString(),
|
357
|
+
// },
|
358
|
+
// },
|
359
|
+
// ]);
|
346
360
|
feeEstimate = Math.round((resp as any).priorityFeeEstimate as number);
|
347
361
|
} catch (e) {
|
348
362
|
// console.error(e);
|
@@ -408,7 +422,10 @@ export async function sendSingleOptimizedTransaction(
|
|
408
422
|
consoleLog("Sending single optimized transaction...");
|
409
423
|
consoleLog("Instructions: ", tx.getInstructions().length);
|
410
424
|
consoleLog("Serialized transaction size: ", tx.getTransactionSize(umi));
|
411
|
-
consoleLog(
|
425
|
+
consoleLog(
|
426
|
+
"Programs: ",
|
427
|
+
tx.getInstructions().map((x) => x.programId)
|
428
|
+
);
|
412
429
|
|
413
430
|
const accounts = tx
|
414
431
|
.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
|
);
|