impermax-sdk 2.1.18 → 2.1.19

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.
@@ -2,6 +2,7 @@ import Offchain from "../index";
2
2
  import { Address } from "../../config/types";
3
3
  import OffchainVault from "./offchainVault";
4
4
  import { VaultBorrowable } from "../offchainTypes";
5
+ import { Amms } from "../../config/amms";
5
6
  export declare enum RiskLevel {
6
7
  LOW = 0,
7
8
  MEDIUM = 1,
@@ -13,4 +14,9 @@ export default class OffchainLendingVault extends OffchainVault {
13
14
  getAvailableLiquidity(): Promise<number>;
14
15
  getAvailableLiquidityUSD(): Promise<number>;
15
16
  getBorrowables(): Promise<Array<VaultBorrowable>>;
17
+ /** Get all borrowables with the AMM of the collateral's underlying pair, if found. can be null */
18
+ getBorrowablesWithAmm(): Promise<Array<VaultBorrowable & {
19
+ amm: Amms | null;
20
+ }>>;
21
+ getBorrowableAmm(borrowable: VaultBorrowable): Promise<Amms | null>;
16
22
  }
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.RiskLevel = void 0;
16
16
  const types_1 = require("../../config/types");
17
17
  const offchainVault_1 = __importDefault(require("./offchainVault"));
18
+ const amms_1 = require("../../config/amms");
18
19
  var RiskLevel;
19
20
  (function (RiskLevel) {
20
21
  RiskLevel[RiskLevel["LOW"] = 0] = "LOW";
@@ -53,5 +54,32 @@ class OffchainLendingVault extends offchainVault_1.default {
53
54
  return vaultData.borrowables;
54
55
  });
55
56
  }
57
+ // WARN: Experimental - Might be removed if can find better way of handling this
58
+ /** Get all borrowables with the AMM of the collateral's underlying pair, if found. can be null */
59
+ getBorrowablesWithAmm() {
60
+ return __awaiter(this, void 0, void 0, function* () {
61
+ const borrowables = yield this.getBorrowables();
62
+ const borrowablesWithAmm = yield Promise.all(borrowables.map((borrowable) => __awaiter(this, void 0, void 0, function* () {
63
+ return (Object.assign(Object.assign({}, borrowable), { amm: yield this.getBorrowableAmm(borrowable) }));
64
+ })));
65
+ return borrowablesWithAmm;
66
+ });
67
+ }
68
+ // WARN: Experimental
69
+ getBorrowableAmm(borrowable) {
70
+ var _a, _b;
71
+ return __awaiter(this, void 0, void 0, function* () {
72
+ const lendingPoolsData = yield this.getOffchain().getLendingPoolsData();
73
+ for (const factory in lendingPoolsData) {
74
+ const pair = lendingPoolsData[factory][borrowable.pairAddress];
75
+ if (pair) {
76
+ // TODO: Rename dexfactory in subgraph to find common solution
77
+ const factoryAddress = factory === "8" ? (_a = pair.nftlp) === null || _a === void 0 ? void 0 : _a.dexFactory : (_b = pair.pair) === null || _b === void 0 ? void 0 : _b.uniswapV2Factory;
78
+ return (0, amms_1.getAmmByFactory)(this.getOffchain().network, factoryAddress);
79
+ }
80
+ }
81
+ return null;
82
+ });
83
+ }
56
84
  }
57
85
  exports.default = OffchainLendingVault;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "2.1.18",
3
+ "version": "2.1.19",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",