@haven-fi/solauto-sdk 1.0.736 → 1.0.737
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/rebalance/rebalanceSwapManager.d.ts.map +1 -1
- package/dist/services/rebalance/rebalanceSwapManager.js +1 -1
- package/dist/services/swap/jupSwapManager.d.ts +2 -1
- package/dist/services/swap/jupSwapManager.d.ts.map +1 -1
- package/dist/services/swap/jupSwapManager.js +3 -2
- package/dist/utils/jitoUtils.d.ts.map +1 -1
- package/dist/utils/jitoUtils.js +4 -6
- package/local/txSandbox.ts +4 -4
- package/package.json +1 -1
- package/src/services/rebalance/rebalanceSwapManager.ts +1 -3
- package/src/services/swap/jupSwapManager.ts +8 -4
- package/src/utils/jitoUtils.ts +23 -24
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"rebalanceSwapManager.d.ts","sourceRoot":"","sources":["../../../src/services/rebalance/rebalanceSwapManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAkB,UAAU,EAAa,MAAM,SAAS,CAAC;AAChE,OAAO,EAA0B,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAiC,MAAM,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"rebalanceSwapManager.d.ts","sourceRoot":"","sources":["../../../src/services/rebalance/rebalanceSwapManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAkB,UAAU,EAAa,MAAM,SAAS,CAAC;AAChE,OAAO,EAA0B,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAiC,MAAM,iBAAiB,CAAC;AAY3E,qBAAa,oBAAoB;IAS7B,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,cAAc,CAAC;IACvB,OAAO,CAAC,2BAA2B,CAAC;IACpC,OAAO,CAAC,SAAS,CAAC;IAZb,UAAU,EAAG,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IAE/B,OAAO,CAAC,cAAc,CAAkB;IACxC,OAAO,CAAC,aAAa,CAAU;gBAGrB,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,cAAc,CAAC,EAAE,qBAAqB,YAAA,EACtC,2BAA2B,CAAC,EAAE,MAAM,YAAA,EACpC,SAAS,CAAC,EAAE,SAAS,YAAA;IAU/B,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,WAAW;IAsCnB,OAAO,CAAC,kCAAkC;YAwE5B,mBAAmB;IAyCjC,OAAO,CAAC,mBAAmB;IAIrB,aAAa,CAAC,UAAU,EAAE,MAAM;IAyEhC,aAAa;;;;;;CAWpB"}
|
@@ -14,7 +14,7 @@ class RebalanceSwapManager {
|
|
14
14
|
this.flRequirements = flRequirements;
|
15
15
|
this.targetLiqUtilizationRateBps = targetLiqUtilizationRateBps;
|
16
16
|
this.priceType = priceType;
|
17
|
-
this.jupSwapManager = new swap_1.JupSwapManager(client.signer);
|
17
|
+
this.jupSwapManager = new swap_1.JupSwapManager(client.signer, true);
|
18
18
|
this.solautoFeeBps = solautoFees_1.SolautoFeesBps.create(this.client.isReferred, this.targetLiqUtilizationRateBps, this.client.pos.netWorthUsd(this.priceType)).getSolautoFeesBps(values.rebalanceDirection).total;
|
19
19
|
}
|
20
20
|
isBoost() {
|
@@ -24,9 +24,10 @@ export interface JupSwapTransactionData {
|
|
24
24
|
}
|
25
25
|
export declare class JupSwapManager {
|
26
26
|
private signer;
|
27
|
+
private limitSize?;
|
27
28
|
jupApi: import("@jup-ag/api").DefaultApi;
|
28
29
|
jupQuote: QuoteResponse | undefined;
|
29
|
-
constructor(signer: Signer);
|
30
|
+
constructor(signer: Signer, limitSize?: boolean | undefined);
|
30
31
|
getQuote(data: SwapInput): Promise<QuoteResponse>;
|
31
32
|
private getJupInstructions;
|
32
33
|
priceImpactBps(): number;
|
@@ -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;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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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"}
|
@@ -6,8 +6,9 @@ const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters"
|
|
6
6
|
const api_1 = require("@jup-ag/api");
|
7
7
|
const utils_1 = require("../../utils");
|
8
8
|
class JupSwapManager {
|
9
|
-
constructor(signer) {
|
9
|
+
constructor(signer, limitSize) {
|
10
10
|
this.signer = signer;
|
11
|
+
this.limitSize = limitSize;
|
11
12
|
this.jupApi = (0, api_1.createJupiterApiClient)();
|
12
13
|
this.jupQuote = undefined;
|
13
14
|
}
|
@@ -27,7 +28,7 @@ class JupSwapManager {
|
|
27
28
|
? "ExactIn"
|
28
29
|
: undefined,
|
29
30
|
slippageBps,
|
30
|
-
maxAccounts: !data.exactOut
|
31
|
+
maxAccounts: !data.exactOut && this.limitSize
|
31
32
|
? (lowLiquidityMint ? 25 : 15) + attemptNum * 5
|
32
33
|
: undefined,
|
33
34
|
}), 6, 250);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"jitoUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jitoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EAIV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAEH,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAgBlE,wBAAgB,mBAAmB,IAAI,SAAS,CAG/C;AAiGD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,kBAAkB;;;;IAkB/D;
|
1
|
+
{"version":3,"file":"jitoUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jitoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EAIV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAEH,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAgBlE,wBAAgB,mBAAmB,IAAI,SAAS,CAG/C;AAiGD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,kBAAkB;;;;IAkB/D;AAsHD,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EAAE,EACtB,YAAY,EAAE,kBAAkB,EAAE,EAClC,MAAM,CAAC,EAAE,kBAAkB,EAC3B,kBAAkB,GAAE,kBAA2C,EAC/D,cAAc,CAAC,EAAE,MAAM,IAAI,EAC3B,eAAe,CAAC,EAAE,eAAe,GAChC,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CAyG/B"}
|
package/dist/utils/jitoUtils.js
CHANGED
@@ -103,11 +103,9 @@ function getAdditionalSigners(message) {
|
|
103
103
|
return signersInfo;
|
104
104
|
}
|
105
105
|
async function umiToVersionedTransactions(umi, blockhash, userSigner, otherSigners, txs, sign, feeEstimates, computeUnitLimits) {
|
106
|
-
let builtTxs =
|
107
|
-
|
108
|
-
|
109
|
-
.build(umi);
|
110
|
-
}));
|
106
|
+
let builtTxs = txs.map((tx, i) => (0, solanaUtils_1.assembleFinalTransaction)(umi, tx, feeEstimates ? feeEstimates[i] : undefined, computeUnitLimits ? computeUnitLimits[i] : undefined)
|
107
|
+
.setBlockhash(blockhash)
|
108
|
+
.build(umi));
|
111
109
|
if (sign) {
|
112
110
|
builtTxs = await userSigner.signAllTransactions(builtTxs);
|
113
111
|
for (const signer of otherSigners) {
|
@@ -199,7 +197,7 @@ async function sendJitoBundledTransactions(umi, connection, userSigner, otherSig
|
|
199
197
|
let builtTxs = [];
|
200
198
|
let simulationResults;
|
201
199
|
if (txType !== "skip-simulation") {
|
202
|
-
builtTxs = await umiToVersionedTransactions(umi, latestBlockhash, userSigner, otherSigners, txs, false, undefined, Array(txs.length).map(_ => 1400000));
|
200
|
+
builtTxs = await umiToVersionedTransactions(umi, latestBlockhash, userSigner, otherSigners, txs, false, undefined, Array(txs.length).map((_) => 1400000));
|
203
201
|
simulationResults = await simulateJitoBundle(umi, builtTxs);
|
204
202
|
}
|
205
203
|
const feeEstimates = (0, services_1.usePriorityFee)(priorityFeeSetting)
|
package/local/txSandbox.ts
CHANGED
@@ -23,7 +23,7 @@ import {
|
|
23
23
|
import { getSecretKey } from "./shared";
|
24
24
|
|
25
25
|
const payForTransaction = false;
|
26
|
-
const testProgram =
|
26
|
+
const testProgram = true;
|
27
27
|
const lpEnv: ProgramEnv = "Prod";
|
28
28
|
|
29
29
|
let [, umi] = getSolanaRpcConnection(
|
@@ -47,14 +47,14 @@ export async function main() {
|
|
47
47
|
});
|
48
48
|
|
49
49
|
await client.initializeExistingSolautoPosition({
|
50
|
-
positionId:
|
51
|
-
authority: new PublicKey("
|
50
|
+
positionId: 5,
|
51
|
+
authority: new PublicKey("5UqsR2PGzbP8pGPbXEeXx86Gjz2N2UFBAuFZUSVydAEe"),
|
52
52
|
// lpUserAccount: new PublicKey(
|
53
53
|
// "GEokw9jqbh6d1xUNA3qaeYFFetbSR5Y1nt7C3chwwgSz"
|
54
54
|
// ),
|
55
55
|
});
|
56
56
|
|
57
|
-
const transactionItems = [rebalance(client)];
|
57
|
+
const transactionItems = [rebalance(client, undefined, 600), rebalance(client, undefined, 600)];
|
58
58
|
|
59
59
|
const txManager = new ClientTransactionsManager({
|
60
60
|
txHandler: client,
|
package/package.json
CHANGED
@@ -6,12 +6,10 @@ import { JupSwapManager, SwapParams, SwapInput } from "../swap";
|
|
6
6
|
import { applyDebtAdjustmentUsd, RebalanceValues } from "./rebalanceValues";
|
7
7
|
import { PriceType, RebalanceDirection, TokenType } from "../../generated";
|
8
8
|
import {
|
9
|
-
bytesToI80F48,
|
10
9
|
consoleLog,
|
11
10
|
fromBaseUnit,
|
12
11
|
fromBps,
|
13
12
|
getLiqUtilzationRateBps,
|
14
|
-
isMarginfiPosition,
|
15
13
|
safeGetPrice,
|
16
14
|
toBaseUnit,
|
17
15
|
tokenInfo,
|
@@ -33,7 +31,7 @@ export class RebalanceSwapManager {
|
|
33
31
|
private targetLiqUtilizationRateBps?: number,
|
34
32
|
private priceType?: PriceType
|
35
33
|
) {
|
36
|
-
this.jupSwapManager = new JupSwapManager(client.signer);
|
34
|
+
this.jupSwapManager = new JupSwapManager(client.signer, true);
|
37
35
|
this.solautoFeeBps = SolautoFeesBps.create(
|
38
36
|
this.client.isReferred,
|
39
37
|
this.targetLiqUtilizationRateBps,
|
@@ -51,7 +51,10 @@ export class JupSwapManager {
|
|
51
51
|
|
52
52
|
public jupQuote: QuoteResponse | undefined = undefined;
|
53
53
|
|
54
|
-
constructor(
|
54
|
+
constructor(
|
55
|
+
private signer: Signer,
|
56
|
+
private limitSize?: boolean
|
57
|
+
) {}
|
55
58
|
|
56
59
|
public async getQuote(data: SwapInput): Promise<QuoteResponse> {
|
57
60
|
const inputMintInfo: TokenInfo | undefined = tokenInfo(data.inputMint);
|
@@ -73,9 +76,10 @@ export class JupSwapManager {
|
|
73
76
|
? "ExactIn"
|
74
77
|
: undefined,
|
75
78
|
slippageBps,
|
76
|
-
maxAccounts:
|
77
|
-
|
78
|
-
|
79
|
+
maxAccounts:
|
80
|
+
!data.exactOut && this.limitSize
|
81
|
+
? (lowLiquidityMint ? 25 : 15) + attemptNum * 5
|
82
|
+
: undefined,
|
79
83
|
}),
|
80
84
|
6,
|
81
85
|
250
|
package/src/utils/jitoUtils.ts
CHANGED
@@ -160,17 +160,15 @@ async function umiToVersionedTransactions(
|
|
160
160
|
feeEstimates?: number[],
|
161
161
|
computeUnitLimits?: number[]
|
162
162
|
): Promise<VersionedTransaction[]> {
|
163
|
-
let builtTxs =
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
)
|
171
|
-
|
172
|
-
.build(umi);
|
173
|
-
})
|
163
|
+
let builtTxs = txs.map((tx, i) =>
|
164
|
+
assembleFinalTransaction(
|
165
|
+
umi,
|
166
|
+
tx,
|
167
|
+
feeEstimates ? feeEstimates[i] : undefined,
|
168
|
+
computeUnitLimits ? computeUnitLimits[i] : undefined
|
169
|
+
)
|
170
|
+
.setBlockhash(blockhash)
|
171
|
+
.build(umi)
|
174
172
|
);
|
175
173
|
|
176
174
|
if (sign) {
|
@@ -280,7 +278,7 @@ export async function sendJitoBundledTransactions(
|
|
280
278
|
abortController?: AbortController
|
281
279
|
): Promise<string[] | undefined> {
|
282
280
|
const txs = [...transactions];
|
283
|
-
|
281
|
+
|
284
282
|
if (txs.length === 1) {
|
285
283
|
const resp = await sendSingleOptimizedTransaction(
|
286
284
|
umi,
|
@@ -313,6 +311,7 @@ export async function sendJitoBundledTransactions(
|
|
313
311
|
if (abortController?.signal.aborted) {
|
314
312
|
return;
|
315
313
|
}
|
314
|
+
|
316
315
|
let builtTxs: VersionedTransaction[] = [];
|
317
316
|
let simulationResults: SimulatedTransactionResponse[] | undefined;
|
318
317
|
if (txType !== "skip-simulation") {
|
@@ -324,24 +323,24 @@ export async function sendJitoBundledTransactions(
|
|
324
323
|
txs,
|
325
324
|
false,
|
326
325
|
undefined,
|
327
|
-
Array(txs.length).map(_ => 1_400_000)
|
326
|
+
Array(txs.length).map((_) => 1_400_000)
|
328
327
|
);
|
329
328
|
simulationResults = await simulateJitoBundle(umi, builtTxs);
|
330
329
|
}
|
331
330
|
|
332
331
|
const feeEstimates = usePriorityFee(priorityFeeSetting)
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
332
|
+
? await Promise.all(
|
333
|
+
txs.map(
|
334
|
+
async (x) =>
|
335
|
+
(await getComputeUnitPriceEstimate(
|
336
|
+
umi,
|
337
|
+
x,
|
338
|
+
priorityFeeSetting,
|
339
|
+
true
|
340
|
+
)) ?? 1000000
|
341
|
+
)
|
342
342
|
)
|
343
|
-
|
344
|
-
: undefined;
|
343
|
+
: undefined;
|
345
344
|
|
346
345
|
if (abortController?.signal.aborted) {
|
347
346
|
return;
|