@haven-fi/solauto-sdk 1.0.619 → 1.0.620
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 +1 -1
- package/dist/services/rebalance/rebalanceSwapManager.js +2 -2
- package/dist/services/rebalance/rebalanceTxBuilder.js +3 -3
- package/dist/services/swap/jupSwapManager.d.ts +1 -1
- package/dist/services/swap/jupSwapManager.d.ts.map +1 -1
- package/dist/services/swap/jupSwapManager.js +2 -2
- package/dist/services/transactions/transactionUtils.js +2 -2
- package/package.json +1 -1
- package/src/services/rebalance/rebalanceSwapManager.ts +2 -2
- package/src/services/rebalance/rebalanceTxBuilder.ts +3 -3
- package/src/services/swap/jupSwapManager.ts +3 -3
- package/src/services/transactions/transactionUtils.ts +2 -2
@@ -23,7 +23,7 @@ export declare class RebalanceSwapManager {
|
|
23
23
|
getSwapTxData(): Promise<{
|
24
24
|
swapQuote: QuoteResponse;
|
25
25
|
lookupTableAddresses: string[];
|
26
|
-
|
26
|
+
setupIx: import("@metaplex-foundation/umi").TransactionBuilder;
|
27
27
|
swapIx: import("@metaplex-foundation/umi").TransactionBuilder;
|
28
28
|
}>;
|
29
29
|
}
|
@@ -136,11 +136,11 @@ class RebalanceSwapManager {
|
|
136
136
|
};
|
137
137
|
}
|
138
138
|
async getSwapTxData() {
|
139
|
-
const { jupQuote, lookupTableAddresses,
|
139
|
+
const { jupQuote, lookupTableAddresses, setupIx, swapIx } = await this.jupSwapManager.getJupSwapTxData(this.swapParams);
|
140
140
|
return {
|
141
141
|
swapQuote: jupQuote,
|
142
142
|
lookupTableAddresses,
|
143
|
-
|
143
|
+
setupIx,
|
144
144
|
swapIx,
|
145
145
|
};
|
146
146
|
}
|
@@ -143,7 +143,7 @@ class RebalanceTxBuilder {
|
|
143
143
|
return false;
|
144
144
|
}
|
145
145
|
async assembleTransaction() {
|
146
|
-
const { swapQuote, lookupTableAddresses,
|
146
|
+
const { swapQuote, lookupTableAddresses, setupIx, swapIx } = await this.swapManager.getSwapTxData();
|
147
147
|
const flashLoanDetails = this.flRequirements
|
148
148
|
? this.getFlashLoanDetails()
|
149
149
|
: undefined;
|
@@ -161,7 +161,7 @@ class RebalanceTxBuilder {
|
|
161
161
|
const firstRebalance = this.client.rebalanceIx(generated_1.RebalanceStep.PreSwap, rebalanceDetails);
|
162
162
|
const lastRebalance = this.client.rebalanceIx(generated_1.RebalanceStep.PostSwap, rebalanceDetails);
|
163
163
|
if (!flashLoanDetails) {
|
164
|
-
tx = tx.add([
|
164
|
+
tx = tx.add([setupIx, firstRebalance, swapIx, lastRebalance]);
|
165
165
|
}
|
166
166
|
else {
|
167
167
|
(0, utils_1.consoleLog)("Flash loan details:", flashLoanDetails);
|
@@ -172,7 +172,7 @@ class RebalanceTxBuilder {
|
|
172
172
|
? (0, utils_1.getTokenAccount)(this.client.pos.publicKey, new web3_js_1.PublicKey(swapQuote.outputMint))
|
173
173
|
: (0, utils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.client.signer.publicKey), new web3_js_1.PublicKey(swapQuote.inputMint));
|
174
174
|
tx = tx.add([
|
175
|
-
|
175
|
+
setupIx,
|
176
176
|
this.client.flProvider.flashBorrow(flashLoanDetails, flashBorrowDest),
|
177
177
|
...(addFirstRebalance ? [firstRebalance] : []),
|
178
178
|
swapIx,
|
@@ -17,7 +17,7 @@ export interface SwapParams extends SwapInput {
|
|
17
17
|
}
|
18
18
|
export interface JupSwapTransactionData {
|
19
19
|
jupQuote: QuoteResponse;
|
20
|
-
|
20
|
+
setupIx: TransactionBuilder;
|
21
21
|
swapIx: TransactionBuilder;
|
22
22
|
cleanupIx: TransactionBuilder;
|
23
23
|
lookupTableAddresses: string[];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"jupSwapManager.d.ts","sourceRoot":"","sources":["../../../src/services/swap/jupSwapManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM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BAAiB,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;YAoBhD,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"}
|
@@ -84,7 +84,7 @@ class JupSwapManager {
|
|
84
84
|
return {
|
85
85
|
jupQuote: this.jupQuote,
|
86
86
|
lookupTableAddresses: instructions.addressLookupTableAddresses,
|
87
|
-
|
87
|
+
setupIx: (0, umi_1.transactionBuilder)((instructions.setupInstructions ?? []).map((ix) => (0, solanaUtils_1.getWrappedInstruction)(this.signer, (0, utils_1.jupIxToSolanaIx)(ix)))),
|
88
88
|
swapIx: (0, umi_1.transactionBuilder)([
|
89
89
|
(0, solanaUtils_1.getWrappedInstruction)(this.signer, (0, utils_1.jupIxToSolanaIx)(instructions.swapInstruction)),
|
90
90
|
]),
|
@@ -99,7 +99,7 @@ class JupSwapManager {
|
|
99
99
|
const swapData = await this.getJupSwapTxData(data);
|
100
100
|
return {
|
101
101
|
tx: (0, umi_1.transactionBuilder)().add([
|
102
|
-
swapData.
|
102
|
+
swapData.setupIx,
|
103
103
|
swapData.swapIx,
|
104
104
|
swapData.cleanupIx,
|
105
105
|
]),
|
@@ -320,7 +320,7 @@ async function convertReferralFeesToDestination(referralManager, tokenAccount, d
|
|
320
320
|
return undefined;
|
321
321
|
}
|
322
322
|
const jupSwapManager = new __1.JupSwapManager(referralManager.umi.identity);
|
323
|
-
const { lookupTableAddresses,
|
323
|
+
const { lookupTableAddresses, setupIx, swapIx, cleanupIx } = await jupSwapManager.getJupSwapTxData({
|
324
324
|
amount: tokenAccountData.amount,
|
325
325
|
destinationWallet: referralManager.referralState,
|
326
326
|
inputMint: tokenAccountData.mint,
|
@@ -329,7 +329,7 @@ async function convertReferralFeesToDestination(referralManager, tokenAccount, d
|
|
329
329
|
slippageIncFactor: 0.25,
|
330
330
|
});
|
331
331
|
let tx = (0, umi_1.transactionBuilder)()
|
332
|
-
.add(
|
332
|
+
.add(setupIx)
|
333
333
|
.add((0, generated_1.convertReferralFees)(referralManager.umi, {
|
334
334
|
signer: referralManager.signer,
|
335
335
|
intermediaryTa: (0, umi_1.publicKey)((0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(referralManager.umi.identity.publicKey), tokenAccountData.mint)),
|
package/package.json
CHANGED
@@ -211,13 +211,13 @@ export class RebalanceSwapManager {
|
|
211
211
|
}
|
212
212
|
|
213
213
|
async getSwapTxData() {
|
214
|
-
const { jupQuote, lookupTableAddresses,
|
214
|
+
const { jupQuote, lookupTableAddresses, setupIx, swapIx } =
|
215
215
|
await this.jupSwapManager.getJupSwapTxData(this.swapParams);
|
216
216
|
|
217
217
|
return {
|
218
218
|
swapQuote: jupQuote,
|
219
219
|
lookupTableAddresses,
|
220
|
-
|
220
|
+
setupIx,
|
221
221
|
swapIx,
|
222
222
|
};
|
223
223
|
}
|
@@ -246,7 +246,7 @@ export class RebalanceTxBuilder {
|
|
246
246
|
}
|
247
247
|
|
248
248
|
private async assembleTransaction(): Promise<TransactionItemInputs> {
|
249
|
-
const { swapQuote, lookupTableAddresses,
|
249
|
+
const { swapQuote, lookupTableAddresses, setupIx, swapIx } =
|
250
250
|
await this.swapManager.getSwapTxData();
|
251
251
|
|
252
252
|
const flashLoanDetails = this.flRequirements
|
@@ -277,7 +277,7 @@ export class RebalanceTxBuilder {
|
|
277
277
|
);
|
278
278
|
|
279
279
|
if (!flashLoanDetails) {
|
280
|
-
tx = tx.add([
|
280
|
+
tx = tx.add([setupIx, firstRebalance, swapIx, lastRebalance]);
|
281
281
|
} else {
|
282
282
|
consoleLog("Flash loan details:", flashLoanDetails);
|
283
283
|
|
@@ -296,7 +296,7 @@ export class RebalanceTxBuilder {
|
|
296
296
|
);
|
297
297
|
|
298
298
|
tx = tx.add([
|
299
|
-
|
299
|
+
setupIx,
|
300
300
|
this.client.flProvider.flashBorrow(flashLoanDetails, flashBorrowDest),
|
301
301
|
...(addFirstRebalance ? [firstRebalance] : []),
|
302
302
|
swapIx,
|
@@ -37,7 +37,7 @@ export interface SwapParams extends SwapInput {
|
|
37
37
|
|
38
38
|
export interface JupSwapTransactionData {
|
39
39
|
jupQuote: QuoteResponse;
|
40
|
-
|
40
|
+
setupIx: TransactionBuilder;
|
41
41
|
swapIx: TransactionBuilder;
|
42
42
|
cleanupIx: TransactionBuilder;
|
43
43
|
lookupTableAddresses: string[];
|
@@ -153,7 +153,7 @@ export class JupSwapManager {
|
|
153
153
|
return {
|
154
154
|
jupQuote: this.jupQuote,
|
155
155
|
lookupTableAddresses: instructions.addressLookupTableAddresses,
|
156
|
-
|
156
|
+
setupIx: transactionBuilder(
|
157
157
|
(instructions.setupInstructions ?? []).map((ix) =>
|
158
158
|
getWrappedInstruction(this.signer, jupIxToSolanaIx(ix))
|
159
159
|
)
|
@@ -182,7 +182,7 @@ export class JupSwapManager {
|
|
182
182
|
|
183
183
|
return {
|
184
184
|
tx: transactionBuilder().add([
|
185
|
-
swapData.
|
185
|
+
swapData.setupIx,
|
186
186
|
swapData.swapIx,
|
187
187
|
swapData.cleanupIx,
|
188
188
|
]),
|
@@ -567,7 +567,7 @@ export async function convertReferralFeesToDestination(
|
|
567
567
|
}
|
568
568
|
|
569
569
|
const jupSwapManager = new JupSwapManager(referralManager.umi.identity);
|
570
|
-
const { lookupTableAddresses,
|
570
|
+
const { lookupTableAddresses, setupIx, swapIx, cleanupIx } =
|
571
571
|
await jupSwapManager.getJupSwapTxData({
|
572
572
|
amount: tokenAccountData.amount,
|
573
573
|
destinationWallet: referralManager.referralState,
|
@@ -578,7 +578,7 @@ export async function convertReferralFeesToDestination(
|
|
578
578
|
});
|
579
579
|
|
580
580
|
let tx = transactionBuilder()
|
581
|
-
.add(
|
581
|
+
.add(setupIx)
|
582
582
|
.add(
|
583
583
|
convertReferralFees(referralManager.umi, {
|
584
584
|
signer: referralManager.signer,
|