@haven-fi/solauto-sdk 1.0.619 → 1.0.621
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/flashLoans/marginfiFlProvider.d.ts.map +1 -1
- package/dist/services/flashLoans/marginfiFlProvider.js +1 -0
- package/dist/services/rebalance/rebalanceSwapManager.d.ts +1 -1
- package/dist/services/rebalance/rebalanceSwapManager.js +2 -2
- package/dist/services/rebalance/rebalanceTxBuilder.d.ts.map +1 -1
- package/dist/services/rebalance/rebalanceTxBuilder.js +4 -6
- package/dist/services/rebalance/solautoFees.d.ts.map +1 -1
- package/dist/services/rebalance/solautoFees.js +1 -2
- 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/flashLoans/marginfiFlProvider.ts +1 -0
- package/src/services/rebalance/rebalanceSwapManager.ts +2 -2
- package/src/services/rebalance/rebalanceTxBuilder.ts +4 -7
- package/src/services/rebalance/solautoFees.ts +1 -4
- package/src/services/swap/jupSwapManager.ts +3 -3
- package/src/services/transactions/transactionUtils.ts +2 -2
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"marginfiFlProvider.d.ts","sourceRoot":"","sources":["../../../src/services/flashLoans/marginfiFlProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAalC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAexE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAQ/C,qBAAa,kBAAmB,SAAQ,cAAc;IACpD,OAAO,CAAC,wBAAwB,CAAqB;IAC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EAAE,SAAS,EAC1B,IAAI,EAAE,SAAS,EACf,aAAa,EAAE,SAAS;CAW3B"}
|
@@ -53,6 +53,7 @@ class MarginfiFlProvider extends flProviderBase_1.FlProviderBase {
|
|
53
53
|
}
|
54
54
|
setIntermediaryAccount(sources) {
|
55
55
|
const compatibleMarginfiAccounts = this.existingMarginfiAccounts.filter((x) => x.group.toString() == this.liquidityBank(sources[0]).group);
|
56
|
+
// TODO: instead of picking first compatibleMarginfiAccoutn, pick one where we already have it in the marginfi Lut
|
56
57
|
const signer = compatibleMarginfiAccounts.length > 0
|
57
58
|
? undefined
|
58
59
|
: (0, umi_1.createSignerFromKeypair)(this.umi, this.umi.eddsa.generateKeypair());
|
@@ -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
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"rebalanceTxBuilder.d.ts","sourceRoot":"","sources":["../../../src/services/rebalance/rebalanceTxBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAGL,qBAAqB,EACtB,MAAM,aAAa,C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@@ -112,7 +112,6 @@ class RebalanceTxBuilder {
|
|
112
112
|
else {
|
113
113
|
this.rebalanceType = generated_1.SolautoRebalanceType.Regular;
|
114
114
|
}
|
115
|
-
(0, utils_1.consoleLog)("Rebalance type:", this.rebalanceType);
|
116
115
|
}
|
117
116
|
async setRebalanceDetails(attemptNum) {
|
118
117
|
this.values = this.getRebalanceValues();
|
@@ -120,7 +119,6 @@ class RebalanceTxBuilder {
|
|
120
119
|
if (this.flRequirements?.flFeeBps) {
|
121
120
|
this.values = this.getRebalanceValues(this.flRequirements.flFeeBps);
|
122
121
|
}
|
123
|
-
(0, utils_1.consoleLog)("Rebalance values:", this.values);
|
124
122
|
this.swapManager = new rebalanceSwapManager_1.RebalanceSwapManager(this.client, this.values, this.flRequirements, this.targetLiqUtilizationRateBps);
|
125
123
|
await this.swapManager.setSwapParams(attemptNum);
|
126
124
|
this.setRebalanceType();
|
@@ -143,7 +141,7 @@ class RebalanceTxBuilder {
|
|
143
141
|
return false;
|
144
142
|
}
|
145
143
|
async assembleTransaction() {
|
146
|
-
const { swapQuote, lookupTableAddresses,
|
144
|
+
const { swapQuote, lookupTableAddresses, setupIx, swapIx } = await this.swapManager.getSwapTxData();
|
147
145
|
const flashLoanDetails = this.flRequirements
|
148
146
|
? this.getFlashLoanDetails()
|
149
147
|
: undefined;
|
@@ -158,13 +156,13 @@ class RebalanceTxBuilder {
|
|
158
156
|
swapQuote,
|
159
157
|
targetLiqUtilizationRateBps: this.targetLiqUtilizationRateBps,
|
160
158
|
};
|
159
|
+
(0, utils_1.consoleLog)("Rebalance details:", rebalanceDetails);
|
161
160
|
const firstRebalance = this.client.rebalanceIx(generated_1.RebalanceStep.PreSwap, rebalanceDetails);
|
162
161
|
const lastRebalance = this.client.rebalanceIx(generated_1.RebalanceStep.PostSwap, rebalanceDetails);
|
163
162
|
if (!flashLoanDetails) {
|
164
|
-
tx = tx.add([
|
163
|
+
tx = tx.add([setupIx, firstRebalance, swapIx, lastRebalance]);
|
165
164
|
}
|
166
165
|
else {
|
167
|
-
(0, utils_1.consoleLog)("Flash loan details:", flashLoanDetails);
|
168
166
|
const exactOut = swapQuote.swapMode === "ExactOut";
|
169
167
|
const addFirstRebalance = (0, utils_1.hasFirstRebalance)(this.rebalanceType);
|
170
168
|
const addLastRebalance = (0, utils_1.hasLastRebalance)(this.rebalanceType);
|
@@ -172,7 +170,7 @@ class RebalanceTxBuilder {
|
|
172
170
|
? (0, utils_1.getTokenAccount)(this.client.pos.publicKey, new web3_js_1.PublicKey(swapQuote.outputMint))
|
173
171
|
: (0, utils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.client.signer.publicKey), new web3_js_1.PublicKey(swapQuote.inputMint));
|
174
172
|
tx = tx.add([
|
175
|
-
|
173
|
+
setupIx,
|
176
174
|
this.client.flProvider.flashBorrow(flashLoanDetails, flashBorrowDest),
|
177
175
|
...(addFirstRebalance ? [firstRebalance] : []),
|
178
176
|
swapIx,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solautoFees.d.ts","sourceRoot":"","sources":["../../../src/services/rebalance/solautoFees.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,qBAAa,cAAc;IAEvB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,2BAA2B;IACnC,OAAO,CAAC,mBAAmB;gBAFnB,UAAU,EAAE,OAAO,EACnB,2BAA2B,EAAE,MAAM,GAAG,SAAS,EAC/C,mBAAmB,EAAE,MAAM;IAGrC,MAAM,CAAC,MAAM,CACX,UAAU,EAAE,OAAO,EACnB,2BAA2B,EAAE,MAAM,GAAG,SAAS,EAC/C,WAAW,EAAE,MAAM;IASrB,iBAAiB,CAAC,kBAAkB,EAAE,kBAAkB;;;;;
|
1
|
+
{"version":3,"file":"solautoFees.d.ts","sourceRoot":"","sources":["../../../src/services/rebalance/solautoFees.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,qBAAa,cAAc;IAEvB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,2BAA2B;IACnC,OAAO,CAAC,mBAAmB;gBAFnB,UAAU,EAAE,OAAO,EACnB,2BAA2B,EAAE,MAAM,GAAG,SAAS,EAC/C,mBAAmB,EAAE,MAAM;IAGrC,MAAM,CAAC,MAAM,CACX,UAAU,EAAE,OAAO,EACnB,2BAA2B,EAAE,MAAM,GAAG,SAAS,EAC/C,WAAW,EAAE,MAAM;IASrB,iBAAiB,CAAC,kBAAkB,EAAE,kBAAkB;;;;;CA+CzD"}
|
@@ -18,8 +18,7 @@ class SolautoFeesBps {
|
|
18
18
|
const maxFeeBps = 50; // Fee in basis points for minSize (0.5%)
|
19
19
|
const minFeeBps = 25; // Fee in basis points for maxSize (0.25%)
|
20
20
|
const k = 1.5;
|
21
|
-
if (this.targetLiqUtilizationRateBps
|
22
|
-
this.targetLiqUtilizationRateBps === 0) {
|
21
|
+
if (this.targetLiqUtilizationRateBps === 0) {
|
23
22
|
return {
|
24
23
|
solauto: 0,
|
25
24
|
referrer: 0,
|
@@ -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,EACN,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAEL,aAAa,EAEd,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAM5C,OAAO,EAAE,qBAAqB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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
@@ -116,6 +116,7 @@ export class MarginfiFlProvider extends FlProviderBase {
|
|
116
116
|
(x) => x.group.toString() == this.liquidityBank(sources[0]).group
|
117
117
|
);
|
118
118
|
|
119
|
+
// TODO: instead of picking first compatibleMarginfiAccoutn, pick one where we already have it in the marginfi Lut
|
119
120
|
const signer =
|
120
121
|
compatibleMarginfiAccounts.length > 0
|
121
122
|
? undefined
|
@@ -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
|
}
|
@@ -197,7 +197,6 @@ export class RebalanceTxBuilder {
|
|
197
197
|
} else {
|
198
198
|
this.rebalanceType = SolautoRebalanceType.Regular;
|
199
199
|
}
|
200
|
-
consoleLog("Rebalance type:", this.rebalanceType);
|
201
200
|
}
|
202
201
|
|
203
202
|
private async setRebalanceDetails(attemptNum: number) {
|
@@ -208,7 +207,6 @@ export class RebalanceTxBuilder {
|
|
208
207
|
this.values = this.getRebalanceValues(this.flRequirements.flFeeBps);
|
209
208
|
}
|
210
209
|
|
211
|
-
consoleLog("Rebalance values:", this.values);
|
212
210
|
this.swapManager = new RebalanceSwapManager(
|
213
211
|
this.client,
|
214
212
|
this.values,
|
@@ -246,7 +244,7 @@ export class RebalanceTxBuilder {
|
|
246
244
|
}
|
247
245
|
|
248
246
|
private async assembleTransaction(): Promise<TransactionItemInputs> {
|
249
|
-
const { swapQuote, lookupTableAddresses,
|
247
|
+
const { swapQuote, lookupTableAddresses, setupIx, swapIx } =
|
250
248
|
await this.swapManager.getSwapTxData();
|
251
249
|
|
252
250
|
const flashLoanDetails = this.flRequirements
|
@@ -266,6 +264,7 @@ export class RebalanceTxBuilder {
|
|
266
264
|
swapQuote,
|
267
265
|
targetLiqUtilizationRateBps: this.targetLiqUtilizationRateBps,
|
268
266
|
};
|
267
|
+
consoleLog("Rebalance details:", rebalanceDetails);
|
269
268
|
|
270
269
|
const firstRebalance = this.client.rebalanceIx(
|
271
270
|
RebalanceStep.PreSwap,
|
@@ -277,10 +276,8 @@ export class RebalanceTxBuilder {
|
|
277
276
|
);
|
278
277
|
|
279
278
|
if (!flashLoanDetails) {
|
280
|
-
tx = tx.add([
|
279
|
+
tx = tx.add([setupIx, firstRebalance, swapIx, lastRebalance]);
|
281
280
|
} else {
|
282
|
-
consoleLog("Flash loan details:", flashLoanDetails);
|
283
|
-
|
284
281
|
const exactOut = swapQuote.swapMode === "ExactOut";
|
285
282
|
const addFirstRebalance = hasFirstRebalance(this.rebalanceType);
|
286
283
|
const addLastRebalance = hasLastRebalance(this.rebalanceType);
|
@@ -296,7 +293,7 @@ export class RebalanceTxBuilder {
|
|
296
293
|
);
|
297
294
|
|
298
295
|
tx = tx.add([
|
299
|
-
|
296
|
+
setupIx,
|
300
297
|
this.client.flProvider.flashBorrow(flashLoanDetails, flashBorrowDest),
|
301
298
|
...(addFirstRebalance ? [firstRebalance] : []),
|
302
299
|
swapIx,
|
@@ -27,10 +27,7 @@ export class SolautoFeesBps {
|
|
27
27
|
const minFeeBps = 25; // Fee in basis points for maxSize (0.25%)
|
28
28
|
const k = 1.5;
|
29
29
|
|
30
|
-
if (
|
31
|
-
this.targetLiqUtilizationRateBps !== undefined &&
|
32
|
-
this.targetLiqUtilizationRateBps === 0
|
33
|
-
) {
|
30
|
+
if (this.targetLiqUtilizationRateBps === 0) {
|
34
31
|
return {
|
35
32
|
solauto: 0,
|
36
33
|
referrer: 0,
|
@@ -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,
|