@defisaver/positions-sdk 2.1.127-midnight-10-dev → 2.1.127-midnight-11-dev

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.
@@ -169,12 +169,14 @@ function _getMorphoMidnightAccountData(provider, network, account, selectedMarke
169
169
  if (new decimal_js_1.default(positionInfo.debt.toString()).gt(0)) {
170
170
  try {
171
171
  const borrowInfo = yield (0, morphoMidnightHelpers_1.getMorphoMidnightUserBorrowInfo)(account, marketId, marketInfo.loanToken);
172
- borrowRate = borrowInfo.borrowRate;
173
- debtBase = borrowInfo.debtBase;
174
- debtInterest = borrowInfo.debtInterest;
175
- usedAssets[marketInfo.loanToken].borrowRate = borrowRate;
176
- // Reflect the real borrow cost in netApy without mutating the shared marketInfo.assetsData.
177
- assetsDataForApy = Object.assign(Object.assign({}, marketInfo.assetsData), { [marketInfo.loanToken]: Object.assign(Object.assign({}, loanTokenData), { borrowRate }) });
172
+ if (new decimal_js_1.default(borrowInfo.debtTotal).gt(0)) {
173
+ borrowRate = borrowInfo.borrowRate;
174
+ debtBase = borrowInfo.debtBase;
175
+ debtInterest = borrowInfo.debtInterest;
176
+ usedAssets[marketInfo.loanToken].borrowRate = borrowRate;
177
+ // Reflect the real borrow cost in netApy without mutating the shared marketInfo.assetsData.
178
+ assetsDataForApy = Object.assign(Object.assign({}, marketInfo.assetsData), { [marketInfo.loanToken]: Object.assign(Object.assign({}, loanTokenData), { borrowRate }) });
179
+ }
178
180
  }
179
181
  catch (err) {
180
182
  // Orderbook API unavailable — keep the on-chain-only fallback above.
@@ -158,12 +158,14 @@ export function _getMorphoMidnightAccountData(provider, network, account, select
158
158
  if (new Dec(positionInfo.debt.toString()).gt(0)) {
159
159
  try {
160
160
  const borrowInfo = yield getMorphoMidnightUserBorrowInfo(account, marketId, marketInfo.loanToken);
161
- borrowRate = borrowInfo.borrowRate;
162
- debtBase = borrowInfo.debtBase;
163
- debtInterest = borrowInfo.debtInterest;
164
- usedAssets[marketInfo.loanToken].borrowRate = borrowRate;
165
- // Reflect the real borrow cost in netApy without mutating the shared marketInfo.assetsData.
166
- assetsDataForApy = Object.assign(Object.assign({}, marketInfo.assetsData), { [marketInfo.loanToken]: Object.assign(Object.assign({}, loanTokenData), { borrowRate }) });
161
+ if (new Dec(borrowInfo.debtTotal).gt(0)) {
162
+ borrowRate = borrowInfo.borrowRate;
163
+ debtBase = borrowInfo.debtBase;
164
+ debtInterest = borrowInfo.debtInterest;
165
+ usedAssets[marketInfo.loanToken].borrowRate = borrowRate;
166
+ // Reflect the real borrow cost in netApy without mutating the shared marketInfo.assetsData.
167
+ assetsDataForApy = Object.assign(Object.assign({}, marketInfo.assetsData), { [marketInfo.loanToken]: Object.assign(Object.assign({}, loanTokenData), { borrowRate }) });
168
+ }
167
169
  }
168
170
  catch (err) {
169
171
  // Orderbook API unavailable — keep the on-chain-only fallback above.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/positions-sdk",
3
- "version": "2.1.127-midnight-10-dev",
3
+ "version": "2.1.127-midnight-11-dev",
4
4
  "description": "",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
@@ -167,15 +167,17 @@ export async function _getMorphoMidnightAccountData(provider: Client, network: N
167
167
  if (new Dec(positionInfo.debt.toString()).gt(0)) {
168
168
  try {
169
169
  const borrowInfo = await getMorphoMidnightUserBorrowInfo(account, marketId, marketInfo.loanToken);
170
- borrowRate = borrowInfo.borrowRate;
171
- debtBase = borrowInfo.debtBase;
172
- debtInterest = borrowInfo.debtInterest;
173
- usedAssets[marketInfo.loanToken].borrowRate = borrowRate;
174
- // Reflect the real borrow cost in netApy without mutating the shared marketInfo.assetsData.
175
- assetsDataForApy = {
176
- ...marketInfo.assetsData,
177
- [marketInfo.loanToken]: { ...loanTokenData, borrowRate },
178
- };
170
+ if (new Dec(borrowInfo.debtTotal).gt(0)) {
171
+ borrowRate = borrowInfo.borrowRate;
172
+ debtBase = borrowInfo.debtBase;
173
+ debtInterest = borrowInfo.debtInterest;
174
+ usedAssets[marketInfo.loanToken].borrowRate = borrowRate;
175
+ // Reflect the real borrow cost in netApy without mutating the shared marketInfo.assetsData.
176
+ assetsDataForApy = {
177
+ ...marketInfo.assetsData,
178
+ [marketInfo.loanToken]: { ...loanTokenData, borrowRate },
179
+ };
180
+ }
179
181
  } catch (err) {
180
182
  // Orderbook API unavailable — keep the on-chain-only fallback above.
181
183
  }