@defisaver/positions-sdk 1.0.26-dev-portfolio-8 → 1.0.26-dev-portfolio-10

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.
@@ -142,11 +142,15 @@ const getChainLinkPricesForTokens = (tokens, network, client) => __awaiter(void
142
142
  }
143
143
  default:
144
144
  // @ts-ignore
145
- if (!results[i + offset].result[1])
146
- acc[token] = '0';
147
- // @ts-ignore
148
- else
145
+ if (results[i + offset].result[1]) {
146
+ // @ts-ignore
149
147
  acc[token] = new decimal_js_1.default(results[i + offset].result[1].toString()).div(1e8).toString();
148
+ }
149
+ else if (results[i + offset].result) {
150
+ acc[token] = new decimal_js_1.default(results[i + offset].result.toString()).div(1e8).toString();
151
+ }
152
+ else
153
+ acc[token] = '0';
150
154
  break;
151
155
  }
152
156
  return acc;
@@ -236,7 +236,7 @@ function getPortfolioDataSlower(provider, network, addresses) {
236
236
  ...llamaLendMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
237
237
  const accData = yield (0, llamaLend_1._getLlamaLendUserData)(client, network, address, market, llamaLendMarketsData[market.value]);
238
238
  if (new decimal_js_1.default(accData.suppliedUsd).gt(0) || new decimal_js_1.default(accData.borrowedUsd).gt(0)) {
239
- positions[address.toLowerCase()].llamaLend[market.value] = accData;
239
+ positions[address.toLowerCase()].llamaLend[market.value] = Object.assign(Object.assign({}, accData), { borrowRate: llamaLendMarketsData[market.value].borrowRate });
240
240
  }
241
241
  }))).flat(),
242
242
  ...liquityV2Markets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
@@ -151,4 +151,6 @@ export interface LlamaLendUserData {
151
151
  suppliedForYieldUsd: string;
152
152
  safetyRatio: string;
153
153
  userBands: UserBandData[];
154
+ loanExists: boolean;
155
+ borrowRate?: string;
154
156
  }
@@ -136,11 +136,15 @@ const getChainLinkPricesForTokens = (tokens, network, client) => __awaiter(void
136
136
  }
137
137
  default:
138
138
  // @ts-ignore
139
- if (!results[i + offset].result[1])
140
- acc[token] = '0';
141
- // @ts-ignore
142
- else
139
+ if (results[i + offset].result[1]) {
140
+ // @ts-ignore
143
141
  acc[token] = new Dec(results[i + offset].result[1].toString()).div(1e8).toString();
142
+ }
143
+ else if (results[i + offset].result) {
144
+ acc[token] = new Dec(results[i + offset].result.toString()).div(1e8).toString();
145
+ }
146
+ else
147
+ acc[token] = '0';
144
148
  break;
145
149
  }
146
150
  return acc;
@@ -229,7 +229,7 @@ export function getPortfolioDataSlower(provider, network, addresses) {
229
229
  ...llamaLendMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
230
230
  const accData = yield _getLlamaLendUserData(client, network, address, market, llamaLendMarketsData[market.value]);
231
231
  if (new Dec(accData.suppliedUsd).gt(0) || new Dec(accData.borrowedUsd).gt(0)) {
232
- positions[address.toLowerCase()].llamaLend[market.value] = accData;
232
+ positions[address.toLowerCase()].llamaLend[market.value] = Object.assign(Object.assign({}, accData), { borrowRate: llamaLendMarketsData[market.value].borrowRate });
233
233
  }
234
234
  }))).flat(),
235
235
  ...liquityV2Markets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
@@ -151,4 +151,6 @@ export interface LlamaLendUserData {
151
151
  suppliedForYieldUsd: string;
152
152
  safetyRatio: string;
153
153
  userBands: UserBandData[];
154
+ loanExists: boolean;
155
+ borrowRate?: string;
154
156
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/positions-sdk",
3
- "version": "1.0.26-dev-portfolio-8",
3
+ "version": "1.0.26-dev-portfolio-10",
4
4
  "description": "",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
@@ -189,9 +189,12 @@ const getChainLinkPricesForTokens = async (
189
189
 
190
190
  default:
191
191
  // @ts-ignore
192
- if (!results[i + offset].result[1]) acc[token] = '0';
193
- // @ts-ignore
194
- else acc[token] = new Dec(results[i + offset].result[1]!.toString() as string).div(1e8).toString();
192
+ if (results[i + offset].result[1]) {
193
+ // @ts-ignore
194
+ acc[token] = new Dec(results[i + offset].result[1]!.toString() as string).div(1e8).toString();
195
+ } else if (results[i + offset].result) {
196
+ acc[token] = new Dec(results[i + offset].result!.toString() as string).div(1e8).toString();
197
+ } else acc[token] = '0';
195
198
  break;
196
199
  }
197
200
  return acc;
@@ -1155,7 +1158,6 @@ const parseT4UserData = (userPositionData: FluidUserPositionStructOutputStruct,
1155
1158
  ...EMPTY_FLUID_DATA,
1156
1159
  lastUpdated: Date.now(),
1157
1160
  };
1158
-
1159
1161
  const collAsset0 = getAssetInfo(marketData.collAsset0);
1160
1162
  const collAsset1 = getAssetInfo(marketData.collAsset1);
1161
1163
  const debtAsset0 = getAssetInfo(marketData.debtAsset0);
@@ -239,7 +239,7 @@ export async function getPortfolioDataSlower(provider: EthereumProvider, network
239
239
  ...llamaLendMarkets.map((market) => addresses.map(async (address) => {
240
240
  const accData = await _getLlamaLendUserData(client, network, address, market, llamaLendMarketsData[market.value]);
241
241
  if (new Dec(accData.suppliedUsd).gt(0) || new Dec(accData.borrowedUsd).gt(0)) {
242
- positions[address.toLowerCase() as EthAddress].llamaLend[market.value] = accData;
242
+ positions[address.toLowerCase() as EthAddress].llamaLend[market.value] = { ...accData, borrowRate: llamaLendMarketsData[market.value].borrowRate };
243
243
  }
244
244
  })).flat(),
245
245
  ...liquityV2Markets.map((market) => addresses.map(async (address) => {
@@ -152,4 +152,6 @@ export interface LlamaLendUserData {
152
152
  suppliedForYieldUsd: string,
153
153
  safetyRatio: string,
154
154
  userBands: UserBandData[],
155
+ loanExists: boolean,
156
+ borrowRate?: string,
155
157
  }