@1delta/margin-fetcher 0.0.229 → 0.0.230

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
@@ -18772,11 +18772,11 @@ var getSiloV2ReservesDataConverter = (lender, chainId, prices, additionalYields,
18772
18772
  const assetMeta = tokenList[tokenAddrLc];
18773
18773
  const oracleKey = toOracleKey(assetMeta?.assetGroup ?? null) || toGenericPriceKey(tokenAddrLc, chainId);
18774
18774
  const price = prices[oracleKey] ?? 0;
18775
- const collateralLt = Number(other.lt) / 1e18;
18776
- const collateralMaxLtv = Number(other.maxLtv) / 1e18;
18777
18775
  const selfLt = Number(self.lt) / 1e18;
18778
- const borrowingEnabled = collateralLt > 0;
18776
+ const selfMaxLtv = Number(self.maxLtv) / 1e18;
18777
+ const otherLt = Number(other.lt) / 1e18;
18779
18778
  const collateralActive = selfLt > 0;
18779
+ const borrowingEnabled = otherLt > 0;
18780
18780
  const marketUid = createMarketUid(chainId, lender, self.silo);
18781
18781
  out[marketUid] = {
18782
18782
  marketUid,
@@ -18819,11 +18819,11 @@ var getSiloV2ReservesDataConverter = (lender, chainId, prices, additionalYields,
18819
18819
  config: {
18820
18820
  0: {
18821
18821
  category: 0,
18822
- borrowCollateralFactor: collateralMaxLtv,
18823
- collateralFactor: collateralLt,
18822
+ borrowCollateralFactor: selfMaxLtv,
18823
+ collateralFactor: selfLt,
18824
18824
  borrowFactor: 1,
18825
- collateralDisabled: !borrowingEnabled,
18826
- debtDisabled: !collateralActive
18825
+ collateralDisabled: !collateralActive,
18826
+ debtDisabled: !borrowingEnabled
18827
18827
  }
18828
18828
  },
18829
18829
  collateralActive,
@@ -18924,11 +18924,11 @@ var getSiloV3ReservesDataConverter = (lender, chainId, prices, additionalYields,
18924
18924
  const assetMeta = tokenList[tokenAddrLc];
18925
18925
  const oracleKey = toOracleKey(assetMeta?.assetGroup ?? null) || toGenericPriceKey(tokenAddrLc, chainId);
18926
18926
  const price = prices[oracleKey] ?? 0;
18927
- const collateralLt = Number(other.lt) / 1e18;
18928
- const collateralMaxLtv = Number(other.maxLtv) / 1e18;
18929
18927
  const selfLt = Number(self.lt) / 1e18;
18930
- const borrowingEnabled = collateralLt > 0;
18928
+ const selfMaxLtv = Number(self.maxLtv) / 1e18;
18929
+ const otherLt = Number(other.lt) / 1e18;
18931
18930
  const collateralActive = selfLt > 0;
18931
+ const borrowingEnabled = otherLt > 0;
18932
18932
  const marketUid = createMarketUid(chainId, lender, self.silo);
18933
18933
  out[marketUid] = {
18934
18934
  marketUid,
@@ -18963,11 +18963,11 @@ var getSiloV3ReservesDataConverter = (lender, chainId, prices, additionalYields,
18963
18963
  config: {
18964
18964
  0: {
18965
18965
  category: 0,
18966
- borrowCollateralFactor: collateralMaxLtv,
18967
- collateralFactor: collateralLt,
18966
+ borrowCollateralFactor: selfMaxLtv,
18967
+ collateralFactor: selfLt,
18968
18968
  borrowFactor: 1,
18969
- collateralDisabled: !borrowingEnabled,
18970
- debtDisabled: !collateralActive
18969
+ collateralDisabled: !collateralActive,
18970
+ debtDisabled: !borrowingEnabled
18971
18971
  }
18972
18972
  },
18973
18973
  collateralActive,
@@ -19424,21 +19424,20 @@ function convertSiloMarketsToPublicResponse(apiItems, chainId, prices, additiona
19424
19424
  const totalDebt = safeNumber(api.borrowed);
19425
19425
  const totalLiquidity = totalDeposits - totalDebt;
19426
19426
  const utilization = totalDeposits > 0 ? totalDebt / totalDeposits : safeNumber(api.utilization);
19427
- const variableBorrowRatePct = safeNumber(api.borrowRate) * 100;
19428
- const depositRatePct = safeNumber(api.depositRate) * 100;
19427
+ const variableBorrowRatePct = safeNumber(api.borrowRate);
19428
+ const depositRatePct = safeNumber(api.depositRate);
19429
19429
  const assetMeta = tokenList[tokenAddrLc];
19430
19430
  const oracleKey = toOracleKey(assetMeta?.assetGroup ?? null) || toGenericPriceKey(tokenAddrLc, chainId);
19431
19431
  const fallbackPrice = prices[oracleKey] ?? 0;
19432
19432
  const totalDepositsUSD = api.supplyUsd != null && api.supplyUsd > 0 ? api.supplyUsd : totalDeposits * fallbackPrice;
19433
19433
  const totalDebtUSD = api.borrowedUsd != null && api.borrowedUsd > 0 ? api.borrowedUsd : totalDebt * fallbackPrice;
19434
19434
  const totalLiquidityUSD = Math.max(totalDepositsUSD - totalDebtUSD, 0);
19435
- const collateralLt = safeLtvOrFee(api, "lt", other.lt);
19436
- const collateralMaxLtv = safeLtvOrFee(api, "maxLtv", other.maxLtv);
19435
+ const otherApi = sides[0].api === api ? apiSide1 : apiSide0;
19437
19436
  const selfLt = bigintToLtv(api.lt ?? self.lt);
19438
- const collateralLtFromApi = sides[0].api === api ? bigintToLtv(apiSide1.lt) : bigintToLtv(apiSide0.lt);
19439
- const collateralMaxLtvFromApi = sides[0].api === api ? bigintToLtv(apiSide1.maxLtv) : bigintToLtv(apiSide0.maxLtv);
19440
- const borrowingEnabled = (collateralLtFromApi || collateralLt) > 0;
19437
+ const selfMaxLtv = bigintToLtv(api.maxLtv ?? self.maxLtv);
19438
+ const otherLt = bigintToLtv(otherApi.lt ?? other.lt);
19441
19439
  const collateralActive = selfLt > 0;
19440
+ const borrowingEnabled = otherLt > 0;
19442
19441
  const siloAddrLc = self.silo.toLowerCase();
19443
19442
  const marketUid = createMarketUid(chainId, lenderKey, siloAddrLc);
19444
19443
  data[marketUid] = {
@@ -19476,11 +19475,11 @@ function convertSiloMarketsToPublicResponse(apiItems, chainId, prices, additiona
19476
19475
  config: {
19477
19476
  0: {
19478
19477
  category: 0,
19479
- borrowCollateralFactor: collateralMaxLtvFromApi || collateralMaxLtv,
19480
- collateralFactor: collateralLtFromApi || collateralLt,
19478
+ borrowCollateralFactor: selfMaxLtv,
19479
+ collateralFactor: selfLt,
19481
19480
  borrowFactor: 1,
19482
- collateralDisabled: !borrowingEnabled,
19483
- debtDisabled: !collateralActive
19481
+ collateralDisabled: !collateralActive,
19482
+ debtDisabled: !borrowingEnabled
19484
19483
  }
19485
19484
  },
19486
19485
  collateralActive,
@@ -19529,9 +19528,6 @@ function bigintToLtv(v) {
19529
19528
  return Number.isFinite(n) ? n / 1e18 : 0;
19530
19529
  }
19531
19530
  }
19532
- function safeLtvOrFee(api, field5, fallback) {
19533
- return bigintToLtv(api[field5] ?? fallback);
19534
- }
19535
19531
 
19536
19532
  // src/lending/public-data/silo-v3/convertPublic.ts
19537
19533
  var ZERO_ADDRESS2 = "0x0000000000000000000000000000000000000000";
@@ -19564,21 +19560,20 @@ function convertSiloV3MarketsToPublicResponse(apiItems, chainId, prices, additio
19564
19560
  const totalDebt = safeNumber2(api.borrowed);
19565
19561
  const totalLiquidity = totalDeposits - totalDebt;
19566
19562
  const utilization = totalDeposits > 0 ? totalDebt / totalDeposits : safeNumber2(api.utilization);
19567
- const variableBorrowRatePct = safeNumber2(api.borrowRate) * 100;
19568
- const depositRatePct = safeNumber2(api.depositRate) * 100;
19563
+ const variableBorrowRatePct = safeNumber2(api.borrowRate);
19564
+ const depositRatePct = safeNumber2(api.depositRate);
19569
19565
  const assetMeta = tokenList[tokenAddrLc];
19570
19566
  const oracleKey = toOracleKey(assetMeta?.assetGroup ?? null) || toGenericPriceKey(tokenAddrLc, chainId);
19571
19567
  const fallbackPrice = prices[oracleKey] ?? 0;
19572
19568
  const totalDepositsUSD = api.supplyUsd != null && api.supplyUsd > 0 ? api.supplyUsd : totalDeposits * fallbackPrice;
19573
19569
  const totalDebtUSD = api.borrowedUsd != null && api.borrowedUsd > 0 ? api.borrowedUsd : totalDebt * fallbackPrice;
19574
19570
  const totalLiquidityUSD = Math.max(totalDepositsUSD - totalDebtUSD, 0);
19575
- const collateralLt = safeLtvOrFee2(api, "lt", other.lt);
19576
- const collateralMaxLtv = safeLtvOrFee2(api, "maxLtv", other.maxLtv);
19571
+ const otherApi = sides[0].api === api ? apiSide1 : apiSide0;
19577
19572
  const selfLt = bigintToLtv2(api.lt ?? self.lt);
19578
- const collateralLtFromApi = sides[0].api === api ? bigintToLtv2(apiSide1.lt) : bigintToLtv2(apiSide0.lt);
19579
- const collateralMaxLtvFromApi = sides[0].api === api ? bigintToLtv2(apiSide1.maxLtv) : bigintToLtv2(apiSide0.maxLtv);
19580
- const borrowingEnabled = (collateralLtFromApi || collateralLt) > 0;
19573
+ const selfMaxLtv = bigintToLtv2(api.maxLtv ?? self.maxLtv);
19574
+ const otherLt = bigintToLtv2(otherApi.lt ?? other.lt);
19581
19575
  const collateralActive = selfLt > 0;
19576
+ const borrowingEnabled = otherLt > 0;
19582
19577
  const siloAddrLc = self.silo.toLowerCase();
19583
19578
  const marketUid = createMarketUid(chainId, lenderKey, siloAddrLc);
19584
19579
  data[marketUid] = {
@@ -19614,11 +19609,11 @@ function convertSiloV3MarketsToPublicResponse(apiItems, chainId, prices, additio
19614
19609
  config: {
19615
19610
  0: {
19616
19611
  category: 0,
19617
- borrowCollateralFactor: collateralMaxLtvFromApi || collateralMaxLtv,
19618
- collateralFactor: collateralLtFromApi || collateralLt,
19612
+ borrowCollateralFactor: selfMaxLtv,
19613
+ collateralFactor: selfLt,
19619
19614
  borrowFactor: 1,
19620
- collateralDisabled: !borrowingEnabled,
19621
- debtDisabled: !collateralActive
19615
+ collateralDisabled: !collateralActive,
19616
+ debtDisabled: !borrowingEnabled
19622
19617
  }
19623
19618
  },
19624
19619
  collateralActive,
@@ -19667,9 +19662,6 @@ function bigintToLtv2(v) {
19667
19662
  return Number.isFinite(n) ? n / 1e18 : 0;
19668
19663
  }
19669
19664
  }
19670
- function safeLtvOrFee2(api, field5, fallback) {
19671
- return bigintToLtv2(api[field5] ?? fallback);
19672
- }
19673
19665
 
19674
19666
  // src/lending/public-data/fetchLenderExt.ts
19675
19667
  async function getLenderDataFromApi(lender, chainId, prices, additionalYields, includeUnlisted = false) {