@gearbox-protocol/ui-kit 4.0.0-next.26 → 4.0.0-next.28

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.
Files changed (34) hide show
  1. package/dist/cjs/components/base/apy-breakdown-body/apy-breakdown-body.cjs +1 -0
  2. package/dist/cjs/components/base/apy-breakdown-body/index.cjs +1 -0
  3. package/dist/cjs/components/base/info-list/info-list.cjs +1 -1
  4. package/dist/cjs/components/base/pool-apy-breakdown-card/constants.cjs +1 -1
  5. package/dist/cjs/components/base/pool-apy-breakdown-card/pool-apy-breakdown-card.cjs +1 -1
  6. package/dist/cjs/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.cjs +1 -1
  7. package/dist/cjs/components/base/values/scalars.cjs +1 -1
  8. package/dist/cjs/components/compound-apy/compound-apy.cjs +1 -1
  9. package/dist/cjs/components/index.cjs +1 -1
  10. package/dist/cjs/components/yield-breakdown-tooltip/index.cjs +1 -1
  11. package/dist/cjs/components/yield-breakdown-tooltip/yield-breakdown-tooltip.cjs +1 -1
  12. package/dist/cjs/index.cjs +1 -1
  13. package/dist/esm/components/base/apy-breakdown-body/apy-breakdown-body.js +106 -0
  14. package/dist/esm/components/base/apy-breakdown-body/index.js +10 -0
  15. package/dist/esm/components/base/info-list/info-list.js +1 -1
  16. package/dist/esm/components/base/pool-apy-breakdown-card/constants.js +5 -2
  17. package/dist/esm/components/base/pool-apy-breakdown-card/pool-apy-breakdown-card.js +111 -57
  18. package/dist/esm/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.js +140 -185
  19. package/dist/esm/components/base/values/scalars.js +11 -10
  20. package/dist/esm/components/compound-apy/compound-apy.js +20 -18
  21. package/dist/esm/components/index.js +45 -44
  22. package/dist/esm/components/yield-breakdown-tooltip/index.js +2 -1
  23. package/dist/esm/components/yield-breakdown-tooltip/yield-breakdown-tooltip.js +136 -156
  24. package/dist/esm/index.js +191 -190
  25. package/dist/globals.css +1 -1
  26. package/dist/types/components/base/apy-breakdown-body/apy-breakdown-body.d.ts +42 -0
  27. package/dist/types/components/base/apy-breakdown-body/index.d.ts +2 -0
  28. package/dist/types/components/base/pool-apy-breakdown-card/constants.d.ts +3 -0
  29. package/dist/types/components/base/pool-apy-breakdown-card/pool-apy-breakdown-card.d.ts +9 -7
  30. package/dist/types/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.d.ts +3 -1
  31. package/dist/types/components/base/values/scalars.d.ts +3 -1
  32. package/dist/types/components/compound-apy/compound-apy.d.ts +3 -1
  33. package/dist/types/components/yield-breakdown-tooltip/yield-breakdown-tooltip.d.ts +23 -3
  34. package/package.json +1 -1
@@ -1,213 +1,168 @@
1
- import { jsxs as n, jsx as e, Fragment as k } from "react/jsx-runtime";
2
- import { PointsIcon as w } from "../../points-icon/points-icon.js";
3
- import { TokenIcon as N } from "../../token-icon/token-icon.js";
4
- import { FormattedMessageTyped as l } from "../../typed-intl/index.js";
5
- import "react";
6
- import { totalApyOf as A, positiveTokenRewardsOf as I, pointProgramsOf as B } from "../../../utils/apy-breakdown.js";
7
- import "@gearbox-protocol/sdk/onchain";
8
- import { bpsToPercent as C } from "../../../utils/bps.js";
9
- import { cn as g } from "../../../utils/cn.js";
10
- import "sonner";
11
- import { formatLeverage as d } from "../../../utils/format-leverage.js";
12
- import "@gearbox-protocol/sdk/common-utils";
13
- import "luxon";
14
- import "../../../utils/z-index.js";
15
- import { StrategyApyBreakdownCardTest as i } from "./constants.js";
16
- const T = "—";
17
- function G({
18
- data: s,
19
- showFormula: o = !1
1
+ import { jsxs as d, jsx as t, Fragment as b } from "react/jsx-runtime";
2
+ import { ApyBreakdownBody as B, formatBreakdownRate as n, ApyBreakdownRow as m, periodMessageId as y, ApyBreakdownDivider as T, BREAKDOWN_DASH as h } from "../apy-breakdown-body/apy-breakdown-body.js";
3
+ import { PointsIcon as x } from "../../points-icon/points-icon.js";
4
+ import { TokenIcon as C } from "../../token-icon/token-icon.js";
5
+ import { FormattedMessageTyped as s } from "../../typed-intl/index.js";
6
+ import { totalApyOf as N, positiveTokenRewardsOf as R, pointProgramsOf as P } from "../../../utils/apy-breakdown.js";
7
+ import { formatLeverage as l } from "../../../utils/format-leverage.js";
8
+ import { StrategyApyBreakdownCardTest as o } from "./constants.js";
9
+ function E({
10
+ data: r,
11
+ showFormula: p = !1,
12
+ period: c
20
13
  }) {
21
- const { leverage: a, collateralApy: r } = s, c = A(s.netApy), u = c + s.borrowCost, h = r ? I(r) : [], b = r ? B(r) : [], v = h.map((t) => ({
22
- reward: t,
23
- value: Math.round(a * (t.supplyApr ?? 0))
24
- })), x = u - v.reduce((t, f) => t + f.value, 0), y = a > 0 ? x / a : void 0;
25
- return /* @__PURE__ */ n(
26
- "div",
14
+ const { leverage: a, collateralApy: i } = r, u = N(r.netApy), f = u + r.borrowCost, w = i ? R(i) : [], g = i ? P(i) : [], k = w.map((e) => ({
15
+ reward: e,
16
+ value: Math.round(a * (e.supplyApr ?? 0))
17
+ })), I = f - k.reduce((e, v) => e + v.value, 0), A = a > 0 ? I / a : void 0;
18
+ return /* @__PURE__ */ d(
19
+ B,
27
20
  {
28
- className: "flex w-full min-w-0 flex-col gap-4 rounded-xl border border-border bg-card p-4",
29
- "data-testid": i.root,
21
+ testId: o.root,
22
+ title: /* @__PURE__ */ t(
23
+ s,
24
+ {
25
+ messageId: y(
26
+ c,
27
+ "components.yieldBreakdown.titleNetAtLeverage",
28
+ "components.yieldBreakdown.titleNetAtLeverage7d"
29
+ ),
30
+ values: { leverage: l(a) }
31
+ }
32
+ ),
33
+ chip: n(u),
34
+ chipPositive: u > 0,
35
+ chipTestId: o.net,
30
36
  children: [
31
- /* @__PURE__ */ n("div", { className: "flex h-6 items-center justify-between gap-3", children: [
32
- /* @__PURE__ */ e("span", { className: "text-base font-semibold leading-4 text-foreground", children: /* @__PURE__ */ e(
33
- l,
34
- {
35
- messageId: "components.yieldBreakdown.titleNetAtLeverage",
36
- values: { leverage: d(a) }
37
- }
38
- ) }),
39
- /* @__PURE__ */ e(
40
- "span",
41
- {
42
- className: g(
43
- "rounded-md px-2 py-0.5 text-sm font-semibold tabular-nums",
44
- c > 0 ? "bg-success/20 text-success" : "bg-muted text-muted-foreground"
45
- ),
46
- "data-testid": i.net,
47
- children: m(c)
48
- }
49
- )
50
- ] }),
51
- /* @__PURE__ */ n("div", { className: "flex flex-col gap-3", children: [
52
- /* @__PURE__ */ e(
53
- p,
54
- {
55
- testId: i.collateral,
56
- label: /* @__PURE__ */ e(l, { messageId: "components.yieldBreakdown.collateralApy" }),
57
- value: m(x),
58
- subtext: o && y !== void 0 ? /* @__PURE__ */ e(
59
- l,
37
+ /* @__PURE__ */ t(
38
+ m,
39
+ {
40
+ testId: o.collateral,
41
+ valueTestId: o.value,
42
+ captionTestId: o.caption,
43
+ label: /* @__PURE__ */ t(
44
+ s,
45
+ {
46
+ messageId: y(
47
+ c,
48
+ "components.yieldBreakdown.collateralApy",
49
+ "components.yieldBreakdown.collateralApy7d"
50
+ )
51
+ }
52
+ ),
53
+ value: n(I),
54
+ subtext: p && A !== void 0 ? /* @__PURE__ */ t(
55
+ s,
56
+ {
57
+ messageId: "components.strategyApyBreakdownCard.formula",
58
+ values: {
59
+ leverage: l(a),
60
+ base: n(A)
61
+ }
62
+ }
63
+ ) : void 0
64
+ }
65
+ ),
66
+ k.map(({ reward: e, value: v }) => /* @__PURE__ */ t(
67
+ m,
68
+ {
69
+ valueTestId: o.value,
70
+ captionTestId: o.caption,
71
+ label: /* @__PURE__ */ d("span", { className: "inline-flex items-center gap-1.5", children: [
72
+ /* @__PURE__ */ t("span", { children: /* @__PURE__ */ t(
73
+ s,
60
74
  {
61
- messageId: "components.strategyApyBreakdownCard.formula",
62
- values: {
63
- leverage: d(a),
64
- base: m(y)
65
- }
75
+ messageId: "components.apyParts.extraAPY",
76
+ values: { symbol: e.token.symbol }
66
77
  }
67
- ) : void 0
68
- }
69
- ),
70
- v.map(({ reward: t, value: f }) => /* @__PURE__ */ e(
71
- p,
78
+ ) }),
79
+ /* @__PURE__ */ t(
80
+ C,
81
+ {
82
+ token: e.token,
83
+ symbol: e.token.symbol,
84
+ size: 16,
85
+ className: "shrink-0"
86
+ }
87
+ )
88
+ ] }),
89
+ value: n(v),
90
+ subtext: p ? /* @__PURE__ */ t(
91
+ s,
92
+ {
93
+ messageId: "components.strategyApyBreakdownCard.formula",
94
+ values: {
95
+ leverage: l(a),
96
+ base: n(e.supplyApr ?? 0)
97
+ }
98
+ }
99
+ ) : void 0
100
+ },
101
+ `incentive-${e.token.address}-${e.supplyApr ?? 0}`
102
+ )),
103
+ /* @__PURE__ */ t(
104
+ m,
105
+ {
106
+ muted: !0,
107
+ testId: o.borrow,
108
+ valueTestId: o.value,
109
+ label: /* @__PURE__ */ t(
110
+ s,
111
+ {
112
+ messageId: y(
113
+ c,
114
+ "components.yieldBreakdown.borrowRate",
115
+ "components.yieldBreakdown.borrowRate7d"
116
+ )
117
+ }
118
+ ),
119
+ value: n(-r.borrowCost)
120
+ }
121
+ ),
122
+ g.length > 0 ? /* @__PURE__ */ d(b, { children: [
123
+ /* @__PURE__ */ t(T, {}),
124
+ g.map((e) => /* @__PURE__ */ t(
125
+ m,
72
126
  {
73
- label: /* @__PURE__ */ n("span", { className: "inline-flex items-center gap-1.5", children: [
74
- /* @__PURE__ */ e("span", { children: /* @__PURE__ */ e(
75
- l,
127
+ valueTestId: o.points,
128
+ captionTestId: o.caption,
129
+ label: /* @__PURE__ */ d("span", { className: "inline-flex items-center gap-1.5", children: [
130
+ /* @__PURE__ */ t("span", { children: /* @__PURE__ */ t(
131
+ s,
76
132
  {
77
- messageId: "components.apyParts.extraAPY",
78
- values: { symbol: t.token.symbol }
133
+ messageId: "components.yieldBreakdown.programPoints",
134
+ values: { name: e.name }
79
135
  }
80
136
  ) }),
81
- /* @__PURE__ */ e(
82
- N,
137
+ /* @__PURE__ */ t(
138
+ x,
83
139
  {
84
- token: t.token,
85
- symbol: t.token.symbol,
140
+ reward: { name: e.name, type: e.id },
86
141
  size: 16,
87
142
  className: "shrink-0"
88
143
  }
89
144
  )
90
145
  ] }),
91
- value: m(f),
92
- subtext: o ? /* @__PURE__ */ e(
93
- l,
146
+ value: e.multiplier != null ? `${l(e.multiplier * a)}×` : h,
147
+ subtext: p && e.multiplier != null ? /* @__PURE__ */ t(
148
+ s,
94
149
  {
95
150
  messageId: "components.strategyApyBreakdownCard.formula",
96
151
  values: {
97
- leverage: d(a),
98
- base: m(t.supplyApr ?? 0)
152
+ leverage: l(a),
153
+ base: l(e.multiplier)
99
154
  }
100
155
  }
101
156
  ) : void 0
102
157
  },
103
- `incentive-${t.token.address}-${t.supplyApr ?? 0}`
104
- )),
105
- /* @__PURE__ */ e(
106
- p,
107
- {
108
- muted: !0,
109
- testId: i.borrow,
110
- label: /* @__PURE__ */ e(l, { messageId: "components.yieldBreakdown.borrowRate" }),
111
- value: m(-s.borrowCost)
112
- }
113
- ),
114
- b.length > 0 ? /* @__PURE__ */ n(k, { children: [
115
- /* @__PURE__ */ e("div", { className: "h-px w-full bg-divider" }),
116
- b.map((t) => /* @__PURE__ */ e(
117
- p,
118
- {
119
- valueTestId: i.points,
120
- label: /* @__PURE__ */ n("span", { className: "inline-flex items-center gap-1.5", children: [
121
- /* @__PURE__ */ e("span", { children: /* @__PURE__ */ e(
122
- l,
123
- {
124
- messageId: "components.yieldBreakdown.programPoints",
125
- values: { name: t.name }
126
- }
127
- ) }),
128
- /* @__PURE__ */ e(
129
- w,
130
- {
131
- reward: { name: t.name, type: t.id },
132
- size: 16,
133
- className: "shrink-0"
134
- }
135
- )
136
- ] }),
137
- value: t.multiplier != null ? `${d(t.multiplier * a)}×` : T,
138
- subtext: o && t.multiplier != null ? /* @__PURE__ */ e(
139
- l,
140
- {
141
- messageId: "components.strategyApyBreakdownCard.formula",
142
- values: {
143
- leverage: d(a),
144
- base: d(t.multiplier)
145
- }
146
- }
147
- ) : void 0
148
- },
149
- t.id
150
- ))
151
- ] }) : null
152
- ] })
153
- ]
154
- }
155
- );
156
- }
157
- function m(s) {
158
- const o = C(s), a = `${Math.abs(o).toFixed(2)}%`;
159
- return o < 0 ? `−${a}` : a;
160
- }
161
- function p({
162
- label: s,
163
- value: o,
164
- subtext: a,
165
- muted: r = !1,
166
- testId: c,
167
- valueTestId: u = i.value
168
- }) {
169
- return /* @__PURE__ */ n(
170
- "div",
171
- {
172
- className: "flex items-start justify-between gap-3",
173
- "data-testid": c,
174
- children: [
175
- /* @__PURE__ */ e(
176
- "span",
177
- {
178
- className: g(
179
- "min-w-0 text-sm font-semibold leading-5",
180
- r ? "text-muted-foreground" : "text-foreground"
181
- ),
182
- children: s
183
- }
184
- ),
185
- /* @__PURE__ */ n("span", { className: "flex shrink-0 flex-col items-end", children: [
186
- /* @__PURE__ */ e(
187
- "span",
188
- {
189
- className: g(
190
- "text-sm font-semibold leading-5 tabular-nums",
191
- r ? "text-muted-foreground" : "text-foreground"
192
- ),
193
- "data-testid": u,
194
- children: o
195
- }
196
- ),
197
- a != null ? /* @__PURE__ */ e(
198
- "span",
199
- {
200
- className: "text-xs leading-4 text-muted-foreground",
201
- "data-testid": i.caption,
202
- children: a
203
- }
204
- ) : null
205
- ] })
158
+ e.id
159
+ ))
160
+ ] }) : null
206
161
  ]
207
162
  }
208
163
  );
209
164
  }
210
165
  export {
211
- G as StrategyApyBreakdownCard,
212
- i as StrategyApyBreakdownCardTest
166
+ E as StrategyApyBreakdownCard,
167
+ o as StrategyApyBreakdownCardTest
213
168
  };
@@ -18,14 +18,15 @@ const x = "—";
18
18
  function n() {
19
19
  return /* @__PURE__ */ r("span", { "data-testid": i.placeholder, children: x });
20
20
  }
21
- function l(t) {
21
+ function s(t) {
22
22
  return `${h(t / 100, 2)}%`;
23
23
  }
24
24
  function H({
25
25
  data: t,
26
- tooltip: e = !0
26
+ tooltip: e = !0,
27
+ period: o
27
28
  }) {
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 }) });
29
+ return t === void 0 ? /* @__PURE__ */ r(n, {}) : typeof t == "number" ? /* @__PURE__ */ r("span", { "data-testid": i.apy, children: s(t) }) : /* @__PURE__ */ r("span", { "data-testid": i.apy, children: /* @__PURE__ */ r(p, { apy: t, tooltip: e, period: o }) });
29
30
  }
30
31
  function N({
31
32
  data: t
@@ -40,7 +41,7 @@ function w({
40
41
  function D({
41
42
  data: t
42
43
  }) {
43
- return t === void 0 ? /* @__PURE__ */ r(n, {}) : /* @__PURE__ */ r("span", { "data-testid": i.utilization, children: l(t) });
44
+ return t === void 0 ? /* @__PURE__ */ r(n, {}) : /* @__PURE__ */ r("span", { "data-testid": i.utilization, children: s(t) });
44
45
  }
45
46
  function M({
46
47
  data: t
@@ -53,26 +54,26 @@ function M({
53
54
  function O({
54
55
  data: t,
55
56
  token: e,
56
- showSymbol: s = !0
57
+ showSymbol: o = !0
57
58
  }) {
58
59
  if (t === void 0 || e === void 0)
59
60
  return /* @__PURE__ */ r(n, {});
60
- const o = u(t, e.decimals);
61
+ const l = u(t, e.decimals);
61
62
  return (
62
63
  // `title` also keeps the amount where a hover tooltip cannot reach:
63
64
  // keyboard, touch, and the browser's own find — and keeps the symbol
64
65
  // reachable there even when the row is the one printing it
65
- /* @__PURE__ */ m("span", { "data-testid": i.tokenBigint, title: `${o} ${e.symbol}`, children: [
66
+ /* @__PURE__ */ m("span", { "data-testid": i.tokenBigint, title: `${l} ${e.symbol}`, children: [
66
67
  /* @__PURE__ */ r(
67
68
  a,
68
69
  {
69
70
  placement: "top",
70
71
  className: "break-all",
71
72
  title: /* @__PURE__ */ r("span", { children: d(t, e.decimals) }),
72
- children: /* @__PURE__ */ r("span", { children: o })
73
+ children: /* @__PURE__ */ r("span", { children: l })
73
74
  }
74
75
  ),
75
- s && ` ${e.symbol}`
76
+ o && ` ${e.symbol}`
76
77
  ] })
77
78
  );
78
79
  }
@@ -83,5 +84,5 @@ export {
83
84
  O as TokenBigint,
84
85
  N as UsdValue,
85
86
  D as UtilizationValue,
86
- l as bps
87
+ s as bps
87
88
  };
@@ -1,18 +1,18 @@
1
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";
2
+ import { useId as x } from "react";
3
+ import { YieldBreakdownTooltip as v } from "../yield-breakdown-tooltip/yield-breakdown-tooltip.js";
4
+ import { totalApyOf as C, positiveTokenRewardsOf as I, pointProgramsOf as k } from "../../utils/apy-breakdown.js";
5
5
  import "@gearbox-protocol/sdk/onchain";
6
- import { bpsToPercent as k } from "../../utils/bps.js";
7
- import { cn as P } from "../../utils/cn.js";
6
+ import { bpsToPercent as P } from "../../utils/bps.js";
7
+ import { cn as A } from "../../utils/cn.js";
8
8
  import "sonner";
9
- import { formatCompactPercent as A } from "../../utils/format-money.js";
9
+ import { formatCompactPercent as O } 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 O() {
15
- const t = `additional-incentives-${w().replace(/:/g, "")}`;
14
+ function F() {
15
+ const t = `additional-incentives-${x().replace(/:/g, "")}`;
16
16
  return /* @__PURE__ */ r(
17
17
  "svg",
18
18
  {
@@ -62,9 +62,9 @@ function O() {
62
62
  );
63
63
  }
64
64
  function c(t) {
65
- return t == null ? !1 : C(t).length > 0 || I(t).length > 0;
65
+ return t == null ? !1 : I(t).length > 0 || k(t).length > 0;
66
66
  }
67
- function U({
67
+ function Z({
68
68
  apy: t,
69
69
  maxLeverage: p,
70
70
  collateralApy: n,
@@ -72,30 +72,32 @@ function U({
72
72
  quotaRate: a,
73
73
  decimals: m = 2,
74
74
  tooltip: f = !0,
75
+ period: h,
75
76
  className: o
76
77
  }) {
77
78
  if (!t)
78
79
  return /* @__PURE__ */ e("span", { className: "text-secondary-foreground", children: "—" });
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
80
+ const i = C(t), u = c(t) || c(n), g = f && i >= 1, s = () => {
81
+ const w = O(P(i), m);
82
+ return /* @__PURE__ */ r("div", { className: A("inline-flex items-center gap-1.5", o), children: [
83
+ /* @__PURE__ */ e("span", { className: "inline-flex items-center", children: w }),
84
+ u ? /* @__PURE__ */ e(F, {}) : null
84
85
  ] });
85
86
  };
86
- return u ? /* @__PURE__ */ e(
87
- x,
87
+ return g ? /* @__PURE__ */ e(
88
+ v,
88
89
  {
89
90
  supplyApy: t,
90
91
  maxLeverage: p,
91
92
  collateralApy: n,
92
93
  borrowApy: d,
93
94
  quotaRate: a,
95
+ period: h,
94
96
  className: o,
95
97
  children: s()
96
98
  }
97
99
  ) : s();
98
100
  }
99
101
  export {
100
- U as CompoundAPY
102
+ Z as CompoundAPY
101
103
  };