@haven-fi/solauto-sdk 1.0.395 → 1.0.397
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.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"jitoUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jitoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAIV,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAEJ,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAKlE,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,SAAS,CAAC,CAa9D;AA2MD,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,MAAM,EACd,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,
|
1
|
+
{"version":3,"file":"jitoUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jitoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAIV,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAEJ,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAKlE,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,SAAS,CAAC,CAa9D;AA2MD,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,MAAM,EACd,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,CAwE/B"}
|
package/dist/utils/jitoUtils.js
CHANGED
@@ -98,7 +98,7 @@ async function simulateJitoBundle(umi, txs) {
|
|
98
98
|
}
|
99
99
|
throw new Error(txFailure ? txFailure[1] : resValue.summary.failed.toString());
|
100
100
|
}
|
101
|
-
else if (res.error.message) {
|
101
|
+
else if (res.error && res.error.message) {
|
102
102
|
throw new Error(res.error.message);
|
103
103
|
}
|
104
104
|
return res;
|
@@ -149,10 +149,10 @@ async function pollBundleStatus(bundleId, interval = 1000, timeout = 40000) {
|
|
149
149
|
}
|
150
150
|
throw new web3_js_1.TransactionExpiredBlockheightExceededError("Unable to confirm transaction. Try a higher priority fee.");
|
151
151
|
}
|
152
|
-
async function sendJitoBundle(transactions) {
|
152
|
+
async function sendJitoBundle(umi, transactions) {
|
153
153
|
let resp;
|
154
154
|
try {
|
155
|
-
resp = await axios_1.default.post(
|
155
|
+
resp = await axios_1.default.post(umi.rpc.getEndpoint(), {
|
156
156
|
jsonrpc: "2.0",
|
157
157
|
id: 1,
|
158
158
|
method: "sendBundle",
|
@@ -198,7 +198,7 @@ async function sendJitoBundledTransactions(umi, signer, txs, txType, priorityFee
|
|
198
198
|
throw new Error("A transaction is too large");
|
199
199
|
}
|
200
200
|
onAwaitingSign?.();
|
201
|
-
const txSigs = await sendJitoBundle(serializedTxs.map((x) => bs58_1.default.encode(x)));
|
201
|
+
const txSigs = await sendJitoBundle(umi, serializedTxs.map((x) => bs58_1.default.encode(x)));
|
202
202
|
return txSigs.length > 0 ? txSigs : undefined;
|
203
203
|
}
|
204
204
|
return undefined;
|
package/package.json
CHANGED
package/src/utils/jitoUtils.ts
CHANGED
@@ -130,7 +130,7 @@ async function simulateJitoBundle(umi: Umi, txs: VersionedTransaction[]) {
|
|
130
130
|
}
|
131
131
|
|
132
132
|
throw new Error(txFailure ? txFailure[1] : resValue.summary.failed.toString());
|
133
|
-
} else if (res.error.message) {
|
133
|
+
} else if (res.error && res.error.message) {
|
134
134
|
throw new Error(res.error.message);
|
135
135
|
}
|
136
136
|
|
@@ -213,11 +213,11 @@ async function pollBundleStatus(
|
|
213
213
|
);
|
214
214
|
}
|
215
215
|
|
216
|
-
async function sendJitoBundle(transactions: string[]): Promise<string[]> {
|
216
|
+
async function sendJitoBundle(umi: Umi, transactions: string[]): Promise<string[]> {
|
217
217
|
let resp: any;
|
218
218
|
try {
|
219
219
|
resp = await axios.post<{ result: string }>(
|
220
|
-
|
220
|
+
umi.rpc.getEndpoint(),
|
221
221
|
{
|
222
222
|
jsonrpc: "2.0",
|
223
223
|
id: 1,
|
@@ -311,6 +311,7 @@ export async function sendJitoBundledTransactions(
|
|
311
311
|
|
312
312
|
onAwaitingSign?.();
|
313
313
|
const txSigs = await sendJitoBundle(
|
314
|
+
umi,
|
314
315
|
serializedTxs.map((x) => base58.encode(x))
|
315
316
|
);
|
316
317
|
return txSigs.length > 0 ? txSigs : undefined;
|
@@ -60,12 +60,12 @@ export function getLeverageFactor(
|
|
60
60
|
}
|
61
61
|
|
62
62
|
describe("Solauto Marginfi tests", async () => {
|
63
|
-
|
64
|
-
const signer = setupTest("solauto-manager");
|
63
|
+
const signer = setupTest();
|
64
|
+
// const signer = setupTest("solauto-manager");
|
65
65
|
|
66
|
-
const payForTransactions =
|
67
|
-
const testProgram =
|
68
|
-
const positionId =
|
66
|
+
const payForTransactions = true;
|
67
|
+
const testProgram = true;
|
68
|
+
const positionId = 1;
|
69
69
|
|
70
70
|
it("open - deposit - borrow - rebalance to 0 - withdraw - close", async () => {
|
71
71
|
const client = new SolautoMarginfiClient(
|
@@ -81,7 +81,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
81
81
|
await client.initialize({
|
82
82
|
signer,
|
83
83
|
positionId,
|
84
|
-
authority: new PublicKey("
|
84
|
+
authority: new PublicKey("rC5dMP5dmSsfQ66rynzfFzuc122Eex9h1RJHVDkeH6D"),
|
85
85
|
// new: true,
|
86
86
|
// marginfiAccount: new PublicKey(
|
87
87
|
// "4nNvUXF5YqHFcH2nGweSiuvy1ct7V5FXfoCLKFYUN36z"
|
@@ -91,7 +91,8 @@ describe("Solauto Marginfi tests", async () => {
|
|
91
91
|
// debtMint: new PublicKey(USDC),
|
92
92
|
});
|
93
93
|
|
94
|
-
console.log(await client.
|
94
|
+
// console.log(await getAllPositionsByAuthority(client.umi, new PublicKey("5UqsR2PGzbP8pGPbXEeXx86Gjz2N2UFBAuFZUSVydAEe"), PositionType.Leverage));
|
95
|
+
|
95
96
|
|
96
97
|
// console.log(JSON.stringify(await getJupPriceData([new PublicKey("7JhmUcZrrfhyt5nTSu3AfsrUq2L9992a7AhwdSDxdoL2")], true), null, 2));
|
97
98
|
// console.log(JSON.stringify(await getJupPriceData([new PublicKey(POPCAT)], true), null, 2));
|
@@ -221,16 +222,16 @@ describe("Solauto Marginfi tests", async () => {
|
|
221
222
|
// )
|
222
223
|
// );
|
223
224
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
225
|
+
transactionItems.push(
|
226
|
+
new TransactionItem(
|
227
|
+
async () => ({
|
228
|
+
tx: client.protocolInteraction(
|
229
|
+
solautoAction("Withdraw", [{ __kind: "Some", fields: [toBaseUnit(0.03, 9)] }])
|
230
|
+
),
|
231
|
+
}),
|
232
|
+
"withdraw"
|
233
|
+
)
|
234
|
+
);
|
234
235
|
// transactionItems.push(
|
235
236
|
// new TransactionItem(
|
236
237
|
// async () => ({
|