@haven-fi/solauto-sdk 1.0.170 → 1.0.172
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/clients/solautoClient.d.ts +1 -1
- package/dist/clients/solautoClient.d.ts.map +1 -1
- package/dist/clients/solautoClient.js +1 -1
- package/dist/clients/solautoMarginfiClient.d.ts +1 -1
- package/dist/clients/solautoMarginfiClient.d.ts.map +1 -1
- package/dist/clients/solautoMarginfiClient.js +3 -3
- package/dist/utils/solauto/rebalanceUtils.d.ts.map +1 -1
- package/dist/utils/solauto/rebalanceUtils.js +13 -20
- package/package.json +1 -1
- package/src/clients/solautoClient.ts +1 -1
- package/src/clients/solautoMarginfiClient.ts +3 -3
- package/src/utils/solauto/rebalanceUtils.ts +22 -30
@@ -56,7 +56,7 @@ export declare abstract class SolautoClient extends TxHandler {
|
|
56
56
|
} | undefined>;
|
57
57
|
solautoPositionSettings(): SolautoSettingsParameters | undefined;
|
58
58
|
solautoPositionActiveDca(): DCASettings | undefined;
|
59
|
-
|
59
|
+
maxLtvAndLiqThresholdBps(): Promise<[number, number] | undefined>;
|
60
60
|
openPosition(settingParams?: SolautoSettingsParametersInpArgs, dca?: DCASettingsInpArgs): TransactionBuilder;
|
61
61
|
updatePositionIx(args: UpdatePositionDataArgs): TransactionBuilder;
|
62
62
|
closePositionIx(): TransactionBuilder;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solautoClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoClient.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAA6B,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EACL,MAAM,EACN,kBAAkB,EAOnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,aAAa,EAEd,MAAM,iDAAiD,CAAC;AACzD,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC,EAE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S,GACjC,kBAAkB;IAErB,QAAQ,CAAC,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,kBAAkB;IAE3E,QAAQ,CAAC,SAAS,CAChB,aAAa,EAAE,GAAG,GAAG,GAAG,EACxB,WAAW,EAAE,cAAc,EAC3B,aAAa,EAAE,wBAAwB,EACvC,SAAS,CAAC,EAAE,gBAAgB,EAC5B,2BAA2B,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,kBAAkB;IAEf,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAalE"}
|
@@ -189,7 +189,7 @@ class SolautoClient extends txHandler_1.TxHandler {
|
|
189
189
|
return (this.livePositionUpdates.activeDca ??
|
190
190
|
this.solautoPositionData?.position.dca);
|
191
191
|
}
|
192
|
-
async
|
192
|
+
async maxLtvAndLiqThresholdBps() {
|
193
193
|
if (this.maxLtvBps !== undefined && this.liqThresholdBps !== undefined) {
|
194
194
|
return [this.maxLtvBps, this.liqThresholdBps];
|
195
195
|
}
|
@@ -30,7 +30,7 @@ export declare class SolautoMarginfiClient extends SolautoClient {
|
|
30
30
|
protocolAccount(): PublicKey;
|
31
31
|
defaultLookupTables(): string[];
|
32
32
|
lutAccountsToAdd(): PublicKey[];
|
33
|
-
|
33
|
+
maxLtvAndLiqThresholdBps(): Promise<[number, number] | undefined>;
|
34
34
|
marginfiAccountInitialize(): TransactionBuilder;
|
35
35
|
openPosition(settingParams?: SolautoSettingsParametersInpArgs, dca?: DCASettingsInpArgs): TransactionBuilder;
|
36
36
|
private marginfiOpenPositionIx;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solautoMarginfiClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoMarginfiClient.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,MAAM,EACN,kBAAkB,EAMnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AACxE,OA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,IAAI,EAAE,yBAAyB;IA+D1C,8BAA8B;IA0CpC,eAAe,IAAI,SAAS;IAI5B,mBAAmB,IAAI,MAAM,EAAE;IAI/B,gBAAgB,IAAI,SAAS,EAAE;IAUzB,wBAAwB,IAAI,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IAyBvE,yBAAyB,IAAI,kBAAkB;IAS/C,YAAY,CACV,aAAa,CAAC,EAAE,gCAAgC,EAChD,GAAG,CAAC,EAAE,kBAAkB,GACvB,kBAAkB;IAMrB,OAAO,CAAC,sBAAsB;IA+C9B,OAAO,IAAI,kBAAkB;IAc7B,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB;IAUhE,OAAO,CAAC,6BAA6B;IAmErC,OAAO,CAAC,oCAAoC;IA0D5C,SAAS,CACP,aAAa,EAAE,GAAG,GAAG,GAAG,EACxB,WAAW,EAAE,cAAc,EAC3B,aAAa,EAAE,wBAAwB,EACvC,SAAS,CAAC,EAAE,gBAAgB,EAC5B,2BAA2B,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,kBAAkB;IAoErB,WAAW,CACT,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,SAAS,GACjC,kBAAkB;IA2BrB,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,kBAAkB;IAoFlE,iCAAiC,IAAI,kBAAkB;IASjD,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAwClE"}
|
@@ -53,7 +53,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
53
53
|
this.supplyPriceOracle = new web3_js_1.PublicKey(this.marginfiSupplyAccounts.priceOracle);
|
54
54
|
this.debtPriceOracle = new web3_js_1.PublicKey(this.marginfiDebtAccounts.priceOracle);
|
55
55
|
if (!this.solautoPositionState) {
|
56
|
-
const result = await this.
|
56
|
+
const result = await this.maxLtvAndLiqThresholdBps();
|
57
57
|
this.solautoPositionState = (0, utils_1.createFakePositionState)({ mint: this.supplyMint }, { mint: this.debtMint }, result ? result[0] : 0, result ? result[1] : 0);
|
58
58
|
}
|
59
59
|
if (!this.initialized) {
|
@@ -96,8 +96,8 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
96
96
|
: []),
|
97
97
|
];
|
98
98
|
}
|
99
|
-
async
|
100
|
-
const result = await super.
|
99
|
+
async maxLtvAndLiqThresholdBps() {
|
100
|
+
const result = await super.maxLtvAndLiqThresholdBps();
|
101
101
|
if (result) {
|
102
102
|
return result;
|
103
103
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"rebalanceUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/solauto/rebalanceUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EACL,WAAW,EACX,aAAa,EAEb,yBAAyB,EACzB,SAAS,EACV,MAAM,iBAAiB,CAAC;AAOzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AA+IjD,MAAM,WAAW,eAAe;IAC9B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,SAAS,CAAC;CAC1B;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,yBAAyB,GAAG,SAAS,EAC/C,GAAG,EAAE,WAAW,GAAG,SAAS,EAC5B,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,2BAA2B,CA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C,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,cAAc,CAyChB"}
|
@@ -120,16 +120,11 @@ function getFlashLoanDetails(client, values, jupQuote, priceImpactBps) {
|
|
120
120
|
let supplyUsd = (0, numberUtils_1.fromBaseUnit)(client.solautoPositionState.supply.amountUsed.baseAmountUsdValue, generalAccounts_1.USD_DECIMALS) +
|
121
121
|
(values.dcaTokenType === generated_1.TokenType.Supply ? values.amountUsdToDcaIn : 0);
|
122
122
|
let debtUsd = (0, numberUtils_1.fromBaseUnit)(client.solautoPositionState.debt.amountUsed.baseAmountUsdValue, generalAccounts_1.USD_DECIMALS);
|
123
|
-
const
|
124
|
-
Math.abs(values.debtAdjustmentUsd) * (0, numberUtils_1.fromBps)(priceImpactBps);
|
123
|
+
const debtAdjustmentUsd = Math.abs(values.debtAdjustmentUsd);
|
125
124
|
supplyUsd =
|
126
|
-
values.debtAdjustmentUsd < 0
|
127
|
-
? supplyUsd - debtAdjustmentWithSlippage
|
128
|
-
: supplyUsd;
|
125
|
+
values.debtAdjustmentUsd < 0 ? supplyUsd - debtAdjustmentUsd : supplyUsd;
|
129
126
|
debtUsd =
|
130
|
-
values.debtAdjustmentUsd > 0
|
131
|
-
? debtUsd + debtAdjustmentWithSlippage
|
132
|
-
: debtUsd;
|
127
|
+
values.debtAdjustmentUsd > 0 ? debtUsd + debtAdjustmentUsd : debtUsd;
|
133
128
|
const tempLiqUtilizationRateBps = (0, numberUtils_1.getLiqUtilzationRateBps)(supplyUsd, debtUsd, client.solautoPositionState.liqThresholdBps);
|
134
129
|
const requiresFlashLoan = supplyUsd <= 0 ||
|
135
130
|
tempLiqUtilizationRateBps >
|
@@ -151,7 +146,7 @@ function getFlashLoanDetails(client, values, jupQuote, priceImpactBps) {
|
|
151
146
|
? {
|
152
147
|
baseUnitAmount: exactAmountBaseUnit
|
153
148
|
? exactAmountBaseUnit
|
154
|
-
: (0, numberUtils_1.toBaseUnit)(
|
149
|
+
: (0, numberUtils_1.toBaseUnit)(debtAdjustmentUsd / flashLoanTokenPrice, flashLoanToken.decimals),
|
155
150
|
mint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(flashLoanToken.mint),
|
156
151
|
}
|
157
152
|
: undefined;
|
@@ -166,22 +161,20 @@ function getJupSwapRebalanceDetails(client, values, targetLiqUtilizationRateBps,
|
|
166
161
|
const usdToSwap = Math.abs(values.debtAdjustmentUsd) +
|
167
162
|
(values.dcaTokenType === generated_1.TokenType.Debt ? values.amountUsdToDcaIn : 0);
|
168
163
|
const inputAmount = (0, numberUtils_1.toBaseUnit)(usdToSwap / (0, generalUtils_2.safeGetPrice)(input.mint), input.decimals);
|
169
|
-
const outputAmount =
|
170
|
-
|
171
|
-
|
164
|
+
const outputAmount = targetLiqUtilizationRateBps === 0
|
165
|
+
? output.amountUsed.baseUnit +
|
166
|
+
BigInt(Math.round(Number(output.amountUsed.baseUnit) *
|
167
|
+
// Add this small percentage to account for the APR on the debt between now and the transaction
|
168
|
+
0.0001))
|
169
|
+
: (0, numberUtils_1.toBaseUnit)(usdToSwap / (0, generalUtils_2.safeGetPrice)(output.mint), output.decimals);
|
170
|
+
const exactOut = targetLiqUtilizationRateBps === 0 || values.repayingCloseToMaxLtv;
|
171
|
+
const exactIn = !exactOut;
|
172
172
|
return {
|
173
173
|
inputMint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(input.mint),
|
174
174
|
outputMint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(output.mint),
|
175
175
|
destinationWallet: client.solautoPosition,
|
176
176
|
slippageIncFactor: 0.5 + (attemptNum ?? 0) * 0.2,
|
177
|
-
amount: exactOut
|
178
|
-
? outputAmount +
|
179
|
-
(targetLiqUtilizationRateBps === 0
|
180
|
-
? BigInt(Math.round(Number(client.solautoPositionState.debt.amountUsed.baseUnit) *
|
181
|
-
// Add this small percentage to account for the APR on the debt between now and the transaction
|
182
|
-
0.0001))
|
183
|
-
: BigInt(0))
|
184
|
-
: inputAmount,
|
177
|
+
amount: exactOut ? outputAmount : inputAmount,
|
185
178
|
exactIn: exactIn,
|
186
179
|
exactOut: exactOut,
|
187
180
|
};
|
package/package.json
CHANGED
@@ -361,7 +361,7 @@ export abstract class SolautoClient extends TxHandler {
|
|
361
361
|
);
|
362
362
|
}
|
363
363
|
|
364
|
-
async
|
364
|
+
async maxLtvAndLiqThresholdBps(): Promise<[number, number] | undefined> {
|
365
365
|
if (this.maxLtvBps !== undefined && this.liqThresholdBps !== undefined) {
|
366
366
|
return [this.maxLtvBps, this.liqThresholdBps];
|
367
367
|
}
|
@@ -133,7 +133,7 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
133
133
|
this.debtPriceOracle = new PublicKey(this.marginfiDebtAccounts.priceOracle);
|
134
134
|
|
135
135
|
if (!this.solautoPositionState) {
|
136
|
-
const result = await this.
|
136
|
+
const result = await this.maxLtvAndLiqThresholdBps()!;
|
137
137
|
this.solautoPositionState = createFakePositionState(
|
138
138
|
{ mint: this.supplyMint },
|
139
139
|
{ mint: this.debtMint },
|
@@ -208,8 +208,8 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
208
208
|
];
|
209
209
|
}
|
210
210
|
|
211
|
-
async
|
212
|
-
const result = await super.
|
211
|
+
async maxLtvAndLiqThresholdBps(): Promise<[number, number] | undefined> {
|
212
|
+
const result = await super.maxLtvAndLiqThresholdBps();
|
213
213
|
if (result) {
|
214
214
|
return result;
|
215
215
|
} else if (
|
@@ -237,7 +237,8 @@ export function getRebalanceValues(
|
|
237
237
|
return {
|
238
238
|
increasingLeverage,
|
239
239
|
debtAdjustmentUsd,
|
240
|
-
repayingCloseToMaxLtv:
|
240
|
+
repayingCloseToMaxLtv:
|
241
|
+
state.liqUtilizationRateBps > maxRepayTo && targetRateBps >= maxRepayTo,
|
241
242
|
amountToDcaIn: amountToDcaIn ?? 0,
|
242
243
|
amountUsdToDcaIn,
|
243
244
|
dcaTokenType: dca?.tokenType,
|
@@ -266,17 +267,11 @@ export function getFlashLoanDetails(
|
|
266
267
|
USD_DECIMALS
|
267
268
|
);
|
268
269
|
|
269
|
-
const
|
270
|
-
Math.abs(values.debtAdjustmentUsd) +
|
271
|
-
Math.abs(values.debtAdjustmentUsd) * fromBps(priceImpactBps);
|
270
|
+
const debtAdjustmentUsd = Math.abs(values.debtAdjustmentUsd);
|
272
271
|
supplyUsd =
|
273
|
-
values.debtAdjustmentUsd < 0
|
274
|
-
? supplyUsd - debtAdjustmentWithSlippage
|
275
|
-
: supplyUsd;
|
272
|
+
values.debtAdjustmentUsd < 0 ? supplyUsd - debtAdjustmentUsd : supplyUsd;
|
276
273
|
debtUsd =
|
277
|
-
values.debtAdjustmentUsd > 0
|
278
|
-
? debtUsd + debtAdjustmentWithSlippage
|
279
|
-
: debtUsd;
|
274
|
+
values.debtAdjustmentUsd > 0 ? debtUsd + debtAdjustmentUsd : debtUsd;
|
280
275
|
|
281
276
|
const tempLiqUtilizationRateBps = getLiqUtilzationRateBps(
|
282
277
|
supplyUsd,
|
@@ -312,7 +307,7 @@ export function getFlashLoanDetails(
|
|
312
307
|
baseUnitAmount: exactAmountBaseUnit
|
313
308
|
? exactAmountBaseUnit
|
314
309
|
: toBaseUnit(
|
315
|
-
|
310
|
+
debtAdjustmentUsd / flashLoanTokenPrice,
|
316
311
|
flashLoanToken.decimals
|
317
312
|
),
|
318
313
|
mint: toWeb3JsPublicKey(flashLoanToken.mint),
|
@@ -341,31 +336,28 @@ export function getJupSwapRebalanceDetails(
|
|
341
336
|
usdToSwap / safeGetPrice(input.mint)!,
|
342
337
|
input.decimals
|
343
338
|
);
|
344
|
-
const outputAmount =
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
339
|
+
const outputAmount =
|
340
|
+
targetLiqUtilizationRateBps === 0
|
341
|
+
? output.amountUsed.baseUnit +
|
342
|
+
BigInt(
|
343
|
+
Math.round(
|
344
|
+
Number(output.amountUsed.baseUnit) *
|
345
|
+
// Add this small percentage to account for the APR on the debt between now and the transaction
|
346
|
+
0.0001
|
347
|
+
)
|
348
|
+
)
|
349
|
+
: toBaseUnit(usdToSwap / safeGetPrice(output.mint)!, output.decimals);
|
350
|
+
|
351
|
+
const exactOut =
|
352
|
+
targetLiqUtilizationRateBps === 0 || values.repayingCloseToMaxLtv;
|
353
|
+
const exactIn = !exactOut;
|
351
354
|
|
352
355
|
return {
|
353
356
|
inputMint: toWeb3JsPublicKey(input.mint),
|
354
357
|
outputMint: toWeb3JsPublicKey(output.mint),
|
355
358
|
destinationWallet: client.solautoPosition,
|
356
359
|
slippageIncFactor: 0.5 + (attemptNum ?? 0) * 0.2,
|
357
|
-
amount: exactOut
|
358
|
-
? outputAmount +
|
359
|
-
(targetLiqUtilizationRateBps === 0
|
360
|
-
? BigInt(
|
361
|
-
Math.round(
|
362
|
-
Number(client.solautoPositionState!.debt.amountUsed.baseUnit) *
|
363
|
-
// Add this small percentage to account for the APR on the debt between now and the transaction
|
364
|
-
0.0001
|
365
|
-
)
|
366
|
-
)
|
367
|
-
: BigInt(0))
|
368
|
-
: inputAmount,
|
360
|
+
amount: exactOut ? outputAmount : inputAmount,
|
369
361
|
exactIn: exactIn,
|
370
362
|
exactOut: exactOut,
|
371
363
|
};
|