@1delta/margin-fetcher 5.0.85 → 5.0.86

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
@@ -16364,6 +16364,16 @@ function getKineticRates(info, chainId) {
16364
16364
  // src/lending/public-data/compound-v2/convert/types.ts
16365
16365
  var PRICE_DECIMALS = 18;
16366
16366
  var RESERVE_MANTISSA_DECIMALS = 18;
16367
+ var resolveMarketPrice = (prices, asset, chainId) => {
16368
+ const group = asset?.assetGroup;
16369
+ if (group != null && prices[group] != null) return prices[group];
16370
+ const address = asset?.address?.toLowerCase();
16371
+ if (address != null) {
16372
+ const fallback = prices[`${chainId}-${address}`];
16373
+ if (fallback != null) return fallback;
16374
+ }
16375
+ return 0;
16376
+ };
16367
16377
 
16368
16378
  // src/lending/public-data/compound-v2/convert/risk.ts
16369
16379
  var DEFAULT_CLOSE_FACTOR = 0.5;
@@ -16429,7 +16439,7 @@ function convertSingleEntry(opts) {
16429
16439
  parseRawAmount(currentEntry?.totalBorrows?.toString(), decs)
16430
16440
  );
16431
16441
  const liquidity = cashLiquidity(currentEntry?.totalCash ?? currentEntry?.cash, decs) ?? totalSupplyUnderlying - totalDebt;
16432
- const price2 = prices[asset.assetGroup] ?? 0;
16442
+ const price2 = resolveMarketPrice(prices, asset, chainId);
16433
16443
  const pausedActions = { ...currentEntry.pausedActions };
16434
16444
  if (opts.pause?.mintPaused !== void 0)
16435
16445
  pausedActions[0 /* MINT */] = opts.pause.mintPaused;
@@ -16519,7 +16529,7 @@ function convertSumerEntry(opts) {
16519
16529
  parseRawAmount(currentEntry.totalBorrows?.toString(), decs)
16520
16530
  );
16521
16531
  const liquidity = cashLiquidity(currentEntry?.totalCash, decs) ?? totalSupplyUnderlying - totalDebt;
16522
- const price2 = prices[asset.assetGroup] ?? 0;
16532
+ const price2 = resolveMarketPrice(prices, asset, chainId);
16523
16533
  const poolId = asset.address;
16524
16534
  const collateralActive = Boolean(currentEntry.isListed);
16525
16535
  const borrowingEnabled = Boolean(currentEntry.isBorrowAllowed);
@@ -16611,7 +16621,7 @@ function convertTakaraEntry(opts) {
16611
16621
  const { entryRaw, asset, chainId, lender, prices, additionalYields, cToken } = opts;
16612
16622
  const info = parseTakaraMarketsInfo(entryRaw);
16613
16623
  const rates = getTakaraRates(info);
16614
- const price2 = prices[asset.assetGroup] ?? 0;
16624
+ const price2 = resolveMarketPrice(prices, asset, chainId);
16615
16625
  const collateralFactor = Number(
16616
16626
  parseRawAmount(info.ltv.toString(), RESERVE_MANTISSA_DECIMALS)
16617
16627
  );
@@ -16690,7 +16700,7 @@ function convertTectonicEntry(opts) {
16690
16700
  const { entryRaw, asset, chainId, lender, prices, additionalYields, cToken } = opts;
16691
16701
  const info = parseTectonicMarketData(entryRaw);
16692
16702
  const rates = getTectonicRates(info, chainId);
16693
- const price2 = prices[asset.assetGroup] ?? 0;
16703
+ const price2 = resolveMarketPrice(prices, asset, chainId);
16694
16704
  const decs = asset.decimals;
16695
16705
  const collateralFactor = Number(
16696
16706
  parseRawAmount(info.collateralFactor.toString(), RESERVE_MANTISSA_DECIMALS)
@@ -16859,7 +16869,7 @@ function getBenqiRates(info, chainId, unitSeconds) {
16859
16869
  function convertBenqiEntry(opts) {
16860
16870
  const { parsed, asset, chainId, lender, prices, additionalYields, cToken } = opts;
16861
16871
  const rates = getBenqiRates(parsed, chainId);
16862
- const price2 = prices[asset.assetGroup] ?? 0;
16872
+ const price2 = resolveMarketPrice(prices, asset, chainId);
16863
16873
  const decs = asset.decimals;
16864
16874
  const collateralFactor = Number(
16865
16875
  parseRawAmount(
@@ -16932,7 +16942,7 @@ function convertBenqiEntry(opts) {
16932
16942
  function convertKineticEntry(opts) {
16933
16943
  const { parsed, asset, chainId, lender, prices, additionalYields, cToken } = opts;
16934
16944
  const rates = getKineticRates(parsed, chainId);
16935
- const price2 = prices[asset.assetGroup] ?? 0;
16945
+ const price2 = resolveMarketPrice(prices, asset, chainId);
16936
16946
  const decs = asset.decimals;
16937
16947
  const collateralFactor = Number(
16938
16948
  parseRawAmount(
@@ -59641,6 +59651,20 @@ function pruneFeedStats(stats, maxAgeSeconds = 30 * 24 * 3600, nowSeconds = Math
59641
59651
  // src/prices/oracle-prices/selectAssetGroupPrices.ts
59642
59652
  var DEFAULT_STALE_REJECT_SECONDS = 172800;
59643
59653
  var AAVE_V4_PREFIX = "AAVE_V4";
59654
+ var PLACEHOLDER_GROUP_SEGMENTS = {
59655
+ undefined: true,
59656
+ "0x": true,
59657
+ unknown: true,
59658
+ "unknown token": true,
59659
+ unk: true,
59660
+ "n/a": true,
59661
+ na: true,
59662
+ none: true,
59663
+ "?": true,
59664
+ "-": true
59665
+ };
59666
+ var isPlaceholderSegment = (segment) => PLACEHOLDER_GROUP_SEGMENTS[segment.trim().toLowerCase()] === true;
59667
+ var isPlaceholderGroup = (group) => group.split("::").some(isPlaceholderSegment);
59644
59668
  var DEFAULT_PRIORITY = {
59645
59669
  chainPriority: [
59646
59670
  Chain.ETHEREUM_MAINNET,
@@ -59747,7 +59771,9 @@ function selectAssetGroupPrices(structuredPrices, lists = {}, depthOrTvl = {}, p
59747
59771
  staleRejectSeconds,
59748
59772
  nowSeconds
59749
59773
  ) : "unknown";
59750
- const oracleKey = tokenList[entry.asset]?.assetGroup ?? `${chainId}-${entry.asset.toLowerCase()}`;
59774
+ const group = tokenList[entry.asset]?.assetGroup;
59775
+ if (group != null && isPlaceholderGroup(group)) continue;
59776
+ const oracleKey = group ?? `${chainId}-${entry.asset.toLowerCase()}`;
59751
59777
  const candidate = {
59752
59778
  oracleKey,
59753
59779
  priceUSD: entry.priceUSD,