impermax-sdk 1.1.78 → 1.1.80

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.
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ const onchainTypes_1 = require("../../onchainTypes");
15
16
  const onchainAccountPoolToken_1 = __importDefault(require("../onchainAccountPoolToken"));
16
17
  class OnchainAccountCollateral extends onchainAccountPoolToken_1.default {
17
18
  constructor(lendingPool) {
@@ -77,6 +78,9 @@ class OnchainAccountCollateral extends onchainAccountPoolToken_1.default {
77
78
  return __awaiter(this, void 0, void 0, function* () {
78
79
  const collateralAmount = yield this.getDeposited();
79
80
  const twapPrice = yield this.lendingPool.getLendingPool().getTWAPPrice();
81
+ const [liqPriceA, liqPriceB] = yield this.lendingPool.getLiquidationPrices(onchainTypes_1.NO_CHANGES);
82
+ console.log("collateralAmount", collateralAmount);
83
+ console.log("liquidationpricenochange", liqPriceA, twapPrice, liqPriceB);
80
84
  // start search
81
85
  let withdrawAmount = collateralAmount;
82
86
  let withdrawAmountPrev = 0;
@@ -86,11 +90,12 @@ class OnchainAccountCollateral extends onchainAccountPoolToken_1.default {
86
90
  if (jump / collateralAmount < 0.001)
87
91
  break;
88
92
  withdrawAmountPrev = withdrawAmount;
89
- const changeCollateral = -1 * Math.max(withdrawAmount * this.getUiMargin(), collateralAmount);
93
+ const changeCollateral = -1 * Math.min(withdrawAmount * this.getUiMargin(), collateralAmount);
90
94
  const changeBorrowedA = 0;
91
95
  const changeBorrowedB = 0;
92
96
  const changes = { changeCollateral, changeBorrowedA, changeBorrowedB };
93
97
  const [liqPriceA, liqPriceB] = yield this.lendingPool.getLiquidationPrices(changes);
98
+ console.log("getMaxWithdrawable", changes, liqPriceA, twapPrice, liqPriceB, bestAmount, withdrawAmount);
94
99
  if (liqPriceA > twapPrice || liqPriceB < twapPrice)
95
100
  withdrawAmount -= jump;
96
101
  else {
@@ -99,7 +104,6 @@ class OnchainAccountCollateral extends onchainAccountPoolToken_1.default {
99
104
  if (withdrawAmount > collateralAmount)
100
105
  break;
101
106
  }
102
- console.log("getMaxWithdrawable", liqPriceA, twapPrice, liqPriceB, bestAmount, withdrawAmount);
103
107
  }
104
108
  return bestAmount / this.getDust();
105
109
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "1.1.78",
3
+ "version": "1.1.80",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",