@gearbox-protocol/ui-kit 4.0.0-next.20 → 4.0.0-next.21
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/cjs/components/base/position-assets/position-assets.cjs +1 -1
- package/dist/cjs/components/base/strategy-apy-breakdown-card/constants.cjs +1 -1
- package/dist/cjs/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.cjs +1 -1
- package/dist/cjs/components/base/values/scalars.cjs +1 -1
- package/dist/cjs/components/compound-apy/compound-apy.cjs +1 -1
- package/dist/cjs/components/yield-breakdown-tooltip/yield-breakdown-tooltip.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/locale/en.json.cjs +1 -1
- package/dist/cjs/utils/index.cjs +1 -1
- package/dist/esm/components/base/position-assets/position-assets.js +62 -39
- package/dist/esm/components/base/strategy-apy-breakdown-card/constants.js +7 -3
- package/dist/esm/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.js +140 -166
- package/dist/esm/components/base/values/scalars.js +40 -35
- package/dist/esm/components/compound-apy/compound-apy.js +24 -23
- package/dist/esm/components/yield-breakdown-tooltip/yield-breakdown-tooltip.js +15 -15
- package/dist/esm/index.js +88 -91
- package/dist/esm/locale/en.json.js +3 -7
- package/dist/esm/utils/index.js +48 -51
- package/dist/globals.css +1 -1
- package/dist/types/components/base/position-assets/position-assets.d.ts +19 -13
- package/dist/types/components/base/strategy-apy-breakdown-card/constants.d.ts +5 -1
- package/dist/types/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.d.ts +39 -14
- package/dist/types/components/base/values/scalars.d.ts +17 -2
- package/dist/types/components/compound-apy/compound-apy.d.ts +11 -1
- package/dist/types/locale/en.json.d.ts +1 -6
- package/dist/types/utils/index.d.ts +0 -1
- package/package.json +1 -1
- package/dist/cjs/utils/strategy-apy.cjs +0 -1
- package/dist/esm/utils/strategy-apy.js +0 -51
- package/dist/types/utils/strategy-apy.d.ts +0 -40
|
@@ -1,82 +1,87 @@
|
|
|
1
|
-
import { jsx as r, jsxs as
|
|
2
|
-
import { formatUnits as
|
|
1
|
+
import { jsx as r, jsxs as m } from "react/jsx-runtime";
|
|
2
|
+
import { formatUnits as u } from "viem";
|
|
3
3
|
import { CompoundAPY as p } from "../../compound-apy/compound-apy.js";
|
|
4
|
-
import { SimpleTooltip as
|
|
4
|
+
import { SimpleTooltip as a } from "../../tooltip/simple-tooltip.js";
|
|
5
5
|
import "../../tooltip/tooltip.js";
|
|
6
6
|
import "react";
|
|
7
7
|
import "@gearbox-protocol/sdk";
|
|
8
|
-
import { cn as
|
|
8
|
+
import { cn as c } from "../../../utils/cn.js";
|
|
9
9
|
import "sonner";
|
|
10
|
-
import { formatAssetAmount as
|
|
11
|
-
import { formatLeverage as
|
|
12
|
-
import { formatPercentAmount as
|
|
10
|
+
import { formatAssetAmount as d } from "../../../utils/format-asset-amount.js";
|
|
11
|
+
import { formatLeverage as f } from "../../../utils/format-leverage.js";
|
|
12
|
+
import { formatPercentAmount as h, formatMoney as v } from "../../../utils/format-money.js";
|
|
13
13
|
import "@gearbox-protocol/sdk/common-utils";
|
|
14
14
|
import "luxon";
|
|
15
15
|
import "../../../utils/z-index.js";
|
|
16
|
-
import { ValueTest as
|
|
17
|
-
const
|
|
16
|
+
import { ValueTest as i } from "./constants.js";
|
|
17
|
+
const x = "—";
|
|
18
18
|
function n() {
|
|
19
|
-
return /* @__PURE__ */ r("span", { "data-testid":
|
|
19
|
+
return /* @__PURE__ */ r("span", { "data-testid": i.placeholder, children: x });
|
|
20
20
|
}
|
|
21
21
|
function l(t) {
|
|
22
|
-
return `${
|
|
23
|
-
}
|
|
24
|
-
function E({ data: t }) {
|
|
25
|
-
return t === void 0 ? /* @__PURE__ */ r(n, {}) : typeof t == "number" ? /* @__PURE__ */ r("span", { "data-testid": e.apy, children: l(t) }) : /* @__PURE__ */ r("span", { "data-testid": e.apy, children: /* @__PURE__ */ r(p, { apy: t }) });
|
|
22
|
+
return `${h(t / 100, 2)}%`;
|
|
26
23
|
}
|
|
27
24
|
function H({
|
|
28
|
-
data: t
|
|
25
|
+
data: t,
|
|
26
|
+
tooltip: e = !0
|
|
29
27
|
}) {
|
|
30
|
-
return t
|
|
28
|
+
return t === void 0 ? /* @__PURE__ */ r(n, {}) : typeof t == "number" ? /* @__PURE__ */ r("span", { "data-testid": i.apy, children: l(t) }) : /* @__PURE__ */ r("span", { "data-testid": i.apy, children: /* @__PURE__ */ r(p, { apy: t, tooltip: e }) });
|
|
31
29
|
}
|
|
32
30
|
function N({
|
|
33
31
|
data: t
|
|
34
32
|
}) {
|
|
35
|
-
return t
|
|
33
|
+
return t == null ? /* @__PURE__ */ r(n, {}) : /* @__PURE__ */ r("span", { "data-testid": i.usd, children: v(t) });
|
|
36
34
|
}
|
|
37
35
|
function w({
|
|
38
36
|
data: t
|
|
39
37
|
}) {
|
|
40
|
-
return t === void 0 ? /* @__PURE__ */ r(n, {}) : /* @__PURE__ */ r("span", { "data-testid":
|
|
38
|
+
return t === void 0 ? /* @__PURE__ */ r(n, {}) : /* @__PURE__ */ r("span", { "data-testid": i.leverage, children: `${f(t)}x` });
|
|
41
39
|
}
|
|
42
40
|
function D({
|
|
43
41
|
data: t
|
|
42
|
+
}) {
|
|
43
|
+
return t === void 0 ? /* @__PURE__ */ r(n, {}) : /* @__PURE__ */ r("span", { "data-testid": i.utilization, children: l(t) });
|
|
44
|
+
}
|
|
45
|
+
function M({
|
|
46
|
+
data: t
|
|
44
47
|
}) {
|
|
45
48
|
if (t === void 0)
|
|
46
49
|
return /* @__PURE__ */ r(n, {});
|
|
47
|
-
const
|
|
48
|
-
return /* @__PURE__ */ r("span", { "data-testid":
|
|
50
|
+
const e = t < 1e4 ? "text-destructive" : t < 11e3 ? "text-warning" : "text-success";
|
|
51
|
+
return /* @__PURE__ */ r("span", { "data-testid": i.healthFactor, className: c(e), children: (t / 1e4).toFixed(2) });
|
|
49
52
|
}
|
|
50
|
-
function
|
|
53
|
+
function O({
|
|
51
54
|
data: t,
|
|
52
|
-
token:
|
|
55
|
+
token: e,
|
|
56
|
+
showSymbol: s = !0
|
|
53
57
|
}) {
|
|
54
|
-
if (t === void 0 ||
|
|
58
|
+
if (t === void 0 || e === void 0)
|
|
55
59
|
return /* @__PURE__ */ r(n, {});
|
|
56
|
-
const o =
|
|
60
|
+
const o = u(t, e.decimals);
|
|
57
61
|
return (
|
|
58
62
|
// `title` also keeps the amount where a hover tooltip cannot reach:
|
|
59
|
-
// keyboard, touch, and the browser's own find
|
|
60
|
-
|
|
63
|
+
// keyboard, touch, and the browser's own find — and keeps the symbol
|
|
64
|
+
// reachable there even when the row is the one printing it
|
|
65
|
+
/* @__PURE__ */ m("span", { "data-testid": i.tokenBigint, title: `${o} ${e.symbol}`, children: [
|
|
61
66
|
/* @__PURE__ */ r(
|
|
62
|
-
|
|
67
|
+
a,
|
|
63
68
|
{
|
|
64
69
|
placement: "top",
|
|
65
70
|
className: "break-all",
|
|
66
|
-
title: /* @__PURE__ */ r("span", { children:
|
|
71
|
+
title: /* @__PURE__ */ r("span", { children: d(t, e.decimals) }),
|
|
67
72
|
children: /* @__PURE__ */ r("span", { children: o })
|
|
68
73
|
}
|
|
69
74
|
),
|
|
70
|
-
` ${
|
|
75
|
+
s && ` ${e.symbol}`
|
|
71
76
|
] })
|
|
72
77
|
);
|
|
73
78
|
}
|
|
74
79
|
export {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
H as ApyValue,
|
|
81
|
+
M as HealthFactorValue,
|
|
82
|
+
w as LeverageValue,
|
|
83
|
+
O as TokenBigint,
|
|
84
|
+
N as UsdValue,
|
|
85
|
+
D as UtilizationValue,
|
|
81
86
|
l as bps
|
|
82
87
|
};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { useId as
|
|
3
|
-
import { YieldBreakdownTooltip as
|
|
4
|
-
import { totalApyOf as
|
|
1
|
+
import { jsx as e, jsxs as r } from "react/jsx-runtime";
|
|
2
|
+
import { useId as w } from "react";
|
|
3
|
+
import { YieldBreakdownTooltip as x } from "../yield-breakdown-tooltip/yield-breakdown-tooltip.js";
|
|
4
|
+
import { totalApyOf as v, positiveTokenRewardsOf as C, pointProgramsOf as I } from "../../utils/apy-breakdown.js";
|
|
5
5
|
import "@gearbox-protocol/sdk";
|
|
6
|
-
import { bpsToPercent as
|
|
7
|
-
import { cn as
|
|
6
|
+
import { bpsToPercent as k } from "../../utils/bps.js";
|
|
7
|
+
import { cn as P } from "../../utils/cn.js";
|
|
8
8
|
import "sonner";
|
|
9
|
-
import { formatCompactPercent as
|
|
9
|
+
import { formatCompactPercent as A } from "../../utils/format-money.js";
|
|
10
10
|
import "@gearbox-protocol/sdk/common-utils";
|
|
11
11
|
import "luxon";
|
|
12
12
|
import "../../utils/z-index.js";
|
|
13
13
|
const l = 14;
|
|
14
|
-
function
|
|
15
|
-
const t = `additional-incentives-${
|
|
16
|
-
return /* @__PURE__ */
|
|
14
|
+
function O() {
|
|
15
|
+
const t = `additional-incentives-${w().replace(/:/g, "")}`;
|
|
16
|
+
return /* @__PURE__ */ r(
|
|
17
17
|
"svg",
|
|
18
18
|
{
|
|
19
19
|
width: l,
|
|
@@ -42,7 +42,7 @@ function A() {
|
|
|
42
42
|
strokeLinecap: "round"
|
|
43
43
|
}
|
|
44
44
|
),
|
|
45
|
-
/* @__PURE__ */ e("defs", { children: /* @__PURE__ */
|
|
45
|
+
/* @__PURE__ */ e("defs", { children: /* @__PURE__ */ r(
|
|
46
46
|
"linearGradient",
|
|
47
47
|
{
|
|
48
48
|
id: t,
|
|
@@ -62,32 +62,33 @@ function A() {
|
|
|
62
62
|
);
|
|
63
63
|
}
|
|
64
64
|
function c(t) {
|
|
65
|
-
return t == null ? !1 :
|
|
65
|
+
return t == null ? !1 : C(t).length > 0 || I(t).length > 0;
|
|
66
66
|
}
|
|
67
|
-
function
|
|
67
|
+
function U({
|
|
68
68
|
apy: t,
|
|
69
69
|
maxLeverage: p,
|
|
70
|
-
collateralApy:
|
|
70
|
+
collateralApy: n,
|
|
71
71
|
borrowApy: d,
|
|
72
72
|
quotaRate: a,
|
|
73
73
|
decimals: m = 2,
|
|
74
|
+
tooltip: f = !0,
|
|
74
75
|
className: o
|
|
75
76
|
}) {
|
|
76
77
|
if (!t)
|
|
77
78
|
return /* @__PURE__ */ e("span", { className: "text-secondary-foreground", children: "—" });
|
|
78
|
-
const i =
|
|
79
|
-
const
|
|
80
|
-
return /* @__PURE__ */
|
|
81
|
-
/* @__PURE__ */ e("span", { className: "inline-flex items-center", children:
|
|
82
|
-
|
|
79
|
+
const i = v(t), h = c(t) || c(n), u = f && i >= 1, s = () => {
|
|
80
|
+
const g = A(k(i), m);
|
|
81
|
+
return /* @__PURE__ */ r("div", { className: P("inline-flex items-center gap-1.5", o), children: [
|
|
82
|
+
/* @__PURE__ */ e("span", { className: "inline-flex items-center", children: g }),
|
|
83
|
+
h ? /* @__PURE__ */ e(O, {}) : null
|
|
83
84
|
] });
|
|
84
85
|
};
|
|
85
|
-
return
|
|
86
|
-
|
|
86
|
+
return u ? /* @__PURE__ */ e(
|
|
87
|
+
x,
|
|
87
88
|
{
|
|
88
89
|
supplyApy: t,
|
|
89
90
|
maxLeverage: p,
|
|
90
|
-
collateralApy:
|
|
91
|
+
collateralApy: n,
|
|
91
92
|
borrowApy: d,
|
|
92
93
|
quotaRate: a,
|
|
93
94
|
className: o,
|
|
@@ -96,5 +97,5 @@ function E({
|
|
|
96
97
|
) : s();
|
|
97
98
|
}
|
|
98
99
|
export {
|
|
99
|
-
|
|
100
|
+
U as CompoundAPY
|
|
100
101
|
};
|
|
@@ -8,7 +8,7 @@ import "react";
|
|
|
8
8
|
import { tokenRewardsOf as I, pointProgramsOf as B, totalApyOf as T } from "../../utils/apy-breakdown.js";
|
|
9
9
|
import "@gearbox-protocol/sdk";
|
|
10
10
|
import { bpsToPercent as $ } from "../../utils/bps.js";
|
|
11
|
-
import { cn as
|
|
11
|
+
import { cn as c } from "../../utils/cn.js";
|
|
12
12
|
import "sonner";
|
|
13
13
|
import { formatLeverage as j } from "../../utils/format-leverage.js";
|
|
14
14
|
import { formatCompactPercent as S } from "../../utils/format-money.js";
|
|
@@ -23,15 +23,15 @@ function V({
|
|
|
23
23
|
supplyApy: n,
|
|
24
24
|
maxLeverage: o,
|
|
25
25
|
collateralApy: r,
|
|
26
|
-
borrowApy:
|
|
27
|
-
quotaRate:
|
|
26
|
+
borrowApy: u,
|
|
27
|
+
quotaRate: f,
|
|
28
28
|
children: h,
|
|
29
|
-
className:
|
|
29
|
+
className: g
|
|
30
30
|
}) {
|
|
31
|
-
const
|
|
31
|
+
const d = o !== void 0 && o > 0, l = d ? r : r ?? n, w = l ? I(l) : [], y = B(n), b = T(n), p = u != null || f != null ? -((u ?? 0) + (f ?? 0)) : void 0, x = y.filter((t) => t.multiplier != null), v = /* @__PURE__ */ a(
|
|
32
32
|
"div",
|
|
33
33
|
{
|
|
34
|
-
className:
|
|
34
|
+
className: c(
|
|
35
35
|
"flex w-[400px] max-w-[calc(100vw-32px)] flex-col gap-4 p-4",
|
|
36
36
|
"rounded-xl",
|
|
37
37
|
"bg-card text-card-foreground",
|
|
@@ -41,7 +41,7 @@ function V({
|
|
|
41
41
|
),
|
|
42
42
|
children: [
|
|
43
43
|
/* @__PURE__ */ a("div", { className: "flex h-6 items-center justify-between gap-3", children: [
|
|
44
|
-
/* @__PURE__ */ e("span", { className: "text-base font-semibold leading-4 text-foreground", children:
|
|
44
|
+
/* @__PURE__ */ e("span", { className: "text-base font-semibold leading-4 text-foreground", children: d ? /* @__PURE__ */ e(
|
|
45
45
|
s,
|
|
46
46
|
{
|
|
47
47
|
messageId: "components.yieldBreakdown.titleNetAtLeverage",
|
|
@@ -53,7 +53,7 @@ function V({
|
|
|
53
53
|
/* @__PURE__ */ e(
|
|
54
54
|
"span",
|
|
55
55
|
{
|
|
56
|
-
className:
|
|
56
|
+
className: c(
|
|
57
57
|
"rounded-md px-2 py-0.5 text-sm font-semibold tabular-nums",
|
|
58
58
|
b > 0 ? "bg-success/20 text-success" : "bg-muted text-muted-foreground"
|
|
59
59
|
),
|
|
@@ -61,7 +61,7 @@ function V({
|
|
|
61
61
|
}
|
|
62
62
|
)
|
|
63
63
|
] }),
|
|
64
|
-
l
|
|
64
|
+
l?.organicApy != null && /* @__PURE__ */ e(
|
|
65
65
|
m,
|
|
66
66
|
{
|
|
67
67
|
muted: l.organicApy < 0,
|
|
@@ -87,12 +87,12 @@ function V({
|
|
|
87
87
|
},
|
|
88
88
|
`incentive-${t.token.address}-${t.supplyApr}`
|
|
89
89
|
)),
|
|
90
|
-
|
|
90
|
+
d && p != null && /* @__PURE__ */ e(
|
|
91
91
|
m,
|
|
92
92
|
{
|
|
93
|
-
muted:
|
|
93
|
+
muted: p < 0,
|
|
94
94
|
label: /* @__PURE__ */ e(s, { messageId: "components.yieldBreakdown.borrowRate" }),
|
|
95
|
-
value: i(
|
|
95
|
+
value: i(p)
|
|
96
96
|
}
|
|
97
97
|
),
|
|
98
98
|
x.length > 0 && /* @__PURE__ */ a(k, { children: [
|
|
@@ -135,8 +135,8 @@ function V({
|
|
|
135
135
|
type: "modal-tooltip",
|
|
136
136
|
minWidth: "100%",
|
|
137
137
|
maxWidth: "100%",
|
|
138
|
-
title: /* @__PURE__ */ e("span", { className:
|
|
139
|
-
triggerClassName:
|
|
138
|
+
title: /* @__PURE__ */ e("span", { className: g, children: h }),
|
|
139
|
+
triggerClassName: g,
|
|
140
140
|
children: v
|
|
141
141
|
}
|
|
142
142
|
);
|
|
@@ -151,7 +151,7 @@ function m({
|
|
|
151
151
|
/* @__PURE__ */ e(
|
|
152
152
|
"span",
|
|
153
153
|
{
|
|
154
|
-
className:
|
|
154
|
+
className: c(
|
|
155
155
|
"shrink-0 font-semibold tabular-nums",
|
|
156
156
|
r ? "text-muted-foreground" : "text-foreground"
|
|
157
157
|
),
|