@haven-fi/solauto-sdk 1.0.484 → 1.0.485
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 -1
- package/dist/utils/jupiterUtils.d.ts.map +1 -1
- package/dist/utils/jupiterUtils.js +4 -3
- package/package.json +1 -1
- package/src/transactions/transactionsManager.ts +10 -5
- package/src/utils/jupiterUtils.ts +10 -5
- package/tests/transactions/solautoMarginfi.ts +6 -6
@@ -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;
|
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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AAO,CAAC,UAAU,CAAS;IAE3B,kBAAkB,SAAmB;gBAG3B,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,EACrC,WAAW,CAAC,EAAE,WAAW;YAab,uBAAuB;IAwCrC,OAAO,CAAC,YAAY;YA6CN,aAAa;IAoB3B,OAAO,CAAC,4BAA4B;IAgBpC,OAAO,CAAC,mBAAmB;YAoBb,SAAS;IAiBV,UAAU,CACrB,YAAY,EAAE,eAAe,EAAE,GAC9B,OAAO,CAAC,0BAA0B,CAAC;IAmGzB,IAAI,CACf,KAAK,EAAE,eAAe,EAAE,GACvB,OAAO,CAAC,0BAA0B,CAAC;YAkCxB,6BAA6B;YAsI7B,qBAAqB;YAoDrB,eAAe;YA0Df,eAAe;CA4D9B"}
|
@@ -14,6 +14,7 @@ const web3_js_1 = require("@solana/web3.js");
|
|
14
14
|
const switchboardConstants_1 = require("../constants/switchboardConstants");
|
15
15
|
const utils_1 = require("../utils");
|
16
16
|
const jitoUtils_1 = require("../utils/jitoUtils");
|
17
|
+
const jupiter_sdk_1 = require("../jupiter-sdk");
|
17
18
|
const CHORES_TX_NAME = "account chores";
|
18
19
|
const MAX_SUPPORTED_ACCOUNT_LOCKS = 64;
|
19
20
|
class TransactionTooLargeError extends Error {
|
@@ -270,7 +271,9 @@ class TransactionsManager {
|
|
270
271
|
for (const item of items) {
|
271
272
|
await item.initialize();
|
272
273
|
}
|
273
|
-
const allAccounts = items
|
274
|
+
const allAccounts = items
|
275
|
+
.filter((x) => x.tx?.getInstructions().find((x) => x.programId !== jupiter_sdk_1.JUPITER_PROGRAM_ID))
|
276
|
+
.flatMap((x) => x.tx
|
274
277
|
?.getInstructions()
|
275
278
|
.flatMap((x) => x.keys.map((x) => x.pubkey.toString())));
|
276
279
|
const swbOracle = allAccounts.find((x) => Object.values(switchboardConstants_1.SWITCHBOARD_PRICE_FEED_IDS).includes(x ?? ""));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"jupiterUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jupiterUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAA0B,MAAM,iBAAiB,CAAC;AAGpE,OAAO,EAGL,aAAa,EACd,MAAM,aAAa,CAAC;AAOrB,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,SAAS,CAAC;IACtB,iBAAiB,EAAE,SAAS,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAgBD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,aAAa,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,iBAAiB,EAAE,kBAAkB,CAAC;IACtC,aAAa,EAAE,kBAAkB,CAAC;IAClC,MAAM,EAAE,kBAAkB,CAAC;CAC5B;AAED,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,cAAc,EAC3B,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,kBAAkB,CAAC,
|
1
|
+
{"version":3,"file":"jupiterUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jupiterUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAA0B,MAAM,iBAAiB,CAAC;AAGpE,OAAO,EAGL,aAAa,EACd,MAAM,aAAa,CAAC;AAOrB,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,SAAS,CAAC;IACtB,iBAAiB,EAAE,SAAS,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAgBD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,aAAa,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,iBAAiB,EAAE,kBAAkB,CAAC;IACtC,aAAa,EAAE,kBAAkB,CAAC;IAClC,MAAM,EAAE,kBAAkB,CAAC;CAC5B;AAED,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,cAAc,EAC3B,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,kBAAkB,CAAC,CA2G7B;AAED,wBAAsB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,SAAS,CAAC,EAAE,OAAO;;GA0B5E"}
|
@@ -25,9 +25,10 @@ function createTransactionInstruction(instruction) {
|
|
25
25
|
async function getJupSwapTransaction(signer, swapDetails, attemptNum) {
|
26
26
|
const memecoinSwap = constants_1.TOKEN_INFO[swapDetails.inputMint.toString()].isMeme ||
|
27
27
|
constants_1.TOKEN_INFO[swapDetails.outputMint.toString()].isMeme;
|
28
|
+
const tokensWithLowAccounts = [constants_1.PYTH, constants_1.INF];
|
28
29
|
// TEMP REVERT ME
|
29
|
-
const
|
30
|
-
swapDetails.outputMint.equals(new web3_js_1.PublicKey(
|
30
|
+
const useLowAccounts = tokensWithLowAccounts.find((x) => swapDetails.inputMint.equals(new web3_js_1.PublicKey(x))) ||
|
31
|
+
tokensWithLowAccounts.find((x) => swapDetails.outputMint.equals(new web3_js_1.PublicKey(x)));
|
31
32
|
const quoteResponse = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => await jupApi.quoteGet({
|
32
33
|
amount: Number(swapDetails.amount),
|
33
34
|
inputMint: swapDetails.inputMint.toString(),
|
@@ -38,7 +39,7 @@ async function getJupSwapTransaction(signer, swapDetails, attemptNum) {
|
|
38
39
|
? "ExactIn"
|
39
40
|
: undefined,
|
40
41
|
slippageBps: memecoinSwap ? 500 : 200,
|
41
|
-
maxAccounts: !swapDetails.exactOut ? (
|
42
|
+
maxAccounts: !swapDetails.exactOut ? (useLowAccounts ? 15 : 40) : undefined,
|
42
43
|
}), 4, 200);
|
43
44
|
const priceImpactBps = Math.round((0, numberUtils_1.toBps)(parseFloat(quoteResponse.priceImpactPct))) + 1;
|
44
45
|
const finalPriceSlippageBps = Math.round(Math.max(50, quoteResponse.slippageBps, priceImpactBps) *
|
package/package.json
CHANGED
@@ -31,6 +31,7 @@ import {
|
|
31
31
|
import { SWITCHBOARD_PRICE_FEED_IDS } from "../constants/switchboardConstants";
|
32
32
|
import { buildSwbSubmitResponseTx, getSwitchboardFeedData } from "../utils";
|
33
33
|
import { sendJitoBundledTransactions } from "../utils/jitoUtils";
|
34
|
+
import { JUPITER_PROGRAM_ID } from "../jupiter-sdk";
|
34
35
|
|
35
36
|
const CHORES_TX_NAME = "account chores";
|
36
37
|
const MAX_SUPPORTED_ACCOUNT_LOCKS = 64;
|
@@ -433,11 +434,15 @@ export class TransactionsManager {
|
|
433
434
|
await item.initialize();
|
434
435
|
}
|
435
436
|
|
436
|
-
const allAccounts = items
|
437
|
-
x
|
438
|
-
?.getInstructions()
|
439
|
-
|
440
|
-
|
437
|
+
const allAccounts = items
|
438
|
+
.filter((x) =>
|
439
|
+
x.tx?.getInstructions().find((x) => x.programId !== JUPITER_PROGRAM_ID)
|
440
|
+
)
|
441
|
+
.flatMap((x) =>
|
442
|
+
x.tx
|
443
|
+
?.getInstructions()
|
444
|
+
.flatMap((x) => x.keys.map((x) => x.pubkey.toString()))
|
445
|
+
);
|
441
446
|
const swbOracle = allAccounts.find((x) =>
|
442
447
|
Object.values(SWITCHBOARD_PRICE_FEED_IDS).includes(x ?? "")
|
443
448
|
);
|
@@ -13,7 +13,7 @@ import {
|
|
13
13
|
} from "@jup-ag/api";
|
14
14
|
import { getTokenAccount } from "./accountUtils";
|
15
15
|
import { consoleLog, retryWithExponentialBackoff } from "./generalUtils";
|
16
|
-
import { PYTH, TOKEN_INFO } from "../constants";
|
16
|
+
import { INF, PYTH, TOKEN_INFO } from "../constants";
|
17
17
|
|
18
18
|
const jupApi = createJupiterApiClient();
|
19
19
|
|
@@ -60,10 +60,15 @@ export async function getJupSwapTransaction(
|
|
60
60
|
TOKEN_INFO[swapDetails.inputMint.toString()].isMeme ||
|
61
61
|
TOKEN_INFO[swapDetails.outputMint.toString()].isMeme;
|
62
62
|
|
63
|
+
const tokensWithLowAccounts = [PYTH, INF];
|
63
64
|
// TEMP REVERT ME
|
64
|
-
const
|
65
|
-
|
66
|
-
|
65
|
+
const useLowAccounts =
|
66
|
+
tokensWithLowAccounts.find((x) =>
|
67
|
+
swapDetails.inputMint.equals(new PublicKey(x))
|
68
|
+
) ||
|
69
|
+
tokensWithLowAccounts.find((x) =>
|
70
|
+
swapDetails.outputMint.equals(new PublicKey(x))
|
71
|
+
);
|
67
72
|
|
68
73
|
const quoteResponse = await retryWithExponentialBackoff(
|
69
74
|
async () =>
|
@@ -77,7 +82,7 @@ export async function getJupSwapTransaction(
|
|
77
82
|
? "ExactIn"
|
78
83
|
: undefined,
|
79
84
|
slippageBps: memecoinSwap ? 500 : 200,
|
80
|
-
maxAccounts: !swapDetails.exactOut ? (
|
85
|
+
maxAccounts: !swapDetails.exactOut ? (useLowAccounts ? 15 : 40) : undefined,
|
81
86
|
}),
|
82
87
|
4,
|
83
88
|
200
|
@@ -51,12 +51,12 @@ export function getFlooredTimestampByMinute(
|
|
51
51
|
}
|
52
52
|
|
53
53
|
describe("Solauto Marginfi tests", async () => {
|
54
|
-
const signer = setupTest();
|
55
|
-
|
54
|
+
// const signer = setupTest();
|
55
|
+
const signer = setupTest("solauto-manager");
|
56
56
|
|
57
|
-
const payForTransactions =
|
57
|
+
const payForTransactions = true;
|
58
58
|
const testProgram = false;
|
59
|
-
const positionId =
|
59
|
+
const positionId = 1;
|
60
60
|
|
61
61
|
it("open - deposit - borrow - rebalance to 0 - withdraw - close", async () => {
|
62
62
|
const client = new SolautoMarginfiClient(
|
@@ -72,7 +72,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
72
72
|
await client.initialize({
|
73
73
|
signer,
|
74
74
|
positionId,
|
75
|
-
authority: new PublicKey("
|
75
|
+
authority: new PublicKey("9j53Z6bejUaAxJCEC64BbxozLPuvsuAFsr6iqWKKDvaw"),
|
76
76
|
// new: true,
|
77
77
|
// marginfiAccount: new PublicKey(
|
78
78
|
// ""
|
@@ -169,7 +169,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
169
169
|
transactionItems.push(
|
170
170
|
new TransactionItem(
|
171
171
|
async (attemptNum) =>
|
172
|
-
await buildSolautoRebalanceTransaction(client,
|
172
|
+
await buildSolautoRebalanceTransaction(client, undefined, attemptNum),
|
173
173
|
"rebalance"
|
174
174
|
)
|
175
175
|
);
|