impermax-sdk 2.1.396 → 2.1.397
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/initializer/privateApi/lendingPoolsApi/nftlp/uniswapV3/uniswapV3Charts.js +1 -1
- package/lib/offchain/offchain.js +3 -0
- package/lib/offchain/offchainAPRHelper.js +3 -1
- package/lib/offchain/offchainEndpointManager.d.ts +5 -0
- package/lib/offchain/offchainEndpointManager.js +16 -7
- package/lib/offchain/offchainPriceHelper.js +2 -0
- package/lib/offchain/offchainPriceHelperV2.js +1 -0
- package/package.json +1 -1
package/lib/offchain/initializer/privateApi/lendingPoolsApi/nftlp/uniswapV3/uniswapV3Charts.js
CHANGED
|
@@ -11,7 +11,7 @@ const private_api_1 = require("../../../../../../config/private-api");
|
|
|
11
11
|
async function fetchUniswapV3Charts() {
|
|
12
12
|
const api = private_api_1.NFTLP_API[this.network][types_1.Extension.UniswapV3];
|
|
13
13
|
if (!api) {
|
|
14
|
-
console.log(`Missing NFTLP uniswapV3 subgraph on ${this.network}?`)
|
|
14
|
+
// console.log(`Missing NFTLP uniswapV3 subgraph on ${this.network}?`)
|
|
15
15
|
return {};
|
|
16
16
|
}
|
|
17
17
|
try {
|
package/lib/offchain/offchain.js
CHANGED
|
@@ -29,6 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
const initializer = __importStar(require("./initializer"));
|
|
30
30
|
const offchainSolidexHelper_1 = __importDefault(require("./offchainSolidexHelper"));
|
|
31
31
|
const account_1 = __importDefault(require("./account"));
|
|
32
|
+
const types_1 = require("../config/types");
|
|
32
33
|
const offchainVault_1 = __importDefault(require("./vault/offchainVault"));
|
|
33
34
|
const configManager_1 = __importDefault(require("./configManager"));
|
|
34
35
|
const whitelist_1 = require("../config/whitelist");
|
|
@@ -133,6 +134,8 @@ class Offchain {
|
|
|
133
134
|
// Staking module is only available on Arbitrum atm,
|
|
134
135
|
// so we initialize it once in the offchainMultichain.
|
|
135
136
|
// this.stakingModule = new OffchainStakingModule(this);
|
|
137
|
+
this.extensionChartsData[types_1.Extension.UniswapV3] = this.fetchUniswapV3Charts();
|
|
138
|
+
this.extensionStatsData[types_1.Extension.UniswapV3] = this.fetchNftlpTvls();
|
|
136
139
|
}
|
|
137
140
|
cleanCache() {
|
|
138
141
|
this.lendingPoolsData = null;
|
|
@@ -54,6 +54,8 @@ class OffchainAPRHelper {
|
|
|
54
54
|
"impermax-v3",
|
|
55
55
|
]);
|
|
56
56
|
this.offchainMultichain = offchainMultichain;
|
|
57
|
+
this.getLlamaYields();
|
|
58
|
+
this.getShadowPools();
|
|
57
59
|
}
|
|
58
60
|
cleanCache() {
|
|
59
61
|
this.llamaAllPools = {};
|
|
@@ -95,7 +97,7 @@ class OffchainAPRHelper {
|
|
|
95
97
|
}
|
|
96
98
|
async initializeShadowPools() {
|
|
97
99
|
try {
|
|
98
|
-
const response = await
|
|
100
|
+
const response = await this.offchainMultichain.getEndpointManager().fetchAPI("https://api.shadow.so/mixed-pairs");
|
|
99
101
|
this.shadowAllPools = response.pairs.reduce((acc, pool) => {
|
|
100
102
|
acc[pool.id.toLowerCase()] = pool;
|
|
101
103
|
return acc;
|
|
@@ -21,6 +21,10 @@ export default class OffchainEndpointManager {
|
|
|
21
21
|
* @param queryBuilder - The query requested from IQueryBuilder interface (ie. `lendingPoolQuery`, `tvlQuery`, etc.)
|
|
22
22
|
*/
|
|
23
23
|
fetch(endpoints: string[], network: Networks, queryBuilder: (builder: IQueryBuilder) => DocumentNode): Promise<any>;
|
|
24
|
+
/**
|
|
25
|
+
* Fetch from rest endpoints
|
|
26
|
+
*/
|
|
27
|
+
fetchAPI(...endpoints: string[]): Promise<any>;
|
|
24
28
|
/**
|
|
25
29
|
* https://stackoverflow.com/questions/61732049/what-is-the-difference-between-promise-any-and-promise-race
|
|
26
30
|
*/
|
|
@@ -35,4 +39,5 @@ export default class OffchainEndpointManager {
|
|
|
35
39
|
private bestEndpointBlock;
|
|
36
40
|
private filterEndpoints;
|
|
37
41
|
private getPreferredEndpoint;
|
|
42
|
+
private fetchTimeout;
|
|
38
43
|
}
|
|
@@ -39,6 +39,13 @@ class OffchainEndpointManager {
|
|
|
39
39
|
async fetch(endpoints, network, queryBuilder) {
|
|
40
40
|
return this.fetchFromEndpoints(endpoints, network, queryBuilder, this.fastFetch);
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Fetch from rest endpoints
|
|
44
|
+
*/
|
|
45
|
+
async fetchAPI(...endpoints) {
|
|
46
|
+
const fetchPromises = endpoints.map(endpoint => fetch(endpoint).then(res => res.json()));
|
|
47
|
+
return this.fetchTimeout(Promise.any(fetchPromises));
|
|
48
|
+
}
|
|
42
49
|
// ---------------- Private ---------------- //
|
|
43
50
|
/**
|
|
44
51
|
* https://stackoverflow.com/questions/61732049/what-is-the-difference-between-promise-any-and-promise-race
|
|
@@ -67,7 +74,7 @@ class OffchainEndpointManager {
|
|
|
67
74
|
.filter((result, index) => {
|
|
68
75
|
if (result.status === "rejected") {
|
|
69
76
|
console.log(`${endpointQueries[index].endpoint} is down?`);
|
|
70
|
-
console.log(result.reason);
|
|
77
|
+
//console.log(result.reason);
|
|
71
78
|
}
|
|
72
79
|
return result.status === "fulfilled";
|
|
73
80
|
})
|
|
@@ -92,12 +99,7 @@ class OffchainEndpointManager {
|
|
|
92
99
|
query,
|
|
93
100
|
fetchPolicy: "cache-first",
|
|
94
101
|
});
|
|
95
|
-
|
|
96
|
-
const timeout = (ms) => new Promise((resolve) => setTimeout(() => resolve(null), ms));
|
|
97
|
-
const result = await Promise.any([call, timeout(this.maxFetchTime)]);
|
|
98
|
-
if (!result) {
|
|
99
|
-
return Promise.reject("fetchFromEndpoint timed out");
|
|
100
|
-
}
|
|
102
|
+
const result = await this.fetchTimeout(call);
|
|
101
103
|
return { endpoint, result };
|
|
102
104
|
}
|
|
103
105
|
/**
|
|
@@ -147,5 +149,12 @@ class OffchainEndpointManager {
|
|
|
147
149
|
return null;
|
|
148
150
|
}
|
|
149
151
|
}
|
|
152
|
+
async fetchTimeout(promise) {
|
|
153
|
+
const timeout = (ms) => new Promise((resolve) => setTimeout(() => resolve(null), ms));
|
|
154
|
+
const result = await Promise.any([promise, timeout(this.maxFetchTime)]);
|
|
155
|
+
if (!result)
|
|
156
|
+
return Promise.reject("fetch timed out");
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
150
159
|
}
|
|
151
160
|
exports.default = OffchainEndpointManager;
|
|
@@ -98,6 +98,8 @@ class OffchainPriceHelper {
|
|
|
98
98
|
this.coingeckoInitialized = null;
|
|
99
99
|
this.offchainMultichain = offchainMultichain;
|
|
100
100
|
this.debankTokensPrice = {};
|
|
101
|
+
this.coingeckoInitialized = this.getAllCoingeckoPrices();
|
|
102
|
+
Object.keys(dexscreener_ids).map(i => this.debankTokensPrice[i] = this.initializeDebankTokenPrice(i));
|
|
101
103
|
}
|
|
102
104
|
cleanCache() {
|
|
103
105
|
this.subgraphTokensPrice = {};
|
|
@@ -13,6 +13,7 @@ class OffchainPriceHelper {
|
|
|
13
13
|
this.apiTokensInitialized = null;
|
|
14
14
|
this.offchainMultichain = offchainMultichain;
|
|
15
15
|
this.offchainPriceHelperV1 = new offchainPriceHelper_1.default(offchainMultichain);
|
|
16
|
+
this.apiTokensInitialized = this.initializeTokenPrices();
|
|
16
17
|
}
|
|
17
18
|
cleanCache() {
|
|
18
19
|
this.apiTokens = null;
|