impermax-sdk 2.1.18 → 2.1.20

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.
@@ -18,7 +18,7 @@ exports.POOL_TOKEN_ROUTER = {
18
18
  [types_1.Networks.Harmony]: '',
19
19
  [types_1.Networks.Moonbeam]: '',
20
20
  [types_1.Networks.Sxnetwork]: '',
21
- [types_1.Networks.Base]: '0x1EBC3b5911B99aDdE07944c75D9E03958abdB49f',
21
+ [types_1.Networks.Base]: '0x9367B2E2C30166Ad0dAD7F2077E12D6eb8c4564b',
22
22
  [types_1.Networks.Scroll]: '0xFF8D0CDC9C857c7fA265121394558B26e1eAAffE',
23
23
  [types_1.Networks.Real]: '0x3784D354863fe8862d60E446E3f29A08c21D1Ea9',
24
24
  [types_1.Networks.Mantle]: '0xF4A9dda025e65945E7A3F873D6146A12c8110A19',
@@ -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;
@@ -25,6 +25,7 @@ export default class OnchainInteractions {
25
25
  getLendingVault(vaultAddress: Address): OnchainInteractionsLendingVault;
26
26
  send(method: any, onTransactionHash: Function, value?: BigNumber): Promise<any>;
27
27
  getDefaultRouterContract(): any;
28
+ getPoolTokenRouter(): any;
28
29
  claimAirdrop(airdropData: AirdropData, merkleDistributor: Contract, onTransactionHash: Function): Promise<any>;
29
30
  claims(pairAddresses: FactoryIndex<Address[]>, onTransactionHash: Function): Promise<any>;
30
31
  claimDistributor(claimableAddress: Address, onTransactionHash: Function): Promise<any>;
@@ -86,6 +86,18 @@ class OnchainInteractions {
86
86
  }
87
87
  return this.cache.defaultRouterContract;
88
88
  }
89
+ // NOTE: Keeping this function to be used exclusively by `OnchainIntereactionsLendingVault`, not sure if should use above function
90
+ getPoolTokenRouter() {
91
+ if (!this.cache.poolTokenRouterContract) {
92
+ const address = routers_1.POOL_TOKEN_ROUTER[this.onchain.network];
93
+ if (!address) {
94
+ console.error("PoolTokenRouter address not found");
95
+ return null;
96
+ }
97
+ this.cache.poolTokenRouterContract = this.onchain.getContractHelper().newPoolTokenRouter(address);
98
+ }
99
+ return this.cache.poolTokenRouterContract;
100
+ }
89
101
  claimAirdrop(airdropData, merkleDistributor, onTransactionHash) {
90
102
  return __awaiter(this, void 0, void 0, function* () {
91
103
  return this.send(merkleDistributor.methods.claim(airdropData.index, this.accountAddress, airdropData.amount, airdropData.proof), onTransactionHash);
@@ -10,7 +10,7 @@ class OnchainInteractionsLendingVault extends onchainInteractionsPoolToken_1.def
10
10
  this.getInteractions = () => this.interactions;
11
11
  this.getVaultAddress = () => this.poolToken.getVaultAddress();
12
12
  this.getAccountLendingVault = this.getAccountPoolToken;
13
- this.getPoolTokenRouter = () => this.interactions.getDefaultRouterContract();
13
+ this.getPoolTokenRouter = () => this.interactions.getPoolTokenRouter();
14
14
  this.interactions = interactions;
15
15
  this.poolToken = lendingVault;
16
16
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "2.1.18",
3
+ "version": "2.1.20",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",