@haven-fi/solauto-sdk 1.0.620 → 1.0.622
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/rebalanceTxBuilder.d.ts.map +1 -1
- package/dist/services/rebalance/rebalanceTxBuilder.js +1 -3
- package/dist/services/rebalance/solautoFees.d.ts.map +1 -1
- package/dist/services/rebalance/solautoFees.js +1 -2
- package/dist/services/solauto/solautoMarginfiClient.js +1 -0
- package/package.json +1 -1
- package/src/services/flashLoans/marginfiFlProvider.ts +1 -0
- package/src/services/rebalance/rebalanceTxBuilder.ts +1 -4
- package/src/services/rebalance/solautoFees.ts +1 -4
- package/src/services/solauto/solautoMarginfiClient.ts +6 -6
@@ -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;IACrD,OAAO,CAAC,yBAAyB,CAAQ;IACzC,OAAO,CAAC,uBAAuB,CAAQ;IACvC,OAAO,CAAC,iBAAiB,CAAe;IACxC,OAAO,CAAC,eAAe,CAAe;IAEhC,UAAU;YAiBF,iBAAiB;IA2C/B,OAAO,CAAC,sBAAsB;
|
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;IACrD,OAAO,CAAC,yBAAyB,CAAQ;IACzC,OAAO,CAAC,uBAAuB,CAAQ;IACvC,OAAO,CAAC,iBAAiB,CAAe;IACxC,OAAO,CAAC,eAAe,CAAe;IAEhC,UAAU;YAiBF,iBAAiB;IA2C/B,OAAO,CAAC,sBAAsB;IA2CxB,sBAAsB,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAyC3D,gBAAgB,IAAI,SAAS,EAAE;IAY/B,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,WAAW;IAMnB,kBAAkB,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM;IAI7C,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,eAAe,CAAC,EAAE,OAAO,GAAG,MAAM;IAc9D,WAAW,CACT,SAAS,EAAE,gBAAgB,EAC3B,gBAAgB,EAAE,SAAS,GAC1B,kBAAkB;IAoCrB,UAAU,CAAC,SAAS,EAAE,gBAAgB,GAAG,kBAAkB;IAyG3D,YAAY,CACV,eAAe,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());
|
@@ -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,CAAC;AA2BrB,qBAAa,kBAAkB;IAO3B,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,2BAA2B,CAAC;IAPtC,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,aAAa,CAAwB;IAC7C,OAAO,CAAC,WAAW,CAAwB;IAC3C,OAAO,CAAC,cAAc,CAAC,CAAwB;gBAGrC,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,YAAA;IAG9C,OAAO,CAAC,0BAA0B;IAQlC,OAAO,CAAC,kBAAkB;IAa1B,OAAO,CAAC,oBAAoB;YAyCd,qBAAqB;IAyCnC,OAAO,CAAC,mBAAmB;IAwB3B,OAAO,CAAC,gBAAgB;
|
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,CAAC;AA2BrB,qBAAa,kBAAkB;IAO3B,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,2BAA2B,CAAC;IAPtC,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,aAAa,CAAwB;IAC7C,OAAO,CAAC,WAAW,CAAwB;IAC3C,OAAO,CAAC,cAAc,CAAC,CAAwB;gBAGrC,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,YAAA;IAG9C,OAAO,CAAC,0BAA0B;IAQlC,OAAO,CAAC,kBAAkB;IAa1B,OAAO,CAAC,oBAAoB;YAyCd,qBAAqB;IAyCnC,OAAO,CAAC,mBAAmB;IAwB3B,OAAO,CAAC,gBAAgB;YA+BV,mBAAmB;YAmBnB,sBAAsB;YAyBtB,mBAAmB;IAiEpB,gBAAgB,CAC3B,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;CAW9C"}
|
@@ -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();
|
@@ -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
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);
|
@@ -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,
|
@@ -261,6 +261,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
261
261
|
(postSwapRebalance &&
|
262
262
|
data.rebalanceType === generated_1.SolautoRebalanceType.FLSwapThenRebalance);
|
263
263
|
const addAuthorityTas = this.selfManaged || data.values.tokenBalanceChange !== undefined;
|
264
|
+
console.log("TARGET LIQ UTILIZATION RATE:", data.targetLiqUtilizationRateBps);
|
264
265
|
return (0, generated_1.marginfiRebalance)(this.umi, {
|
265
266
|
signer: this.signer,
|
266
267
|
marginfiProgram: (0, umi_1.publicKey)(marginfi_sdk_1.MARGINFI_PROGRAM_ID),
|
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
|
@@ -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,
|
@@ -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,
|
@@ -279,8 +278,6 @@ export class RebalanceTxBuilder {
|
|
279
278
|
if (!flashLoanDetails) {
|
280
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);
|
@@ -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,
|
@@ -391,6 +391,10 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
391
391
|
const addAuthorityTas =
|
392
392
|
this.selfManaged || data.values.tokenBalanceChange !== undefined;
|
393
393
|
|
394
|
+
console.log(
|
395
|
+
"TARGET LIQ UTILIZATION RATE:",
|
396
|
+
data.targetLiqUtilizationRateBps
|
397
|
+
);
|
394
398
|
return marginfiRebalance(this.umi, {
|
395
399
|
signer: this.signer,
|
396
400
|
marginfiProgram: publicKey(MARGINFI_PROGRAM_ID),
|
@@ -425,9 +429,7 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
425
429
|
supplyPriceOracle: publicKey(this.supplyPriceOracle),
|
426
430
|
positionSupplyTa: publicKey(this.positionSupplyTa),
|
427
431
|
authoritySupplyTa: addAuthorityTas
|
428
|
-
? publicKey(
|
429
|
-
getTokenAccount(this.authority, this.pos.supplyMint())
|
430
|
-
)
|
432
|
+
? publicKey(getTokenAccount(this.authority, this.pos.supplyMint()))
|
431
433
|
: undefined,
|
432
434
|
vaultSupplyTa: needSupplyAccounts
|
433
435
|
? publicKey(this.marginfiSupplyAccounts.liquidityVault)
|
@@ -439,9 +441,7 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
439
441
|
debtPriceOracle: publicKey(this.debtPriceOracle),
|
440
442
|
positionDebtTa: publicKey(this.positionDebtTa),
|
441
443
|
authorityDebtTa: addAuthorityTas
|
442
|
-
? publicKey(
|
443
|
-
getTokenAccount(this.authority, this.pos.debtMint())
|
444
|
-
)
|
444
|
+
? publicKey(getTokenAccount(this.authority, this.pos.debtMint()))
|
445
445
|
: undefined,
|
446
446
|
vaultDebtTa: needDebtAccounts
|
447
447
|
? publicKey(this.marginfiDebtAccounts.liquidityVault)
|