@deframe-sdk/components 0.1.67 → 0.1.69

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.mjs CHANGED
@@ -10384,6 +10384,24 @@ var GroupedStrategyListView = ({
10384
10384
  ] })
10385
10385
  ] });
10386
10386
  };
10387
+
10388
+ // src/utils/strategyDisplayName.ts
10389
+ function getNormalizedMetadataString(value) {
10390
+ if (typeof value !== "string") return "";
10391
+ return value.trim();
10392
+ }
10393
+ function getStrategyDisplayName(strategy) {
10394
+ var _a, _b;
10395
+ const displayName = getNormalizedMetadataString((_a = strategy == null ? void 0 : strategy.metadata) == null ? void 0 : _a.displayName);
10396
+ if (displayName) return displayName;
10397
+ return (_b = strategy == null ? void 0 : strategy.assetName) != null ? _b : "";
10398
+ }
10399
+ function getStrategyDisplayLogo(strategy) {
10400
+ var _a, _b;
10401
+ const displayLogo = getNormalizedMetadataString((_a = strategy == null ? void 0 : strategy.metadata) == null ? void 0 : _a.displayLogo);
10402
+ if (displayLogo) return displayLogo;
10403
+ return (_b = strategy == null ? void 0 : strategy.logourl) != null ? _b : "";
10404
+ }
10387
10405
  var wrapperBaseClasses = [
10388
10406
  "w-full max-w-[900px] mx-auto flex flex-col",
10389
10407
  "gap-[var(--deframe-widget-size-gap-md)]",
@@ -10435,25 +10453,6 @@ var GroupedStrategyListViewSimple = ({
10435
10453
  }) => {
10436
10454
  const category = categories.find((c) => c.id === categoryId);
10437
10455
  const categoryTitle = category == null ? void 0 : category.title;
10438
- const allClaimedAssets = React6__default.useMemo(() => {
10439
- const claimed = /* @__PURE__ */ new Set();
10440
- for (const category2 of categories) {
10441
- if (category2.assetFilter.length > 0) {
10442
- for (const symbol of category2.assetFilter) {
10443
- claimed.add(symbol.toUpperCase());
10444
- }
10445
- }
10446
- }
10447
- return claimed;
10448
- }, [categories]);
10449
- const filteredStrategies = React6__default.useMemo(() => {
10450
- const assetFilter = category == null ? void 0 : category.assetFilter;
10451
- if (!assetFilter || assetFilter.length === 0) {
10452
- return strategies.filter((s) => !allClaimedAssets.has(s.assetName.toUpperCase()));
10453
- }
10454
- const upperFilter = new Set(assetFilter.map((a) => a.toUpperCase()));
10455
- return strategies.filter((s) => upperFilter.has(s.assetName.toUpperCase()));
10456
- }, [strategies, category, allClaimedAssets]);
10457
10456
  if (isLoading) {
10458
10457
  return /* @__PURE__ */ jsxs("div", { "data-test-id": "grouped-strategy-list-view-simple-loading", className: twMerge(wrapperBaseClasses, className), children: [
10459
10458
  /* @__PURE__ */ jsx(Skeleton, { variant: "rect", width: "40%", height: 24 }),
@@ -10488,29 +10487,32 @@ var GroupedStrategyListViewSimple = ({
10488
10487
  }
10489
10488
  )
10490
10489
  ] }),
10491
- filteredStrategies.length === 0 ? /* @__PURE__ */ jsx("div", { "data-test-id": "grouped-strategy-list-view-simple-empty", className: emptyBoxClasses, children: /* @__PURE__ */ jsx("span", { className: "text-[length:var(--deframe-widget-font-size-sm)] text-[color:var(--deframe-widget-color-text-tertiary)] font-[var(--deframe-widget-font-family)]", children: emptyMessage }) }) : /* @__PURE__ */ jsx(
10490
+ strategies.length === 0 ? /* @__PURE__ */ jsx("div", { "data-test-id": "grouped-strategy-list-view-simple-empty", className: emptyBoxClasses, children: /* @__PURE__ */ jsx("span", { className: "text-[length:var(--deframe-widget-font-size-sm)] text-[color:var(--deframe-widget-color-text-tertiary)] font-[var(--deframe-widget-font-family)]", children: emptyMessage }) }) : /* @__PURE__ */ jsx(
10492
10491
  "div",
10493
10492
  {
10494
10493
  "data-test-id": "grouped-strategy-list-view-simple-items",
10495
10494
  className: "flex flex-col gap-[var(--deframe-widget-size-gap-sm)]",
10496
- children: filteredStrategies.map((s) => /* @__PURE__ */ jsx(
10497
- StrategyGridCardSimple,
10498
- {
10499
- logoUrl: s.logourl,
10500
- title: s.assetName,
10501
- subtitle: s.assetName,
10502
- chainName: s.network,
10503
- apyFormatted: s.apyFormatted,
10504
- apyLabel: yieldLabel,
10505
- riskLevel: "low",
10506
- onInvestClick: onDeposit ? () => onDeposit(s.id) : () => {
10507
- },
10508
- onWithdrawClick: onWithdraw ? () => onWithdraw(s.id) : () => {
10495
+ children: strategies.map((s) => {
10496
+ const displayName = getStrategyDisplayName(s);
10497
+ return /* @__PURE__ */ jsx(
10498
+ StrategyGridCardSimple,
10499
+ {
10500
+ logoUrl: getStrategyDisplayLogo(s),
10501
+ title: displayName,
10502
+ subtitle: displayName,
10503
+ chainName: s.network,
10504
+ apyFormatted: s.apyFormatted,
10505
+ apyLabel: yieldLabel,
10506
+ riskLevel: "low",
10507
+ onInvestClick: onDeposit ? () => onDeposit(s.id) : () => {
10508
+ },
10509
+ onWithdrawClick: onWithdraw ? () => onWithdraw(s.id) : () => {
10510
+ },
10511
+ labels: { investLabel, riskLow, riskMedium, riskHigh }
10509
10512
  },
10510
- labels: { investLabel, riskLow, riskMedium, riskHigh }
10511
- },
10512
- s.id
10513
- ))
10513
+ s.id
10514
+ );
10515
+ })
10514
10516
  }
10515
10517
  )
10516
10518
  ] });
@@ -11293,13 +11295,11 @@ function buildEarnHistoryByAsset(items, { currency, locale, formatCurrency, onHi
11293
11295
  var EARN_CATEGORY_DEFINITIONS = [
11294
11296
  {
11295
11297
  id: "dolar",
11296
- imageUrl: mascotUsdUrl,
11297
- assetFilter: ["USDC", "USDT", "DAI", "thbill"]
11298
+ imageUrl: mascotUsdUrl
11298
11299
  },
11299
11300
  {
11300
11301
  id: "real",
11301
- imageUrl: mascotBrlUrl,
11302
- assetFilter: ["BRLA"]
11302
+ imageUrl: mascotBrlUrl
11303
11303
  }
11304
11304
  ];
11305
11305
  var wrapperBaseClasses2 = [
@@ -11362,12 +11362,11 @@ var BANNER_COLORS = [
11362
11362
  "var(--deframe-widget-color-brand-primary)",
11363
11363
  "var(--deframe-widget-color-brand-secondary)"
11364
11364
  ];
11365
- var STABLECOIN_SYMBOLS = /* @__PURE__ */ new Set(["USDC", "USDT", "DAI"]);
11366
11365
  var DEFAULT_POSITIONS = { positions: [], summary: { totalUnderlyingBalanceUSD: 0, totalProfitInUSD: 0 } };
11367
11366
  var defaultFormatCurrency = (amount) => `$${amount.toFixed(2)}`;
11368
11367
  var EarnDesktopViewSimple = ({
11369
11368
  positions = DEFAULT_POSITIONS,
11370
- strategies = [],
11369
+ strategiesByCategory = {},
11371
11370
  historyItems = [],
11372
11371
  formatCurrency = defaultFormatCurrency,
11373
11372
  currency,
@@ -11383,6 +11382,7 @@ var EarnDesktopViewSimple = ({
11383
11382
  summary,
11384
11383
  categories
11385
11384
  }) => {
11385
+ var _a;
11386
11386
  const [activeCategoryId, setActiveCategoryId] = React6__default.useState(null);
11387
11387
  const totalEarnings = positions.summary.totalProfitInUSD;
11388
11388
  const statsCards = React6__default.useMemo(() => [
@@ -11391,25 +11391,24 @@ var EarnDesktopViewSimple = ({
11391
11391
  ], [positions.summary.totalUnderlyingBalanceUSD, totalEarnings, formatCurrency, labels == null ? void 0 : labels.totalInvestedLabel, labels == null ? void 0 : labels.totalInvestedDescription, labels == null ? void 0 : labels.accumulatedEarningsLabel, labels == null ? void 0 : labels.accumulatedEarningsDescription]);
11392
11392
  const categoryBanners = React6__default.useMemo(() => {
11393
11393
  return categories.map((category) => {
11394
- var _a;
11395
- const upperFilter = new Set(category.assetFilter.map((a) => a.toUpperCase()));
11394
+ var _a2, _b;
11395
+ const categoryStrategies = (_a2 = strategiesByCategory[category.id]) != null ? _a2 : [];
11396
11396
  let bestApy = null;
11397
- for (const strategy of strategies) {
11398
- if (upperFilter.has(strategy.assetName.toUpperCase()) && strategy.apy > ((_a = bestApy == null ? void 0 : bestApy.apy) != null ? _a : 0)) {
11397
+ for (const strategy of categoryStrategies) {
11398
+ if (strategy.apy > ((_b = bestApy == null ? void 0 : bestApy.apy) != null ? _b : 0)) {
11399
11399
  bestApy = strategy;
11400
11400
  }
11401
11401
  }
11402
- const isStablecoin = category.assetFilter.some((a) => STABLECOIN_SYMBOLS.has(a.toUpperCase()));
11403
11402
  return {
11404
11403
  id: category.id,
11405
11404
  imageUrl: category.imageUrl,
11406
11405
  alt: category.alt,
11407
11406
  apyFormatted: bestApy == null ? void 0 : bestApy.apyFormatted,
11408
- description: isStablecoin ? labels == null ? void 0 : labels.stablecoinsBannerDescription : labels == null ? void 0 : labels.realsBannerDescription,
11407
+ description: category.id === "dolar" ? labels == null ? void 0 : labels.stablecoinsBannerDescription : labels == null ? void 0 : labels.realsBannerDescription,
11409
11408
  handleClick: () => setActiveCategoryId(category.id)
11410
11409
  };
11411
11410
  });
11412
- }, [categories, strategies, labels == null ? void 0 : labels.stablecoinsBannerDescription, labels == null ? void 0 : labels.realsBannerDescription]);
11411
+ }, [categories, strategiesByCategory, labels == null ? void 0 : labels.stablecoinsBannerDescription, labels == null ? void 0 : labels.realsBannerDescription]);
11413
11412
  const cardLabels = React6__default.useMemo(() => ({
11414
11413
  investLabel: labels == null ? void 0 : labels.investLabel,
11415
11414
  withdrawLabel: labels == null ? void 0 : labels.cardWithdrawLabel,
@@ -11434,15 +11433,16 @@ var EarnDesktopViewSimple = ({
11434
11433
  );
11435
11434
  const strategyRows = React6__default.useMemo(() => {
11436
11435
  return formattedPositions.positions.filter((p) => p.spotPosition.underlyingBalanceUSD > 0.01).map((p) => {
11437
- var _a, _b;
11436
+ var _a2, _b;
11437
+ const strategyDisplayName = getStrategyDisplayName(p.strategy);
11438
11438
  return {
11439
- logoUrl: p.strategy.logourl,
11440
- assetName: p.strategy.assetName,
11439
+ logoUrl: getStrategyDisplayLogo(p.strategy),
11440
+ assetName: strategyDisplayName,
11441
11441
  network: p.strategy.network,
11442
11442
  investedFormatted: p.spotPosition.investedFormatted,
11443
11443
  earningsFormatted: `${(p.spotPosition.apy * 100).toFixed(2)}%`,
11444
11444
  profitFormatted: formatCurrency(p.spotPosition.profitInUSD),
11445
- totalValueFormatted: (_a = p.spotPosition.totalValueFormatted) != null ? _a : formatCurrency(p.spotPosition.underlyingBalanceUSD),
11445
+ totalValueFormatted: (_a2 = p.spotPosition.totalValueFormatted) != null ? _a2 : formatCurrency(p.spotPosition.underlyingBalanceUSD),
11446
11446
  isLoading: false,
11447
11447
  history: (_b = historyByAsset[p.strategy.assetName.toUpperCase()]) != null ? _b : [],
11448
11448
  onInvestClick: onDeposit ? () => onDeposit(p.strategy.id) : () => {
@@ -11467,7 +11467,7 @@ var EarnDesktopViewSimple = ({
11467
11467
  GroupedStrategyListViewSimple,
11468
11468
  {
11469
11469
  categoryId: activeCategoryId,
11470
- strategies,
11470
+ strategies: (_a = strategiesByCategory[activeCategoryId]) != null ? _a : [],
11471
11471
  isLoading,
11472
11472
  onBack: () => setActiveCategoryId(null),
11473
11473
  onDeposit,