impermax-sdk 2.1.315 → 2.1.317

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.
@@ -381,7 +381,6 @@ exports.WHITELISTED_OLD = {
381
381
  // SwapFish
382
382
  "0xd6F5C7Eb3d61a00610a81FB909Aa4033affA827b",
383
383
  "0x1EFB0E92315fAb41993b03075A49c314A1CbE1Eb",
384
- "0x1bE5e42f53B54F3eC887340Db1A7394a0A664c95",
385
384
  "0xeb45c2F38A2c6AE9dDca11DfBcfef50Dea5Cd293",
386
385
  "0xbeb61368A3e9c6b6ab43429FD0a5F27A4c6bC913",
387
386
  "0x507A83d094EF1166273bDd76d6951A46e2E521aD",
@@ -68,6 +68,10 @@ class OffchainLendingPool {
68
68
  this.getBorrowableA().getTokenPriceAccurate(),
69
69
  this.getBorrowableB().getTokenPriceAccurate()
70
70
  ]);
71
+ if (!priceA || !priceB) {
72
+ console.warn("Can't calculate price for", await this.getBorrowableA().getSymbol(), await this.getBorrowableA().getSymbol());
73
+ return 0;
74
+ }
71
75
  return priceA / priceB;
72
76
  }
73
77
  async getMarketPrice() {
@@ -6,16 +6,17 @@ const LOWEST_PRICE = 1 / 1e18;
6
6
  const HIGHEST_PRICE = 1e18;
7
7
  class GenericPosition {
8
8
  constructor(params) {
9
+ if (isNaN(params.marketPrice) || params.marketPrice < LOWEST_PRICE || params.marketPrice > HIGHEST_PRICE) {
10
+ console.log("Position initialization error: market price =", params.marketPrice);
11
+ }
9
12
  this.liquidity = params.liquidity;
10
13
  this.debtX = params.debtX;
11
14
  this.debtY = params.debtY;
12
15
  this.initialLiquidity = params.liquidity;
13
16
  this.initialDebtX = params.debtX;
14
17
  this.initialDebtY = params.debtY;
15
- this.marketPrice = (isNaN(params.marketPrice) || params.marketPrice < LOWEST_PRICE) ? LOWEST_PRICE
16
- : params.marketPrice > HIGHEST_PRICE ? HIGHEST_PRICE : this.marketPrice;
17
- this.oraclePrice = (isNaN(params.oraclePrice) || params.oraclePrice < LOWEST_PRICE) ? LOWEST_PRICE
18
- : params.oraclePrice > HIGHEST_PRICE ? HIGHEST_PRICE : this.oraclePrice;
18
+ this.marketPrice = params.marketPrice;
19
+ this.oraclePrice = params.oraclePrice;
19
20
  this.safetyMargin = params.safetyMargin;
20
21
  this.liquidationPenalty = params.liquidationPenalty;
21
22
  this.borrowableX = params.borrowableX;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "2.1.315",
3
+ "version": "2.1.317",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",