@haven-fi/solauto-sdk 1.0.481 → 1.0.482
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 +2 -1
- package/dist/utils/jupiterUtils.d.ts.map +1 -1
- package/dist/utils/jupiterUtils.js +3 -1
- package/package.json +1 -1
- package/src/transactions/transactionsManager.ts +2 -1
- package/src/utils/jupiterUtils.ts +6 -2
- package/tests/transactions/solautoMarginfi.ts +12 -8
@@ -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;AAY7D,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;IA+FzB,IAAI,CACf,KAAK,EAAE,eAAe,EAAE,GACvB,OAAO,CAAC,0BAA0B,CAAC;YAkCxB,6BAA6B;YAsI7B,qBAAqB;YAoDrB,eAAe;YA0Df,eAAe;CA4D9B"}
|
@@ -15,6 +15,7 @@ const switchboardConstants_1 = require("../constants/switchboardConstants");
|
|
15
15
|
const utils_1 = require("../utils");
|
16
16
|
const jitoUtils_1 = require("../utils/jitoUtils");
|
17
17
|
const CHORES_TX_NAME = "account chores";
|
18
|
+
const MAX_SUPPORTED_ACCOUNT_LOCKS = 64;
|
18
19
|
class TransactionTooLargeError extends Error {
|
19
20
|
constructor(message) {
|
20
21
|
super(message);
|
@@ -82,7 +83,7 @@ class TransactionSet {
|
|
82
83
|
...this.items.map((x) => x.uniqueAccounts()),
|
83
84
|
...item.uniqueAccounts(),
|
84
85
|
])).length;
|
85
|
-
if (accountLocks >
|
86
|
+
if (accountLocks > MAX_SUPPORTED_ACCOUNT_LOCKS) {
|
86
87
|
return false;
|
87
88
|
}
|
88
89
|
const singleTx = await this.getSingleTransaction();
|
@@ -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,CAqG7B;AAED,wBAAsB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,SAAS,CAAC,EAAE,OAAO;;GA0B5E"}
|
@@ -25,6 +25,8 @@ 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 usingPyth = swapDetails.inputMint.equals(new web3_js_1.PublicKey(constants_1.PYTH)) ||
|
29
|
+
swapDetails.outputMint.equals(new web3_js_1.PublicKey(constants_1.PYTH));
|
28
30
|
const quoteResponse = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => await jupApi.quoteGet({
|
29
31
|
amount: Number(swapDetails.amount),
|
30
32
|
inputMint: swapDetails.inputMint.toString(),
|
@@ -35,7 +37,7 @@ async function getJupSwapTransaction(signer, swapDetails, attemptNum) {
|
|
35
37
|
? "ExactIn"
|
36
38
|
: undefined,
|
37
39
|
slippageBps: memecoinSwap ? 500 : 200,
|
38
|
-
maxAccounts: !swapDetails.exactOut ? 40 : undefined,
|
40
|
+
maxAccounts: !swapDetails.exactOut ? (usingPyth ? 20 : 40) : undefined,
|
39
41
|
}), 4, 200);
|
40
42
|
const priceImpactBps = Math.round((0, numberUtils_1.toBps)(parseFloat(quoteResponse.priceImpactPct))) + 1;
|
41
43
|
const finalPriceSlippageBps = Math.round(Math.max(50, quoteResponse.slippageBps, priceImpactBps) *
|
package/package.json
CHANGED
@@ -33,6 +33,7 @@ import { buildSwbSubmitResponseTx, getSwitchboardFeedData } from "../utils";
|
|
33
33
|
import { sendJitoBundledTransactions } from "../utils/jitoUtils";
|
34
34
|
|
35
35
|
const CHORES_TX_NAME = "account chores";
|
36
|
+
const MAX_SUPPORTED_ACCOUNT_LOCKS = 64;
|
36
37
|
|
37
38
|
export class TransactionTooLargeError extends Error {
|
38
39
|
constructor(message: string) {
|
@@ -132,7 +133,7 @@ class TransactionSet {
|
|
132
133
|
...item.uniqueAccounts(),
|
133
134
|
])
|
134
135
|
).length;
|
135
|
-
if (accountLocks >
|
136
|
+
if (accountLocks > MAX_SUPPORTED_ACCOUNT_LOCKS) {
|
136
137
|
return false;
|
137
138
|
}
|
138
139
|
|
@@ -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 { TOKEN_INFO } from "../constants";
|
16
|
+
import { PYTH, TOKEN_INFO } from "../constants";
|
17
17
|
|
18
18
|
const jupApi = createJupiterApiClient();
|
19
19
|
|
@@ -60,6 +60,10 @@ export async function getJupSwapTransaction(
|
|
60
60
|
TOKEN_INFO[swapDetails.inputMint.toString()].isMeme ||
|
61
61
|
TOKEN_INFO[swapDetails.outputMint.toString()].isMeme;
|
62
62
|
|
63
|
+
const usingPyth =
|
64
|
+
swapDetails.inputMint.equals(new PublicKey(PYTH)) ||
|
65
|
+
swapDetails.outputMint.equals(new PublicKey(PYTH));
|
66
|
+
|
63
67
|
const quoteResponse = await retryWithExponentialBackoff(
|
64
68
|
async () =>
|
65
69
|
await jupApi.quoteGet({
|
@@ -72,7 +76,7 @@ export async function getJupSwapTransaction(
|
|
72
76
|
? "ExactIn"
|
73
77
|
: undefined,
|
74
78
|
slippageBps: memecoinSwap ? 500 : 200,
|
75
|
-
maxAccounts: !swapDetails.exactOut ? 40 : undefined,
|
79
|
+
maxAccounts: !swapDetails.exactOut ? (usingPyth ? 20 : 40) : undefined,
|
76
80
|
}),
|
77
81
|
4,
|
78
82
|
200
|
@@ -38,7 +38,11 @@ import {
|
|
38
38
|
retryWithExponentialBackoff,
|
39
39
|
} from "../../src/utils";
|
40
40
|
import { PriorityFeeSetting } from "../../src/types";
|
41
|
-
import {
|
41
|
+
import {
|
42
|
+
buildIronforgeApiUrl,
|
43
|
+
fetchSolautoPosition,
|
44
|
+
fetchTokenPrices,
|
45
|
+
} from "../../dist";
|
42
46
|
import { safeFetchBank } from "../../src/marginfi-sdk";
|
43
47
|
|
44
48
|
export function getFlooredTimestampByMinute(
|
@@ -51,12 +55,12 @@ export function getFlooredTimestampByMinute(
|
|
51
55
|
}
|
52
56
|
|
53
57
|
describe("Solauto Marginfi tests", async () => {
|
54
|
-
const signer = setupTest();
|
55
|
-
|
58
|
+
// const signer = setupTest();
|
59
|
+
const signer = setupTest("solauto-manager");
|
56
60
|
|
57
|
-
const payForTransactions =
|
61
|
+
const payForTransactions = true;
|
58
62
|
const testProgram = false;
|
59
|
-
const positionId =
|
63
|
+
const positionId = 4;
|
60
64
|
|
61
65
|
it("open - deposit - borrow - rebalance to 0 - withdraw - close", async () => {
|
62
66
|
const client = new SolautoMarginfiClient(
|
@@ -72,7 +76,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
72
76
|
await client.initialize({
|
73
77
|
signer,
|
74
78
|
positionId,
|
75
|
-
authority: new PublicKey("
|
79
|
+
authority: new PublicKey("EBhRj7jbF2EVE21i19JSuCX1BAbnZFYhoKW64HnaZ3kf"),
|
76
80
|
// new: true,
|
77
81
|
// marginfiAccount: new PublicKey(
|
78
82
|
// ""
|
@@ -169,7 +173,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
169
173
|
transactionItems.push(
|
170
174
|
new TransactionItem(
|
171
175
|
async (attemptNum) =>
|
172
|
-
await buildSolautoRebalanceTransaction(client,
|
176
|
+
await buildSolautoRebalanceTransaction(client, undefined, attemptNum),
|
173
177
|
"rebalance"
|
174
178
|
)
|
175
179
|
);
|
@@ -214,7 +218,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
214
218
|
undefined,
|
215
219
|
!payForTransactions ? "only-simulate" : "normal",
|
216
220
|
PriorityFeeSetting.Min,
|
217
|
-
true
|
221
|
+
true,
|
218
222
|
).clientSend(transactionItems);
|
219
223
|
|
220
224
|
console.log(statuses);
|