@deframe-sdk/components 0.1.66 → 0.1.67
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 +21 -21
- package/dist/index.d.ts +21 -21
- package/dist/index.js +122 -82
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +122 -82
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +63 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -10919,7 +10919,7 @@ var ImageBannerCard = ({
|
|
|
10919
10919
|
"aria-label": alt,
|
|
10920
10920
|
onClick,
|
|
10921
10921
|
className: twMerge(
|
|
10922
|
-
"relative w-full overflow-hidden text-left",
|
|
10922
|
+
"group relative w-full overflow-hidden text-left",
|
|
10923
10923
|
"rounded-[var(--deframe-widget-size-radius-md)]",
|
|
10924
10924
|
"border",
|
|
10925
10925
|
"transition-[transform,opacity] duration-150",
|
|
@@ -10933,44 +10933,54 @@ var ImageBannerCard = ({
|
|
|
10933
10933
|
/* @__PURE__ */ jsxs(
|
|
10934
10934
|
"div",
|
|
10935
10935
|
{
|
|
10936
|
-
className: "
|
|
10936
|
+
className: "relative z-[2] flex flex-col justify-center",
|
|
10937
10937
|
style: { flex: imageUrl ? "0 0 55%" : "1 1 auto" },
|
|
10938
10938
|
children: [
|
|
10939
|
-
/* @__PURE__ */ jsx(
|
|
10940
|
-
"
|
|
10939
|
+
imageUrl && /* @__PURE__ */ jsx(
|
|
10940
|
+
"div",
|
|
10941
10941
|
{
|
|
10942
|
-
"
|
|
10943
|
-
className: "
|
|
10944
|
-
style: {
|
|
10945
|
-
children: alt
|
|
10942
|
+
"aria-hidden": "true",
|
|
10943
|
+
className: "absolute inset-y-0 left-full pointer-events-none transition-[width] duration-500 ease-out w-[33%]",
|
|
10944
|
+
style: { background: "linear-gradient(to right, #080a0e, transparent)" }
|
|
10946
10945
|
}
|
|
10947
10946
|
),
|
|
10948
|
-
|
|
10947
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-[var(--deframe-widget-size-gap-xs)] px-[var(--deframe-widget-size-padding-x-md)] py-[var(--deframe-widget-size-padding-y-xl)] transition-transform duration-500 ease-out origin-left group-hover:scale-[1.04]", children: [
|
|
10949
10948
|
/* @__PURE__ */ jsx(
|
|
10950
10949
|
"span",
|
|
10951
10950
|
{
|
|
10952
|
-
|
|
10953
|
-
|
|
10954
|
-
|
|
10951
|
+
"data-test-id": "image-banner-card-name",
|
|
10952
|
+
className: "text-[length:var(--deframe-widget-font-size-xs)] [font-weight:var(--deframe-widget-font-weight-medium)] font-[var(--deframe-widget-font-family)] uppercase tracking-[0.08em]",
|
|
10953
|
+
style: { color: `color-mix(in srgb, ${colorToken} 80%, var(--deframe-widget-color-text-secondary))` },
|
|
10954
|
+
children: alt
|
|
10955
10955
|
}
|
|
10956
10956
|
),
|
|
10957
|
-
/* @__PURE__ */
|
|
10957
|
+
apyFormatted && /* @__PURE__ */ jsxs("div", { "data-test-id": "image-banner-card-apy", className: "flex items-baseline gap-[4px]", children: [
|
|
10958
|
+
/* @__PURE__ */ jsx(
|
|
10959
|
+
"span",
|
|
10960
|
+
{
|
|
10961
|
+
className: "text-[38px] [font-weight:var(--deframe-widget-font-weight-bold)] font-[var(--deframe-widget-font-family)] leading-[1]",
|
|
10962
|
+
style: { color: colorToken },
|
|
10963
|
+
children: apyFormatted
|
|
10964
|
+
}
|
|
10965
|
+
),
|
|
10966
|
+
/* @__PURE__ */ jsx(
|
|
10967
|
+
"span",
|
|
10968
|
+
{
|
|
10969
|
+
className: "text-[length:var(--deframe-widget-font-size-xs)] [font-weight:var(--deframe-widget-font-weight-semibold)] font-[var(--deframe-widget-font-family)] uppercase tracking-[0.1em]",
|
|
10970
|
+
style: { color: `color-mix(in srgb, ${colorToken} 60%, transparent)` },
|
|
10971
|
+
children: "APY"
|
|
10972
|
+
}
|
|
10973
|
+
)
|
|
10974
|
+
] }),
|
|
10975
|
+
description && /* @__PURE__ */ jsx(
|
|
10958
10976
|
"span",
|
|
10959
10977
|
{
|
|
10960
|
-
|
|
10961
|
-
|
|
10962
|
-
children:
|
|
10978
|
+
"data-test-id": "image-banner-card-description",
|
|
10979
|
+
className: "text-[length:var(--deframe-widget-font-size-xs)] leading-[var(--deframe-widget-font-leading-sm)] text-[color:var(--deframe-widget-color-text-tertiary)] font-[var(--deframe-widget-font-family)]",
|
|
10980
|
+
children: description
|
|
10963
10981
|
}
|
|
10964
10982
|
)
|
|
10965
|
-
] })
|
|
10966
|
-
description && /* @__PURE__ */ jsx(
|
|
10967
|
-
"span",
|
|
10968
|
-
{
|
|
10969
|
-
"data-test-id": "image-banner-card-description",
|
|
10970
|
-
className: "text-[length:var(--deframe-widget-font-size-xs)] leading-[var(--deframe-widget-font-leading-sm)] text-[color:var(--deframe-widget-color-text-tertiary)] font-[var(--deframe-widget-font-family)]",
|
|
10971
|
-
children: description
|
|
10972
|
-
}
|
|
10973
|
-
)
|
|
10983
|
+
] })
|
|
10974
10984
|
]
|
|
10975
10985
|
}
|
|
10976
10986
|
),
|
|
@@ -10979,7 +10989,7 @@ var ImageBannerCard = ({
|
|
|
10979
10989
|
{
|
|
10980
10990
|
"data-test-id": "image-banner-card-image-wrapper",
|
|
10981
10991
|
className: "relative flex-1 overflow-hidden",
|
|
10982
|
-
style: { minHeight: 160 },
|
|
10992
|
+
style: { background: "linear-gradient(to left, #080a0e, transparent)", minHeight: 160 },
|
|
10983
10993
|
children: [
|
|
10984
10994
|
/* @__PURE__ */ jsx(
|
|
10985
10995
|
"img",
|
|
@@ -10988,16 +10998,14 @@ var ImageBannerCard = ({
|
|
|
10988
10998
|
src: imageUrl,
|
|
10989
10999
|
alt: "",
|
|
10990
11000
|
"aria-hidden": "true",
|
|
10991
|
-
className: "absolute inset-0 w-full h-full object-cover object-center"
|
|
11001
|
+
className: "absolute inset-0 w-full h-full object-cover object-center transition-transform duration-500 ease-out origin-right group-hover:scale-110"
|
|
10992
11002
|
}
|
|
10993
11003
|
),
|
|
10994
11004
|
/* @__PURE__ */ jsx(
|
|
10995
11005
|
"div",
|
|
10996
11006
|
{
|
|
10997
|
-
|
|
10998
|
-
|
|
10999
|
-
background: "linear-gradient(to right, #080a0e 0%, transparent 40%)"
|
|
11000
|
-
}
|
|
11007
|
+
"aria-hidden": "true",
|
|
11008
|
+
className: "absolute inset-y-0 left-0 z-[1] pointer-events-none transition-[width,transform] duration-500 ease-out w-[40%] group-hover:w-[80%] group-hover:-translate-x-3"
|
|
11001
11009
|
}
|
|
11002
11010
|
)
|
|
11003
11011
|
]
|
|
@@ -11007,7 +11015,7 @@ var ImageBannerCard = ({
|
|
|
11007
11015
|
}
|
|
11008
11016
|
);
|
|
11009
11017
|
};
|
|
11010
|
-
var GRID_COLS = "grid grid-cols-[
|
|
11018
|
+
var GRID_COLS = "grid grid-cols-[1fr_100px_100px_100px_100px] gap-x-[var(--deframe-widget-size-gap-md)]";
|
|
11011
11019
|
var HISTORY_COLORS = {
|
|
11012
11020
|
deposit: "var(--deframe-widget-color-state-info)",
|
|
11013
11021
|
withdraw: "var(--deframe-widget-color-text-secondary)",
|
|
@@ -11020,6 +11028,7 @@ var EarnHubStrategyCard = ({
|
|
|
11020
11028
|
investedFormatted,
|
|
11021
11029
|
earningsFormatted,
|
|
11022
11030
|
profitFormatted,
|
|
11031
|
+
totalValueFormatted,
|
|
11023
11032
|
isLoading,
|
|
11024
11033
|
onInvestClick,
|
|
11025
11034
|
onWithdrawClick,
|
|
@@ -11040,7 +11049,7 @@ var EarnHubStrategyCard = ({
|
|
|
11040
11049
|
{
|
|
11041
11050
|
"data-slot": "earn-hub-strategy-card",
|
|
11042
11051
|
"data-test-id": "earn-hub-strategy-card",
|
|
11043
|
-
className: "border-t border-[color:var(--deframe-widget-color-border-secondary)] list-none",
|
|
11052
|
+
className: "border-t border-[color:var(--deframe-widget-color-border-secondary)] list-none overflow-hidden",
|
|
11044
11053
|
children: [
|
|
11045
11054
|
/* @__PURE__ */ jsxs(
|
|
11046
11055
|
"div",
|
|
@@ -11049,14 +11058,14 @@ var EarnHubStrategyCard = ({
|
|
|
11049
11058
|
onClick: () => setExpanded((v) => !v),
|
|
11050
11059
|
className: twMerge(
|
|
11051
11060
|
GRID_COLS,
|
|
11052
|
-
"items-center cursor-pointer",
|
|
11061
|
+
"group items-center cursor-pointer",
|
|
11053
11062
|
"px-[var(--deframe-widget-size-padding-x-md)] py-[13px]",
|
|
11054
11063
|
"transition-colors duration-150",
|
|
11055
11064
|
"hover:bg-[color:color-mix(in_srgb,var(--deframe-widget-color-bg-tertiary)_60%,transparent)]"
|
|
11056
11065
|
),
|
|
11057
11066
|
children: [
|
|
11058
11067
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-[var(--deframe-widget-size-gap-sm)] min-w-0", children: [
|
|
11059
|
-
/* @__PURE__ */ jsx("div", { className: "w-[36px] h-[36px] rounded-full bg-[var(--deframe-widget-color-bg-tertiary)] flex items-center justify-center overflow-hidden shrink-0", children: /* @__PURE__ */ jsx("img", { alt: assetName, src: logoUrl, referrerPolicy: "no-referrer", className: "w-full h-full object-contain" }) }),
|
|
11068
|
+
/* @__PURE__ */ jsx("div", { className: "w-[36px] h-[36px] rounded-full bg-[var(--deframe-widget-color-bg-tertiary)] flex items-center justify-center overflow-hidden shrink-0", children: /* @__PURE__ */ jsx("img", { alt: assetName, src: logoUrl, referrerPolicy: "no-referrer", className: "w-full h-full object-contain transition-transform duration-500 ease-out group-hover:scale-110" }) }),
|
|
11060
11069
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col min-w-0", children: [
|
|
11061
11070
|
/* @__PURE__ */ jsx("span", { className: "text-[length:var(--deframe-widget-font-size-sm)] [font-weight:var(--deframe-widget-font-weight-semibold)] text-[color:var(--deframe-widget-color-text-primary)] leading-[var(--deframe-widget-font-leading-sm)] font-[var(--deframe-widget-font-family)] truncate", children: assetName }),
|
|
11062
11071
|
network && /* @__PURE__ */ jsx("span", { className: "text-[length:var(--deframe-widget-font-size-xs)] text-[color:var(--deframe-widget-color-text-secondary)] leading-[var(--deframe-widget-font-leading-xs)]", children: network })
|
|
@@ -11071,11 +11080,9 @@ var EarnHubStrategyCard = ({
|
|
|
11071
11080
|
}
|
|
11072
11081
|
) }),
|
|
11073
11082
|
/* @__PURE__ */ jsx("div", { className: "flex justify-center", children: isLoading ? /* @__PURE__ */ jsx(Skeleton, { variant: "rect", width: 50, height: 16 }) : profitFormatted ? /* @__PURE__ */ jsx("span", { className: "text-[length:var(--deframe-widget-font-size-sm)] [font-weight:var(--deframe-widget-font-weight-semibold)] text-[color:var(--deframe-widget-color-text-primary)] font-[var(--deframe-widget-font-family)] leading-none", children: profitFormatted }) : /* @__PURE__ */ jsx("span", { className: "text-[length:var(--deframe-widget-font-size-xs)] text-[color:var(--deframe-widget-color-text-tertiary)]", children: "\u2014" }) }),
|
|
11083
|
+
/* @__PURE__ */ jsx("div", { className: "flex justify-end", children: isLoading ? /* @__PURE__ */ jsx(Skeleton, { variant: "rect", width: 60, height: 16 }) : investedFormatted ? /* @__PURE__ */ jsx("span", { className: "text-[length:var(--deframe-widget-font-size-sm)] [font-weight:var(--deframe-widget-font-weight-semibold)] text-[color:var(--deframe-widget-color-text-primary)] leading-[var(--deframe-widget-font-leading-sm)] font-[var(--deframe-widget-font-family)]", children: investedFormatted }) : /* @__PURE__ */ jsx("span", { className: "text-[length:var(--deframe-widget-font-size-xs)] text-[color:var(--deframe-widget-color-text-tertiary)]", children: "\u2014" }) }),
|
|
11074
11084
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-[var(--deframe-widget-size-gap-xs)]", children: [
|
|
11075
|
-
/* @__PURE__ */ jsx(
|
|
11076
|
-
/* @__PURE__ */ jsx("span", { className: "text-[length:var(--deframe-widget-font-size-sm)] [font-weight:var(--deframe-widget-font-weight-semibold)] text-[color:var(--deframe-widget-color-text-primary)] leading-[var(--deframe-widget-font-leading-sm)] font-[var(--deframe-widget-font-family)]", children: investedFormatted }),
|
|
11077
|
-
(labels == null ? void 0 : labels.investedLabel) && /* @__PURE__ */ jsx("span", { className: "text-[length:var(--deframe-widget-font-size-xs)] text-[color:var(--deframe-widget-color-text-secondary)] leading-[var(--deframe-widget-font-leading-xs)]", children: labels.investedLabel })
|
|
11078
|
-
] }) : /* @__PURE__ */ jsx("span", { className: "text-[length:var(--deframe-widget-font-size-xs)] text-[color:var(--deframe-widget-color-text-tertiary)]", children: "\u2014" }) }),
|
|
11085
|
+
isLoading ? /* @__PURE__ */ jsx(Skeleton, { variant: "rect", width: 60, height: 16 }) : totalValueFormatted ? /* @__PURE__ */ jsx("span", { className: "text-[length:var(--deframe-widget-font-size-sm)] [font-weight:var(--deframe-widget-font-weight-semibold)] text-[color:var(--deframe-widget-color-text-primary)] leading-[var(--deframe-widget-font-leading-sm)] font-[var(--deframe-widget-font-family)]", children: totalValueFormatted }) : /* @__PURE__ */ jsx("span", { className: "text-[length:var(--deframe-widget-font-size-xs)] text-[color:var(--deframe-widget-color-text-tertiary)]", children: "\u2014" }),
|
|
11079
11086
|
/* @__PURE__ */ jsx(
|
|
11080
11087
|
"svg",
|
|
11081
11088
|
{
|
|
@@ -11229,6 +11236,60 @@ function formatHistoryAssetAmount(input) {
|
|
|
11229
11236
|
}
|
|
11230
11237
|
return "";
|
|
11231
11238
|
}
|
|
11239
|
+
|
|
11240
|
+
// src/utils/formatEarnPositions.ts
|
|
11241
|
+
function formatEarnPositions(positions, { currency, locale, formatCurrency }) {
|
|
11242
|
+
return __spreadProps(__spreadValues({}, positions), {
|
|
11243
|
+
positions: positions.positions.map((p) => {
|
|
11244
|
+
var _a, _b;
|
|
11245
|
+
const symbol = p.strategy.assetName.toUpperCase();
|
|
11246
|
+
const isBrlPegged = currency === "BRL" && BRL_PEGGED_SYMBOLS.has(symbol);
|
|
11247
|
+
const principalHumanized = parseFloat((_b = (_a = p.spotPosition.principal) == null ? void 0 : _a.humanized) != null ? _b : "0");
|
|
11248
|
+
const principalUSD = p.spotPosition.underlyingBalanceUSD - p.spotPosition.profitInUSD;
|
|
11249
|
+
const investedFormatted = isBrlPegged && p.spotPosition.principal ? formatHistoryAssetAmount({ amountHumanized: p.spotPosition.principal.humanized, symbol, currency, locale, formatCurrency }) : formatCurrency(principalUSD);
|
|
11250
|
+
const totalBrla = isBrlPegged && principalHumanized > 0 && principalUSD > 0 ? p.spotPosition.underlyingBalanceUSD * principalHumanized / principalUSD : null;
|
|
11251
|
+
const totalValueFormatted = totalBrla !== null ? formatHistoryAssetAmount({ amountHumanized: String(totalBrla), symbol, currency, locale, formatCurrency }) : formatCurrency(p.spotPosition.underlyingBalanceUSD);
|
|
11252
|
+
return __spreadProps(__spreadValues({}, p), { spotPosition: __spreadProps(__spreadValues({}, p.spotPosition), { investedFormatted, totalValueFormatted }) });
|
|
11253
|
+
})
|
|
11254
|
+
});
|
|
11255
|
+
}
|
|
11256
|
+
|
|
11257
|
+
// src/utils/buildEarnHistoryByAsset.ts
|
|
11258
|
+
function buildEarnHistoryByAsset(items, { currency, locale, formatCurrency, onHistoryDetail }) {
|
|
11259
|
+
var _a, _b, _c, _d, _e;
|
|
11260
|
+
const map = {};
|
|
11261
|
+
for (const item of items) {
|
|
11262
|
+
const isDeposit = item.type.includes("DEPOSIT");
|
|
11263
|
+
const primaryAsset = isDeposit ? (_a = item.amounts) == null ? void 0 : _a.assetIn : (_b = item.amounts) == null ? void 0 : _b.assetOut;
|
|
11264
|
+
const symbol = (_e = (_d = (_c = primaryAsset == null ? void 0 : primaryAsset.token) == null ? void 0 : _c.symbol) == null ? void 0 : _d.toUpperCase()) != null ? _e : "";
|
|
11265
|
+
if (!symbol || !primaryAsset) continue;
|
|
11266
|
+
const amount = formatHistoryAssetAmount({
|
|
11267
|
+
amountHumanized: primaryAsset.amountHumanized,
|
|
11268
|
+
amountInUSD: primaryAsset.amountInUSD,
|
|
11269
|
+
symbol,
|
|
11270
|
+
currency,
|
|
11271
|
+
locale,
|
|
11272
|
+
formatCurrency
|
|
11273
|
+
});
|
|
11274
|
+
const date = new Date(item.createdAt).toLocaleString(locale, {
|
|
11275
|
+
day: "2-digit",
|
|
11276
|
+
month: "2-digit",
|
|
11277
|
+
year: "numeric",
|
|
11278
|
+
hour: "2-digit",
|
|
11279
|
+
minute: "2-digit"
|
|
11280
|
+
});
|
|
11281
|
+
const entry = {
|
|
11282
|
+
id: item.id,
|
|
11283
|
+
date,
|
|
11284
|
+
type: isDeposit ? "deposit" : "withdraw",
|
|
11285
|
+
amount,
|
|
11286
|
+
onClick: () => onHistoryDetail(item.id, isDeposit)
|
|
11287
|
+
};
|
|
11288
|
+
if (!map[symbol]) map[symbol] = [];
|
|
11289
|
+
map[symbol].push(entry);
|
|
11290
|
+
}
|
|
11291
|
+
return map;
|
|
11292
|
+
}
|
|
11232
11293
|
var EARN_CATEGORY_DEFINITIONS = [
|
|
11233
11294
|
{
|
|
11234
11295
|
id: "dolar",
|
|
@@ -11296,7 +11357,7 @@ var columnHeaderClasses = [
|
|
|
11296
11357
|
"text-[color:var(--deframe-widget-color-text-tertiary)]",
|
|
11297
11358
|
"leading-[var(--deframe-widget-font-leading-xs)]"
|
|
11298
11359
|
].join(" ");
|
|
11299
|
-
var GRID_COLS2 = "grid grid-cols-[
|
|
11360
|
+
var GRID_COLS2 = "grid grid-cols-[1fr_100px_100px_100px_100px] gap-x-[var(--deframe-widget-size-gap-md)]";
|
|
11300
11361
|
var BANNER_COLORS = [
|
|
11301
11362
|
"var(--deframe-widget-color-brand-primary)",
|
|
11302
11363
|
"var(--deframe-widget-color-brand-secondary)"
|
|
@@ -11349,41 +11410,6 @@ var EarnDesktopViewSimple = ({
|
|
|
11349
11410
|
};
|
|
11350
11411
|
});
|
|
11351
11412
|
}, [categories, strategies, labels == null ? void 0 : labels.stablecoinsBannerDescription, labels == null ? void 0 : labels.realsBannerDescription]);
|
|
11352
|
-
const historyByAsset = React6__default.useMemo(() => {
|
|
11353
|
-
var _a, _b, _c, _d, _e;
|
|
11354
|
-
const map = /* @__PURE__ */ new Map();
|
|
11355
|
-
for (const item of historyItems) {
|
|
11356
|
-
const isDeposit = item.type.includes("DEPOSIT");
|
|
11357
|
-
const primaryAsset = isDeposit ? (_a = item.amounts) == null ? void 0 : _a.assetIn : (_b = item.amounts) == null ? void 0 : _b.assetOut;
|
|
11358
|
-
const symbol = (_e = primaryAsset && "token" in primaryAsset ? (_d = (_c = primaryAsset.token) == null ? void 0 : _c.symbol) == null ? void 0 : _d.toUpperCase() : null) != null ? _e : "";
|
|
11359
|
-
if (!symbol) continue;
|
|
11360
|
-
const amount = formatHistoryAssetAmount({
|
|
11361
|
-
amountHumanized: primaryAsset && "amountHumanized" in primaryAsset ? primaryAsset.amountHumanized : void 0,
|
|
11362
|
-
amountInUSD: primaryAsset && "amountInUSD" in primaryAsset ? primaryAsset.amountInUSD : void 0,
|
|
11363
|
-
symbol,
|
|
11364
|
-
currency,
|
|
11365
|
-
locale,
|
|
11366
|
-
formatCurrency
|
|
11367
|
-
});
|
|
11368
|
-
const date = new Date(item.createdAt).toLocaleString(locale, {
|
|
11369
|
-
day: "2-digit",
|
|
11370
|
-
month: "2-digit",
|
|
11371
|
-
year: "numeric",
|
|
11372
|
-
hour: "2-digit",
|
|
11373
|
-
minute: "2-digit"
|
|
11374
|
-
});
|
|
11375
|
-
const entry = {
|
|
11376
|
-
id: item.id,
|
|
11377
|
-
date,
|
|
11378
|
-
type: isDeposit ? "deposit" : "withdraw",
|
|
11379
|
-
amount,
|
|
11380
|
-
onClick: onHistoryDetail ? () => onHistoryDetail(item.id, isDeposit) : void 0
|
|
11381
|
-
};
|
|
11382
|
-
if (!map.has(symbol)) map.set(symbol, []);
|
|
11383
|
-
map.get(symbol).push(entry);
|
|
11384
|
-
}
|
|
11385
|
-
return map;
|
|
11386
|
-
}, [historyItems, locale, formatCurrency, currency, onHistoryDetail]);
|
|
11387
11413
|
const cardLabels = React6__default.useMemo(() => ({
|
|
11388
11414
|
investLabel: labels == null ? void 0 : labels.investLabel,
|
|
11389
11415
|
withdrawLabel: labels == null ? void 0 : labels.cardWithdrawLabel,
|
|
@@ -11393,18 +11419,32 @@ var EarnDesktopViewSimple = ({
|
|
|
11393
11419
|
historyWithdrawnLabel: labels == null ? void 0 : labels.cardHistoryWithdrawnLabel,
|
|
11394
11420
|
historyInterestReceivedLabel: labels == null ? void 0 : labels.cardHistoryInterestReceivedLabel
|
|
11395
11421
|
}), [labels == null ? void 0 : labels.investLabel, labels == null ? void 0 : labels.cardWithdrawLabel, labels == null ? void 0 : labels.cardInvestedLabel, labels == null ? void 0 : labels.cardHistoryTitle, labels == null ? void 0 : labels.cardHistoryDepositedLabel, labels == null ? void 0 : labels.cardHistoryWithdrawnLabel, labels == null ? void 0 : labels.cardHistoryInterestReceivedLabel]);
|
|
11422
|
+
const formattedPositions = useMemo(
|
|
11423
|
+
() => formatEarnPositions(positions, { currency, locale, formatCurrency }),
|
|
11424
|
+
[positions, currency, locale, formatCurrency]
|
|
11425
|
+
);
|
|
11426
|
+
const historyByAsset = useMemo(
|
|
11427
|
+
() => buildEarnHistoryByAsset(historyItems, {
|
|
11428
|
+
currency,
|
|
11429
|
+
locale,
|
|
11430
|
+
formatCurrency,
|
|
11431
|
+
onHistoryDetail: (id, isDeposit) => onHistoryDetail == null ? void 0 : onHistoryDetail(id, isDeposit)
|
|
11432
|
+
}),
|
|
11433
|
+
[historyItems, currency, locale, formatCurrency, onHistoryDetail]
|
|
11434
|
+
);
|
|
11396
11435
|
const strategyRows = React6__default.useMemo(() => {
|
|
11397
|
-
return
|
|
11398
|
-
var _a;
|
|
11436
|
+
return formattedPositions.positions.filter((p) => p.spotPosition.underlyingBalanceUSD > 0.01).map((p) => {
|
|
11437
|
+
var _a, _b;
|
|
11399
11438
|
return {
|
|
11400
11439
|
logoUrl: p.strategy.logourl,
|
|
11401
11440
|
assetName: p.strategy.assetName,
|
|
11402
11441
|
network: p.strategy.network,
|
|
11403
|
-
investedFormatted:
|
|
11442
|
+
investedFormatted: p.spotPosition.investedFormatted,
|
|
11404
11443
|
earningsFormatted: `${(p.spotPosition.apy * 100).toFixed(2)}%`,
|
|
11405
11444
|
profitFormatted: formatCurrency(p.spotPosition.profitInUSD),
|
|
11445
|
+
totalValueFormatted: (_a = p.spotPosition.totalValueFormatted) != null ? _a : formatCurrency(p.spotPosition.underlyingBalanceUSD),
|
|
11406
11446
|
isLoading: false,
|
|
11407
|
-
history: (
|
|
11447
|
+
history: (_b = historyByAsset[p.strategy.assetName.toUpperCase()]) != null ? _b : [],
|
|
11408
11448
|
onInvestClick: onDeposit ? () => onDeposit(p.strategy.id) : () => {
|
|
11409
11449
|
},
|
|
11410
11450
|
onWithdrawClick: onWithdraw ? () => onWithdraw(p.strategy.id) : () => {
|
|
@@ -11414,7 +11454,7 @@ var EarnDesktopViewSimple = ({
|
|
|
11414
11454
|
labels: cardLabels
|
|
11415
11455
|
};
|
|
11416
11456
|
});
|
|
11417
|
-
}, [
|
|
11457
|
+
}, [formattedPositions.positions, formatCurrency, historyByAsset, onDeposit, onWithdraw, onDetails, cardLabels]);
|
|
11418
11458
|
if (isLoading) {
|
|
11419
11459
|
return /* @__PURE__ */ jsxs("div", { "data-test-id": "earn-hub-view-simple-loading", className: twMerge(wrapperBaseClasses2, className), children: [
|
|
11420
11460
|
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-[var(--deframe-widget-size-gap-sm)]", children: [0, 1].map((i) => /* @__PURE__ */ jsx(Skeleton, { variant: "rect", width: "100%", height: 100 }, i)) }),
|
|
@@ -11561,13 +11601,13 @@ var EarnDesktopViewSimple = ({
|
|
|
11561
11601
|
"px-[var(--deframe-widget-size-padding-x-md)] py-[var(--deframe-widget-size-padding-y-sm)]",
|
|
11562
11602
|
"border-t border-[color:var(--deframe-widget-color-border-secondary)]"
|
|
11563
11603
|
),
|
|
11564
|
-
children: [labels == null ? void 0 : labels.columnStrategy, labels == null ? void 0 : labels.columnApy, labels == null ? void 0 : labels.columnProfit, labels == null ? void 0 : labels.columnTotalValue].map((label, i) => /* @__PURE__ */ jsx(
|
|
11604
|
+
children: [labels == null ? void 0 : labels.columnStrategy, labels == null ? void 0 : labels.columnApy, labels == null ? void 0 : labels.columnProfit, labels == null ? void 0 : labels.columnInvested, labels == null ? void 0 : labels.columnTotalValue].map((label, i) => /* @__PURE__ */ jsx(
|
|
11565
11605
|
"span",
|
|
11566
11606
|
{
|
|
11567
11607
|
className: twMerge(
|
|
11568
11608
|
columnHeaderClasses,
|
|
11569
11609
|
(i === 1 || i === 2) && "text-center",
|
|
11570
|
-
i === 3 && "text-right"
|
|
11610
|
+
(i === 3 || i === 4) && "text-right"
|
|
11571
11611
|
),
|
|
11572
11612
|
children: label
|
|
11573
11613
|
},
|