@defisaver/positions-sdk 1.0.34-dev-portfolio-1 → 1.0.34-dev-portfolio-2

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.
@@ -40620,7 +40620,7 @@ export declare const CompV3View: {
40620
40620
  }];
40621
40621
  readonly networks: {
40622
40622
  readonly "1": {
40623
- readonly address: "0x566b1Bd61E4C164DC22f51883942655DaA7Ea297";
40623
+ readonly address: "0x687bf45bb6279b47a104052b5036da008315f622";
40624
40624
  readonly createdBlock: 20368483;
40625
40625
  readonly oldVersions: {
40626
40626
  readonly "15520449": {
@@ -411,7 +411,7 @@ exports.CompV3View = {
411
411
  "abi": [{ "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "address", "name": "_user", "type": "address" }, { "internalType": "uint256", "name": "_supplyAmount", "type": "uint256" }, { "internalType": "uint256", "name": "_borrowAmount", "type": "uint256" }], "name": "getApyAfterValuesEstimation", "outputs": [{ "internalType": "uint256", "name": "utilization", "type": "uint256" }, { "internalType": "uint256", "name": "supplyRate", "type": "uint256" }, { "internalType": "uint256", "name": "borrowRate", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "address", "name": "_tokenAddr", "type": "address" }], "name": "getAssetPrice", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }], "name": "getAssets", "outputs": [{ "components": [{ "internalType": "uint8", "name": "offset", "type": "uint8" }, { "internalType": "address", "name": "asset", "type": "address" }, { "internalType": "address", "name": "priceFeed", "type": "address" }, { "internalType": "uint64", "name": "scale", "type": "uint64" }, { "internalType": "uint64", "name": "borrowCollateralFactor", "type": "uint64" }, { "internalType": "uint64", "name": "liquidateCollateralFactor", "type": "uint64" }, { "internalType": "uint64", "name": "liquidationFactor", "type": "uint64" }, { "internalType": "uint128", "name": "supplyCap", "type": "uint128" }], "internalType": "struct IComet.AssetInfo[]", "name": "assets", "type": "tuple[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }], "name": "getFullBaseTokenInfo", "outputs": [{ "components": [{ "internalType": "address", "name": "tokenAddr", "type": "address" }, { "internalType": "uint256", "name": "price", "type": "uint256" }, { "internalType": "uint256", "name": "supplyIndex", "type": "uint256" }, { "internalType": "uint256", "name": "borrowIndex", "type": "uint256" }, { "internalType": "uint256", "name": "trackingSupplyIndex", "type": "uint256" }, { "internalType": "uint256", "name": "trackingBorrowIndex", "type": "uint256" }, { "internalType": "uint256", "name": "supplyRate", "type": "uint256" }, { "internalType": "uint256", "name": "borrowRate", "type": "uint256" }, { "internalType": "uint256", "name": "totalSupply", "type": "uint256" }, { "internalType": "uint256", "name": "totalBorrow", "type": "uint256" }, { "internalType": "uint256", "name": "utilization", "type": "uint256" }, { "internalType": "uint256", "name": "baseBorrowMin", "type": "uint256" }, { "internalType": "uint256", "name": "baseTrackingBorrowRewardsSpeed", "type": "uint256" }, { "internalType": "uint256", "name": "baseTrackingSupplyRewardsSpeed", "type": "uint256" }], "internalType": "struct CompV3View.BaseTokenInfoFull", "name": "baseToken", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "address", "name": "_tokenAddr", "type": "address" }], "name": "getFullCollInfo", "outputs": [{ "components": [{ "internalType": "address", "name": "tokenAddr", "type": "address" }, { "internalType": "uint256", "name": "totalSupply", "type": "uint256" }, { "internalType": "uint256", "name": "supplyReserved", "type": "uint256" }, { "internalType": "uint256", "name": "borrowCollateralFactor", "type": "uint256" }, { "internalType": "uint256", "name": "liquidateCollateralFactor", "type": "uint256" }, { "internalType": "uint256", "name": "liquidationFactor", "type": "uint256" }, { "internalType": "uint256", "name": "price", "type": "uint256" }, { "internalType": "uint256", "name": "supplyCap", "type": "uint256" }], "internalType": "struct CompV3View.CollateralInfoFull", "name": "coll", "type": "tuple" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }], "name": "getFullCollInfos", "outputs": [{ "components": [{ "internalType": "address", "name": "tokenAddr", "type": "address" }, { "internalType": "uint256", "name": "totalSupply", "type": "uint256" }, { "internalType": "uint256", "name": "supplyReserved", "type": "uint256" }, { "internalType": "uint256", "name": "borrowCollateralFactor", "type": "uint256" }, { "internalType": "uint256", "name": "liquidateCollateralFactor", "type": "uint256" }, { "internalType": "uint256", "name": "liquidationFactor", "type": "uint256" }, { "internalType": "uint256", "name": "price", "type": "uint256" }, { "internalType": "uint256", "name": "supplyCap", "type": "uint256" }], "internalType": "struct CompV3View.CollateralInfoFull[]", "name": "colls", "type": "tuple[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }], "name": "getGovernanceInfoFull", "outputs": [{ "components": [{ "internalType": "bool", "name": "isSupplyPaused", "type": "bool" }, { "internalType": "bool", "name": "isTransferPaused", "type": "bool" }, { "internalType": "bool", "name": "isWithdrawPaused", "type": "bool" }, { "internalType": "bool", "name": "isAbsorbPaused", "type": "bool" }], "internalType": "struct CompV3View.GovernanceInfoFull", "name": "govInfo", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "address", "name": "_user", "type": "address" }], "name": "getLoanData", "outputs": [{ "components": [{ "internalType": "address", "name": "user", "type": "address" }, { "internalType": "address[]", "name": "collAddr", "type": "address[]" }, { "internalType": "uint256[]", "name": "collAmounts", "type": "uint256[]" }, { "internalType": "uint256", "name": "depositAmount", "type": "uint256" }, { "internalType": "uint256", "name": "depositValue", "type": "uint256" }, { "internalType": "uint256", "name": "borrowAmount", "type": "uint256" }, { "internalType": "uint256", "name": "borrowValue", "type": "uint256" }, { "internalType": "uint256", "name": "collValue", "type": "uint256" }], "internalType": "struct CompV3View.LoanData", "name": "data", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "address[]", "name": "_users", "type": "address[]" }], "name": "getLoanDataArr", "outputs": [{ "components": [{ "internalType": "address", "name": "user", "type": "address" }, { "internalType": "address[]", "name": "collAddr", "type": "address[]" }, { "internalType": "uint256[]", "name": "collAmounts", "type": "uint256[]" }, { "internalType": "uint256", "name": "depositAmount", "type": "uint256" }, { "internalType": "uint256", "name": "depositValue", "type": "uint256" }, { "internalType": "uint256", "name": "borrowAmount", "type": "uint256" }, { "internalType": "uint256", "name": "borrowValue", "type": "uint256" }, { "internalType": "uint256", "name": "collValue", "type": "uint256" }], "internalType": "struct CompV3View.LoanData[]", "name": "loans", "type": "tuple[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "address", "name": "_user", "type": "address" }], "name": "getRewardsOwed", "outputs": [{ "components": [{ "internalType": "address", "name": "token", "type": "address" }, { "internalType": "uint256", "name": "owed", "type": "uint256" }], "internalType": "struct ICometRewards.RewardOwed", "name": "rewardsOwed", "type": "tuple" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "components": [{ "internalType": "uint64", "name": "baseSupplyIndex", "type": "uint64" }, { "internalType": "uint64", "name": "baseBorrowIndex", "type": "uint64" }, { "internalType": "uint64", "name": "trackingSupplyIndex", "type": "uint64" }, { "internalType": "uint64", "name": "trackingBorrowIndex", "type": "uint64" }, { "internalType": "uint104", "name": "totalSupplyBase", "type": "uint104" }, { "internalType": "uint104", "name": "totalBorrowBase", "type": "uint104" }, { "internalType": "uint40", "name": "lastAccrualTime", "type": "uint40" }, { "internalType": "uint8", "name": "pauseFlags", "type": "uint8" }], "internalType": "struct IComet.TotalsBasic", "name": "totals", "type": "tuple" }], "name": "getUtilization", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "pure", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "address", "name": "_owner", "type": "address" }, { "internalType": "address", "name": "_manager", "type": "address" }], "name": "isAllowed", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }],
412
412
  "networks": {
413
413
  "1": {
414
- "address": "0x566b1Bd61E4C164DC22f51883942655DaA7Ea297",
414
+ "address": "0x687bf45bb6279b47a104052b5036da008315f622",
415
415
  "createdBlock": 20368483,
416
416
  "oldVersions": {
417
417
  "15520449": {
@@ -45,7 +45,7 @@ exports.v3USDbCCollAssets = {
45
45
  [common_1.NetworkNumber.Arb]: [],
46
46
  [common_1.NetworkNumber.Base]: exports.v3USDbCCollAssetsBase,
47
47
  };
48
- exports.v3USDTCollAssetsEth = ['COMP', 'ETH', 'WBTC', 'UNI', 'LINK', 'wstETH', 'cbBTC', 'tBTC', 'wUSDM', 'sFRAX', 'mETH', 'weETH', 'sdeUSD', 'deUSD'];
48
+ exports.v3USDTCollAssetsEth = ['COMP', 'ETH', 'WBTC', 'UNI', 'LINK', 'wstETH', 'cbBTC', 'tBTC', 'sFRAX', 'mETH', 'weETH', 'sdeUSD', 'deUSD'];
49
49
  exports.v3USDTCollAssetsArb = ['ETH', 'WBTC', 'wstETH', 'ARB', 'GMX'];
50
50
  exports.v3USDTCollAssetsOpt = ['ETH', 'WBTC', 'OP', 'wstETH'];
51
51
  // @dev Keep assets in array, do not assign directly, so we can parse it and edit it programmatically with `scripts/updateMarkets`
@@ -84,10 +84,13 @@ function getPortfolioData(provider, network, defaultProvider, addresses, summerF
84
84
  liquity: {},
85
85
  crvUsd: {},
86
86
  llamaLend: {},
87
- fluid: {},
87
+ fluid: {
88
+ error: '',
89
+ data: {},
90
+ },
88
91
  };
89
92
  }
90
- yield Promise.all([
93
+ yield Promise.allSettled([
91
94
  ...morphoMarkets.map((market) => __awaiter(this, void 0, void 0, function* () {
92
95
  const marketData = yield (0, morphoBlue_1._getMorphoBlueMarketData)(client, network, market);
93
96
  morphoMarketsData[market.value] = marketData;
@@ -131,86 +134,164 @@ function getPortfolioData(provider, network, defaultProvider, addresses, summerF
131
134
  llamaLendMarketsData[market.value] = marketData;
132
135
  })),
133
136
  ...addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
134
- if (isOpt)
135
- return; // Fluid is not available on Optimism
136
- const userPositions = yield (0, fluid_1._getUserPositionsPortfolio)(client, network, address);
137
- for (const position of userPositions) {
138
- if (new decimal_js_1.default(position.userData.suppliedUsd).gt(0)) {
139
- positions[address.toLowerCase()].fluid[position.userData.nftId] = position.userData;
137
+ try {
138
+ if (isOpt)
139
+ return; // Fluid is not available on Optimism
140
+ const userPositions = yield (0, fluid_1._getUserPositionsPortfolio)(client, network, address);
141
+ for (const position of userPositions) {
142
+ if (new decimal_js_1.default(position.userData.suppliedUsd).gt(0)) {
143
+ positions[address.toLowerCase()].fluid.data[position.userData.nftId] = position.userData;
144
+ }
140
145
  }
141
146
  }
147
+ catch (error) {
148
+ console.error(`Error fetching Fluid positions for address ${address}:`, error);
149
+ positions[address.toLowerCase()].fluid = {
150
+ error: `Error fetching Fluid positions for address ${address}`,
151
+ data: {},
152
+ };
153
+ }
142
154
  })),
143
155
  ]);
144
156
  yield Promise.all([
145
157
  ...aaveV3Markets.map((market) => allAddresses.map((address) => __awaiter(this, void 0, void 0, function* () {
146
- const accData = yield (0, aaveV3_1._getAaveV3AccountData)(client, network, address, Object.assign({ selectedMarket: market }, aaveV3MarketsData[market.value]));
147
- if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
148
- positions[address.toLowerCase()].aaveV3[market.value] = accData;
158
+ try {
159
+ const accData = yield (0, aaveV3_1._getAaveV3AccountData)(client, network, address, Object.assign({ selectedMarket: market }, aaveV3MarketsData[market.value]));
160
+ if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
161
+ positions[address.toLowerCase()].aaveV3[market.value] = { error: '', data: accData };
162
+ }
163
+ catch (error) {
164
+ console.error(`Error fetching AaveV3 account data for address ${address} on market ${market.value}:`, error);
165
+ positions[address.toLowerCase()].aaveV3[market.value] = { error: `Error fetching AaveV3 account data for address ${address} on market ${market.value}`, data: null };
166
+ }
149
167
  }))).flat(),
150
168
  ...morphoMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
151
- const accData = yield (0, morphoBlue_1._getMorphoBlueAccountData)(client, network, address, market, morphoMarketsData[market.value]);
152
- if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
153
- positions[address.toLowerCase()].morphoBlue[market.value] = accData;
169
+ try {
170
+ const accData = yield (0, morphoBlue_1._getMorphoBlueAccountData)(client, network, address, market, morphoMarketsData[market.value]);
171
+ if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
172
+ positions[address.toLowerCase()].morphoBlue[market.value] = { error: '', data: accData };
173
+ }
174
+ catch (error) {
175
+ console.error(`Error fetching MorphoBlue account data for address ${address} on market ${market.value}:`, error);
176
+ positions[address.toLowerCase()].morphoBlue[market.value] = { error: `Error fetching MorphoBlue account data for address ${address} on market ${market.value}`, data: null };
177
+ }
154
178
  }))).flat(),
155
179
  ...compoundV3Markets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
156
- const accData = yield (0, compoundV3_1._getCompoundV3AccountData)(client, network, address, constants_1.ZERO_ADDRESS, { selectedMarket: market, assetsData: compoundV3MarketsData[market.value].assetsData });
157
- if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
158
- positions[address.toLowerCase()].compoundV3[market.value] = accData;
180
+ try {
181
+ const accData = yield (0, compoundV3_1._getCompoundV3AccountData)(client, network, address, constants_1.ZERO_ADDRESS, { selectedMarket: market, assetsData: compoundV3MarketsData[market.value].assetsData });
182
+ if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
183
+ positions[address.toLowerCase()].compoundV3[market.value] = { error: '', data: accData };
184
+ }
185
+ catch (error) {
186
+ console.error(`Error fetching CompoundV3 account data for address ${address} on market ${market.value}:`, error);
187
+ positions[address.toLowerCase()].compoundV3[market.value] = { error: `Error fetching CompoundV3 account data for address ${address} on market ${market.value}`, data: null };
188
+ }
159
189
  }))).flat(),
160
190
  ...sparkMarkets.map((market) => allAddresses.map((address) => __awaiter(this, void 0, void 0, function* () {
161
- const accData = yield (0, spark_1._getSparkAccountData)(client, network, address, { selectedMarket: market, assetsData: sparkMarketsData[market.value].assetsData });
162
- if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
163
- positions[address.toLowerCase()].spark[market.value] = accData;
191
+ try {
192
+ const accData = yield (0, spark_1._getSparkAccountData)(client, network, address, { selectedMarket: market, assetsData: sparkMarketsData[market.value].assetsData });
193
+ if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
194
+ positions[address.toLowerCase()].spark[market.value] = { error: '', data: accData };
195
+ }
196
+ catch (error) {
197
+ console.error(`Error fetching Spark account data for address ${address} on market ${market.value}:`, error);
198
+ positions[address.toLowerCase()].spark[market.value] = { error: `Error fetching Spark account data for address ${address} on market ${market.value}`, data: null };
199
+ }
164
200
  }))).flat(),
165
201
  ...eulerV2Markets.map((market) => addresses.map((address) => {
166
202
  const eulerV2SubAccounts = (0, eulerHelpers_1.getEulerV2SubAccounts)(address);
167
203
  const eulerV2Addresses = [address, ...eulerV2SubAccounts];
168
204
  return Promise.all(eulerV2Addresses.map((eulerAddress) => __awaiter(this, void 0, void 0, function* () {
169
- const accData = yield (0, eulerV2_1._getEulerV2AccountData)(client, network, eulerAddress, eulerAddress, Object.assign({ selectedMarket: market }, eulerV2MarketsData[market.value]));
170
- if (new decimal_js_1.default(accData.suppliedUsd).gt(0) || new decimal_js_1.default(accData.borrowedUsd).gt(0)) {
205
+ try {
206
+ const accData = yield (0, eulerV2_1._getEulerV2AccountData)(client, network, eulerAddress, eulerAddress, Object.assign({ selectedMarket: market }, eulerV2MarketsData[market.value]));
207
+ if (new decimal_js_1.default(accData.suppliedUsd).gt(0) || new decimal_js_1.default(accData.borrowedUsd).gt(0)) {
208
+ if (!positions[address.toLowerCase()].eulerV2[market.value]) {
209
+ positions[address.toLowerCase()].eulerV2[market.value] = {};
210
+ }
211
+ positions[address.toLowerCase()].eulerV2[market.value][eulerAddress.toLowerCase()] = { error: '', data: accData };
212
+ }
213
+ }
214
+ catch (error) {
215
+ console.error(`Error fetching EulerV2 account data for address ${eulerAddress} on market ${market.value}:`, error);
171
216
  if (!positions[address.toLowerCase()].eulerV2[market.value]) {
172
217
  positions[address.toLowerCase()].eulerV2[market.value] = {};
173
218
  }
174
- positions[address.toLowerCase()].eulerV2[market.value][eulerAddress.toLowerCase()] = accData;
219
+ positions[address.toLowerCase()].eulerV2[market.value][eulerAddress.toLowerCase()] = { error: `Error fetching EulerV2 account data for address ${eulerAddress} on market ${market.value}`, data: null };
175
220
  }
176
221
  })));
177
222
  }).flat()).flat(),
178
223
  ...addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
179
224
  var _a;
180
225
  return (_a = makerCdps[address.toLowerCase()]) === null || _a === void 0 ? void 0 : _a.map((cdpInfo) => __awaiter(this, void 0, void 0, function* () {
181
- const cdpData = yield (0, maker_1._getMakerCdpData)(client, network, cdpInfo);
182
- if (cdpData) {
183
- positions[address.toLowerCase()].maker[cdpInfo.id] = cdpData;
226
+ try {
227
+ const cdpData = yield (0, maker_1._getMakerCdpData)(client, network, cdpInfo);
228
+ if (cdpData) {
229
+ positions[address.toLowerCase()].maker[cdpInfo.id] = { error: '', data: cdpData };
230
+ }
231
+ }
232
+ catch (error) {
233
+ console.error(`Error fetching Maker CDP data for address ${address} with ID ${cdpInfo.id}:`, error);
234
+ positions[address.toLowerCase()].maker[cdpInfo.id] = { error: `Error fetching Maker CDP data for address ${address} with ID ${cdpInfo.id}`, data: null };
184
235
  }
185
236
  }));
186
237
  })).flat(),
187
238
  ...aaveV2Markets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
188
- const accData = yield (0, aaveV2_1._getAaveV2AccountData)(client, network, address, aaveV2MarketsData[market.value].assetsData, market);
189
- if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
190
- positions[address.toLowerCase()].aaveV2[market.value] = accData;
239
+ try {
240
+ const accData = yield (0, aaveV2_1._getAaveV2AccountData)(client, network, address, aaveV2MarketsData[market.value].assetsData, market);
241
+ if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
242
+ positions[address.toLowerCase()].aaveV2[market.value] = { error: '', data: accData };
243
+ }
244
+ catch (error) {
245
+ console.error(`Error fetching AaveV2 account data for address ${address}:`, error);
246
+ positions[address.toLowerCase()].aaveV2[market.value] = { error: `Error fetching AaveV2 account data for address ${address}`, data: null };
247
+ }
191
248
  }))).flat(),
192
249
  ...compoundV2Markets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
193
- const accData = yield (0, compoundV2_1._getCompoundV2AccountData)(client, network, address, compoundV2MarketsData[market.value].assetsData);
194
- if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
195
- positions[address.toLowerCase()].compoundV2[market.value] = accData;
250
+ try {
251
+ const accData = yield (0, compoundV2_1._getCompoundV2AccountData)(client, network, address, compoundV2MarketsData[market.value].assetsData);
252
+ if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
253
+ positions[address.toLowerCase()].compoundV2[market.value] = { error: '', data: accData };
254
+ }
255
+ catch (error) {
256
+ console.error(`Error fetching CompoundV2 account data for address ${address}:`, error);
257
+ positions[address.toLowerCase()].compoundV2[market.value] = { error: `Error fetching CompoundV2 account data for address ${address}`, data: null };
258
+ }
196
259
  }))).flat(),
197
260
  ...addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
198
- if (!isMainnet)
199
- return; // Liquity trove info is only available on mainnet
200
- const troveInfo = yield (0, liquity_1._getLiquityTroveInfo)(client, network, address);
201
- if (new decimal_js_1.default(troveInfo.collateral).gt(0))
202
- positions[address.toLowerCase()].liquity = troveInfo;
261
+ try {
262
+ if (!isMainnet)
263
+ return; // Liquity trove info is only available on mainnet
264
+ const troveInfo = yield (0, liquity_1._getLiquityTroveInfo)(client, network, address);
265
+ if (new decimal_js_1.default(troveInfo.collateral).gt(0))
266
+ positions[address.toLowerCase()].liquity = { error: '', data: troveInfo };
267
+ }
268
+ catch (error) {
269
+ console.error(`Error fetching Liquity trove info for address ${address}:`, error);
270
+ positions[address.toLowerCase()].liquity = { error: `Error fetching Liquity trove info for address ${address}`, data: null };
271
+ }
203
272
  })),
204
273
  ...crvUsdMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
205
- const accData = yield (0, curveUsd_1._getCurveUsdUserData)(client, network, address, market, crvUsdMarketsData[market.value].activeBand);
206
- if (new decimal_js_1.default(accData.suppliedUsd).gt(0) || new decimal_js_1.default(accData.borrowedUsd).gt(0)) {
207
- positions[address.toLowerCase()].crvUsd[market.value] = Object.assign(Object.assign({}, accData), { borrowRate: crvUsdMarketsData[market.value].borrowRate });
274
+ try {
275
+ const accData = yield (0, curveUsd_1._getCurveUsdUserData)(client, network, address, market, crvUsdMarketsData[market.value].activeBand);
276
+ if (new decimal_js_1.default(accData.suppliedUsd).gt(0) || new decimal_js_1.default(accData.borrowedUsd).gt(0)) {
277
+ positions[address.toLowerCase()].crvUsd[market.value] = { error: '', data: Object.assign(Object.assign({}, accData), { borrowRate: crvUsdMarketsData[market.value].borrowRate }) };
278
+ }
279
+ }
280
+ catch (error) {
281
+ console.error(`Error fetching Curve USD account data for address ${address} on market ${market.value}:`, error);
282
+ positions[address.toLowerCase()].crvUsd[market.value] = { error: `Error fetching Curve USD account data for address ${address} on market ${market.value}`, data: null };
208
283
  }
209
284
  }))).flat(),
210
285
  ...llamaLendMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
211
- const accData = yield (0, llamaLend_1._getLlamaLendUserData)(client, network, address, market, llamaLendMarketsData[market.value]);
212
- if (new decimal_js_1.default(accData.suppliedUsd).gt(0) || new decimal_js_1.default(accData.borrowedUsd).gt(0)) {
213
- positions[address.toLowerCase()].llamaLend[market.value] = Object.assign(Object.assign({}, accData), { borrowRate: llamaLendMarketsData[market.value].borrowRate });
286
+ try {
287
+ const accData = yield (0, llamaLend_1._getLlamaLendUserData)(client, network, address, market, llamaLendMarketsData[market.value]);
288
+ if (new decimal_js_1.default(accData.suppliedUsd).gt(0) || new decimal_js_1.default(accData.borrowedUsd).gt(0)) {
289
+ positions[address.toLowerCase()].llamaLend[market.value] = { error: '', data: Object.assign(Object.assign({}, accData), { borrowRate: llamaLendMarketsData[market.value].borrowRate }) };
290
+ }
291
+ }
292
+ catch (error) {
293
+ console.error(`Error fetching LlamaLend account data for address ${address} on market ${market.value}:`, error);
294
+ positions[address.toLowerCase()].llamaLend[market.value] = { error: `Error fetching LlamaLend account data for address ${address} on market ${market.value}`, data: null };
214
295
  }
215
296
  }))).flat(),
216
297
  ]);
@@ -9,40 +9,47 @@ import { LlamaLendUserData, LlamaLendVersionsType } from './llamaLend';
9
9
  import { CdpData } from './maker';
10
10
  import { MorphoBluePositionData, MorphoBlueVersions } from './morphoBlue';
11
11
  import { SparkPositionData, SparkVersions } from './spark';
12
+ export interface PortfolioProtocolData<T> {
13
+ error: string;
14
+ data: T | null;
15
+ }
12
16
  export interface PortfolioPositionsDataForAddress {
13
17
  aaveV3: {
14
- [key in AaveVersions]?: AaveV3PositionData;
18
+ [key in AaveVersions]?: PortfolioProtocolData<AaveV3PositionData>;
15
19
  };
16
20
  morphoBlue: {
17
- [key in MorphoBlueVersions]?: MorphoBluePositionData;
21
+ [key in MorphoBlueVersions]?: PortfolioProtocolData<MorphoBluePositionData>;
18
22
  };
19
23
  compoundV3: {
20
- [key in CompoundVersions]?: CompoundV3PositionData;
24
+ [key in CompoundVersions]?: PortfolioProtocolData<CompoundV3PositionData>;
21
25
  };
22
26
  spark: {
23
- [key in SparkVersions]?: SparkPositionData;
27
+ [key in SparkVersions]?: PortfolioProtocolData<SparkPositionData>;
24
28
  };
25
29
  eulerV2: {
26
- [key in EulerV2Versions]?: Record<EthAddress, EulerV2PositionData>;
30
+ [key in EulerV2Versions]?: Record<EthAddress, PortfolioProtocolData<EulerV2PositionData>>;
27
31
  };
28
32
  maker: {
29
- [key: string]: CdpData;
33
+ [key: string]: PortfolioProtocolData<CdpData>;
30
34
  };
31
35
  aaveV2: {
32
- [key in AaveVersions]?: AaveV2PositionData;
36
+ [key in AaveVersions]?: PortfolioProtocolData<AaveV2PositionData>;
33
37
  };
34
38
  compoundV2: {
35
- [key in CompoundVersions]?: CompoundV2PositionData;
39
+ [key in CompoundVersions]?: PortfolioProtocolData<CompoundV2PositionData>;
36
40
  };
37
- liquity: LiquityTroveInfo | {};
41
+ liquity: PortfolioProtocolData<LiquityTroveInfo> | {};
38
42
  crvUsd: {
39
- [key in CrvUSDVersions]?: CrvUSDUserData;
43
+ [key in CrvUSDVersions]?: PortfolioProtocolData<CrvUSDUserData>;
40
44
  };
41
45
  llamaLend: {
42
- [key in LlamaLendVersionsType]?: LlamaLendUserData;
46
+ [key in LlamaLendVersionsType]?: PortfolioProtocolData<LlamaLendUserData>;
43
47
  };
44
48
  fluid: {
45
- [key: string]: FluidVaultData;
49
+ error: string;
50
+ data: {
51
+ [key: string]: FluidVaultData;
52
+ };
46
53
  };
47
54
  }
48
55
  export interface PortfolioPositionsData {
@@ -40620,7 +40620,7 @@ export declare const CompV3View: {
40620
40620
  }];
40621
40621
  readonly networks: {
40622
40622
  readonly "1": {
40623
- readonly address: "0x566b1Bd61E4C164DC22f51883942655DaA7Ea297";
40623
+ readonly address: "0x687bf45bb6279b47a104052b5036da008315f622";
40624
40624
  readonly createdBlock: 20368483;
40625
40625
  readonly oldVersions: {
40626
40626
  readonly "15520449": {
@@ -407,7 +407,7 @@ export const CompV3View = {
407
407
  "abi": [{ "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "address", "name": "_user", "type": "address" }, { "internalType": "uint256", "name": "_supplyAmount", "type": "uint256" }, { "internalType": "uint256", "name": "_borrowAmount", "type": "uint256" }], "name": "getApyAfterValuesEstimation", "outputs": [{ "internalType": "uint256", "name": "utilization", "type": "uint256" }, { "internalType": "uint256", "name": "supplyRate", "type": "uint256" }, { "internalType": "uint256", "name": "borrowRate", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "address", "name": "_tokenAddr", "type": "address" }], "name": "getAssetPrice", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }], "name": "getAssets", "outputs": [{ "components": [{ "internalType": "uint8", "name": "offset", "type": "uint8" }, { "internalType": "address", "name": "asset", "type": "address" }, { "internalType": "address", "name": "priceFeed", "type": "address" }, { "internalType": "uint64", "name": "scale", "type": "uint64" }, { "internalType": "uint64", "name": "borrowCollateralFactor", "type": "uint64" }, { "internalType": "uint64", "name": "liquidateCollateralFactor", "type": "uint64" }, { "internalType": "uint64", "name": "liquidationFactor", "type": "uint64" }, { "internalType": "uint128", "name": "supplyCap", "type": "uint128" }], "internalType": "struct IComet.AssetInfo[]", "name": "assets", "type": "tuple[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }], "name": "getFullBaseTokenInfo", "outputs": [{ "components": [{ "internalType": "address", "name": "tokenAddr", "type": "address" }, { "internalType": "uint256", "name": "price", "type": "uint256" }, { "internalType": "uint256", "name": "supplyIndex", "type": "uint256" }, { "internalType": "uint256", "name": "borrowIndex", "type": "uint256" }, { "internalType": "uint256", "name": "trackingSupplyIndex", "type": "uint256" }, { "internalType": "uint256", "name": "trackingBorrowIndex", "type": "uint256" }, { "internalType": "uint256", "name": "supplyRate", "type": "uint256" }, { "internalType": "uint256", "name": "borrowRate", "type": "uint256" }, { "internalType": "uint256", "name": "totalSupply", "type": "uint256" }, { "internalType": "uint256", "name": "totalBorrow", "type": "uint256" }, { "internalType": "uint256", "name": "utilization", "type": "uint256" }, { "internalType": "uint256", "name": "baseBorrowMin", "type": "uint256" }, { "internalType": "uint256", "name": "baseTrackingBorrowRewardsSpeed", "type": "uint256" }, { "internalType": "uint256", "name": "baseTrackingSupplyRewardsSpeed", "type": "uint256" }], "internalType": "struct CompV3View.BaseTokenInfoFull", "name": "baseToken", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "address", "name": "_tokenAddr", "type": "address" }], "name": "getFullCollInfo", "outputs": [{ "components": [{ "internalType": "address", "name": "tokenAddr", "type": "address" }, { "internalType": "uint256", "name": "totalSupply", "type": "uint256" }, { "internalType": "uint256", "name": "supplyReserved", "type": "uint256" }, { "internalType": "uint256", "name": "borrowCollateralFactor", "type": "uint256" }, { "internalType": "uint256", "name": "liquidateCollateralFactor", "type": "uint256" }, { "internalType": "uint256", "name": "liquidationFactor", "type": "uint256" }, { "internalType": "uint256", "name": "price", "type": "uint256" }, { "internalType": "uint256", "name": "supplyCap", "type": "uint256" }], "internalType": "struct CompV3View.CollateralInfoFull", "name": "coll", "type": "tuple" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }], "name": "getFullCollInfos", "outputs": [{ "components": [{ "internalType": "address", "name": "tokenAddr", "type": "address" }, { "internalType": "uint256", "name": "totalSupply", "type": "uint256" }, { "internalType": "uint256", "name": "supplyReserved", "type": "uint256" }, { "internalType": "uint256", "name": "borrowCollateralFactor", "type": "uint256" }, { "internalType": "uint256", "name": "liquidateCollateralFactor", "type": "uint256" }, { "internalType": "uint256", "name": "liquidationFactor", "type": "uint256" }, { "internalType": "uint256", "name": "price", "type": "uint256" }, { "internalType": "uint256", "name": "supplyCap", "type": "uint256" }], "internalType": "struct CompV3View.CollateralInfoFull[]", "name": "colls", "type": "tuple[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }], "name": "getGovernanceInfoFull", "outputs": [{ "components": [{ "internalType": "bool", "name": "isSupplyPaused", "type": "bool" }, { "internalType": "bool", "name": "isTransferPaused", "type": "bool" }, { "internalType": "bool", "name": "isWithdrawPaused", "type": "bool" }, { "internalType": "bool", "name": "isAbsorbPaused", "type": "bool" }], "internalType": "struct CompV3View.GovernanceInfoFull", "name": "govInfo", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "address", "name": "_user", "type": "address" }], "name": "getLoanData", "outputs": [{ "components": [{ "internalType": "address", "name": "user", "type": "address" }, { "internalType": "address[]", "name": "collAddr", "type": "address[]" }, { "internalType": "uint256[]", "name": "collAmounts", "type": "uint256[]" }, { "internalType": "uint256", "name": "depositAmount", "type": "uint256" }, { "internalType": "uint256", "name": "depositValue", "type": "uint256" }, { "internalType": "uint256", "name": "borrowAmount", "type": "uint256" }, { "internalType": "uint256", "name": "borrowValue", "type": "uint256" }, { "internalType": "uint256", "name": "collValue", "type": "uint256" }], "internalType": "struct CompV3View.LoanData", "name": "data", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "address[]", "name": "_users", "type": "address[]" }], "name": "getLoanDataArr", "outputs": [{ "components": [{ "internalType": "address", "name": "user", "type": "address" }, { "internalType": "address[]", "name": "collAddr", "type": "address[]" }, { "internalType": "uint256[]", "name": "collAmounts", "type": "uint256[]" }, { "internalType": "uint256", "name": "depositAmount", "type": "uint256" }, { "internalType": "uint256", "name": "depositValue", "type": "uint256" }, { "internalType": "uint256", "name": "borrowAmount", "type": "uint256" }, { "internalType": "uint256", "name": "borrowValue", "type": "uint256" }, { "internalType": "uint256", "name": "collValue", "type": "uint256" }], "internalType": "struct CompV3View.LoanData[]", "name": "loans", "type": "tuple[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "address", "name": "_user", "type": "address" }], "name": "getRewardsOwed", "outputs": [{ "components": [{ "internalType": "address", "name": "token", "type": "address" }, { "internalType": "uint256", "name": "owed", "type": "uint256" }], "internalType": "struct ICometRewards.RewardOwed", "name": "rewardsOwed", "type": "tuple" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "components": [{ "internalType": "uint64", "name": "baseSupplyIndex", "type": "uint64" }, { "internalType": "uint64", "name": "baseBorrowIndex", "type": "uint64" }, { "internalType": "uint64", "name": "trackingSupplyIndex", "type": "uint64" }, { "internalType": "uint64", "name": "trackingBorrowIndex", "type": "uint64" }, { "internalType": "uint104", "name": "totalSupplyBase", "type": "uint104" }, { "internalType": "uint104", "name": "totalBorrowBase", "type": "uint104" }, { "internalType": "uint40", "name": "lastAccrualTime", "type": "uint40" }, { "internalType": "uint8", "name": "pauseFlags", "type": "uint8" }], "internalType": "struct IComet.TotalsBasic", "name": "totals", "type": "tuple" }], "name": "getUtilization", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "pure", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "address", "name": "_owner", "type": "address" }, { "internalType": "address", "name": "_manager", "type": "address" }], "name": "isAllowed", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }],
408
408
  "networks": {
409
409
  "1": {
410
- "address": "0x566b1Bd61E4C164DC22f51883942655DaA7Ea297",
410
+ "address": "0x687bf45bb6279b47a104052b5036da008315f622",
411
411
  "createdBlock": 20368483,
412
412
  "oldVersions": {
413
413
  "15520449": {
@@ -42,7 +42,7 @@ export const v3USDbCCollAssets = {
42
42
  [NetworkNumber.Arb]: [],
43
43
  [NetworkNumber.Base]: v3USDbCCollAssetsBase,
44
44
  };
45
- export const v3USDTCollAssetsEth = ['COMP', 'ETH', 'WBTC', 'UNI', 'LINK', 'wstETH', 'cbBTC', 'tBTC', 'wUSDM', 'sFRAX', 'mETH', 'weETH', 'sdeUSD', 'deUSD'];
45
+ export const v3USDTCollAssetsEth = ['COMP', 'ETH', 'WBTC', 'UNI', 'LINK', 'wstETH', 'cbBTC', 'tBTC', 'sFRAX', 'mETH', 'weETH', 'sdeUSD', 'deUSD'];
46
46
  export const v3USDTCollAssetsArb = ['ETH', 'WBTC', 'wstETH', 'ARB', 'GMX'];
47
47
  export const v3USDTCollAssetsOpt = ['ETH', 'WBTC', 'OP', 'wstETH'];
48
48
  // @dev Keep assets in array, do not assign directly, so we can parse it and edit it programmatically with `scripts/updateMarkets`
@@ -78,10 +78,13 @@ export function getPortfolioData(provider, network, defaultProvider, addresses,
78
78
  liquity: {},
79
79
  crvUsd: {},
80
80
  llamaLend: {},
81
- fluid: {},
81
+ fluid: {
82
+ error: '',
83
+ data: {},
84
+ },
82
85
  };
83
86
  }
84
- yield Promise.all([
87
+ yield Promise.allSettled([
85
88
  ...morphoMarkets.map((market) => __awaiter(this, void 0, void 0, function* () {
86
89
  const marketData = yield _getMorphoBlueMarketData(client, network, market);
87
90
  morphoMarketsData[market.value] = marketData;
@@ -125,86 +128,164 @@ export function getPortfolioData(provider, network, defaultProvider, addresses,
125
128
  llamaLendMarketsData[market.value] = marketData;
126
129
  })),
127
130
  ...addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
128
- if (isOpt)
129
- return; // Fluid is not available on Optimism
130
- const userPositions = yield _getUserPositionsPortfolio(client, network, address);
131
- for (const position of userPositions) {
132
- if (new Dec(position.userData.suppliedUsd).gt(0)) {
133
- positions[address.toLowerCase()].fluid[position.userData.nftId] = position.userData;
131
+ try {
132
+ if (isOpt)
133
+ return; // Fluid is not available on Optimism
134
+ const userPositions = yield _getUserPositionsPortfolio(client, network, address);
135
+ for (const position of userPositions) {
136
+ if (new Dec(position.userData.suppliedUsd).gt(0)) {
137
+ positions[address.toLowerCase()].fluid.data[position.userData.nftId] = position.userData;
138
+ }
134
139
  }
135
140
  }
141
+ catch (error) {
142
+ console.error(`Error fetching Fluid positions for address ${address}:`, error);
143
+ positions[address.toLowerCase()].fluid = {
144
+ error: `Error fetching Fluid positions for address ${address}`,
145
+ data: {},
146
+ };
147
+ }
136
148
  })),
137
149
  ]);
138
150
  yield Promise.all([
139
151
  ...aaveV3Markets.map((market) => allAddresses.map((address) => __awaiter(this, void 0, void 0, function* () {
140
- const accData = yield _getAaveV3AccountData(client, network, address, Object.assign({ selectedMarket: market }, aaveV3MarketsData[market.value]));
141
- if (new Dec(accData.suppliedUsd).gt(0))
142
- positions[address.toLowerCase()].aaveV3[market.value] = accData;
152
+ try {
153
+ const accData = yield _getAaveV3AccountData(client, network, address, Object.assign({ selectedMarket: market }, aaveV3MarketsData[market.value]));
154
+ if (new Dec(accData.suppliedUsd).gt(0))
155
+ positions[address.toLowerCase()].aaveV3[market.value] = { error: '', data: accData };
156
+ }
157
+ catch (error) {
158
+ console.error(`Error fetching AaveV3 account data for address ${address} on market ${market.value}:`, error);
159
+ positions[address.toLowerCase()].aaveV3[market.value] = { error: `Error fetching AaveV3 account data for address ${address} on market ${market.value}`, data: null };
160
+ }
143
161
  }))).flat(),
144
162
  ...morphoMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
145
- const accData = yield _getMorphoBlueAccountData(client, network, address, market, morphoMarketsData[market.value]);
146
- if (new Dec(accData.suppliedUsd).gt(0))
147
- positions[address.toLowerCase()].morphoBlue[market.value] = accData;
163
+ try {
164
+ const accData = yield _getMorphoBlueAccountData(client, network, address, market, morphoMarketsData[market.value]);
165
+ if (new Dec(accData.suppliedUsd).gt(0))
166
+ positions[address.toLowerCase()].morphoBlue[market.value] = { error: '', data: accData };
167
+ }
168
+ catch (error) {
169
+ console.error(`Error fetching MorphoBlue account data for address ${address} on market ${market.value}:`, error);
170
+ positions[address.toLowerCase()].morphoBlue[market.value] = { error: `Error fetching MorphoBlue account data for address ${address} on market ${market.value}`, data: null };
171
+ }
148
172
  }))).flat(),
149
173
  ...compoundV3Markets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
150
- const accData = yield _getCompoundV3AccountData(client, network, address, ZERO_ADDRESS, { selectedMarket: market, assetsData: compoundV3MarketsData[market.value].assetsData });
151
- if (new Dec(accData.suppliedUsd).gt(0))
152
- positions[address.toLowerCase()].compoundV3[market.value] = accData;
174
+ try {
175
+ const accData = yield _getCompoundV3AccountData(client, network, address, ZERO_ADDRESS, { selectedMarket: market, assetsData: compoundV3MarketsData[market.value].assetsData });
176
+ if (new Dec(accData.suppliedUsd).gt(0))
177
+ positions[address.toLowerCase()].compoundV3[market.value] = { error: '', data: accData };
178
+ }
179
+ catch (error) {
180
+ console.error(`Error fetching CompoundV3 account data for address ${address} on market ${market.value}:`, error);
181
+ positions[address.toLowerCase()].compoundV3[market.value] = { error: `Error fetching CompoundV3 account data for address ${address} on market ${market.value}`, data: null };
182
+ }
153
183
  }))).flat(),
154
184
  ...sparkMarkets.map((market) => allAddresses.map((address) => __awaiter(this, void 0, void 0, function* () {
155
- const accData = yield _getSparkAccountData(client, network, address, { selectedMarket: market, assetsData: sparkMarketsData[market.value].assetsData });
156
- if (new Dec(accData.suppliedUsd).gt(0))
157
- positions[address.toLowerCase()].spark[market.value] = accData;
185
+ try {
186
+ const accData = yield _getSparkAccountData(client, network, address, { selectedMarket: market, assetsData: sparkMarketsData[market.value].assetsData });
187
+ if (new Dec(accData.suppliedUsd).gt(0))
188
+ positions[address.toLowerCase()].spark[market.value] = { error: '', data: accData };
189
+ }
190
+ catch (error) {
191
+ console.error(`Error fetching Spark account data for address ${address} on market ${market.value}:`, error);
192
+ positions[address.toLowerCase()].spark[market.value] = { error: `Error fetching Spark account data for address ${address} on market ${market.value}`, data: null };
193
+ }
158
194
  }))).flat(),
159
195
  ...eulerV2Markets.map((market) => addresses.map((address) => {
160
196
  const eulerV2SubAccounts = getEulerV2SubAccounts(address);
161
197
  const eulerV2Addresses = [address, ...eulerV2SubAccounts];
162
198
  return Promise.all(eulerV2Addresses.map((eulerAddress) => __awaiter(this, void 0, void 0, function* () {
163
- const accData = yield _getEulerV2AccountData(client, network, eulerAddress, eulerAddress, Object.assign({ selectedMarket: market }, eulerV2MarketsData[market.value]));
164
- if (new Dec(accData.suppliedUsd).gt(0) || new Dec(accData.borrowedUsd).gt(0)) {
199
+ try {
200
+ const accData = yield _getEulerV2AccountData(client, network, eulerAddress, eulerAddress, Object.assign({ selectedMarket: market }, eulerV2MarketsData[market.value]));
201
+ if (new Dec(accData.suppliedUsd).gt(0) || new Dec(accData.borrowedUsd).gt(0)) {
202
+ if (!positions[address.toLowerCase()].eulerV2[market.value]) {
203
+ positions[address.toLowerCase()].eulerV2[market.value] = {};
204
+ }
205
+ positions[address.toLowerCase()].eulerV2[market.value][eulerAddress.toLowerCase()] = { error: '', data: accData };
206
+ }
207
+ }
208
+ catch (error) {
209
+ console.error(`Error fetching EulerV2 account data for address ${eulerAddress} on market ${market.value}:`, error);
165
210
  if (!positions[address.toLowerCase()].eulerV2[market.value]) {
166
211
  positions[address.toLowerCase()].eulerV2[market.value] = {};
167
212
  }
168
- positions[address.toLowerCase()].eulerV2[market.value][eulerAddress.toLowerCase()] = accData;
213
+ positions[address.toLowerCase()].eulerV2[market.value][eulerAddress.toLowerCase()] = { error: `Error fetching EulerV2 account data for address ${eulerAddress} on market ${market.value}`, data: null };
169
214
  }
170
215
  })));
171
216
  }).flat()).flat(),
172
217
  ...addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
173
218
  var _a;
174
219
  return (_a = makerCdps[address.toLowerCase()]) === null || _a === void 0 ? void 0 : _a.map((cdpInfo) => __awaiter(this, void 0, void 0, function* () {
175
- const cdpData = yield _getMakerCdpData(client, network, cdpInfo);
176
- if (cdpData) {
177
- positions[address.toLowerCase()].maker[cdpInfo.id] = cdpData;
220
+ try {
221
+ const cdpData = yield _getMakerCdpData(client, network, cdpInfo);
222
+ if (cdpData) {
223
+ positions[address.toLowerCase()].maker[cdpInfo.id] = { error: '', data: cdpData };
224
+ }
225
+ }
226
+ catch (error) {
227
+ console.error(`Error fetching Maker CDP data for address ${address} with ID ${cdpInfo.id}:`, error);
228
+ positions[address.toLowerCase()].maker[cdpInfo.id] = { error: `Error fetching Maker CDP data for address ${address} with ID ${cdpInfo.id}`, data: null };
178
229
  }
179
230
  }));
180
231
  })).flat(),
181
232
  ...aaveV2Markets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
182
- const accData = yield _getAaveV2AccountData(client, network, address, aaveV2MarketsData[market.value].assetsData, market);
183
- if (new Dec(accData.suppliedUsd).gt(0))
184
- positions[address.toLowerCase()].aaveV2[market.value] = accData;
233
+ try {
234
+ const accData = yield _getAaveV2AccountData(client, network, address, aaveV2MarketsData[market.value].assetsData, market);
235
+ if (new Dec(accData.suppliedUsd).gt(0))
236
+ positions[address.toLowerCase()].aaveV2[market.value] = { error: '', data: accData };
237
+ }
238
+ catch (error) {
239
+ console.error(`Error fetching AaveV2 account data for address ${address}:`, error);
240
+ positions[address.toLowerCase()].aaveV2[market.value] = { error: `Error fetching AaveV2 account data for address ${address}`, data: null };
241
+ }
185
242
  }))).flat(),
186
243
  ...compoundV2Markets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
187
- const accData = yield _getCompoundV2AccountData(client, network, address, compoundV2MarketsData[market.value].assetsData);
188
- if (new Dec(accData.suppliedUsd).gt(0))
189
- positions[address.toLowerCase()].compoundV2[market.value] = accData;
244
+ try {
245
+ const accData = yield _getCompoundV2AccountData(client, network, address, compoundV2MarketsData[market.value].assetsData);
246
+ if (new Dec(accData.suppliedUsd).gt(0))
247
+ positions[address.toLowerCase()].compoundV2[market.value] = { error: '', data: accData };
248
+ }
249
+ catch (error) {
250
+ console.error(`Error fetching CompoundV2 account data for address ${address}:`, error);
251
+ positions[address.toLowerCase()].compoundV2[market.value] = { error: `Error fetching CompoundV2 account data for address ${address}`, data: null };
252
+ }
190
253
  }))).flat(),
191
254
  ...addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
192
- if (!isMainnet)
193
- return; // Liquity trove info is only available on mainnet
194
- const troveInfo = yield _getLiquityTroveInfo(client, network, address);
195
- if (new Dec(troveInfo.collateral).gt(0))
196
- positions[address.toLowerCase()].liquity = troveInfo;
255
+ try {
256
+ if (!isMainnet)
257
+ return; // Liquity trove info is only available on mainnet
258
+ const troveInfo = yield _getLiquityTroveInfo(client, network, address);
259
+ if (new Dec(troveInfo.collateral).gt(0))
260
+ positions[address.toLowerCase()].liquity = { error: '', data: troveInfo };
261
+ }
262
+ catch (error) {
263
+ console.error(`Error fetching Liquity trove info for address ${address}:`, error);
264
+ positions[address.toLowerCase()].liquity = { error: `Error fetching Liquity trove info for address ${address}`, data: null };
265
+ }
197
266
  })),
198
267
  ...crvUsdMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
199
- const accData = yield _getCurveUsdUserData(client, network, address, market, crvUsdMarketsData[market.value].activeBand);
200
- if (new Dec(accData.suppliedUsd).gt(0) || new Dec(accData.borrowedUsd).gt(0)) {
201
- positions[address.toLowerCase()].crvUsd[market.value] = Object.assign(Object.assign({}, accData), { borrowRate: crvUsdMarketsData[market.value].borrowRate });
268
+ try {
269
+ const accData = yield _getCurveUsdUserData(client, network, address, market, crvUsdMarketsData[market.value].activeBand);
270
+ if (new Dec(accData.suppliedUsd).gt(0) || new Dec(accData.borrowedUsd).gt(0)) {
271
+ positions[address.toLowerCase()].crvUsd[market.value] = { error: '', data: Object.assign(Object.assign({}, accData), { borrowRate: crvUsdMarketsData[market.value].borrowRate }) };
272
+ }
273
+ }
274
+ catch (error) {
275
+ console.error(`Error fetching Curve USD account data for address ${address} on market ${market.value}:`, error);
276
+ positions[address.toLowerCase()].crvUsd[market.value] = { error: `Error fetching Curve USD account data for address ${address} on market ${market.value}`, data: null };
202
277
  }
203
278
  }))).flat(),
204
279
  ...llamaLendMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
205
- const accData = yield _getLlamaLendUserData(client, network, address, market, llamaLendMarketsData[market.value]);
206
- if (new Dec(accData.suppliedUsd).gt(0) || new Dec(accData.borrowedUsd).gt(0)) {
207
- positions[address.toLowerCase()].llamaLend[market.value] = Object.assign(Object.assign({}, accData), { borrowRate: llamaLendMarketsData[market.value].borrowRate });
280
+ try {
281
+ const accData = yield _getLlamaLendUserData(client, network, address, market, llamaLendMarketsData[market.value]);
282
+ if (new Dec(accData.suppliedUsd).gt(0) || new Dec(accData.borrowedUsd).gt(0)) {
283
+ positions[address.toLowerCase()].llamaLend[market.value] = { error: '', data: Object.assign(Object.assign({}, accData), { borrowRate: llamaLendMarketsData[market.value].borrowRate }) };
284
+ }
285
+ }
286
+ catch (error) {
287
+ console.error(`Error fetching LlamaLend account data for address ${address} on market ${market.value}:`, error);
288
+ positions[address.toLowerCase()].llamaLend[market.value] = { error: `Error fetching LlamaLend account data for address ${address} on market ${market.value}`, data: null };
208
289
  }
209
290
  }))).flat(),
210
291
  ]);
@@ -9,40 +9,47 @@ import { LlamaLendUserData, LlamaLendVersionsType } from './llamaLend';
9
9
  import { CdpData } from './maker';
10
10
  import { MorphoBluePositionData, MorphoBlueVersions } from './morphoBlue';
11
11
  import { SparkPositionData, SparkVersions } from './spark';
12
+ export interface PortfolioProtocolData<T> {
13
+ error: string;
14
+ data: T | null;
15
+ }
12
16
  export interface PortfolioPositionsDataForAddress {
13
17
  aaveV3: {
14
- [key in AaveVersions]?: AaveV3PositionData;
18
+ [key in AaveVersions]?: PortfolioProtocolData<AaveV3PositionData>;
15
19
  };
16
20
  morphoBlue: {
17
- [key in MorphoBlueVersions]?: MorphoBluePositionData;
21
+ [key in MorphoBlueVersions]?: PortfolioProtocolData<MorphoBluePositionData>;
18
22
  };
19
23
  compoundV3: {
20
- [key in CompoundVersions]?: CompoundV3PositionData;
24
+ [key in CompoundVersions]?: PortfolioProtocolData<CompoundV3PositionData>;
21
25
  };
22
26
  spark: {
23
- [key in SparkVersions]?: SparkPositionData;
27
+ [key in SparkVersions]?: PortfolioProtocolData<SparkPositionData>;
24
28
  };
25
29
  eulerV2: {
26
- [key in EulerV2Versions]?: Record<EthAddress, EulerV2PositionData>;
30
+ [key in EulerV2Versions]?: Record<EthAddress, PortfolioProtocolData<EulerV2PositionData>>;
27
31
  };
28
32
  maker: {
29
- [key: string]: CdpData;
33
+ [key: string]: PortfolioProtocolData<CdpData>;
30
34
  };
31
35
  aaveV2: {
32
- [key in AaveVersions]?: AaveV2PositionData;
36
+ [key in AaveVersions]?: PortfolioProtocolData<AaveV2PositionData>;
33
37
  };
34
38
  compoundV2: {
35
- [key in CompoundVersions]?: CompoundV2PositionData;
39
+ [key in CompoundVersions]?: PortfolioProtocolData<CompoundV2PositionData>;
36
40
  };
37
- liquity: LiquityTroveInfo | {};
41
+ liquity: PortfolioProtocolData<LiquityTroveInfo> | {};
38
42
  crvUsd: {
39
- [key in CrvUSDVersions]?: CrvUSDUserData;
43
+ [key in CrvUSDVersions]?: PortfolioProtocolData<CrvUSDUserData>;
40
44
  };
41
45
  llamaLend: {
42
- [key in LlamaLendVersionsType]?: LlamaLendUserData;
46
+ [key in LlamaLendVersionsType]?: PortfolioProtocolData<LlamaLendUserData>;
43
47
  };
44
48
  fluid: {
45
- [key: string]: FluidVaultData;
49
+ error: string;
50
+ data: {
51
+ [key: string]: FluidVaultData;
52
+ };
46
53
  };
47
54
  }
48
55
  export interface PortfolioPositionsData {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/positions-sdk",
3
- "version": "1.0.34-dev-portfolio-1",
3
+ "version": "1.0.34-dev-portfolio-2",
4
4
  "description": "",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
@@ -15,7 +15,6 @@
15
15
  "test": "mocha tests/*",
16
16
  "test-single": "mocha ./tests/$npm_config_name.ts",
17
17
  "test:debugger": "mocha --inspect-brk tests/*",
18
- "test-single": "mocha ./tests/$npm_config_name.ts",
19
18
  "version-bump": "git commit -am \"Version bump to $(npm version patch | cut -c 2-)\""
20
19
  },
21
20
  "keywords": [],
@@ -409,7 +409,7 @@ export const CompV3View = {
409
409
  "abi": [{"inputs":[{"internalType":"address","name":"_market","type":"address"},{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_supplyAmount","type":"uint256"},{"internalType":"uint256","name":"_borrowAmount","type":"uint256"}],"name":"getApyAfterValuesEstimation","outputs":[{"internalType":"uint256","name":"utilization","type":"uint256"},{"internalType":"uint256","name":"supplyRate","type":"uint256"},{"internalType":"uint256","name":"borrowRate","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_market","type":"address"},{"internalType":"address","name":"_tokenAddr","type":"address"}],"name":"getAssetPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_market","type":"address"}],"name":"getAssets","outputs":[{"components":[{"internalType":"uint8","name":"offset","type":"uint8"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"address","name":"priceFeed","type":"address"},{"internalType":"uint64","name":"scale","type":"uint64"},{"internalType":"uint64","name":"borrowCollateralFactor","type":"uint64"},{"internalType":"uint64","name":"liquidateCollateralFactor","type":"uint64"},{"internalType":"uint64","name":"liquidationFactor","type":"uint64"},{"internalType":"uint128","name":"supplyCap","type":"uint128"}],"internalType":"struct IComet.AssetInfo[]","name":"assets","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_market","type":"address"}],"name":"getFullBaseTokenInfo","outputs":[{"components":[{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"supplyIndex","type":"uint256"},{"internalType":"uint256","name":"borrowIndex","type":"uint256"},{"internalType":"uint256","name":"trackingSupplyIndex","type":"uint256"},{"internalType":"uint256","name":"trackingBorrowIndex","type":"uint256"},{"internalType":"uint256","name":"supplyRate","type":"uint256"},{"internalType":"uint256","name":"borrowRate","type":"uint256"},{"internalType":"uint256","name":"totalSupply","type":"uint256"},{"internalType":"uint256","name":"totalBorrow","type":"uint256"},{"internalType":"uint256","name":"utilization","type":"uint256"},{"internalType":"uint256","name":"baseBorrowMin","type":"uint256"},{"internalType":"uint256","name":"baseTrackingBorrowRewardsSpeed","type":"uint256"},{"internalType":"uint256","name":"baseTrackingSupplyRewardsSpeed","type":"uint256"}],"internalType":"struct CompV3View.BaseTokenInfoFull","name":"baseToken","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_market","type":"address"},{"internalType":"address","name":"_tokenAddr","type":"address"}],"name":"getFullCollInfo","outputs":[{"components":[{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"totalSupply","type":"uint256"},{"internalType":"uint256","name":"supplyReserved","type":"uint256"},{"internalType":"uint256","name":"borrowCollateralFactor","type":"uint256"},{"internalType":"uint256","name":"liquidateCollateralFactor","type":"uint256"},{"internalType":"uint256","name":"liquidationFactor","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"supplyCap","type":"uint256"}],"internalType":"struct CompV3View.CollateralInfoFull","name":"coll","type":"tuple"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_market","type":"address"}],"name":"getFullCollInfos","outputs":[{"components":[{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"totalSupply","type":"uint256"},{"internalType":"uint256","name":"supplyReserved","type":"uint256"},{"internalType":"uint256","name":"borrowCollateralFactor","type":"uint256"},{"internalType":"uint256","name":"liquidateCollateralFactor","type":"uint256"},{"internalType":"uint256","name":"liquidationFactor","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"supplyCap","type":"uint256"}],"internalType":"struct CompV3View.CollateralInfoFull[]","name":"colls","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_market","type":"address"}],"name":"getGovernanceInfoFull","outputs":[{"components":[{"internalType":"bool","name":"isSupplyPaused","type":"bool"},{"internalType":"bool","name":"isTransferPaused","type":"bool"},{"internalType":"bool","name":"isWithdrawPaused","type":"bool"},{"internalType":"bool","name":"isAbsorbPaused","type":"bool"}],"internalType":"struct CompV3View.GovernanceInfoFull","name":"govInfo","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_market","type":"address"},{"internalType":"address","name":"_user","type":"address"}],"name":"getLoanData","outputs":[{"components":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address[]","name":"collAddr","type":"address[]"},{"internalType":"uint256[]","name":"collAmounts","type":"uint256[]"},{"internalType":"uint256","name":"depositAmount","type":"uint256"},{"internalType":"uint256","name":"depositValue","type":"uint256"},{"internalType":"uint256","name":"borrowAmount","type":"uint256"},{"internalType":"uint256","name":"borrowValue","type":"uint256"},{"internalType":"uint256","name":"collValue","type":"uint256"}],"internalType":"struct CompV3View.LoanData","name":"data","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_market","type":"address"},{"internalType":"address[]","name":"_users","type":"address[]"}],"name":"getLoanDataArr","outputs":[{"components":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address[]","name":"collAddr","type":"address[]"},{"internalType":"uint256[]","name":"collAmounts","type":"uint256[]"},{"internalType":"uint256","name":"depositAmount","type":"uint256"},{"internalType":"uint256","name":"depositValue","type":"uint256"},{"internalType":"uint256","name":"borrowAmount","type":"uint256"},{"internalType":"uint256","name":"borrowValue","type":"uint256"},{"internalType":"uint256","name":"collValue","type":"uint256"}],"internalType":"struct CompV3View.LoanData[]","name":"loans","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_market","type":"address"},{"internalType":"address","name":"_user","type":"address"}],"name":"getRewardsOwed","outputs":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"owed","type":"uint256"}],"internalType":"struct ICometRewards.RewardOwed","name":"rewardsOwed","type":"tuple"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint64","name":"baseSupplyIndex","type":"uint64"},{"internalType":"uint64","name":"baseBorrowIndex","type":"uint64"},{"internalType":"uint64","name":"trackingSupplyIndex","type":"uint64"},{"internalType":"uint64","name":"trackingBorrowIndex","type":"uint64"},{"internalType":"uint104","name":"totalSupplyBase","type":"uint104"},{"internalType":"uint104","name":"totalBorrowBase","type":"uint104"},{"internalType":"uint40","name":"lastAccrualTime","type":"uint40"},{"internalType":"uint8","name":"pauseFlags","type":"uint8"}],"internalType":"struct IComet.TotalsBasic","name":"totals","type":"tuple"}],"name":"getUtilization","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_market","type":"address"},{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_manager","type":"address"}],"name":"isAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}],
410
410
  "networks": {
411
411
  "1": {
412
- "address": "0x566b1Bd61E4C164DC22f51883942655DaA7Ea297",
412
+ "address": "0x687bf45bb6279b47a104052b5036da008315f622",
413
413
  "createdBlock": 20368483,
414
414
  "oldVersions": {
415
415
  "15520449": {
@@ -52,7 +52,7 @@ export const v3USDbCCollAssets = {
52
52
  [NetworkNumber.Base]: v3USDbCCollAssetsBase,
53
53
  };
54
54
 
55
- export const v3USDTCollAssetsEth = ['COMP', 'ETH', 'WBTC', 'UNI', 'LINK', 'wstETH', 'cbBTC', 'tBTC', 'wUSDM', 'sFRAX', 'mETH', 'weETH', 'sdeUSD', 'deUSD'];
55
+ export const v3USDTCollAssetsEth = ['COMP', 'ETH', 'WBTC', 'UNI', 'LINK', 'wstETH', 'cbBTC', 'tBTC', 'sFRAX', 'mETH', 'weETH', 'sdeUSD', 'deUSD'];
56
56
  export const v3USDTCollAssetsArb = ['ETH', 'WBTC', 'wstETH', 'ARB', 'GMX'];
57
57
  export const v3USDTCollAssetsOpt = ['ETH', 'WBTC', 'OP', 'wstETH'];
58
58
 
@@ -91,11 +91,14 @@ export async function getPortfolioData(provider: EthereumProvider, network: Netw
91
91
  liquity: {},
92
92
  crvUsd: {},
93
93
  llamaLend: {},
94
- fluid: {},
94
+ fluid: {
95
+ error: '',
96
+ data: {},
97
+ },
95
98
  };
96
99
  }
97
100
 
98
- await Promise.all([
101
+ await Promise.allSettled([
99
102
  ...morphoMarkets.map(async (market) => {
100
103
  const marketData = await _getMorphoBlueMarketData(client, network, market);
101
104
  morphoMarketsData[market.value] = marketData;
@@ -138,12 +141,20 @@ export async function getPortfolioData(provider: EthereumProvider, network: Netw
138
141
  llamaLendMarketsData[market.value] = marketData;
139
142
  }),
140
143
  ...addresses.map(async (address) => {
141
- if (isOpt) return; // Fluid is not available on Optimism
142
- const userPositions = await _getUserPositionsPortfolio(client, network, address);
143
- for (const position of userPositions) {
144
- if (new Dec(position.userData.suppliedUsd).gt(0)) {
145
- positions[address.toLowerCase() as EthAddress].fluid[position.userData.nftId] = position.userData;
144
+ try {
145
+ if (isOpt) return; // Fluid is not available on Optimism
146
+ const userPositions = await _getUserPositionsPortfolio(client, network, address);
147
+ for (const position of userPositions) {
148
+ if (new Dec(position.userData.suppliedUsd).gt(0)) {
149
+ positions[address.toLowerCase() as EthAddress].fluid.data[position.userData.nftId] = position.userData;
150
+ }
146
151
  }
152
+ } catch (error) {
153
+ console.error(`Error fetching Fluid positions for address ${address}:`, error);
154
+ positions[address.toLowerCase() as EthAddress].fluid = {
155
+ error: `Error fetching Fluid positions for address ${address}`,
156
+ data: {},
157
+ };
147
158
  }
148
159
  }),
149
160
  ]);
@@ -151,63 +162,121 @@ export async function getPortfolioData(provider: EthereumProvider, network: Netw
151
162
 
152
163
  await Promise.all([
153
164
  ...aaveV3Markets.map((market) => allAddresses.map(async (address) => {
154
- const accData = await _getAaveV3AccountData(client, network, address, { selectedMarket: market, ...aaveV3MarketsData[market.value] });
155
- if (new Dec(accData.suppliedUsd).gt(0)) positions[address.toLowerCase() as EthAddress].aaveV3[market.value] = accData;
165
+ try {
166
+ const accData = await _getAaveV3AccountData(client, network, address, { selectedMarket: market, ...aaveV3MarketsData[market.value] });
167
+ if (new Dec(accData.suppliedUsd).gt(0)) positions[address.toLowerCase() as EthAddress].aaveV3[market.value] = { error: '', data: accData };
168
+ } catch (error) {
169
+ console.error(`Error fetching AaveV3 account data for address ${address} on market ${market.value}:`, error);
170
+ positions[address.toLowerCase() as EthAddress].aaveV3[market.value] = { error: `Error fetching AaveV3 account data for address ${address} on market ${market.value}`, data: null };
171
+ }
156
172
  })).flat(),
157
173
  ...morphoMarkets.map((market) => addresses.map(async (address) => {
158
- const accData = await _getMorphoBlueAccountData(client, network, address, market, morphoMarketsData[market.value]);
159
- if (new Dec(accData.suppliedUsd).gt(0)) positions[address.toLowerCase() as EthAddress].morphoBlue[market.value] = accData;
174
+ try {
175
+ const accData = await _getMorphoBlueAccountData(client, network, address, market, morphoMarketsData[market.value]);
176
+ if (new Dec(accData.suppliedUsd).gt(0)) positions[address.toLowerCase() as EthAddress].morphoBlue[market.value] = { error: '', data: accData };
177
+ } catch (error) {
178
+ console.error(`Error fetching MorphoBlue account data for address ${address} on market ${market.value}:`, error);
179
+ positions[address.toLowerCase() as EthAddress].morphoBlue[market.value] = { error: `Error fetching MorphoBlue account data for address ${address} on market ${market.value}`, data: null };
180
+ }
160
181
  })).flat(),
161
182
  ...compoundV3Markets.map((market) => addresses.map(async (address) => {
162
- const accData = await _getCompoundV3AccountData(client, network, address, ZERO_ADDRESS, { selectedMarket: market, assetsData: compoundV3MarketsData[market.value].assetsData });
163
- if (new Dec(accData.suppliedUsd).gt(0)) positions[address.toLowerCase() as EthAddress].compoundV3[market.value] = accData;
183
+ try {
184
+ const accData = await _getCompoundV3AccountData(client, network, address, ZERO_ADDRESS, { selectedMarket: market, assetsData: compoundV3MarketsData[market.value].assetsData });
185
+ if (new Dec(accData.suppliedUsd).gt(0)) positions[address.toLowerCase() as EthAddress].compoundV3[market.value] = { error: '', data: accData };
186
+ } catch (error) {
187
+ console.error(`Error fetching CompoundV3 account data for address ${address} on market ${market.value}:`, error);
188
+ positions[address.toLowerCase() as EthAddress].compoundV3[market.value] = { error: `Error fetching CompoundV3 account data for address ${address} on market ${market.value}`, data: null };
189
+ }
164
190
  })).flat(),
165
191
  ...sparkMarkets.map((market) => allAddresses.map(async (address) => {
166
- const accData = await _getSparkAccountData(client, network, address, { selectedMarket: market, assetsData: sparkMarketsData[market.value].assetsData });
167
- if (new Dec(accData.suppliedUsd).gt(0)) positions[address.toLowerCase() as EthAddress].spark[market.value] = accData;
192
+ try {
193
+ const accData = await _getSparkAccountData(client, network, address, { selectedMarket: market, assetsData: sparkMarketsData[market.value].assetsData });
194
+ if (new Dec(accData.suppliedUsd).gt(0)) positions[address.toLowerCase() as EthAddress].spark[market.value] = { error: '', data: accData };
195
+ } catch (error) {
196
+ console.error(`Error fetching Spark account data for address ${address} on market ${market.value}:`, error);
197
+ positions[address.toLowerCase() as EthAddress].spark[market.value] = { error: `Error fetching Spark account data for address ${address} on market ${market.value}`, data: null };
198
+ }
168
199
  })).flat(),
169
200
  ...eulerV2Markets.map((market) => addresses.map((address) => {
170
201
  const eulerV2SubAccounts = getEulerV2SubAccounts(address);
171
202
  const eulerV2Addresses = [address, ...eulerV2SubAccounts];
172
203
  return Promise.all(eulerV2Addresses.map(async (eulerAddress) => {
173
- const accData = await _getEulerV2AccountData(client, network, eulerAddress, eulerAddress, { selectedMarket: market, ...eulerV2MarketsData[market.value] });
174
- if (new Dec(accData.suppliedUsd).gt(0) || new Dec(accData.borrowedUsd).gt(0)) {
204
+ try {
205
+ const accData = await _getEulerV2AccountData(client, network, eulerAddress, eulerAddress, { selectedMarket: market, ...eulerV2MarketsData[market.value] });
206
+ if (new Dec(accData.suppliedUsd).gt(0) || new Dec(accData.borrowedUsd).gt(0)) {
207
+ if (!positions[address.toLowerCase() as EthAddress].eulerV2[market.value]) {
208
+ positions[address.toLowerCase() as EthAddress].eulerV2[market.value] = {};
209
+ }
210
+ positions[address.toLowerCase() as EthAddress].eulerV2[market.value]![eulerAddress.toLowerCase() as EthAddress] = { error: '', data: accData };
211
+ }
212
+ } catch (error) {
213
+ console.error(`Error fetching EulerV2 account data for address ${eulerAddress} on market ${market.value}:`, error);
175
214
  if (!positions[address.toLowerCase() as EthAddress].eulerV2[market.value]) {
176
215
  positions[address.toLowerCase() as EthAddress].eulerV2[market.value] = {};
177
216
  }
178
- positions[address.toLowerCase() as EthAddress].eulerV2[market.value]![eulerAddress.toLowerCase() as EthAddress] = accData;
217
+ positions[address.toLowerCase() as EthAddress].eulerV2[market.value]![eulerAddress.toLowerCase() as EthAddress] = { error: `Error fetching EulerV2 account data for address ${eulerAddress} on market ${market.value}`, data: null };
179
218
  }
180
219
  }));
181
220
  }).flat()).flat(),
182
221
  ...addresses.map(async (address) => makerCdps[address.toLowerCase() as EthAddress]?.map(async (cdpInfo) => {
183
- const cdpData = await _getMakerCdpData(client, network, cdpInfo);
184
- if (cdpData) {
185
- positions[address.toLowerCase() as EthAddress].maker[cdpInfo.id] = cdpData;
222
+ try {
223
+ const cdpData = await _getMakerCdpData(client, network, cdpInfo);
224
+ if (cdpData) {
225
+ positions[address.toLowerCase() as EthAddress].maker[cdpInfo.id] = { error: '', data: cdpData };
226
+ }
227
+ } catch (error) {
228
+ console.error(`Error fetching Maker CDP data for address ${address} with ID ${cdpInfo.id}:`, error);
229
+ positions[address.toLowerCase() as EthAddress].maker[cdpInfo.id] = { error: `Error fetching Maker CDP data for address ${address} with ID ${cdpInfo.id}`, data: null };
186
230
  }
187
231
  })).flat(),
188
232
  ...aaveV2Markets.map((market) => addresses.map(async (address) => {
189
- const accData = await _getAaveV2AccountData(client, network, address, aaveV2MarketsData[market.value].assetsData, market);
190
- if (new Dec(accData.suppliedUsd).gt(0)) positions[address.toLowerCase() as EthAddress].aaveV2[market.value] = accData;
233
+ try {
234
+ const accData = await _getAaveV2AccountData(client, network, address, aaveV2MarketsData[market.value].assetsData, market);
235
+ if (new Dec(accData.suppliedUsd).gt(0)) positions[address.toLowerCase() as EthAddress].aaveV2[market.value] = { error: '', data: accData };
236
+ } catch (error) {
237
+ console.error(`Error fetching AaveV2 account data for address ${address}:`, error);
238
+ positions[address.toLowerCase() as EthAddress].aaveV2[market.value] = { error: `Error fetching AaveV2 account data for address ${address}`, data: null };
239
+ }
191
240
  })).flat(),
192
241
  ...compoundV2Markets.map((market) => addresses.map(async (address) => {
193
- const accData = await _getCompoundV2AccountData(client, network, address, compoundV2MarketsData[market.value].assetsData);
194
- if (new Dec(accData.suppliedUsd).gt(0)) positions[address.toLowerCase() as EthAddress].compoundV2[market.value] = accData;
242
+ try {
243
+ const accData = await _getCompoundV2AccountData(client, network, address, compoundV2MarketsData[market.value].assetsData);
244
+ if (new Dec(accData.suppliedUsd).gt(0)) positions[address.toLowerCase() as EthAddress].compoundV2[market.value] = { error: '', data: accData };
245
+ } catch (error) {
246
+ console.error(`Error fetching CompoundV2 account data for address ${address}:`, error);
247
+ positions[address.toLowerCase() as EthAddress].compoundV2[market.value] = { error: `Error fetching CompoundV2 account data for address ${address}`, data: null };
248
+ }
195
249
  })).flat(),
196
250
  ...addresses.map(async (address) => {
197
- if (!isMainnet) return; // Liquity trove info is only available on mainnet
198
- const troveInfo = await _getLiquityTroveInfo(client, network, address);
199
- if (new Dec(troveInfo.collateral).gt(0)) positions[address.toLowerCase() as EthAddress].liquity = troveInfo;
251
+ try {
252
+ if (!isMainnet) return; // Liquity trove info is only available on mainnet
253
+ const troveInfo = await _getLiquityTroveInfo(client, network, address);
254
+ if (new Dec(troveInfo.collateral).gt(0)) positions[address.toLowerCase() as EthAddress].liquity = { error: '', data: troveInfo };
255
+ } catch (error) {
256
+ console.error(`Error fetching Liquity trove info for address ${address}:`, error);
257
+ positions[address.toLowerCase() as EthAddress].liquity = { error: `Error fetching Liquity trove info for address ${address}`, data: null };
258
+ }
200
259
  }),
201
260
  ...crvUsdMarkets.map((market) => addresses.map(async (address) => {
202
- const accData = await _getCurveUsdUserData(client, network, address, market, crvUsdMarketsData[market.value].activeBand);
203
- if (new Dec(accData.suppliedUsd).gt(0) || new Dec(accData.borrowedUsd).gt(0)) {
204
- positions[address.toLowerCase() as EthAddress].crvUsd[market.value] = { ...accData, borrowRate: crvUsdMarketsData[market.value].borrowRate };
261
+ try {
262
+ const accData = await _getCurveUsdUserData(client, network, address, market, crvUsdMarketsData[market.value].activeBand);
263
+ if (new Dec(accData.suppliedUsd).gt(0) || new Dec(accData.borrowedUsd).gt(0)) {
264
+ positions[address.toLowerCase() as EthAddress].crvUsd[market.value] = { error: '', data: { ...accData, borrowRate: crvUsdMarketsData[market.value].borrowRate } };
265
+ }
266
+ } catch (error) {
267
+ console.error(`Error fetching Curve USD account data for address ${address} on market ${market.value}:`, error);
268
+ positions[address.toLowerCase() as EthAddress].crvUsd[market.value] = { error: `Error fetching Curve USD account data for address ${address} on market ${market.value}`, data: null };
205
269
  }
206
270
  })).flat(),
207
271
  ...llamaLendMarkets.map((market) => addresses.map(async (address) => {
208
- const accData = await _getLlamaLendUserData(client, network, address, market, llamaLendMarketsData[market.value]);
209
- if (new Dec(accData.suppliedUsd).gt(0) || new Dec(accData.borrowedUsd).gt(0)) {
210
- positions[address.toLowerCase() as EthAddress].llamaLend[market.value] = { ...accData, borrowRate: llamaLendMarketsData[market.value].borrowRate };
272
+ try {
273
+ const accData = await _getLlamaLendUserData(client, network, address, market, llamaLendMarketsData[market.value]);
274
+ if (new Dec(accData.suppliedUsd).gt(0) || new Dec(accData.borrowedUsd).gt(0)) {
275
+ positions[address.toLowerCase() as EthAddress].llamaLend[market.value] = { error: '', data: { ...accData, borrowRate: llamaLendMarketsData[market.value].borrowRate } };
276
+ }
277
+ } catch (error) {
278
+ console.error(`Error fetching LlamaLend account data for address ${address} on market ${market.value}:`, error);
279
+ positions[address.toLowerCase() as EthAddress].llamaLend[market.value] = { error: `Error fetching LlamaLend account data for address ${address} on market ${market.value}`, data: null };
211
280
  }
212
281
  })).flat(),
213
282
  ]);
@@ -11,41 +11,49 @@ import { CdpData } from './maker';
11
11
  import { MorphoBluePositionData, MorphoBlueVersions } from './morphoBlue';
12
12
  import { SparkPositionData, SparkVersions } from './spark';
13
13
 
14
+ export interface PortfolioProtocolData<T> {
15
+ error: string,
16
+ data: T | null,
17
+ }
18
+
14
19
  export interface PortfolioPositionsDataForAddress {
15
20
  aaveV3: {
16
- [key in AaveVersions]?: AaveV3PositionData;
21
+ [key in AaveVersions]?: PortfolioProtocolData<AaveV3PositionData>;
17
22
  };
18
23
  morphoBlue: {
19
- [key in MorphoBlueVersions]?: MorphoBluePositionData;
24
+ [key in MorphoBlueVersions]?: PortfolioProtocolData<MorphoBluePositionData>;
20
25
  };
21
26
  compoundV3: {
22
- [key in CompoundVersions]?: CompoundV3PositionData;
27
+ [key in CompoundVersions]?: PortfolioProtocolData<CompoundV3PositionData>;
23
28
  };
24
29
  spark: {
25
- [key in SparkVersions]?: SparkPositionData;
26
- }
30
+ [key in SparkVersions]?: PortfolioProtocolData<SparkPositionData>;
31
+ };
27
32
  eulerV2: {
28
- [key in EulerV2Versions]?: Record<EthAddress, EulerV2PositionData>;
33
+ [key in EulerV2Versions]?: Record<EthAddress, PortfolioProtocolData<EulerV2PositionData>>;
29
34
  };
30
35
  maker: {
31
- [key: string]: CdpData;
36
+ [key: string]: PortfolioProtocolData<CdpData>;
32
37
  };
33
38
  aaveV2: {
34
- [key in AaveVersions]?: AaveV2PositionData;
39
+ [key in AaveVersions]?: PortfolioProtocolData<AaveV2PositionData>;
35
40
  };
36
41
  compoundV2: {
37
- [key in CompoundVersions]?: CompoundV2PositionData;
42
+ [key in CompoundVersions]?: PortfolioProtocolData<CompoundV2PositionData>;
38
43
  };
39
- liquity: LiquityTroveInfo | {};
44
+ liquity: PortfolioProtocolData<LiquityTroveInfo> | {};
40
45
  crvUsd: {
41
- [key in CrvUSDVersions]?: CrvUSDUserData;
46
+ [key in CrvUSDVersions]?: PortfolioProtocolData<CrvUSDUserData>;
42
47
  };
43
48
  llamaLend: {
44
- [key in LlamaLendVersionsType]?: LlamaLendUserData;
49
+ [key in LlamaLendVersionsType]?: PortfolioProtocolData<LlamaLendUserData>;
45
50
  };
46
51
  fluid: {
47
- [key: string]: FluidVaultData;
48
- }
52
+ error: string;
53
+ data: {
54
+ [key: string]: FluidVaultData;
55
+ };
56
+ };
49
57
  }
50
58
 
51
59
  export interface PortfolioPositionsData {