impermax-sdk 2.1.415 → 2.1.417

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.
@@ -9,7 +9,9 @@ exports.NFTLP_SUBGRAPH_URL = {
9
9
  [types_1.Networks.Mainnet]: {},
10
10
  [types_1.Networks.Polygon]: {},
11
11
  [types_1.Networks.Arbitrum]: {
12
- [types_1.Extension.UniswapV3]: ["https://arbitrum-nftlp-uniswapv3.up.railway.app/"]
12
+ [types_1.Extension.UniswapV3]: [
13
+ "https://arbitrum-nftlp-uniswapv3.up.railway.app/",
14
+ ]
13
15
  },
14
16
  [types_1.Networks.Avalanche]: {},
15
17
  [types_1.Networks.Mantle]: {},
@@ -24,7 +26,10 @@ exports.NFTLP_SUBGRAPH_URL = {
24
26
  [types_1.Networks.Sxnetwork]: {},
25
27
  [types_1.Networks.Blast]: {},
26
28
  [types_1.Networks.Base]: {
27
- [types_1.Extension.UniswapV3]: ["https://base-nftlp-uniswapv3.up.railway.app/"]
29
+ [types_1.Extension.UniswapV3]: [
30
+ "https://base-nftlp-uniswapv3.up.railway.app/",
31
+ "https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/deployments/id/QmbfefvrPCPYfFf3dCxeHzX8PNVhN29SKWnDMoEKLxWzfr"
32
+ ]
28
33
  },
29
34
  [types_1.Networks.Scroll]: {},
30
35
  [types_1.Networks.Optimism]: {},
@@ -32,7 +37,10 @@ exports.NFTLP_SUBGRAPH_URL = {
32
37
  [types_1.Networks.Sonic]: {},
33
38
  [types_1.Networks.Linea]: {},
34
39
  [types_1.Networks.Unichain]: {
35
- [types_1.Extension.UniswapV3]: ["https://unichain-nftlp-uniswapv3.up.railway.app/"]
40
+ [types_1.Extension.UniswapV3]: [
41
+ "https://unichain-nftlp-uniswapv3.up.railway.app/",
42
+ "https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/deployments/id/QmdoAJLJhsknGtQdj1KzUknhBzzQhsaQfEiNE2EzHMuPg7"
43
+ ]
36
44
  }
37
45
  };
38
46
  // NFTLP Factory addresses for each network
@@ -111,6 +111,7 @@ exports.IMPERMAX_SUBGRAPH_URL = {
111
111
  ],
112
112
  [types_1.Factory.V3]: [
113
113
  "https://base-factory-v3-production.up.railway.app/",
114
+ "https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/deployments/id/QmXJ2ZJChdQadtVnviZgf2NsWkQHo7UvpR8BnmPZd5q1eG"
114
115
  ],
115
116
  },
116
117
  [types_1.Networks.Scroll]: {
@@ -159,7 +160,8 @@ exports.IMPERMAX_SUBGRAPH_URL = {
159
160
  },
160
161
  [types_1.Networks.Unichain]: {
161
162
  [types_1.Factory.V3]: [
162
- 'https://unichain-factoryv3-production.up.railway.app/'
163
+ 'https://unichain-factoryv3-production.up.railway.app/',
164
+ 'https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/deployments/id/QmepRQA4dcnHnfBET4AEY4sJxRYc5x8hpKHjMTegP6z6rE'
163
165
  ]
164
166
  },
165
167
  };
@@ -10,6 +10,7 @@ export declare class TheGraphQueryBuilder implements IQueryBuilder {
10
10
  tvlQuery(): import("graphql").DocumentNode;
11
11
  nftlpsQuery(extension: Extension, network: Networks): import("graphql").DocumentNode;
12
12
  nftlpPositionQuery(extension: Extension, positionIds: string[]): import("graphql").DocumentNode;
13
+ private nftlpUniswapV3PositionsQuery;
13
14
  vaultsQuery(vaultType: VaultType, addressesFilter: Address[]): import("graphql").DocumentNode;
14
15
  vaultsUserQuery(account: Address): import("graphql").DocumentNode;
15
16
  proposalsMetaQuery(rangeBegin: any, rangeLength: any, descending: any): import("graphql").DocumentNode;
@@ -34,10 +34,103 @@ class TheGraphQueryBuilder {
34
34
  * 2. Lending pools V3
35
35
  *-----------------------------*/
36
36
  lendingPoolsV3Query(factory, addressesFilter) {
37
- return (0, graphql_tag_1.default) `{}`;
37
+ const tokenStr = `{
38
+ id
39
+ symbol
40
+ name
41
+ decimals
42
+ }`;
43
+ const borrowableStr = `{
44
+ id
45
+ underlying ${tokenStr}
46
+ totalBalance
47
+ totalBorrows
48
+ borrowRate
49
+ reserveFactor
50
+ kinkBorrowRate
51
+ kinkUtilizationRate
52
+ adjustSpeed
53
+ borrowIndex
54
+ accrualTimestamp
55
+ exchangeRate
56
+ debtCeiling
57
+ }`;
58
+ const collateralStr = `{
59
+ id
60
+ safetyMargin
61
+ liquidationIncentive
62
+ liquidationFee
63
+ }`;
64
+ const nftlpStr = `{
65
+ id
66
+ factory
67
+ }`;
68
+ const id_in_string = addressesFilter?.length ? `where: {id_in: ["${addressesFilter.join('","').toLowerCase()}"]}` : "";
69
+ return (0, graphql_tag_1.default) `{
70
+ lendingPools(
71
+ first: 1000
72
+ ${id_in_string}
73
+ ) {
74
+ id
75
+ borrowable0 ${borrowableStr}
76
+ borrowable1 ${borrowableStr}
77
+ collateral ${collateralStr}
78
+ nftlp ${nftlpStr}
79
+ }
80
+ _meta {
81
+ block {
82
+ number
83
+ }
84
+ hasIndexingErrors
85
+ }
86
+ }`;
38
87
  }
39
88
  userQueryV3(account, network, factory) {
40
- return (0, graphql_tag_1.default) `{}`;
89
+ return (0, graphql_tag_1.default) `{
90
+ user(id: "${account.toLowerCase()}") {
91
+ id
92
+ positions(first: 1000) {
93
+ id
94
+ tokenId
95
+ lendingPool {
96
+ id
97
+ nftlp {
98
+ factory
99
+ }
100
+ }
101
+ borrowPositions(first: 1000) {
102
+ borrowBalance
103
+ borrowIndex
104
+ borrowable {
105
+ id
106
+ underlying {
107
+ id
108
+ }
109
+ }
110
+ }
111
+ }
112
+ supplyPositions(first: 1000) {
113
+ balance
114
+ cumulativeEarnings
115
+ lastExchangeRate
116
+ borrowable {
117
+ id
118
+ underlying {
119
+ id
120
+ }
121
+ lendingPool {
122
+ id
123
+ }
124
+ }
125
+ }
126
+ }
127
+ _meta {
128
+ block {
129
+ number
130
+ }
131
+ hasIndexingErrors
132
+ }
133
+ }`;
41
134
  }
42
135
  /*-----------------------------*
43
136
  * 2. Lending pools
@@ -132,7 +225,6 @@ class TheGraphQueryBuilder {
132
225
  }
133
226
  }`;
134
227
  }
135
- // TODO: Fix earnings once all networks support
136
228
  userQuery(account, network, factory) {
137
229
  if (factory === types_1.Factory.V3)
138
230
  return this.userQueryV3(account, network, factory);
@@ -202,11 +294,68 @@ class TheGraphQueryBuilder {
202
294
  * Nftlps
203
295
  *-----------------------------*/
204
296
  nftlpsQuery(extension, network) {
297
+ if (extension === types_1.Extension.UniswapV3) {
298
+ return (0, graphql_tag_1.default) `{
299
+ nftlps(first: 1000) {
300
+ id
301
+ dexFactory
302
+ uniswapV3Pools {
303
+ liquidity
304
+ fee
305
+ uniswapV3PoolId
306
+ reserve0
307
+ reserve1
308
+ }
309
+ }
310
+ _meta {
311
+ block {
312
+ number
313
+ }
314
+ hasIndexingErrors
315
+ }
316
+ }`;
317
+ }
318
+ if (extension === types_1.Extension.UniswapV2) {
319
+ // TODO
320
+ }
321
+ console.warn(`nftlpsQuery not implemented for extension: ${extension}`);
205
322
  return (0, graphql_tag_1.default) `{}`;
206
323
  }
207
324
  nftlpPositionQuery(extension, positionIds) {
325
+ if (extension === types_1.Extension.UniswapV3)
326
+ return this.nftlpUniswapV3PositionsQuery(positionIds);
208
327
  return (0, graphql_tag_1.default) `{}`;
209
328
  }
329
+ nftlpUniswapV3PositionsQuery(positionIds) {
330
+ const id_in_string = positionIds?.length ? `where: {id_in: ["${positionIds.join('","').toLowerCase()}"]}` : "";
331
+ return (0, graphql_tag_1.default) `{
332
+ nftlpPositions(first: 1000 ${id_in_string}) {
333
+ liquidity
334
+ fee
335
+ tickLower
336
+ tickUpper
337
+ tokenId
338
+ feeGrowthInside0LastX128
339
+ feeGrowthInside1LastX128
340
+ storedTotalFeesEarned0
341
+ storedTotalFeesEarned1
342
+ storedUnclaimedFees0
343
+ storedUnclaimedFees1
344
+ id
345
+ nftlp {
346
+ factory {
347
+ id
348
+ }
349
+ }
350
+ }
351
+ _meta {
352
+ block {
353
+ number
354
+ }
355
+ hasIndexingErrors
356
+ }
357
+ }`;
358
+ }
210
359
  /*-----------------------------*
211
360
  * Lending vaults
212
361
  *-----------------------------*/
@@ -36,12 +36,8 @@ class OnchainLendingPoolV2 extends onchainLendingPool_1.default {
36
36
  }
37
37
  // Lending Pool V2 functions
38
38
  async initializeIsStakedLPToken() {
39
- try {
40
- return await this.impermaxFactory.getRouter().methods.isStakedLPToken(this.id).call();
41
- }
42
- catch (e) {
43
- return false;
44
- }
39
+ const offchainLendingPool = await this.getOffchainLendingPool();
40
+ return offchainLendingPool.isStakedLPToken();
45
41
  }
46
42
  async getIsStakedLPToken() {
47
43
  if (!this.cache.isStakedLPToken)
@@ -59,10 +55,9 @@ class OnchainLendingPoolV2 extends onchainLendingPool_1.default {
59
55
  return this.cache.stakedLPToken;
60
56
  }
61
57
  async initializeUniswapV2Pair() {
62
- const stakedLPToken = await this.getOffchainLendingPool();
63
- return this.getContractHelper().newUniswapV2Pair(stakedLPToken
64
- ? await stakedLPToken.getUniswapV2PairAddress()
65
- : this.id);
58
+ const offchainLendingPool = await this.getOffchainLendingPool();
59
+ const isStakedLPToken = await this.getStakedLPToken();
60
+ return this.getContractHelper().newUniswapV2Pair(isStakedLPToken ? await offchainLendingPool.getUniswapV2PairAddress() : this.id);
66
61
  }
67
62
  async getUniswapV2Pair() {
68
63
  if (!this.cache.uniswapV2Pair)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "2.1.415",
3
+ "version": "2.1.417",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",