@pear-protocol/symmio-client 0.2.30 → 0.2.31

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.
@@ -25998,6 +25998,12 @@ function useSymmChartSelection(input) {
25998
25998
  }
25999
25999
 
26000
26000
  // src/utils/chart-metrics.ts
26001
+ function normalizeWeight(weight) {
26002
+ if (!Number.isFinite(weight) || weight <= 0) {
26003
+ return 0;
26004
+ }
26005
+ return weight <= 1 ? weight : weight / 100;
26006
+ }
26001
26007
  function getPositiveValue(metadata, field) {
26002
26008
  const value = metadata?.[field];
26003
26009
  if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
@@ -26017,7 +26023,8 @@ function computeWeightedProduct(tokens, metadataMap, field, invert = false) {
26017
26023
  return null;
26018
26024
  }
26019
26025
  hasToken = true;
26020
- const exponent = invert ? -(token.weight / 100) : token.weight / 100;
26026
+ const normalizedWeight = normalizeWeight(token.weight);
26027
+ const exponent = invert ? -normalizedWeight : normalizedWeight;
26021
26028
  product *= Math.pow(price, exponent);
26022
26029
  }
26023
26030
  return hasToken ? product : 1;
@@ -26244,7 +26251,6 @@ function useSymmTokenSelectionMetadata(selection, options = {}) {
26244
26251
  const weightedRatio24h = computeWeightedRatio24h(metricInput) ?? 0;
26245
26252
  const sumNetFunding = computeNetFundingSum(metricInput);
26246
26253
  return {
26247
- query,
26248
26254
  isLoading,
26249
26255
  isPriceDataReady,
26250
26256
  isUnsupported,
@@ -26301,6 +26307,12 @@ function toBinanceInterval(interval) {
26301
26307
  }
26302
26308
 
26303
26309
  // src/react/hooks/use-symm-chart-candles.ts
26310
+ function normalizeWeight2(weight) {
26311
+ if (!Number.isFinite(weight) || weight <= 0) {
26312
+ return 0;
26313
+ }
26314
+ return weight <= 1 ? weight : weight / 100;
26315
+ }
26304
26316
  function areIntervalsEqual(currentInterval, nextInterval) {
26305
26317
  return currentInterval === toBinanceInterval(nextInterval);
26306
26318
  }
@@ -26338,7 +26350,8 @@ function computeWeightedValues(tokens, candlesBySymbol, invert = false) {
26338
26350
  if (!(candle.o > 0 && candle.h > 0 && candle.l > 0 && candle.c > 0)) {
26339
26351
  return null;
26340
26352
  }
26341
- const exponent = invert ? -(token.weight / 100) : token.weight / 100;
26353
+ const normalizedWeight = normalizeWeight2(token.weight);
26354
+ const exponent = invert ? -normalizedWeight : normalizedWeight;
26342
26355
  o *= Math.pow(candle.o, exponent);
26343
26356
  h *= Math.pow(candle.h, exponent);
26344
26357
  l *= Math.pow(candle.l, exponent);