impermax-sdk 1.1.73 → 1.1.74
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.
|
@@ -94,7 +94,7 @@ class OnchainAccountBorrowable extends onchainAccountPoolToken_1.default {
|
|
|
94
94
|
let bestAmount = 0;
|
|
95
95
|
for (let i = 0; i < 1000; i++) {
|
|
96
96
|
const jump = Math.abs(borrowAmount - borrowAmountPrev) / 2;
|
|
97
|
-
if (jump / availableCash <
|
|
97
|
+
if (jump / availableCash < 1e-9)
|
|
98
98
|
break;
|
|
99
99
|
borrowAmountPrev = borrowAmount;
|
|
100
100
|
const changeCollateral = 0;
|
|
@@ -191,9 +191,9 @@ class OnchainAccountLendingPool {
|
|
|
191
191
|
return __awaiter(this, void 0, void 0, function* () {
|
|
192
192
|
if (!changes)
|
|
193
193
|
changes = onchainTypes_1.NO_CHANGES;
|
|
194
|
-
const collateralAmount = (yield this.getCollateral().getDeposited()) + changes.changeCollateral;
|
|
195
|
-
const debtA = (yield this.getBorrowableA().getBorrowed()) + changes.changeBorrowedA;
|
|
196
|
-
const debtB = (yield this.getBorrowableB().getBorrowed()) + changes.changeBorrowedB;
|
|
194
|
+
const collateralAmount = Math.max((yield this.getCollateral().getDeposited()) + changes.changeCollateral, 0);
|
|
195
|
+
const debtA = Math.max((yield this.getBorrowableA().getBorrowed()) + changes.changeBorrowedA, 0);
|
|
196
|
+
const debtB = Math.max((yield this.getBorrowableB().getBorrowed()) + changes.changeBorrowedB, 0);
|
|
197
197
|
const safetyMargin = yield this.getSafetyMargin();
|
|
198
198
|
const liquidationPenalty = yield this.getLiquidationPenalty();
|
|
199
199
|
const actualCollateral = collateralAmount / liquidationPenalty;
|
|
@@ -201,7 +201,6 @@ class OnchainAccountLendingPool {
|
|
|
201
201
|
const [priceA, priceB] = yield this.lendingPool.getPriceDenomLP();
|
|
202
202
|
const collateralA = actualCollateral * reservesWeight0 / priceA;
|
|
203
203
|
const collateralB = actualCollateral * reservesWeight1 / priceB;
|
|
204
|
-
console.log("getLiquidationPrices", collateralA, collateralB, debtA, debtB);
|
|
205
204
|
let priceSwingA, priceSwingB;
|
|
206
205
|
if (factories_1.STABLE_FACTORIES.includes(this.lendingPool.getImpermaxFactory().getFactory())) {
|
|
207
206
|
priceSwingA = (0, lliquidity_math_1.solidlyStable_getLiquidatableXPriceDecrease)(collateralA, collateralB, debtA, debtB) * safetyMargin;
|