@deframe-sdk/components 0.1.68 → 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.d.mts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +15 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -37
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -10453,25 +10453,6 @@ var GroupedStrategyListViewSimple = ({
|
|
|
10453
10453
|
}) => {
|
|
10454
10454
|
const category = categories.find((c) => c.id === categoryId);
|
|
10455
10455
|
const categoryTitle = category == null ? void 0 : category.title;
|
|
10456
|
-
const allClaimedAssets = React6__default.useMemo(() => {
|
|
10457
|
-
const claimed = /* @__PURE__ */ new Set();
|
|
10458
|
-
for (const category2 of categories) {
|
|
10459
|
-
if (category2.assetFilter.length > 0) {
|
|
10460
|
-
for (const symbol of category2.assetFilter) {
|
|
10461
|
-
claimed.add(symbol.toUpperCase());
|
|
10462
|
-
}
|
|
10463
|
-
}
|
|
10464
|
-
}
|
|
10465
|
-
return claimed;
|
|
10466
|
-
}, [categories]);
|
|
10467
|
-
const filteredStrategies = React6__default.useMemo(() => {
|
|
10468
|
-
const assetFilter = category == null ? void 0 : category.assetFilter;
|
|
10469
|
-
if (!assetFilter || assetFilter.length === 0) {
|
|
10470
|
-
return strategies.filter((s) => !allClaimedAssets.has(s.assetName.toUpperCase()));
|
|
10471
|
-
}
|
|
10472
|
-
const upperFilter = new Set(assetFilter.map((a) => a.toUpperCase()));
|
|
10473
|
-
return strategies.filter((s) => upperFilter.has(s.assetName.toUpperCase()));
|
|
10474
|
-
}, [strategies, category, allClaimedAssets]);
|
|
10475
10456
|
if (isLoading) {
|
|
10476
10457
|
return /* @__PURE__ */ jsxs("div", { "data-test-id": "grouped-strategy-list-view-simple-loading", className: twMerge(wrapperBaseClasses, className), children: [
|
|
10477
10458
|
/* @__PURE__ */ jsx(Skeleton, { variant: "rect", width: "40%", height: 24 }),
|
|
@@ -10506,12 +10487,12 @@ var GroupedStrategyListViewSimple = ({
|
|
|
10506
10487
|
}
|
|
10507
10488
|
)
|
|
10508
10489
|
] }),
|
|
10509
|
-
|
|
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(
|
|
10510
10491
|
"div",
|
|
10511
10492
|
{
|
|
10512
10493
|
"data-test-id": "grouped-strategy-list-view-simple-items",
|
|
10513
10494
|
className: "flex flex-col gap-[var(--deframe-widget-size-gap-sm)]",
|
|
10514
|
-
children:
|
|
10495
|
+
children: strategies.map((s) => {
|
|
10515
10496
|
const displayName = getStrategyDisplayName(s);
|
|
10516
10497
|
return /* @__PURE__ */ jsx(
|
|
10517
10498
|
StrategyGridCardSimple,
|
|
@@ -11314,13 +11295,11 @@ function buildEarnHistoryByAsset(items, { currency, locale, formatCurrency, onHi
|
|
|
11314
11295
|
var EARN_CATEGORY_DEFINITIONS = [
|
|
11315
11296
|
{
|
|
11316
11297
|
id: "dolar",
|
|
11317
|
-
imageUrl: mascotUsdUrl
|
|
11318
|
-
assetFilter: ["USDC", "USDT", "DAI", "thbill", "podsUSDCy"]
|
|
11298
|
+
imageUrl: mascotUsdUrl
|
|
11319
11299
|
},
|
|
11320
11300
|
{
|
|
11321
11301
|
id: "real",
|
|
11322
|
-
imageUrl: mascotBrlUrl
|
|
11323
|
-
assetFilter: ["BRLA"]
|
|
11302
|
+
imageUrl: mascotBrlUrl
|
|
11324
11303
|
}
|
|
11325
11304
|
];
|
|
11326
11305
|
var wrapperBaseClasses2 = [
|
|
@@ -11383,12 +11362,11 @@ var BANNER_COLORS = [
|
|
|
11383
11362
|
"var(--deframe-widget-color-brand-primary)",
|
|
11384
11363
|
"var(--deframe-widget-color-brand-secondary)"
|
|
11385
11364
|
];
|
|
11386
|
-
var STABLECOIN_SYMBOLS = /* @__PURE__ */ new Set(["USDC", "USDT", "DAI"]);
|
|
11387
11365
|
var DEFAULT_POSITIONS = { positions: [], summary: { totalUnderlyingBalanceUSD: 0, totalProfitInUSD: 0 } };
|
|
11388
11366
|
var defaultFormatCurrency = (amount) => `$${amount.toFixed(2)}`;
|
|
11389
11367
|
var EarnDesktopViewSimple = ({
|
|
11390
11368
|
positions = DEFAULT_POSITIONS,
|
|
11391
|
-
|
|
11369
|
+
strategiesByCategory = {},
|
|
11392
11370
|
historyItems = [],
|
|
11393
11371
|
formatCurrency = defaultFormatCurrency,
|
|
11394
11372
|
currency,
|
|
@@ -11404,6 +11382,7 @@ var EarnDesktopViewSimple = ({
|
|
|
11404
11382
|
summary,
|
|
11405
11383
|
categories
|
|
11406
11384
|
}) => {
|
|
11385
|
+
var _a;
|
|
11407
11386
|
const [activeCategoryId, setActiveCategoryId] = React6__default.useState(null);
|
|
11408
11387
|
const totalEarnings = positions.summary.totalProfitInUSD;
|
|
11409
11388
|
const statsCards = React6__default.useMemo(() => [
|
|
@@ -11412,25 +11391,24 @@ var EarnDesktopViewSimple = ({
|
|
|
11412
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]);
|
|
11413
11392
|
const categoryBanners = React6__default.useMemo(() => {
|
|
11414
11393
|
return categories.map((category) => {
|
|
11415
|
-
var
|
|
11416
|
-
const
|
|
11394
|
+
var _a2, _b;
|
|
11395
|
+
const categoryStrategies = (_a2 = strategiesByCategory[category.id]) != null ? _a2 : [];
|
|
11417
11396
|
let bestApy = null;
|
|
11418
|
-
for (const strategy of
|
|
11419
|
-
if (
|
|
11397
|
+
for (const strategy of categoryStrategies) {
|
|
11398
|
+
if (strategy.apy > ((_b = bestApy == null ? void 0 : bestApy.apy) != null ? _b : 0)) {
|
|
11420
11399
|
bestApy = strategy;
|
|
11421
11400
|
}
|
|
11422
11401
|
}
|
|
11423
|
-
const isStablecoin = category.assetFilter.some((a) => STABLECOIN_SYMBOLS.has(a.toUpperCase()));
|
|
11424
11402
|
return {
|
|
11425
11403
|
id: category.id,
|
|
11426
11404
|
imageUrl: category.imageUrl,
|
|
11427
11405
|
alt: category.alt,
|
|
11428
11406
|
apyFormatted: bestApy == null ? void 0 : bestApy.apyFormatted,
|
|
11429
|
-
description:
|
|
11407
|
+
description: category.id === "dolar" ? labels == null ? void 0 : labels.stablecoinsBannerDescription : labels == null ? void 0 : labels.realsBannerDescription,
|
|
11430
11408
|
handleClick: () => setActiveCategoryId(category.id)
|
|
11431
11409
|
};
|
|
11432
11410
|
});
|
|
11433
|
-
}, [categories,
|
|
11411
|
+
}, [categories, strategiesByCategory, labels == null ? void 0 : labels.stablecoinsBannerDescription, labels == null ? void 0 : labels.realsBannerDescription]);
|
|
11434
11412
|
const cardLabels = React6__default.useMemo(() => ({
|
|
11435
11413
|
investLabel: labels == null ? void 0 : labels.investLabel,
|
|
11436
11414
|
withdrawLabel: labels == null ? void 0 : labels.cardWithdrawLabel,
|
|
@@ -11455,7 +11433,7 @@ var EarnDesktopViewSimple = ({
|
|
|
11455
11433
|
);
|
|
11456
11434
|
const strategyRows = React6__default.useMemo(() => {
|
|
11457
11435
|
return formattedPositions.positions.filter((p) => p.spotPosition.underlyingBalanceUSD > 0.01).map((p) => {
|
|
11458
|
-
var
|
|
11436
|
+
var _a2, _b;
|
|
11459
11437
|
const strategyDisplayName = getStrategyDisplayName(p.strategy);
|
|
11460
11438
|
return {
|
|
11461
11439
|
logoUrl: getStrategyDisplayLogo(p.strategy),
|
|
@@ -11464,7 +11442,7 @@ var EarnDesktopViewSimple = ({
|
|
|
11464
11442
|
investedFormatted: p.spotPosition.investedFormatted,
|
|
11465
11443
|
earningsFormatted: `${(p.spotPosition.apy * 100).toFixed(2)}%`,
|
|
11466
11444
|
profitFormatted: formatCurrency(p.spotPosition.profitInUSD),
|
|
11467
|
-
totalValueFormatted: (
|
|
11445
|
+
totalValueFormatted: (_a2 = p.spotPosition.totalValueFormatted) != null ? _a2 : formatCurrency(p.spotPosition.underlyingBalanceUSD),
|
|
11468
11446
|
isLoading: false,
|
|
11469
11447
|
history: (_b = historyByAsset[p.strategy.assetName.toUpperCase()]) != null ? _b : [],
|
|
11470
11448
|
onInvestClick: onDeposit ? () => onDeposit(p.strategy.id) : () => {
|
|
@@ -11489,7 +11467,7 @@ var EarnDesktopViewSimple = ({
|
|
|
11489
11467
|
GroupedStrategyListViewSimple,
|
|
11490
11468
|
{
|
|
11491
11469
|
categoryId: activeCategoryId,
|
|
11492
|
-
strategies,
|
|
11470
|
+
strategies: (_a = strategiesByCategory[activeCategoryId]) != null ? _a : [],
|
|
11493
11471
|
isLoading,
|
|
11494
11472
|
onBack: () => setActiveCategoryId(null),
|
|
11495
11473
|
onDeposit,
|