impermax-sdk 2.1.50 → 2.1.52
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.
- package/lib/offchain/lendingPool/offchainLendingPool.js +9 -1
- package/lib/offchain/vault/offchainLendingVault.d.ts +4 -3
- package/lib/offchain/vault/offchainLendingVault.js +27 -10
- package/lib/offchain/vault/offchainVault.d.ts +1 -0
- package/lib/offchain/vault/offchainVault.js +14 -0
- package/package.json +1 -1
|
@@ -26,6 +26,9 @@ var LendingPoolVersion;
|
|
|
26
26
|
LendingPoolVersion["V2"] = "V2";
|
|
27
27
|
LendingPoolVersion["V3"] = "V3";
|
|
28
28
|
})(LendingPoolVersion = exports.LendingPoolVersion || (exports.LendingPoolVersion = {}));
|
|
29
|
+
// Adjust these to filter out pools with `isLowTVL` and `isHighTVL`
|
|
30
|
+
const LOW_TVL = 25000;
|
|
31
|
+
const HIGH_TVL = 100000;
|
|
29
32
|
class OffchainLendingPool {
|
|
30
33
|
constructor(offchain, factory, pairAddress) {
|
|
31
34
|
this.getOffchain = () => this.offchain;
|
|
@@ -246,7 +249,6 @@ class OffchainLendingPool {
|
|
|
246
249
|
return uniswapAPR + stakingAPR;
|
|
247
250
|
});
|
|
248
251
|
}
|
|
249
|
-
// NOTE: Should this also include collateral totalBalanceUSD ?
|
|
250
252
|
getTVL() {
|
|
251
253
|
return __awaiter(this, void 0, void 0, function* () {
|
|
252
254
|
const [supply0USD, supply1USD, totalBalanceUSD] = yield Promise.all([
|
|
@@ -272,11 +274,17 @@ class OffchainLendingPool {
|
|
|
272
274
|
}
|
|
273
275
|
isLowTVL() {
|
|
274
276
|
return __awaiter(this, void 0, void 0, function* () {
|
|
277
|
+
const tvl = yield this.getTVL();
|
|
278
|
+
if (tvl < LOW_TVL)
|
|
279
|
+
return true;
|
|
275
280
|
return false;
|
|
276
281
|
});
|
|
277
282
|
}
|
|
278
283
|
isHighTVL() {
|
|
279
284
|
return __awaiter(this, void 0, void 0, function* () {
|
|
285
|
+
const tvl = yield this.getTVL();
|
|
286
|
+
if (tvl > HIGH_TVL)
|
|
287
|
+
return true;
|
|
280
288
|
return false;
|
|
281
289
|
});
|
|
282
290
|
}
|
|
@@ -9,13 +9,14 @@ export declare enum RiskLevel {
|
|
|
9
9
|
HIGH = 2
|
|
10
10
|
}
|
|
11
11
|
export default class OffchainLendingVault extends OffchainVault {
|
|
12
|
+
protected vaultBorrowables: Array<VaultBorrowable> | null;
|
|
12
13
|
constructor(offchain: Offchain, vaultAddress: Address);
|
|
13
14
|
getRiskLevel(): Promise<RiskLevel>;
|
|
14
15
|
getAvailableLiquidity(): Promise<number>;
|
|
15
16
|
getAvailableLiquidityUSD(): Promise<number>;
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
getLendingVaultBorrowableAmm(borrowable: VaultBorrowable): Promise<Amms | null>;
|
|
18
|
+
getLendingVaultBorrowablesWithAmm(): Promise<Array<VaultBorrowable & {
|
|
18
19
|
amm: Amms | null;
|
|
19
20
|
}>>;
|
|
20
|
-
|
|
21
|
+
getLendingVaultBorrowables(): Promise<Array<VaultBorrowable> | null>;
|
|
21
22
|
}
|
|
@@ -16,6 +16,7 @@ exports.RiskLevel = void 0;
|
|
|
16
16
|
const types_1 = require("../../config/types");
|
|
17
17
|
const offchainVault_1 = __importDefault(require("./offchainVault"));
|
|
18
18
|
const amms_1 = require("../../config/amms");
|
|
19
|
+
const private_api_1 = require("../../config/private-api");
|
|
19
20
|
var RiskLevel;
|
|
20
21
|
(function (RiskLevel) {
|
|
21
22
|
RiskLevel[RiskLevel["LOW"] = 0] = "LOW";
|
|
@@ -25,6 +26,7 @@ var RiskLevel;
|
|
|
25
26
|
class OffchainLendingVault extends offchainVault_1.default {
|
|
26
27
|
constructor(offchain, vaultAddress) {
|
|
27
28
|
super(offchain, vaultAddress);
|
|
29
|
+
this.vaultBorrowables = null;
|
|
28
30
|
this.vaultType = types_1.VaultType.LENDING;
|
|
29
31
|
}
|
|
30
32
|
getRiskLevel() {
|
|
@@ -45,7 +47,7 @@ class OffchainLendingVault extends offchainVault_1.default {
|
|
|
45
47
|
return availableLiquidity * tokenPrice;
|
|
46
48
|
});
|
|
47
49
|
}
|
|
48
|
-
|
|
50
|
+
getLendingVaultBorrowableAmm(borrowable) {
|
|
49
51
|
var _a, _b;
|
|
50
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
53
|
const lendingPoolsData = yield this.getOffchain().getLendingPoolsData();
|
|
@@ -62,22 +64,37 @@ class OffchainLendingVault extends offchainVault_1.default {
|
|
|
62
64
|
return null;
|
|
63
65
|
});
|
|
64
66
|
}
|
|
65
|
-
|
|
67
|
+
getLendingVaultBorrowablesWithAmm() {
|
|
66
68
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
const borrowables = yield this.
|
|
69
|
+
const borrowables = yield this.getLendingVaultBorrowables();
|
|
70
|
+
if (!borrowables)
|
|
71
|
+
return [];
|
|
68
72
|
const borrowablesWithAmm = yield Promise.all(borrowables.map((borrowable) => __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
return (Object.assign(Object.assign({}, borrowable), { amm: yield this.
|
|
73
|
+
return (Object.assign(Object.assign({}, borrowable), { amm: yield this.getLendingVaultBorrowableAmm(borrowable) }));
|
|
70
74
|
})));
|
|
71
75
|
return borrowablesWithAmm;
|
|
72
76
|
});
|
|
73
77
|
}
|
|
74
|
-
//
|
|
75
|
-
|
|
78
|
+
// Avoid doing this through initializer and do it as-needed
|
|
79
|
+
getLendingVaultBorrowables() {
|
|
76
80
|
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
if (this.vaultBorrowables)
|
|
82
|
+
return this.vaultBorrowables;
|
|
83
|
+
const network = this.getOffchain().network;
|
|
84
|
+
const vaultAddress = this.getVaultAddress();
|
|
85
|
+
const api = private_api_1.IMPERMAX_VAULT_API[network][this.vaultType];
|
|
86
|
+
if (!api) {
|
|
87
|
+
console.log(`Missing API for ${vaultAddress} on ${network}?`);
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
this.vaultBorrowables = yield fetch(api.concat(vaultAddress, '/borrowables')).then((i) => i.json());
|
|
92
|
+
}
|
|
93
|
+
catch (err) {
|
|
94
|
+
console.log(`No vault data found for ${vaultAddress} on ${network}`);
|
|
95
|
+
this.vaultBorrowables = []; // Leave empty to prevent refeteching
|
|
96
|
+
}
|
|
97
|
+
return this.vaultBorrowables;
|
|
81
98
|
});
|
|
82
99
|
}
|
|
83
100
|
}
|
|
@@ -50,6 +50,7 @@ export default class OffchainVault extends OffchainPoolToken {
|
|
|
50
50
|
isDeprecated(): Promise<boolean>;
|
|
51
51
|
isBlacklisted(): Promise<boolean>;
|
|
52
52
|
isStable(): Promise<boolean>;
|
|
53
|
+
isLowTVL(): Promise<boolean>;
|
|
53
54
|
isHighTVL(): Promise<boolean>;
|
|
54
55
|
getVaultChart(): Promise<Array<VaultDayData> | null>;
|
|
55
56
|
}
|
|
@@ -29,6 +29,9 @@ var VaultStatus;
|
|
|
29
29
|
VaultStatus["BLACKLISTED"] = "Blacklisted";
|
|
30
30
|
VaultStatus["ACTIVE"] = "Active";
|
|
31
31
|
})(VaultStatus = exports.VaultStatus || (exports.VaultStatus = {}));
|
|
32
|
+
// Adjust these to filter out vaults with `isLowTVL` and `isHighTVL`
|
|
33
|
+
const LOW_TVL = 25000;
|
|
34
|
+
const HIGH_TVL = 100000;
|
|
32
35
|
class OffchainVault extends offchainPoolToken_1.default {
|
|
33
36
|
constructor(offchain, vaultAddress) {
|
|
34
37
|
super();
|
|
@@ -138,8 +141,19 @@ class OffchainVault extends offchainPoolToken_1.default {
|
|
|
138
141
|
return false;
|
|
139
142
|
});
|
|
140
143
|
}
|
|
144
|
+
isLowTVL() {
|
|
145
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
146
|
+
const tvl = yield this.getVaultSupplyUSD();
|
|
147
|
+
if (tvl < LOW_TVL)
|
|
148
|
+
return true;
|
|
149
|
+
return false;
|
|
150
|
+
});
|
|
151
|
+
}
|
|
141
152
|
isHighTVL() {
|
|
142
153
|
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
+
const tvl = yield this.getVaultSupplyUSD();
|
|
155
|
+
if (tvl > HIGH_TVL)
|
|
156
|
+
return true;
|
|
143
157
|
return false;
|
|
144
158
|
});
|
|
145
159
|
}
|