@haven-fi/solauto-sdk 1.0.530 → 1.0.531
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.
@@ -138,9 +138,9 @@ function postRebalanceLiqUtilizationRateBps(client, values, swapOutputAmount) {
|
|
138
138
|
? (0, numberUtils_1.fromBaseUnit)(swapOutputAmount, (0, generalUtils_2.tokenInfo)(outputToken).decimals) *
|
139
139
|
((0, priceUtils_1.safeGetPrice)(outputToken) ?? 0)
|
140
140
|
: debtAdjustmentUsdAbs;
|
141
|
-
supplyUsd =
|
142
|
-
? supplyUsd
|
143
|
-
: supplyUsd
|
141
|
+
supplyUsd = boost
|
142
|
+
? supplyUsd + swapOutputUsd
|
143
|
+
: supplyUsd - debtAdjustmentUsdAbs;
|
144
144
|
debtUsd = boost ? debtUsd + debtAdjustmentUsdAbs : debtUsd - swapOutputUsd;
|
145
145
|
return (0, numberUtils_1.getLiqUtilzationRateBps)(supplyUsd, debtUsd, client.solautoPositionState?.liqThresholdBps ?? 0);
|
146
146
|
}
|
@@ -171,7 +171,7 @@ async function getFlashLoanRequirements(client, values, attemptNum) {
|
|
171
171
|
let useDebtLiquidity = values.rebalanceDirection === generated_1.RebalanceDirection.Boost ||
|
172
172
|
insufficientSupplyLiquidity;
|
173
173
|
let signerFlashLoan = false;
|
174
|
-
if ((attemptNum ?? 0)
|
174
|
+
if ((attemptNum ?? 0) >= 3 ||
|
175
175
|
(insufficientSupplyLiquidity && insufficientDebtLiquidity)) {
|
176
176
|
const { supplyBalance, debtBalance } = await client.signerBalances();
|
177
177
|
const sufficientSignerSupplyLiquidity = !insufficientLiquidity(debtAdjustmentUsd, supplyBalance, (0, generalUtils_2.tokenInfo)(client.supplyMint).decimals, supplyPrice);
|
@@ -216,21 +216,21 @@ function getFlashLoanDetails(client, flRequirements, values, jupQuote) {
|
|
216
216
|
async function findSufficientQuote(client, values, jupSwapInput, criteria) {
|
217
217
|
let jupQuote;
|
218
218
|
let insufficient = false;
|
219
|
-
for (let i = 0; i <
|
219
|
+
for (let i = 0; i < 10; i++) {
|
220
220
|
(0, generalUtils_2.consoleLog)("Finding sufficient quote...");
|
221
221
|
jupQuote = await (0, jupiterUtils_1.getJupQuote)(jupSwapInput);
|
222
222
|
const outputAmount = parseInt(jupQuote.outAmount);
|
223
|
-
const postRebalanceRate = postRebalanceLiqUtilizationRateBps(client, values);
|
223
|
+
const postRebalanceRate = postRebalanceLiqUtilizationRateBps(client, values, BigInt(outputAmount));
|
224
224
|
insufficient = criteria.minOutputAmount
|
225
225
|
? outputAmount < Number(criteria.minOutputAmount)
|
226
226
|
: criteria.minLiqUtilizationRateBps
|
227
227
|
? postRebalanceRate < criteria.minLiqUtilizationRateBps
|
228
228
|
: postRebalanceRate > criteria.maxLiqUtilizationRateBps;
|
229
229
|
if (insufficient) {
|
230
|
+
(0, generalUtils_2.consoleLog)(jupQuote);
|
230
231
|
jupSwapInput.amount =
|
231
232
|
jupSwapInput.amount +
|
232
|
-
BigInt(Math.round(Number(jupSwapInput.amount) * 0.
|
233
|
-
(0, generalUtils_2.consoleLog)(jupQuote);
|
233
|
+
BigInt(Math.round(Number(jupSwapInput.amount) * 0.01));
|
234
234
|
}
|
235
235
|
else {
|
236
236
|
break;
|
@@ -276,7 +276,7 @@ async function getJupSwapRebalanceDetails(client, values, flRequirements, target
|
|
276
276
|
jupQuote = await findSufficientQuote(client, values, jupSwapInput, {
|
277
277
|
minOutputAmount: rebalanceToZero ? outputAmount : undefined,
|
278
278
|
maxLiqUtilizationRateBps: values.repayingCloseToMaxLtv
|
279
|
-
? (0, numberUtils_1.maxRepayToBps)(client.solautoPositionState?.maxLtvBps ?? 0, client.solautoPositionState?.liqThresholdBps ?? 0)
|
279
|
+
? (0, numberUtils_1.maxRepayToBps)(client.solautoPositionState?.maxLtvBps ?? 0, client.solautoPositionState?.liqThresholdBps ?? 0) - 15
|
280
280
|
: undefined,
|
281
281
|
});
|
282
282
|
}
|
package/package.json
CHANGED
@@ -289,9 +289,9 @@ function postRebalanceLiqUtilizationRateBps(
|
|
289
289
|
(safeGetPrice(outputToken) ?? 0)
|
290
290
|
: debtAdjustmentUsdAbs;
|
291
291
|
|
292
|
-
supplyUsd =
|
293
|
-
? supplyUsd
|
294
|
-
: supplyUsd
|
292
|
+
supplyUsd = boost
|
293
|
+
? supplyUsd + swapOutputUsd
|
294
|
+
: supplyUsd - debtAdjustmentUsdAbs;
|
295
295
|
debtUsd = boost ? debtUsd + debtAdjustmentUsdAbs : debtUsd - swapOutputUsd;
|
296
296
|
|
297
297
|
return getLiqUtilzationRateBps(
|
@@ -377,7 +377,7 @@ export async function getFlashLoanRequirements(
|
|
377
377
|
|
378
378
|
let signerFlashLoan = false;
|
379
379
|
if (
|
380
|
-
(attemptNum ?? 0)
|
380
|
+
(attemptNum ?? 0) >= 3 ||
|
381
381
|
(insufficientSupplyLiquidity && insufficientDebtLiquidity)
|
382
382
|
) {
|
383
383
|
const { supplyBalance, debtBalance } = await client.signerBalances();
|
@@ -471,14 +471,15 @@ async function findSufficientQuote(
|
|
471
471
|
let jupQuote: QuoteResponse;
|
472
472
|
let insufficient: boolean = false;
|
473
473
|
|
474
|
-
for (let i = 0; i <
|
474
|
+
for (let i = 0; i < 10; i++) {
|
475
475
|
consoleLog("Finding sufficient quote...");
|
476
476
|
jupQuote = await getJupQuote(jupSwapInput);
|
477
477
|
|
478
478
|
const outputAmount = parseInt(jupQuote.outAmount);
|
479
479
|
const postRebalanceRate = postRebalanceLiqUtilizationRateBps(
|
480
480
|
client,
|
481
|
-
values
|
481
|
+
values,
|
482
|
+
BigInt(outputAmount)
|
482
483
|
);
|
483
484
|
insufficient = criteria.minOutputAmount
|
484
485
|
? outputAmount < Number(criteria.minOutputAmount)
|
@@ -487,11 +488,10 @@ async function findSufficientQuote(
|
|
487
488
|
: postRebalanceRate > criteria.maxLiqUtilizationRateBps!;
|
488
489
|
|
489
490
|
if (insufficient) {
|
491
|
+
consoleLog(jupQuote);
|
490
492
|
jupSwapInput.amount =
|
491
493
|
jupSwapInput.amount +
|
492
|
-
BigInt(Math.round(Number(jupSwapInput.amount) * 0.
|
493
|
-
|
494
|
-
consoleLog(jupQuote);
|
494
|
+
BigInt(Math.round(Number(jupSwapInput.amount) * 0.01));
|
495
495
|
} else {
|
496
496
|
break;
|
497
497
|
}
|
@@ -565,7 +565,7 @@ export async function getJupSwapRebalanceDetails(
|
|
565
565
|
? maxRepayToBps(
|
566
566
|
client.solautoPositionState?.maxLtvBps ?? 0,
|
567
567
|
client.solautoPositionState?.liqThresholdBps ?? 0
|
568
|
-
)
|
568
|
+
) - 15
|
569
569
|
: undefined,
|
570
570
|
});
|
571
571
|
}
|