impermax-sdk 2.1.335 → 2.1.337

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.
@@ -13,15 +13,19 @@ exports.IMPERMAX_SUBGRAPH_URL = {
13
13
  [types_1.Networks.Polygon]: {
14
14
  [types_1.Factory.V2V1_1]: [
15
15
  "https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/F3BfecWo2by5QKrwhkXwuXjyLZnQqJ1wqoejwe67KuyG",
16
+ "https://polygon-factory-production.up.railway.app/"
16
17
  ],
17
18
  [types_1.Factory.V2V2]: [
18
19
  "https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/5JbuAaWwyRm78yWpRCJJS217hXXft59g9MbsjTTZnYQa",
20
+ "https://polygon-factory-production.up.railway.app/"
19
21
  ],
20
22
  [types_1.Factory.SOLV2]: [
21
23
  "https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/Giwg5N4SCehmUzNwXtAQZnZvUuTjcp7cr3nzUZosRDFU",
24
+ "https://polygon-factory-production.up.railway.app/"
22
25
  ],
23
26
  [types_1.Factory.SOL_STABLE]: [
24
27
  "https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/EWckMdMiZeDSGHxq2V8gZBDF549Xjr9iKkPvisqckF11",
28
+ "https://polygon-factory-production.up.railway.app/"
25
29
  ],
26
30
  },
27
31
  [types_1.Networks.Arbitrum]: {
@@ -45,12 +49,15 @@ exports.IMPERMAX_SUBGRAPH_URL = {
45
49
  [types_1.Networks.Avalanche]: {
46
50
  [types_1.Factory.V2V1_2]: [
47
51
  "https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/HXhHppWXhFqgLfdmTahFj2x7F5Xq8BwADxGY3nbCUAwr",
52
+ "https://avalanche-factory-production.up.railway.app/"
48
53
  ],
49
54
  [types_1.Factory.V2V2]: [
50
55
  "https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/8Gz5ZGyRkSA7WBrSteeyez39AgZQsoEbtXe8GtHD7JMQ",
56
+ "https://avalanche-factory-production.up.railway.app/"
51
57
  ],
52
58
  [types_1.Factory.SOLV2]: [
53
59
  "https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/78e6cZp11r2coLx8YYo5y4AqzEhQXYT6sw3Bg5Tiy5XU",
60
+ "https://avalanche-factory-production.up.railway.app/"
54
61
  ],
55
62
  },
56
63
  [types_1.Networks.Mantle]: {
@@ -84,6 +91,7 @@ exports.IMPERMAX_SUBGRAPH_URL = {
84
91
  [types_1.Networks.ZksyncEra]: {
85
92
  [types_1.Factory.SOLV2]: [
86
93
  "https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/8YSS88X8ChDw1QvuAMtxjezSXNiYer9k9d3Uu8XFLHzX",
94
+ "https://zksync-factory-production.up.railway.app/"
87
95
  ],
88
96
  },
89
97
  [types_1.Networks.Harmony]: {},
@@ -92,9 +100,11 @@ exports.IMPERMAX_SUBGRAPH_URL = {
92
100
  [types_1.Networks.Blast]: {
93
101
  [types_1.Factory.SOLV2]: [
94
102
  "https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/4FDikpVjE2XnDJ5QcpQ1YJXWcUDiAgE7x8ErtsHh33UB",
103
+ "https://blast-factory-production.up.railway.app/"
95
104
  ],
96
105
  [types_1.Factory.V2V2]: [
97
106
  "https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/6xkrXFPJ4wqh9cy9ayP19WGr2wZVSMP3FniMjcW2LUG4",
107
+ "https://blast-factory-production.up.railway.app/"
98
108
  ],
99
109
  },
100
110
  [types_1.Networks.Base]: {
@@ -117,9 +127,11 @@ exports.IMPERMAX_SUBGRAPH_URL = {
117
127
  [types_1.Networks.Scroll]: {
118
128
  [types_1.Factory.SOLV2]: [
119
129
  "https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/9HL6kLRt3AbQsprTvk7KZdaHunJ5GGsLdYWd27nNfCFC",
130
+ "https://scroll-factory-production.up.railway.app/"
120
131
  ],
121
132
  [types_1.Factory.SOL_STABLE]: [
122
133
  "https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/C42ymmkDArE1T5wdYKwao6mntqNSjP2E34TeGusiF3sk",
134
+ "https://scroll-factory-production.up.railway.app/"
123
135
  ],
124
136
  },
125
137
  [types_1.Networks.Optimism]: {
@@ -142,15 +154,18 @@ exports.IMPERMAX_SUBGRAPH_URL = {
142
154
  'https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/HK9BA4oFp1xaoQW7YVP4m2nbxX7q2bQCZWNPKBtudtZR'
143
155
  ],
144
156
  [types_1.Factory.SOL_STABLE]: [
157
+ 'https://sonic-factory-production.up.railway.app/',
145
158
  'https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/61ZJXkM5uRGntP1HZkmH4iaKRzsf1BBhQdZYi9euLkpM'
146
159
  ]
147
160
  },
148
161
  [types_1.Networks.Linea]: {
149
162
  [types_1.Factory.SOLV2]: [
150
- 'https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/AyFSeFRAtUm4aY3cb1zTJqoMjcgSNrRipucuSxkEZ1v9'
163
+ 'https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/AyFSeFRAtUm4aY3cb1zTJqoMjcgSNrRipucuSxkEZ1v9',
164
+ 'https://linea-factory-production.up.railway.app/'
151
165
  ],
152
166
  [types_1.Factory.SOL_STABLE]: [
153
- 'https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/Ah5k6hzS9YicNHWuA4Uts9MQQQGbPLDtwD8tYjKaX8Ls'
167
+ 'https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/Ah5k6hzS9YicNHWuA4Uts9MQQQGbPLDtwD8tYjKaX8Ls',
168
+ 'https://linea-factory-production.up.railway.app/'
154
169
  ]
155
170
  }
156
171
  };
@@ -194,6 +209,7 @@ exports.VAULT_SUBGRAPH_URL = {
194
209
  },
195
210
  [types_1.Networks.Mantle]: {},
196
211
  [types_1.Networks.Scroll]: {
212
+ // TODO: raiwlay endpoint
197
213
  [types_1.VaultType.LENDING]: [
198
214
  "https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/BaPMX2ubiRZ4ujqTFmWyrk72fPo6yFLQ7A5Z4BLXCTFU",
199
215
  ],
@@ -212,7 +228,8 @@ exports.VAULT_SUBGRAPH_URL = {
212
228
  },
213
229
  [types_1.Networks.Sonic]: {
214
230
  [types_1.VaultType.LENDING]: [
215
- "https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/AHj91C4xwYSfyHAnZiMa1pC4ZwRtzqG3QGVyJchEsJAC"
231
+ "https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/AHj91C4xwYSfyHAnZiMa1pC4ZwRtzqG3QGVyJchEsJAC",
232
+ "https://sonic-lendingvaults-production.up.railway.app/"
216
233
  ]
217
234
  },
218
235
  [types_1.Networks.Linea]: {},
@@ -41,6 +41,7 @@ class OffchainAccount {
41
41
  return this.vaults[vaultAddress];
42
42
  }
43
43
  async getUserData() {
44
+ console.log("Getting user data in offchainAccount.ts");
44
45
  return this.offchain.getUserData(this.accountAddress);
45
46
  }
46
47
  async getVaultsUserData() {
@@ -1,18 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fetchUserData = exports.initializeUserData = exports.getUserData = void 0;
4
- const subgraphs_1 = require("../../../../config/subgraphs");
5
- const types_1 = require("../../../../config/types");
6
- const offchainTypes_1 = require("../../../offchainTypes");
7
- const positionsV2_1 = require("./positionsV2");
8
- const positionsV3_1 = require("./positionsV3");
4
+ // import { initializeV2Positions } from "./positionsV2";
5
+ // import { initializeV3Positions } from "./positionsV3";
9
6
  /*--------------------------------------------------------------------------*
10
7
  * Getters *
11
8
  *--------------------------------------------------------------------------*/
12
9
  async function getUserData(account) {
13
- if (!(account in this.usersData))
14
- this.usersData[account] = this.initializeUserData(account);
15
- return this.usersData[account];
10
+ console.log("Account: ", account);
11
+ return null;
16
12
  }
17
13
  exports.getUserData = getUserData;
18
14
  /*--------------------------------------------------------------------------*
@@ -23,53 +19,52 @@ exports.getUserData = getUserData;
23
19
  // - `initializeV2Positions` for V2
24
20
  // - `initializeV3Positions` for V3
25
21
  async function initializeUserData(account) {
26
- const result = {};
27
- const userData = await this.fetchUserData(account);
28
- if (!userData)
29
- return null;
30
- for (const factory in userData) {
31
- const userDataOfFactory = userData[factory];
32
- result[factory] = {
33
- positions: {},
34
- collateralPositions: {},
35
- supplyPositions: {},
36
- borrowPositions: {},
37
- };
38
- // Get collateral/borrow positions for V2/V3
39
- if ((0, offchainTypes_1.isV3Factory)(factory)) {
40
- // TODO: V3 pair filter (nftlp)
41
- const v3Data = await (0, positionsV3_1.initializeV3Positions)(this, factory, userDataOfFactory);
42
- result[factory].positions = v3Data.positions;
43
- }
44
- else {
45
- // Pass filtered pairs
46
- const v2Data = await (0, positionsV2_1.initializeV2Positions)(this, factory, userDataOfFactory, []);
47
- result[factory].collateralPositions = v2Data.collateralPositions;
48
- result[factory].borrowPositions = v2Data.borrowPositions;
49
- }
50
- // Supply positions is same for v2 and v3
51
- for (const supplyPosition of userDataOfFactory.supplyPositions) {
52
- const lendingPoolId = supplyPosition.borrowable.lendingPool.id;
53
- // Don't include supply positions if lending pool is not in pair list
54
- // if (pairs.length > 0 && !pairs.includes(lendingPoolId)) continue
55
- const underlyingId = supplyPosition.borrowable.underlying.id;
56
- const lendingPool = await this.getLendingPool(factory, lendingPoolId);
57
- if (!lendingPool) {
58
- console.error("Can't resolve supplyPosition because lendingPool is null. Lending pool:", lendingPoolId, this.network);
59
- continue;
60
- }
61
- const borrowableA = lendingPool.getBorrowableA();
62
- const addressA = await borrowableA.getUnderlyingAddress();
63
- const poolTokenType = underlyingId === addressA
64
- ? types_1.PoolTokenType.BorrowableA
65
- : types_1.PoolTokenType.BorrowableB;
66
- if (!(lendingPoolId in result[factory].supplyPositions)) {
67
- result[factory].supplyPositions[lendingPoolId] = {};
68
- }
69
- result[factory].supplyPositions[lendingPoolId][poolTokenType] = supplyPosition;
70
- }
71
- }
72
- return result;
22
+ return null;
23
+ // const result: FactoryIndex<UserData> = {};
24
+ // const userData = await this.fetchUserData(account);
25
+ // if (!userData) return null;
26
+ // for (const factory in userData) {
27
+ // const userDataOfFactory = userData[factory];
28
+ // result[factory] = {
29
+ // positions: {},
30
+ // collateralPositions: {},
31
+ // supplyPositions: {},
32
+ // borrowPositions: {},
33
+ // };
34
+ // // Get collateral/borrow positions for V2/V3
35
+ // if (isV3Factory(factory)) {
36
+ // // TODO: V3 pair filter (nftlp)
37
+ // const v3Data = await initializeV3Positions(this, factory as Factory, userDataOfFactory);
38
+ // result[factory].positions = v3Data.positions;
39
+ // } else {
40
+ // // Pass filtered pairs
41
+ // const v2Data = await initializeV2Positions(this, factory as Factory, userDataOfFactory, []);
42
+ // result[factory].collateralPositions = v2Data.collateralPositions;
43
+ // result[factory].borrowPositions = v2Data.borrowPositions;
44
+ // }
45
+ // // Supply positions is same for v2 and v3
46
+ // for (const supplyPosition of userDataOfFactory.supplyPositions) {
47
+ // const lendingPoolId = supplyPosition.borrowable.lendingPool.id;
48
+ // // Don't include supply positions if lending pool is not in pair list
49
+ // // if (pairs.length > 0 && !pairs.includes(lendingPoolId)) continue
50
+ // const underlyingId = supplyPosition.borrowable.underlying.id;
51
+ // const lendingPool = await this.getLendingPool(factory as Factory, lendingPoolId);
52
+ // if (!lendingPool) {
53
+ // console.error("Can't resolve supplyPosition because lendingPool is null. Lending pool:", lendingPoolId, this.network);
54
+ // continue;
55
+ // }
56
+ // const borrowableA = lendingPool.getBorrowableA();
57
+ // const addressA = await borrowableA.getUnderlyingAddress();
58
+ // const poolTokenType = underlyingId === addressA
59
+ // ? PoolTokenType.BorrowableA
60
+ // : PoolTokenType.BorrowableB;
61
+ // if (!(lendingPoolId in result[factory].supplyPositions)) {
62
+ // result[factory].supplyPositions[lendingPoolId] = {};
63
+ // }
64
+ // result[factory].supplyPositions[lendingPoolId][poolTokenType] = supplyPosition;
65
+ // }
66
+ // }
67
+ // return result;
73
68
  }
74
69
  exports.initializeUserData = initializeUserData;
75
70
  /*--------------------------------------------------------------------------*
@@ -77,21 +72,25 @@ exports.initializeUserData = initializeUserData;
77
72
  *--------------------------------------------------------------------------*/
78
73
  // User Data
79
74
  async function fetchUserData(account) {
80
- const positions = {};
81
- for (const factory in subgraphs_1.IMPERMAX_SUBGRAPH_URL[this.network]) {
82
- const subgraphs = subgraphs_1.IMPERMAX_SUBGRAPH_URL[this.network][factory];
83
- // Decides for v3 query internally
84
- const result = await this.getEndpointManager().fetch(subgraphs, this.network, (queryBuilder) => queryBuilder.userQuery(account, this.network, factory));
85
- if (!result || !result.data?.user)
86
- continue;
87
- const user = result.data.user;
88
- positions[factory] = {
89
- positions: user.positions,
90
- supplyPositions: user.supplyPositions,
91
- collateralPositions: user.collateralPositions,
92
- borrowPositions: user.borrowPositions, // Undefined if V3
93
- };
94
- }
95
- return positions;
75
+ return 0;
76
+ // const positions: FactoryIndex<RawUserData> = {};
77
+ // for (const factory in IMPERMAX_SUBGRAPH_URL[this.network]) {
78
+ // const subgraphs = IMPERMAX_SUBGRAPH_URL[this.network][factory] as string[];
79
+ // // Decides for v3 query internally
80
+ // const result = await this.getEndpointManager().fetch(
81
+ // subgraphs,
82
+ // this.network,
83
+ // (queryBuilder) => queryBuilder.userQuery(account, this.network, factory as Factory),
84
+ // );
85
+ // if (!result || !result.data?.user) continue;
86
+ // const user = result.data.user;
87
+ // positions[factory as Factory] = {
88
+ // positions: user.positions, // Undefined if v2
89
+ // supplyPositions: user.supplyPositions,
90
+ // collateralPositions: user.collateralPositions, // Undefined if V3
91
+ // borrowPositions: user.borrowPositions, // Undefined if V3
92
+ // }
93
+ // }
94
+ // return positions;
96
95
  }
97
96
  exports.fetchUserData = fetchUserData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "2.1.335",
3
+ "version": "2.1.337",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",