@deframe-sdk/components 0.1.66 → 0.1.68
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 +29 -21
- package/dist/index.d.ts +29 -21
- package/dist/index.js +164 -102
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +164 -102
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +63 -2
- package/package.json +1 -1
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)]",
|
|
@@ -10493,24 +10511,27 @@ var GroupedStrategyListViewSimple = ({
|
|
|
10493
10511
|
{
|
|
10494
10512
|
"data-test-id": "grouped-strategy-list-view-simple-items",
|
|
10495
10513
|
className: "flex flex-col gap-[var(--deframe-widget-size-gap-sm)]",
|
|
10496
|
-
children: filteredStrategies.map((s) =>
|
|
10497
|
-
|
|
10498
|
-
|
|
10499
|
-
|
|
10500
|
-
|
|
10501
|
-
|
|
10502
|
-
|
|
10503
|
-
|
|
10504
|
-
|
|
10505
|
-
|
|
10506
|
-
|
|
10507
|
-
|
|
10508
|
-
|
|
10514
|
+
children: filteredStrategies.map((s) => {
|
|
10515
|
+
const displayName = getStrategyDisplayName(s);
|
|
10516
|
+
return /* @__PURE__ */ jsx(
|
|
10517
|
+
StrategyGridCardSimple,
|
|
10518
|
+
{
|
|
10519
|
+
logoUrl: getStrategyDisplayLogo(s),
|
|
10520
|
+
title: displayName,
|
|
10521
|
+
subtitle: displayName,
|
|
10522
|
+
chainName: s.network,
|
|
10523
|
+
apyFormatted: s.apyFormatted,
|
|
10524
|
+
apyLabel: yieldLabel,
|
|
10525
|
+
riskLevel: "low",
|
|
10526
|
+
onInvestClick: onDeposit ? () => onDeposit(s.id) : () => {
|
|
10527
|
+
},
|
|
10528
|
+
onWithdrawClick: onWithdraw ? () => onWithdraw(s.id) : () => {
|
|
10529
|
+
},
|
|
10530
|
+
labels: { investLabel, riskLow, riskMedium, riskHigh }
|
|
10509
10531
|
},
|
|
10510
|
-
|
|
10511
|
-
|
|
10512
|
-
|
|
10513
|
-
))
|
|
10532
|
+
s.id
|
|
10533
|
+
);
|
|
10534
|
+
})
|
|
10514
10535
|
}
|
|
10515
10536
|
)
|
|
10516
10537
|
] });
|
|
@@ -10919,7 +10940,7 @@ var ImageBannerCard = ({
|
|
|
10919
10940
|
"aria-label": alt,
|
|
10920
10941
|
onClick,
|
|
10921
10942
|
className: twMerge(
|
|
10922
|
-
"relative w-full overflow-hidden text-left",
|
|
10943
|
+
"group relative w-full overflow-hidden text-left",
|
|
10923
10944
|
"rounded-[var(--deframe-widget-size-radius-md)]",
|
|
10924
10945
|
"border",
|
|
10925
10946
|
"transition-[transform,opacity] duration-150",
|
|
@@ -10933,44 +10954,54 @@ var ImageBannerCard = ({
|
|
|
10933
10954
|
/* @__PURE__ */ jsxs(
|
|
10934
10955
|
"div",
|
|
10935
10956
|
{
|
|
10936
|
-
className: "
|
|
10957
|
+
className: "relative z-[2] flex flex-col justify-center",
|
|
10937
10958
|
style: { flex: imageUrl ? "0 0 55%" : "1 1 auto" },
|
|
10938
10959
|
children: [
|
|
10939
|
-
/* @__PURE__ */ jsx(
|
|
10940
|
-
"
|
|
10960
|
+
imageUrl && /* @__PURE__ */ jsx(
|
|
10961
|
+
"div",
|
|
10941
10962
|
{
|
|
10942
|
-
"
|
|
10943
|
-
className: "
|
|
10944
|
-
style: {
|
|
10945
|
-
children: alt
|
|
10963
|
+
"aria-hidden": "true",
|
|
10964
|
+
className: "absolute inset-y-0 left-full pointer-events-none transition-[width] duration-500 ease-out w-[33%]",
|
|
10965
|
+
style: { background: "linear-gradient(to right, #080a0e, transparent)" }
|
|
10946
10966
|
}
|
|
10947
10967
|
),
|
|
10948
|
-
|
|
10968
|
+
/* @__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
10969
|
/* @__PURE__ */ jsx(
|
|
10950
10970
|
"span",
|
|
10951
10971
|
{
|
|
10952
|
-
|
|
10953
|
-
|
|
10954
|
-
|
|
10972
|
+
"data-test-id": "image-banner-card-name",
|
|
10973
|
+
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]",
|
|
10974
|
+
style: { color: `color-mix(in srgb, ${colorToken} 80%, var(--deframe-widget-color-text-secondary))` },
|
|
10975
|
+
children: alt
|
|
10955
10976
|
}
|
|
10956
10977
|
),
|
|
10957
|
-
/* @__PURE__ */
|
|
10978
|
+
apyFormatted && /* @__PURE__ */ jsxs("div", { "data-test-id": "image-banner-card-apy", className: "flex items-baseline gap-[4px]", children: [
|
|
10979
|
+
/* @__PURE__ */ jsx(
|
|
10980
|
+
"span",
|
|
10981
|
+
{
|
|
10982
|
+
className: "text-[38px] [font-weight:var(--deframe-widget-font-weight-bold)] font-[var(--deframe-widget-font-family)] leading-[1]",
|
|
10983
|
+
style: { color: colorToken },
|
|
10984
|
+
children: apyFormatted
|
|
10985
|
+
}
|
|
10986
|
+
),
|
|
10987
|
+
/* @__PURE__ */ jsx(
|
|
10988
|
+
"span",
|
|
10989
|
+
{
|
|
10990
|
+
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]",
|
|
10991
|
+
style: { color: `color-mix(in srgb, ${colorToken} 60%, transparent)` },
|
|
10992
|
+
children: "APY"
|
|
10993
|
+
}
|
|
10994
|
+
)
|
|
10995
|
+
] }),
|
|
10996
|
+
description && /* @__PURE__ */ jsx(
|
|
10958
10997
|
"span",
|
|
10959
10998
|
{
|
|
10960
|
-
|
|
10961
|
-
|
|
10962
|
-
children:
|
|
10999
|
+
"data-test-id": "image-banner-card-description",
|
|
11000
|
+
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)]",
|
|
11001
|
+
children: description
|
|
10963
11002
|
}
|
|
10964
11003
|
)
|
|
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
|
-
)
|
|
11004
|
+
] })
|
|
10974
11005
|
]
|
|
10975
11006
|
}
|
|
10976
11007
|
),
|
|
@@ -10979,7 +11010,7 @@ var ImageBannerCard = ({
|
|
|
10979
11010
|
{
|
|
10980
11011
|
"data-test-id": "image-banner-card-image-wrapper",
|
|
10981
11012
|
className: "relative flex-1 overflow-hidden",
|
|
10982
|
-
style: { minHeight: 160 },
|
|
11013
|
+
style: { background: "linear-gradient(to left, #080a0e, transparent)", minHeight: 160 },
|
|
10983
11014
|
children: [
|
|
10984
11015
|
/* @__PURE__ */ jsx(
|
|
10985
11016
|
"img",
|
|
@@ -10988,16 +11019,14 @@ var ImageBannerCard = ({
|
|
|
10988
11019
|
src: imageUrl,
|
|
10989
11020
|
alt: "",
|
|
10990
11021
|
"aria-hidden": "true",
|
|
10991
|
-
className: "absolute inset-0 w-full h-full object-cover object-center"
|
|
11022
|
+
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
11023
|
}
|
|
10993
11024
|
),
|
|
10994
11025
|
/* @__PURE__ */ jsx(
|
|
10995
11026
|
"div",
|
|
10996
11027
|
{
|
|
10997
|
-
|
|
10998
|
-
|
|
10999
|
-
background: "linear-gradient(to right, #080a0e 0%, transparent 40%)"
|
|
11000
|
-
}
|
|
11028
|
+
"aria-hidden": "true",
|
|
11029
|
+
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
11030
|
}
|
|
11002
11031
|
)
|
|
11003
11032
|
]
|
|
@@ -11007,7 +11036,7 @@ var ImageBannerCard = ({
|
|
|
11007
11036
|
}
|
|
11008
11037
|
);
|
|
11009
11038
|
};
|
|
11010
|
-
var GRID_COLS = "grid grid-cols-[
|
|
11039
|
+
var GRID_COLS = "grid grid-cols-[1fr_100px_100px_100px_100px] gap-x-[var(--deframe-widget-size-gap-md)]";
|
|
11011
11040
|
var HISTORY_COLORS = {
|
|
11012
11041
|
deposit: "var(--deframe-widget-color-state-info)",
|
|
11013
11042
|
withdraw: "var(--deframe-widget-color-text-secondary)",
|
|
@@ -11020,6 +11049,7 @@ var EarnHubStrategyCard = ({
|
|
|
11020
11049
|
investedFormatted,
|
|
11021
11050
|
earningsFormatted,
|
|
11022
11051
|
profitFormatted,
|
|
11052
|
+
totalValueFormatted,
|
|
11023
11053
|
isLoading,
|
|
11024
11054
|
onInvestClick,
|
|
11025
11055
|
onWithdrawClick,
|
|
@@ -11040,7 +11070,7 @@ var EarnHubStrategyCard = ({
|
|
|
11040
11070
|
{
|
|
11041
11071
|
"data-slot": "earn-hub-strategy-card",
|
|
11042
11072
|
"data-test-id": "earn-hub-strategy-card",
|
|
11043
|
-
className: "border-t border-[color:var(--deframe-widget-color-border-secondary)] list-none",
|
|
11073
|
+
className: "border-t border-[color:var(--deframe-widget-color-border-secondary)] list-none overflow-hidden",
|
|
11044
11074
|
children: [
|
|
11045
11075
|
/* @__PURE__ */ jsxs(
|
|
11046
11076
|
"div",
|
|
@@ -11049,14 +11079,14 @@ var EarnHubStrategyCard = ({
|
|
|
11049
11079
|
onClick: () => setExpanded((v) => !v),
|
|
11050
11080
|
className: twMerge(
|
|
11051
11081
|
GRID_COLS,
|
|
11052
|
-
"items-center cursor-pointer",
|
|
11082
|
+
"group items-center cursor-pointer",
|
|
11053
11083
|
"px-[var(--deframe-widget-size-padding-x-md)] py-[13px]",
|
|
11054
11084
|
"transition-colors duration-150",
|
|
11055
11085
|
"hover:bg-[color:color-mix(in_srgb,var(--deframe-widget-color-bg-tertiary)_60%,transparent)]"
|
|
11056
11086
|
),
|
|
11057
11087
|
children: [
|
|
11058
11088
|
/* @__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" }) }),
|
|
11089
|
+
/* @__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
11090
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col min-w-0", children: [
|
|
11061
11091
|
/* @__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
11092
|
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 +11101,9 @@ var EarnHubStrategyCard = ({
|
|
|
11071
11101
|
}
|
|
11072
11102
|
) }),
|
|
11073
11103
|
/* @__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" }) }),
|
|
11104
|
+
/* @__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
11105
|
/* @__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" }) }),
|
|
11106
|
+
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
11107
|
/* @__PURE__ */ jsx(
|
|
11080
11108
|
"svg",
|
|
11081
11109
|
{
|
|
@@ -11229,11 +11257,65 @@ function formatHistoryAssetAmount(input) {
|
|
|
11229
11257
|
}
|
|
11230
11258
|
return "";
|
|
11231
11259
|
}
|
|
11260
|
+
|
|
11261
|
+
// src/utils/formatEarnPositions.ts
|
|
11262
|
+
function formatEarnPositions(positions, { currency, locale, formatCurrency }) {
|
|
11263
|
+
return __spreadProps(__spreadValues({}, positions), {
|
|
11264
|
+
positions: positions.positions.map((p) => {
|
|
11265
|
+
var _a, _b;
|
|
11266
|
+
const symbol = p.strategy.assetName.toUpperCase();
|
|
11267
|
+
const isBrlPegged = currency === "BRL" && BRL_PEGGED_SYMBOLS.has(symbol);
|
|
11268
|
+
const principalHumanized = parseFloat((_b = (_a = p.spotPosition.principal) == null ? void 0 : _a.humanized) != null ? _b : "0");
|
|
11269
|
+
const principalUSD = p.spotPosition.underlyingBalanceUSD - p.spotPosition.profitInUSD;
|
|
11270
|
+
const investedFormatted = isBrlPegged && p.spotPosition.principal ? formatHistoryAssetAmount({ amountHumanized: p.spotPosition.principal.humanized, symbol, currency, locale, formatCurrency }) : formatCurrency(principalUSD);
|
|
11271
|
+
const totalBrla = isBrlPegged && principalHumanized > 0 && principalUSD > 0 ? p.spotPosition.underlyingBalanceUSD * principalHumanized / principalUSD : null;
|
|
11272
|
+
const totalValueFormatted = totalBrla !== null ? formatHistoryAssetAmount({ amountHumanized: String(totalBrla), symbol, currency, locale, formatCurrency }) : formatCurrency(p.spotPosition.underlyingBalanceUSD);
|
|
11273
|
+
return __spreadProps(__spreadValues({}, p), { spotPosition: __spreadProps(__spreadValues({}, p.spotPosition), { investedFormatted, totalValueFormatted }) });
|
|
11274
|
+
})
|
|
11275
|
+
});
|
|
11276
|
+
}
|
|
11277
|
+
|
|
11278
|
+
// src/utils/buildEarnHistoryByAsset.ts
|
|
11279
|
+
function buildEarnHistoryByAsset(items, { currency, locale, formatCurrency, onHistoryDetail }) {
|
|
11280
|
+
var _a, _b, _c, _d, _e;
|
|
11281
|
+
const map = {};
|
|
11282
|
+
for (const item of items) {
|
|
11283
|
+
const isDeposit = item.type.includes("DEPOSIT");
|
|
11284
|
+
const primaryAsset = isDeposit ? (_a = item.amounts) == null ? void 0 : _a.assetIn : (_b = item.amounts) == null ? void 0 : _b.assetOut;
|
|
11285
|
+
const symbol = (_e = (_d = (_c = primaryAsset == null ? void 0 : primaryAsset.token) == null ? void 0 : _c.symbol) == null ? void 0 : _d.toUpperCase()) != null ? _e : "";
|
|
11286
|
+
if (!symbol || !primaryAsset) continue;
|
|
11287
|
+
const amount = formatHistoryAssetAmount({
|
|
11288
|
+
amountHumanized: primaryAsset.amountHumanized,
|
|
11289
|
+
amountInUSD: primaryAsset.amountInUSD,
|
|
11290
|
+
symbol,
|
|
11291
|
+
currency,
|
|
11292
|
+
locale,
|
|
11293
|
+
formatCurrency
|
|
11294
|
+
});
|
|
11295
|
+
const date = new Date(item.createdAt).toLocaleString(locale, {
|
|
11296
|
+
day: "2-digit",
|
|
11297
|
+
month: "2-digit",
|
|
11298
|
+
year: "numeric",
|
|
11299
|
+
hour: "2-digit",
|
|
11300
|
+
minute: "2-digit"
|
|
11301
|
+
});
|
|
11302
|
+
const entry = {
|
|
11303
|
+
id: item.id,
|
|
11304
|
+
date,
|
|
11305
|
+
type: isDeposit ? "deposit" : "withdraw",
|
|
11306
|
+
amount,
|
|
11307
|
+
onClick: () => onHistoryDetail(item.id, isDeposit)
|
|
11308
|
+
};
|
|
11309
|
+
if (!map[symbol]) map[symbol] = [];
|
|
11310
|
+
map[symbol].push(entry);
|
|
11311
|
+
}
|
|
11312
|
+
return map;
|
|
11313
|
+
}
|
|
11232
11314
|
var EARN_CATEGORY_DEFINITIONS = [
|
|
11233
11315
|
{
|
|
11234
11316
|
id: "dolar",
|
|
11235
11317
|
imageUrl: mascotUsdUrl,
|
|
11236
|
-
assetFilter: ["USDC", "USDT", "DAI", "thbill"]
|
|
11318
|
+
assetFilter: ["USDC", "USDT", "DAI", "thbill", "podsUSDCy"]
|
|
11237
11319
|
},
|
|
11238
11320
|
{
|
|
11239
11321
|
id: "real",
|
|
@@ -11296,7 +11378,7 @@ var columnHeaderClasses = [
|
|
|
11296
11378
|
"text-[color:var(--deframe-widget-color-text-tertiary)]",
|
|
11297
11379
|
"leading-[var(--deframe-widget-font-leading-xs)]"
|
|
11298
11380
|
].join(" ");
|
|
11299
|
-
var GRID_COLS2 = "grid grid-cols-[
|
|
11381
|
+
var GRID_COLS2 = "grid grid-cols-[1fr_100px_100px_100px_100px] gap-x-[var(--deframe-widget-size-gap-md)]";
|
|
11300
11382
|
var BANNER_COLORS = [
|
|
11301
11383
|
"var(--deframe-widget-color-brand-primary)",
|
|
11302
11384
|
"var(--deframe-widget-color-brand-secondary)"
|
|
@@ -11349,41 +11431,6 @@ var EarnDesktopViewSimple = ({
|
|
|
11349
11431
|
};
|
|
11350
11432
|
});
|
|
11351
11433
|
}, [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
11434
|
const cardLabels = React6__default.useMemo(() => ({
|
|
11388
11435
|
investLabel: labels == null ? void 0 : labels.investLabel,
|
|
11389
11436
|
withdrawLabel: labels == null ? void 0 : labels.cardWithdrawLabel,
|
|
@@ -11393,18 +11440,33 @@ var EarnDesktopViewSimple = ({
|
|
|
11393
11440
|
historyWithdrawnLabel: labels == null ? void 0 : labels.cardHistoryWithdrawnLabel,
|
|
11394
11441
|
historyInterestReceivedLabel: labels == null ? void 0 : labels.cardHistoryInterestReceivedLabel
|
|
11395
11442
|
}), [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]);
|
|
11443
|
+
const formattedPositions = useMemo(
|
|
11444
|
+
() => formatEarnPositions(positions, { currency, locale, formatCurrency }),
|
|
11445
|
+
[positions, currency, locale, formatCurrency]
|
|
11446
|
+
);
|
|
11447
|
+
const historyByAsset = useMemo(
|
|
11448
|
+
() => buildEarnHistoryByAsset(historyItems, {
|
|
11449
|
+
currency,
|
|
11450
|
+
locale,
|
|
11451
|
+
formatCurrency,
|
|
11452
|
+
onHistoryDetail: (id, isDeposit) => onHistoryDetail == null ? void 0 : onHistoryDetail(id, isDeposit)
|
|
11453
|
+
}),
|
|
11454
|
+
[historyItems, currency, locale, formatCurrency, onHistoryDetail]
|
|
11455
|
+
);
|
|
11396
11456
|
const strategyRows = React6__default.useMemo(() => {
|
|
11397
|
-
return
|
|
11398
|
-
var _a;
|
|
11457
|
+
return formattedPositions.positions.filter((p) => p.spotPosition.underlyingBalanceUSD > 0.01).map((p) => {
|
|
11458
|
+
var _a, _b;
|
|
11459
|
+
const strategyDisplayName = getStrategyDisplayName(p.strategy);
|
|
11399
11460
|
return {
|
|
11400
|
-
logoUrl: p.strategy
|
|
11401
|
-
assetName:
|
|
11461
|
+
logoUrl: getStrategyDisplayLogo(p.strategy),
|
|
11462
|
+
assetName: strategyDisplayName,
|
|
11402
11463
|
network: p.strategy.network,
|
|
11403
|
-
investedFormatted:
|
|
11464
|
+
investedFormatted: p.spotPosition.investedFormatted,
|
|
11404
11465
|
earningsFormatted: `${(p.spotPosition.apy * 100).toFixed(2)}%`,
|
|
11405
11466
|
profitFormatted: formatCurrency(p.spotPosition.profitInUSD),
|
|
11467
|
+
totalValueFormatted: (_a = p.spotPosition.totalValueFormatted) != null ? _a : formatCurrency(p.spotPosition.underlyingBalanceUSD),
|
|
11406
11468
|
isLoading: false,
|
|
11407
|
-
history: (
|
|
11469
|
+
history: (_b = historyByAsset[p.strategy.assetName.toUpperCase()]) != null ? _b : [],
|
|
11408
11470
|
onInvestClick: onDeposit ? () => onDeposit(p.strategy.id) : () => {
|
|
11409
11471
|
},
|
|
11410
11472
|
onWithdrawClick: onWithdraw ? () => onWithdraw(p.strategy.id) : () => {
|
|
@@ -11414,7 +11476,7 @@ var EarnDesktopViewSimple = ({
|
|
|
11414
11476
|
labels: cardLabels
|
|
11415
11477
|
};
|
|
11416
11478
|
});
|
|
11417
|
-
}, [
|
|
11479
|
+
}, [formattedPositions.positions, formatCurrency, historyByAsset, onDeposit, onWithdraw, onDetails, cardLabels]);
|
|
11418
11480
|
if (isLoading) {
|
|
11419
11481
|
return /* @__PURE__ */ jsxs("div", { "data-test-id": "earn-hub-view-simple-loading", className: twMerge(wrapperBaseClasses2, className), children: [
|
|
11420
11482
|
/* @__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 +11623,13 @@ var EarnDesktopViewSimple = ({
|
|
|
11561
11623
|
"px-[var(--deframe-widget-size-padding-x-md)] py-[var(--deframe-widget-size-padding-y-sm)]",
|
|
11562
11624
|
"border-t border-[color:var(--deframe-widget-color-border-secondary)]"
|
|
11563
11625
|
),
|
|
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(
|
|
11626
|
+
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
11627
|
"span",
|
|
11566
11628
|
{
|
|
11567
11629
|
className: twMerge(
|
|
11568
11630
|
columnHeaderClasses,
|
|
11569
11631
|
(i === 1 || i === 2) && "text-center",
|
|
11570
|
-
i === 3 && "text-right"
|
|
11632
|
+
(i === 3 || i === 4) && "text-right"
|
|
11571
11633
|
),
|
|
11572
11634
|
children: label
|
|
11573
11635
|
},
|