@1delta/margin-fetcher 0.0.306 → 0.0.308
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.
package/dist/index.js
CHANGED
|
@@ -6917,6 +6917,7 @@ var Chain = /* @__PURE__ */ ((Chain2) => {
|
|
|
6917
6917
|
Chain2["AREON_NETWORK_MAINNET"] = "463";
|
|
6918
6918
|
Chain2["MST_CHAIN"] = "4646";
|
|
6919
6919
|
Chain2["APPCHAIN"] = "466";
|
|
6920
|
+
Chain2["ROBINHOOD_CHAIN"] = "4663";
|
|
6920
6921
|
Chain2["IOTEX_NETWORK_MAINNET"] = "4689";
|
|
6921
6922
|
Chain2["ACRIA_INTELLICHAIN"] = "47";
|
|
6922
6923
|
Chain2["ULTRA_PRO_MAINNET"] = "473861";
|
|
@@ -11413,7 +11414,9 @@ function createBaseTypeUserState(payload, lenderData, totalDeposits24h = 0, tota
|
|
|
11413
11414
|
collateralAllActive += (userConfigForAsset?.collateralFactor ?? 1) * depositsUSDOracle;
|
|
11414
11415
|
}
|
|
11415
11416
|
depositInterest += depositRate * depositsUSD;
|
|
11416
|
-
|
|
11417
|
+
const posStableRate = Number(pos.stableBorrowRate);
|
|
11418
|
+
const effStableBorrowRate = Number.isFinite(posStableRate) && posStableRate > 0 ? posStableRate : stableBorrowRate;
|
|
11419
|
+
borrowInterest += debtStableUSD * effStableBorrowRate + debtUSD * variableBorrowRate;
|
|
11417
11420
|
}
|
|
11418
11421
|
const nav = deposits - debt;
|
|
11419
11422
|
const balanceData2 = {
|
|
@@ -23177,10 +23180,12 @@ function createMorphoEntryFromMarketWithLens(balanceInfo, metaMap, chainId, lend
|
|
|
23177
23180
|
};
|
|
23178
23181
|
};
|
|
23179
23182
|
let sumFixedRaw = 0n;
|
|
23183
|
+
let weightedAprNumerator = 0;
|
|
23180
23184
|
for (const loan of brokerData.fixedLoans) {
|
|
23181
23185
|
const trancheRaw = BigInt(loan.outstanding) + BigInt(loan.accruedInterest);
|
|
23182
23186
|
sumFixedRaw += trancheRaw;
|
|
23183
23187
|
const trancheToken = parseRawAmount(trancheRaw.toString(), loanDecimals);
|
|
23188
|
+
weightedAprNumerator += Number(trancheToken) * loan.apr;
|
|
23184
23189
|
mkTermPosition(`${loanMarketUid}#${loan.posId}`, trancheToken, {
|
|
23185
23190
|
loanId: loan.posId,
|
|
23186
23191
|
termId: loan.termId,
|
|
@@ -23203,12 +23208,18 @@ function createMorphoEntryFromMarketWithLens(balanceInfo, metaMap, chainId, lend
|
|
|
23203
23208
|
dataForLoanAsset.debtStable = fixedToken;
|
|
23204
23209
|
dataForLoanAsset.debtStableUSD = Number(fixedToken) * priceLoan;
|
|
23205
23210
|
dataForLoanAsset.debtStableUSDOracle = Number(fixedToken) * oraclePriceLoan;
|
|
23211
|
+
const fixedTokenNum = Number(fixedToken);
|
|
23212
|
+
dataForLoanAsset.stableBorrowRate = fixedTokenNum > 0 ? (weightedAprNumerator / fixedTokenNum).toString() : "0";
|
|
23206
23213
|
aggregateDebtToken = parseRawAmount(totalRaw.toString(), loanDecimals);
|
|
23207
23214
|
if (dynRaw > 0n) {
|
|
23208
23215
|
mkTermPosition(`${loanMarketUid}#dynamic`, dynToken, {
|
|
23209
23216
|
loanId: LISTA_DYNAMIC_LOAN_ID,
|
|
23210
23217
|
isDynamic: true,
|
|
23211
|
-
debt: dynToken
|
|
23218
|
+
debt: dynToken,
|
|
23219
|
+
// the flexible loan accrues at the underlying Moolah market's variable borrow rate
|
|
23220
|
+
// (PERCENT). Expired fixed positions refinance into this dynamic loan, so without
|
|
23221
|
+
// this the migrated debt would (incorrectly) report a 0% borrow rate.
|
|
23222
|
+
apr: loanAssetMeta?.variableBorrowRate ?? 0
|
|
23212
23223
|
});
|
|
23213
23224
|
}
|
|
23214
23225
|
}
|