@haven-fi/solauto-sdk 1.0.709 → 1.0.711
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/services/swap/jupSwapManager.d.ts.map +1 -1
- package/dist/services/swap/jupSwapManager.js +10 -3
- package/dist/utils/stringUtils.d.ts +4 -0
- package/dist/utils/stringUtils.d.ts.map +1 -1
- package/dist/utils/stringUtils.js +8 -3
- package/local/logPositions.ts +1 -3
- package/package.json +1 -1
- package/src/services/swap/jupSwapManager.ts +12 -4
- package/src/utils/stringUtils.ts +8 -3
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"jupSwapManager.d.ts","sourceRoot":"","sources":["../../../src/services/swap/jupSwapManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,MAAM,EACN,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAEL,aAAa,EAEd,MAAM,aAAa,CAAC;AAWrB,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;
|
1
|
+
{"version":3,"file":"jupSwapManager.d.ts","sourceRoot":"","sources":["../../../src/services/swap/jupSwapManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,MAAM,EACN,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAEL,aAAa,EAEd,MAAM,aAAa,CAAC;AAWrB,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGpD,MAAM,WAAW,SAAS;IACxB,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;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,UAAW,SAAQ,SAAS;IAC3C,iBAAiB,CAAC,EAAE,SAAS,CAAC;IAC9B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,aAAa,CAAC;IACxB,OAAO,EAAE,kBAAkB,CAAC;IAC5B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,SAAS,EAAE,kBAAkB,CAAC;IAC9B,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC;AAED,qBAAa,cAAc;IAKb,OAAO,CAAC,MAAM;IAJ1B,MAAM,mCAA4B;IAE3B,QAAQ,EAAE,aAAa,GAAG,SAAS,CAAa;gBAEnC,MAAM,EAAE,MAAM;IAErB,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC;YA+BhD,kBAAkB;IAsChC,cAAc;IAId,OAAO,CAAC,0BAA0B;IAQlC,OAAO,CAAC,0BAA0B;IAc5B,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,sBAAsB,CAAC;IA2CnE,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAYlE"}
|
@@ -12,8 +12,13 @@ class JupSwapManager {
|
|
12
12
|
this.jupQuote = undefined;
|
13
13
|
}
|
14
14
|
async getQuote(data) {
|
15
|
-
const
|
16
|
-
const
|
15
|
+
const inputMintInfo = (0, utils_1.tokenInfo)(data.inputMint);
|
16
|
+
const outputMintInfo = (0, utils_1.tokenInfo)(data.outputMint);
|
17
|
+
const lowLiquidityMint = !inputMintInfo ||
|
18
|
+
inputMintInfo?.isMeme ||
|
19
|
+
!outputMintInfo ||
|
20
|
+
outputMintInfo?.isMeme;
|
21
|
+
const slippageBps = data.slippageBps ?? (lowLiquidityMint ? 250 : 100);
|
17
22
|
return await (0, utils_1.retryWithExponentialBackoff)(async (attemptNum) => await this.jupApi.quoteGet({
|
18
23
|
amount: Number(data.amount),
|
19
24
|
inputMint: data.inputMint.toString(),
|
@@ -24,7 +29,9 @@ class JupSwapManager {
|
|
24
29
|
? "ExactIn"
|
25
30
|
: undefined,
|
26
31
|
slippageBps,
|
27
|
-
maxAccounts: !data.exactOut
|
32
|
+
maxAccounts: !data.exactOut
|
33
|
+
? (lowLiquidityMint ? 25 : 15) + attemptNum * 5
|
34
|
+
: undefined,
|
28
35
|
}), 6, 250);
|
29
36
|
}
|
30
37
|
async getJupInstructions(data) {
|
@@ -1,6 +1,10 @@
|
|
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 ratioMintDetails(supplyMint?: PublicKey, debtMint?: PublicKey): {
|
5
|
+
order: (PublicKey | undefined)[];
|
6
|
+
strategyName: string;
|
7
|
+
};
|
4
8
|
export declare function ratioName(supplyMint?: PublicKey, debtMint?: PublicKey): string;
|
5
9
|
export declare function solautoStrategyName(supplyMint?: PublicKey, debtMint?: PublicKey): string;
|
6
10
|
export declare function strategyType(supplyMint: PublicKey, debtMint: PublicKey): StrategyType;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"stringUtils.d.ts","sourceRoot":"","sources":["../../src/utils/stringUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAK5C,eAAO,MAAM,aAAa,qCAAsC,CAAC;AACjE,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAc1D,wBAAgB,SAAS,CAAC,UAAU,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,SAAS,
|
1
|
+
{"version":3,"file":"stringUtils.d.ts","sourceRoot":"","sources":["../../src/utils/stringUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAK5C,eAAO,MAAM,aAAa,qCAAsC,CAAC;AACjE,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAc1D,wBAAgB,gBAAgB,CAAC,UAAU,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,SAAS;;;EAY5E;AAED,wBAAgB,SAAS,CAAC,UAAU,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,SAAS,UAGrE;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.ratioMintDetails = ratioMintDetails;
|
4
5
|
exports.ratioName = ratioName;
|
5
6
|
exports.solautoStrategyName = solautoStrategyName;
|
6
7
|
exports.strategyType = strategyType;
|
@@ -21,18 +22,22 @@ function adjustedTicker(mint) {
|
|
21
22
|
return info.ticker;
|
22
23
|
}
|
23
24
|
}
|
24
|
-
function
|
25
|
+
function ratioMintDetails(supplyMint, debtMint) {
|
25
26
|
if (((0, generalUtils_1.tokenInfo)(supplyMint).isLST && debtMint?.equals(spl_token_1.NATIVE_MINT)) ||
|
26
27
|
(supplyMint &&
|
27
28
|
debtMint &&
|
28
29
|
constants_1.MAJORS_PRIO[supplyMint?.toString() ?? ""] >
|
29
30
|
constants_1.MAJORS_PRIO[debtMint?.toString() ?? ""])) {
|
30
|
-
return
|
31
|
+
return { order: [supplyMint, debtMint], strategyName: "Long" };
|
31
32
|
}
|
32
33
|
else {
|
33
|
-
return
|
34
|
+
return { order: [debtMint, supplyMint], strategyName: "Short" };
|
34
35
|
}
|
35
36
|
}
|
37
|
+
function ratioName(supplyMint, debtMint) {
|
38
|
+
const { order, strategyName } = ratioMintDetails(supplyMint, debtMint);
|
39
|
+
return `${adjustedTicker(order[0])}/${adjustedTicker(order[1])} ${strategyName}`;
|
40
|
+
}
|
36
41
|
function solautoStrategyName(supplyMint, debtMint) {
|
37
42
|
const strat = strategyType(supplyMint ?? web3_js_1.PublicKey.default, debtMint ?? web3_js_1.PublicKey.default);
|
38
43
|
if (strat === "Long") {
|
package/local/logPositions.ts
CHANGED
@@ -7,7 +7,6 @@ import {
|
|
7
7
|
getSolanaRpcConnection,
|
8
8
|
getSolautoManagedPositions,
|
9
9
|
LOCAL_IRONFORGE_API_URL,
|
10
|
-
PRICES,
|
11
10
|
ProgramEnv,
|
12
11
|
SOLAUTO_PROD_PROGRAM,
|
13
12
|
SOLAUTO_TEST_PROGRAM,
|
@@ -109,7 +108,6 @@ async function main(filterWhitelist: boolean, programEnv: ProgramEnv = "Prod") {
|
|
109
108
|
)
|
110
109
|
);
|
111
110
|
await fetchTokenPrices(tokensUsed.map((x) => new PublicKey(x)));
|
112
|
-
console.log(PRICES);
|
113
111
|
|
114
112
|
console.log("\n\n");
|
115
113
|
|
@@ -122,7 +120,7 @@ async function main(filterWhitelist: boolean, programEnv: ProgramEnv = "Prod") {
|
|
122
120
|
const repayFrom = pos.settings!.repayToBps + pos.settings!.repayGap;
|
123
121
|
const unhealthy = actionToTake === "repay";
|
124
122
|
const healthText = unhealthy
|
125
|
-
? `(Unhealthy: ${pos.
|
123
|
+
? `(Unhealthy: ${pos.liqUtilizationRateBps() - repayFrom}bps)`
|
126
124
|
: "";
|
127
125
|
if (unhealthy) {
|
128
126
|
unhealthyPositions += 1;
|
package/package.json
CHANGED
@@ -21,6 +21,7 @@ import {
|
|
21
21
|
tokenInfo,
|
22
22
|
} from "../../utils";
|
23
23
|
import { TransactionItemInputs } from "../../types";
|
24
|
+
import { TokenInfo } from "../../constants";
|
24
25
|
|
25
26
|
export interface SwapInput {
|
26
27
|
inputMint: PublicKey;
|
@@ -53,9 +54,14 @@ export class JupSwapManager {
|
|
53
54
|
constructor(private signer: Signer) {}
|
54
55
|
|
55
56
|
public async getQuote(data: SwapInput): Promise<QuoteResponse> {
|
56
|
-
const
|
57
|
-
|
58
|
-
const
|
57
|
+
const inputMintInfo: TokenInfo | undefined = tokenInfo(data.inputMint);
|
58
|
+
const outputMintInfo: TokenInfo | undefined = tokenInfo(data.outputMint);
|
59
|
+
const lowLiquidityMint =
|
60
|
+
!inputMintInfo ||
|
61
|
+
inputMintInfo?.isMeme ||
|
62
|
+
!outputMintInfo ||
|
63
|
+
outputMintInfo?.isMeme;
|
64
|
+
const slippageBps = data.slippageBps ?? (lowLiquidityMint ? 250 : 100);
|
59
65
|
|
60
66
|
return await retryWithExponentialBackoff(
|
61
67
|
async (attemptNum: number) =>
|
@@ -69,7 +75,9 @@ export class JupSwapManager {
|
|
69
75
|
? "ExactIn"
|
70
76
|
: undefined,
|
71
77
|
slippageBps,
|
72
|
-
maxAccounts: !data.exactOut
|
78
|
+
maxAccounts: !data.exactOut
|
79
|
+
? (lowLiquidityMint ? 25 : 15) + attemptNum * 5
|
80
|
+
: undefined,
|
73
81
|
}),
|
74
82
|
6,
|
75
83
|
250
|
package/src/utils/stringUtils.ts
CHANGED
@@ -18,7 +18,7 @@ function adjustedTicker(mint?: PublicKey) {
|
|
18
18
|
}
|
19
19
|
}
|
20
20
|
|
21
|
-
export function
|
21
|
+
export function ratioMintDetails(supplyMint?: PublicKey, debtMint?: PublicKey) {
|
22
22
|
if (
|
23
23
|
(tokenInfo(supplyMint).isLST && debtMint?.equals(NATIVE_MINT)) ||
|
24
24
|
(supplyMint &&
|
@@ -26,12 +26,17 @@ export function ratioName(supplyMint?: PublicKey, debtMint?: PublicKey) {
|
|
26
26
|
MAJORS_PRIO[supplyMint?.toString() ?? ""] >
|
27
27
|
MAJORS_PRIO[debtMint?.toString() ?? ""])
|
28
28
|
) {
|
29
|
-
return
|
29
|
+
return { order: [supplyMint, debtMint], strategyName: "Long" };
|
30
30
|
} else {
|
31
|
-
return
|
31
|
+
return { order: [debtMint, supplyMint], strategyName: "Short" };
|
32
32
|
}
|
33
33
|
}
|
34
34
|
|
35
|
+
export function ratioName(supplyMint?: PublicKey, debtMint?: PublicKey) {
|
36
|
+
const { order, strategyName } = ratioMintDetails(supplyMint, debtMint);
|
37
|
+
return `${adjustedTicker(order[0])}/${adjustedTicker(order[1])} ${strategyName}`;
|
38
|
+
}
|
39
|
+
|
35
40
|
export function solautoStrategyName(
|
36
41
|
supplyMint?: PublicKey,
|
37
42
|
debtMint?: PublicKey
|