@haven-fi/solauto-sdk 1.0.124 → 1.0.126
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/clients/solautoMarginfiClient.js +7 -7
- package/dist/utils/solauto/rebalanceUtils.d.ts.map +1 -1
- package/dist/utils/solauto/rebalanceUtils.js +9 -3
- package/package.json +1 -1
- package/src/clients/solautoMarginfiClient.ts +7 -7
- package/src/transactions/transactionUtils.ts +2 -2
- package/src/utils/solauto/rebalanceUtils.ts +9 -8
@@ -417,15 +417,15 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
417
417
|
}
|
418
418
|
const freshState = await (0, marginfiUtils_1.getMarginfiAccountPositionState)(this.umi, this.marginfiAccountPk, this.supplyMint, this.debtMint, this.livePositionUpdates);
|
419
419
|
if (freshState) {
|
420
|
+
this.log("Fresh state", freshState);
|
420
421
|
const supplyPrice = constants_1.PRICES[(freshState?.supply.mint ?? web3_js_1.PublicKey.default).toString()].price;
|
421
422
|
const debtPrice = constants_1.PRICES[(freshState?.debt.mint ?? web3_js_1.PublicKey.default).toString()].price;
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
console.log("Debt USD:", (0, numberUtils_1.fromBaseUnit)(freshState.debt.amountUsed.baseUnit, freshState.supply.decimals) * debtPrice);
|
423
|
+
this.log("Supply price: ", supplyPrice);
|
424
|
+
this.log("Debt price: ", debtPrice);
|
425
|
+
this.log("Liq threshold bps:", freshState.liqThresholdBps);
|
426
|
+
this.log("Liq utilization rate bps:", freshState.liqUtilizationRateBps);
|
427
|
+
this.log("Supply USD:", (0, numberUtils_1.fromBaseUnit)(freshState.supply.amountUsed.baseUnit, freshState.supply.decimals) * supplyPrice);
|
428
|
+
this.log("Debt USD:", (0, numberUtils_1.fromBaseUnit)(freshState.debt.amountUsed.baseUnit, freshState.debt.decimals) * debtPrice);
|
429
429
|
}
|
430
430
|
return freshState;
|
431
431
|
}
|
@@ -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,EAC1B,MAAM,iBAAiB,CAAC;AAOzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAkJjD,MAAM,WAAW,eAAe;IAC9B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,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,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,eAAe,CA0EjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,aAAa,GACtB,gBAAgB,GAAG,SAAS,
|
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,EAC1B,MAAM,iBAAiB,CAAC;AAOzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAkJjD,MAAM,WAAW,eAAe;IAC9B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,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,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,eAAe,CA0EjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,aAAa,GACtB,gBAAgB,GAAG,SAAS,CAoE9B;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,cAAc,CAkChB"}
|
@@ -131,9 +131,15 @@ function getFlashLoanDetails(client, values, jupQuote) {
|
|
131
131
|
? debtUsd + debtAdjustmentWithSlippage
|
132
132
|
: debtUsd;
|
133
133
|
const tempLiqUtilizationRateBps = (0, numberUtils_1.getLiqUtilzationRateBps)(supplyUsd, debtUsd, client.solautoPositionState.liqThresholdBps);
|
134
|
-
|
135
|
-
|
136
|
-
|
134
|
+
//TODO: revert me:
|
135
|
+
const requiresFlashLoan = true;
|
136
|
+
// supplyUsd <= 0 ||
|
137
|
+
// tempLiqUtilizationRateBps >
|
138
|
+
// getMaxLiqUtilizationRateBps(
|
139
|
+
// client.solautoPositionState!.maxLtvBps,
|
140
|
+
// client.solautoPositionState!.liqThresholdBps,
|
141
|
+
// 0.01
|
142
|
+
// );
|
137
143
|
let flashLoanToken = undefined;
|
138
144
|
let flashLoanTokenPrice = 0;
|
139
145
|
if (values.increasingLeverage) {
|
package/package.json
CHANGED
@@ -629,15 +629,15 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
629
629
|
);
|
630
630
|
|
631
631
|
if (freshState) {
|
632
|
+
this.log("Fresh state", freshState);
|
632
633
|
const supplyPrice = PRICES[(freshState?.supply.mint ?? PublicKey.default).toString()].price;
|
633
634
|
const debtPrice = PRICES[(freshState?.debt.mint ?? PublicKey.default).toString()].price;
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
console.log("Debt USD:", fromBaseUnit(freshState.debt.amountUsed.baseUnit, freshState.supply.decimals) * debtPrice);
|
635
|
+
this.log("Supply price: ", supplyPrice);
|
636
|
+
this.log("Debt price: ", debtPrice);
|
637
|
+
this.log("Liq threshold bps:", freshState.liqThresholdBps);
|
638
|
+
this.log("Liq utilization rate bps:", freshState.liqUtilizationRateBps);
|
639
|
+
this.log("Supply USD:", fromBaseUnit(freshState.supply.amountUsed.baseUnit, freshState.supply.decimals) * supplyPrice);
|
640
|
+
this.log("Debt USD:", fromBaseUnit(freshState.debt.amountUsed.baseUnit, freshState.debt.decimals) * debtPrice);
|
641
641
|
}
|
642
642
|
|
643
643
|
return freshState;
|
@@ -287,14 +287,15 @@ export function getFlashLoanDetails(
|
|
287
287
|
debtUsd,
|
288
288
|
client.solautoPositionState!.liqThresholdBps
|
289
289
|
);
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
290
|
+
//TODO: revert me:
|
291
|
+
const requiresFlashLoan = true;
|
292
|
+
// supplyUsd <= 0 ||
|
293
|
+
// tempLiqUtilizationRateBps >
|
294
|
+
// getMaxLiqUtilizationRateBps(
|
295
|
+
// client.solautoPositionState!.maxLtvBps,
|
296
|
+
// client.solautoPositionState!.liqThresholdBps,
|
297
|
+
// 0.01
|
298
|
+
// );
|
298
299
|
|
299
300
|
let flashLoanToken: PositionTokenUsage | undefined = undefined;
|
300
301
|
let flashLoanTokenPrice = 0;
|