@haven-fi/solauto-sdk 1.0.547 → 1.0.549
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/utils/jupiterUtils.d.ts.map +1 -1
- package/dist/utils/jupiterUtils.js +1 -3
- package/dist/utils/solauto/rebalanceUtils.js +1 -1
- package/dist/utils/stringUtils.d.ts +1 -0
- package/dist/utils/stringUtils.d.ts.map +1 -1
- package/dist/utils/stringUtils.js +13 -10
- package/package.json +1 -1
- package/src/utils/jupiterUtils.ts +1 -5
- package/src/utils/solauto/rebalanceUtils.ts +1 -1
- package/src/utils/stringUtils.ts +14 -11
@@ -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;AAUrB,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,SAAS,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,cAAe,SAAQ,YAAY;IAClD,iBAAiB,EAAE,SAAS,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B;AAgBD,wBAAsB,WAAW,CAAC,WAAW,EAAE,YAAY,
|
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;AAUrB,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,SAAS,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,cAAe,SAAQ,YAAY;IAClD,iBAAiB,EAAE,SAAS,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B;AAgBD,wBAAsB,WAAW,CAAC,WAAW,EAAE,YAAY,0BAkB1D;AAED,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,CAAC,EAAE,kBAAkB,CAAC;IACnC,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,CAoF7B;AAED,wBAAsB,eAAe,CACnC,KAAK,EAAE,SAAS,EAAE,EAClB,oBAAoB,CAAC,EAAE,OAAO;;GAwC/B"}
|
@@ -23,8 +23,6 @@ function createTransactionInstruction(instruction) {
|
|
23
23
|
});
|
24
24
|
}
|
25
25
|
async function getJupQuote(swapDetails) {
|
26
|
-
const memecoinSwap = (0, generalUtils_1.tokenInfo)(swapDetails.inputMint)?.isMeme ||
|
27
|
-
(0, generalUtils_1.tokenInfo)(swapDetails.outputMint)?.isMeme;
|
28
26
|
return await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum) => await jupApi.quoteGet({
|
29
27
|
amount: Number(swapDetails.amount),
|
30
28
|
inputMint: swapDetails.inputMint.toString(),
|
@@ -34,7 +32,7 @@ async function getJupQuote(swapDetails) {
|
|
34
32
|
: swapDetails.exactIn
|
35
33
|
? "ExactIn"
|
36
34
|
: undefined,
|
37
|
-
slippageBps:
|
35
|
+
slippageBps: 300,
|
38
36
|
maxAccounts: !swapDetails.exactOut ? 15 + attemptNum * 5 : undefined,
|
39
37
|
}), 3, 200);
|
40
38
|
}
|
@@ -176,7 +176,7 @@ async function getFlashLoanRequirements(client, values, attemptNum) {
|
|
176
176
|
!sufficientSignerSupplyLiquidity;
|
177
177
|
}
|
178
178
|
else {
|
179
|
-
throw new Error(`
|
179
|
+
throw new Error(`Insufficient liquidity to perform the transaction`);
|
180
180
|
}
|
181
181
|
}
|
182
182
|
(0, generalUtils_2.consoleLog)("Requires flash loan:", requiresFlashLoan);
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { PublicKey } from "@solana/web3.js";
|
2
2
|
export declare const StrategyTypes: readonly ["Long", "Short", "Ratio"];
|
3
3
|
export type StrategyType = (typeof StrategyTypes)[number];
|
4
|
+
export declare function ratioName(supplyMint?: PublicKey, debtMint?: PublicKey): string;
|
4
5
|
export declare function solautoStrategyName(supplyMint?: PublicKey, debtMint?: PublicKey): string;
|
5
6
|
export declare function strategyType(supplyMint: PublicKey, debtMint: PublicKey): StrategyType;
|
6
7
|
//# sourceMappingURL=stringUtils.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"stringUtils.d.ts","sourceRoot":"","sources":["../../src/utils/stringUtils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,eAAO,MAAM,aAAa,qCAAsC,CAAC;AACjE,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAoB1D,wBAAgB,mBAAmB,CACjC,UAAU,CAAC,EAAE,SAAS,EACtB,QAAQ,CAAC,EAAE,SAAS,
|
1
|
+
{"version":3,"file":"stringUtils.d.ts","sourceRoot":"","sources":["../../src/utils/stringUtils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,eAAO,MAAM,aAAa,qCAAsC,CAAC;AACjE,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAoB1D,wBAAgB,SAAS,CAAC,UAAU,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,SAAS,UAWrE;AAED,wBAAgB,mBAAmB,CACjC,UAAU,CAAC,EAAE,SAAS,EACtB,QAAQ,CAAC,EAAE,SAAS,UAcrB;AAED,wBAAgB,YAAY,CAC1B,UAAU,EAAE,SAAS,EACrB,QAAQ,EAAE,SAAS,GAClB,YAAY,CAWd"}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.StrategyTypes = void 0;
|
4
|
+
exports.ratioName = ratioName;
|
4
5
|
exports.solautoStrategyName = solautoStrategyName;
|
5
6
|
exports.strategyType = strategyType;
|
6
7
|
const spl_token_1 = require("@solana/spl-token");
|
@@ -25,22 +26,24 @@ function adjustedTicker(mint) {
|
|
25
26
|
return info.ticker;
|
26
27
|
}
|
27
28
|
}
|
29
|
+
function ratioName(supplyMint, debtMint) {
|
30
|
+
if (((0, generalUtils_1.tokenInfo)(supplyMint).isLST && debtMint?.equals(spl_token_1.NATIVE_MINT)) ||
|
31
|
+
(supplyMint &&
|
32
|
+
debtMint &&
|
33
|
+
MAJORS_PRIO[supplyMint.toString()] > MAJORS_PRIO[debtMint.toString()])) {
|
34
|
+
return `${adjustedTicker(supplyMint)}/${adjustedTicker(debtMint)} Long`;
|
35
|
+
}
|
36
|
+
else {
|
37
|
+
return `${adjustedTicker(debtMint)}/${adjustedTicker(supplyMint)} Short`;
|
38
|
+
}
|
39
|
+
}
|
28
40
|
function solautoStrategyName(supplyMint, debtMint) {
|
29
|
-
const supplyInfo = (0, generalUtils_1.tokenInfo)(supplyMint);
|
30
41
|
const strat = strategyType(supplyMint ?? web3_js_1.PublicKey.default, debtMint ?? web3_js_1.PublicKey.default);
|
31
42
|
if (strat === "Long") {
|
32
43
|
return `${adjustedTicker(supplyMint)} Long`;
|
33
44
|
}
|
34
45
|
else if (strat === "Ratio") {
|
35
|
-
|
36
|
-
(supplyMint &&
|
37
|
-
debtMint &&
|
38
|
-
MAJORS_PRIO[supplyMint.toString()] > MAJORS_PRIO[debtMint.toString()])) {
|
39
|
-
return `${adjustedTicker(supplyMint)}/${adjustedTicker(debtMint)} Long`;
|
40
|
-
}
|
41
|
-
else {
|
42
|
-
return `${adjustedTicker(debtMint)}/${adjustedTicker(supplyMint)} Short`;
|
43
|
-
}
|
46
|
+
return ratioName(supplyMint, debtMint);
|
44
47
|
}
|
45
48
|
else {
|
46
49
|
return `${adjustedTicker(debtMint)} Short`;
|
package/package.json
CHANGED
@@ -50,10 +50,6 @@ function createTransactionInstruction(
|
|
50
50
|
}
|
51
51
|
|
52
52
|
export async function getJupQuote(swapDetails: JupSwapInput) {
|
53
|
-
const memecoinSwap =
|
54
|
-
tokenInfo(swapDetails.inputMint)?.isMeme ||
|
55
|
-
tokenInfo(swapDetails.outputMint)?.isMeme;
|
56
|
-
|
57
53
|
return await retryWithExponentialBackoff(
|
58
54
|
async (attemptNum: number) =>
|
59
55
|
await jupApi.quoteGet({
|
@@ -65,7 +61,7 @@ export async function getJupQuote(swapDetails: JupSwapInput) {
|
|
65
61
|
: swapDetails.exactIn
|
66
62
|
? "ExactIn"
|
67
63
|
: undefined,
|
68
|
-
slippageBps:
|
64
|
+
slippageBps: 300,
|
69
65
|
maxAccounts: !swapDetails.exactOut ? 15 + attemptNum * 5 : undefined,
|
70
66
|
}),
|
71
67
|
3,
|
@@ -377,7 +377,7 @@ export async function getFlashLoanRequirements(
|
|
377
377
|
!sufficientSignerSupplyLiquidity;
|
378
378
|
} else {
|
379
379
|
throw new Error(
|
380
|
-
`
|
380
|
+
`Insufficient liquidity to perform the transaction`
|
381
381
|
);
|
382
382
|
}
|
383
383
|
}
|
package/src/utils/stringUtils.ts
CHANGED
@@ -24,11 +24,23 @@ function adjustedTicker(mint?: PublicKey) {
|
|
24
24
|
}
|
25
25
|
}
|
26
26
|
|
27
|
+
export function ratioName(supplyMint?: PublicKey, debtMint?: PublicKey) {
|
28
|
+
if (
|
29
|
+
(tokenInfo(supplyMint).isLST && debtMint?.equals(NATIVE_MINT)) ||
|
30
|
+
(supplyMint &&
|
31
|
+
debtMint &&
|
32
|
+
MAJORS_PRIO[supplyMint!.toString()] > MAJORS_PRIO[debtMint!.toString()])
|
33
|
+
) {
|
34
|
+
return `${adjustedTicker(supplyMint)}/${adjustedTicker(debtMint)} Long`;
|
35
|
+
} else {
|
36
|
+
return `${adjustedTicker(debtMint)}/${adjustedTicker(supplyMint)} Short`;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
27
40
|
export function solautoStrategyName(
|
28
41
|
supplyMint?: PublicKey,
|
29
42
|
debtMint?: PublicKey
|
30
43
|
) {
|
31
|
-
const supplyInfo = tokenInfo(supplyMint);
|
32
44
|
const strat = strategyType(
|
33
45
|
supplyMint ?? PublicKey.default,
|
34
46
|
debtMint ?? PublicKey.default
|
@@ -37,16 +49,7 @@ export function solautoStrategyName(
|
|
37
49
|
if (strat === "Long") {
|
38
50
|
return `${adjustedTicker(supplyMint)} Long`;
|
39
51
|
} else if (strat === "Ratio") {
|
40
|
-
|
41
|
-
(supplyInfo.isLST && debtMint?.equals(NATIVE_MINT)) ||
|
42
|
-
(supplyMint &&
|
43
|
-
debtMint &&
|
44
|
-
MAJORS_PRIO[supplyMint!.toString()] > MAJORS_PRIO[debtMint!.toString()])
|
45
|
-
) {
|
46
|
-
return `${adjustedTicker(supplyMint)}/${adjustedTicker(debtMint)} Long`;
|
47
|
-
} else {
|
48
|
-
return `${adjustedTicker(debtMint)}/${adjustedTicker(supplyMint)} Short`;
|
49
|
-
}
|
52
|
+
return ratioName(supplyMint, debtMint);
|
50
53
|
} else {
|
51
54
|
return `${adjustedTicker(debtMint)} Short`;
|
52
55
|
}
|