@gearbox-protocol/ui-kit 4.0.0-next.17 → 4.0.0-next.18

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.
@@ -1,194 +1,199 @@
1
- import { jsxs as u, jsx as l, Fragment as M } from "react/jsx-runtime";
2
- import { PointsIcon as $ } from "../../points-icon/points-icon.js";
3
- import { TokenIcon as q } from "../../token-icon/token-icon.js";
4
- import { FormattedMessageTyped as d } from "../../typed-intl/index.js";
1
+ import { jsxs as i, jsx as t, Fragment as B } from "react/jsx-runtime";
2
+ import { PointsIcon as I } from "../../points-icon/points-icon.js";
3
+ import { TokenIcon as P } from "../../token-icon/token-icon.js";
4
+ import { FormattedMessageTyped as p } from "../../typed-intl/index.js";
5
5
  import "react";
6
- import { positiveTokenRewardsOf as F, pointProgramsOf as T, totalApyOf as R } from "../../../utils/apy-breakdown.js";
6
+ import { positiveTokenRewardsOf as M, pointProgramsOf as L, totalApyOf as T } from "../../../utils/apy-breakdown.js";
7
7
  import "@gearbox-protocol/sdk";
8
- import { bpsToPercent as j } from "../../../utils/bps.js";
9
- import { cn as w } from "../../../utils/cn.js";
8
+ import { bpsToPercent as $ } from "../../../utils/bps.js";
9
+ import { cn as h } from "../../../utils/cn.js";
10
10
  import "sonner";
11
- import { formatLeverage as s } from "../../../utils/format-leverage.js";
12
- import { formatCompactPercent as S } from "../../../utils/format-money.js";
13
- import { strategyApyPartsAtLeverage as O } from "../../../utils/strategy-apy.js";
11
+ import { formatLeverage as a } from "../../../utils/format-leverage.js";
12
+ import { formatCompactPercent as F } from "../../../utils/format-money.js";
13
+ import { strategyApyPartsAtLeverage as j } from "../../../utils/strategy-apy.js";
14
14
  import "@gearbox-protocol/sdk/common-utils";
15
15
  import "luxon";
16
16
  import "../../../utils/z-index.js";
17
- import { StrategyApyBreakdownCardTest as h } from "./constants.js";
18
- const i = "—";
19
- function a(e) {
20
- const r = j(e);
21
- if (Math.abs(r) >= 1e3) {
22
- const p = S(Math.abs(r));
23
- return r < 0 ? `−${p}` : p;
17
+ import { StrategyApyBreakdownCardTest as w } from "./constants.js";
18
+ const u = "—";
19
+ function s(e) {
20
+ const n = $(e);
21
+ if (Math.abs(n) >= 1e3) {
22
+ const d = F(Math.abs(n));
23
+ return n < 0 ? `−${d}` : d;
24
24
  }
25
- const m = Math.abs(r).toFixed(2);
26
- return r < 0 ? `−${m}%` : `${m}%`;
25
+ const m = Math.abs(n).toFixed(2);
26
+ return n < 0 ? `−${m}%` : `${m}%`;
27
27
  }
28
- function z(e) {
28
+ function S(e) {
29
29
  return e == null || e <= 0 ? "bg-muted text-muted-foreground" : "bg-success/20 text-success";
30
30
  }
31
31
  function g({
32
32
  base: e,
33
- leverage: r
33
+ leverage: n
34
34
  }) {
35
- return /* @__PURE__ */ l(
36
- d,
35
+ return /* @__PURE__ */ t(
36
+ p,
37
37
  {
38
38
  messageId: "components.strategyApyBreakdownCard.formula",
39
- values: { base: e, leverage: r }
39
+ values: { base: e, leverage: n }
40
40
  }
41
41
  );
42
42
  }
43
- function oe({
43
+ function te({
44
44
  data: e,
45
- leverage: r
45
+ leverage: n
46
46
  }) {
47
- const t = r ?? (e.maxLeverage != null && e.maxLeverage > 0 ? e.maxLeverage : void 0), m = t != null ? s(t) : i, p = e.collateralApy ? F(e.collateralApy) : [], k = e.collateralApy ? T(e.collateralApy) : [], n = t != null ? O({
48
- leverage: t,
49
- maxLeverage: e.maxLeverage,
47
+ const o = n ?? (e.maxLeverage != null && e.maxLeverage > 0 ? e.maxLeverage : void 0), m = o != null ? a(o) : u, d = e.collateralApy ? M(e.collateralApy) : [], k = e.collateralApy ? L(e.collateralApy) : [], r = o != null ? j({
48
+ leverage: o,
50
49
  borrowApy: e.borrowApy,
51
- additionalBorrowApy: e.additionalBorrowApy
52
- }) : void 0, y = e.collateralApy?.organicApy, b = y != null && t != null ? y * t : void 0, f = p.map(
53
- (o) => o.supplyApr != null && t != null ? o.supplyApr * t : void 0
54
- ), N = e.borrowApy != null && n != null ? -n.borrowCost : void 0, L = e.additionalBorrowApy, x = L != null && L !== 0, B = x && n != null ? n.quotaRate : void 0, C = x && n != null ? -n.quotaCost : void 0, I = b != null && n != null && f.every((o) => o != null) ? b + f.reduce((o, c) => o + (c ?? 0), 0) - n.totalCost : void 0, P = t != null && e.maxLeverage != null && e.maxLeverage > 0 && Math.abs(t - e.maxLeverage) < 1e-9, A = e.netApy != null ? R(e.netApy) : P && e.maxLeverageApy != null ? R(e.maxLeverageApy) : I;
55
- return /* @__PURE__ */ u(
50
+ quotaRate: e.quotaRate,
51
+ liquidationThreshold: e.liquidationThreshold,
52
+ quotaMode: e.quotaMode
53
+ }) : void 0, f = e.collateralApy?.organicApy, y = f != null && o != null ? f * o : void 0, v = d.map(
54
+ (l) => l.supplyApr != null && o != null ? l.supplyApr * o : void 0
55
+ ), N = e.borrowApy != null && r != null ? -r.borrowCost : void 0, x = e.quotaRate != null && e.quotaRate !== 0, q = x && r != null ? r.quotaRate : void 0, R = x && r != null ? -r.quotaCost : void 0, C = y != null && r != null && v.every((l) => l != null) ? y + v.reduce((l, c) => l + (c ?? 0), 0) - r.totalCost : void 0, A = e.netApy != null ? T(e.netApy) : C;
56
+ return /* @__PURE__ */ i(
56
57
  "div",
57
58
  {
58
59
  className: "flex w-full min-w-0 flex-col gap-4 rounded-xl border border-border bg-card p-4",
59
- "data-testid": h.root,
60
+ "data-testid": w.root,
60
61
  children: [
61
- /* @__PURE__ */ u("div", { className: "flex h-6 items-center justify-between gap-3", children: [
62
- /* @__PURE__ */ l("span", { className: "text-base font-semibold leading-4 text-foreground", children: /* @__PURE__ */ l(
63
- d,
62
+ /* @__PURE__ */ i("div", { className: "flex h-6 items-center justify-between gap-3", children: [
63
+ /* @__PURE__ */ t("span", { className: "text-base font-semibold leading-4 text-foreground", children: /* @__PURE__ */ t(
64
+ p,
64
65
  {
65
66
  messageId: "components.strategyApyBreakdownCard.titleAtLeverage",
66
67
  values: { leverage: m }
67
68
  }
68
69
  ) }),
69
- /* @__PURE__ */ l(
70
+ /* @__PURE__ */ t(
70
71
  "span",
71
72
  {
72
- className: w(
73
+ className: h(
73
74
  "rounded-md px-2 py-0.5 text-sm font-semibold tabular-nums",
74
- z(A)
75
+ S(A)
75
76
  ),
76
- "data-testid": h.net,
77
- children: A == null ? i : a(A)
77
+ "data-testid": w.net,
78
+ children: A == null ? u : s(A)
78
79
  }
79
80
  )
80
81
  ] }),
81
- /* @__PURE__ */ u("div", { className: "flex flex-col gap-3", children: [
82
- /* @__PURE__ */ l(
83
- v,
82
+ /* @__PURE__ */ i("div", { className: "flex flex-col gap-3", children: [
83
+ /* @__PURE__ */ t(
84
+ b,
84
85
  {
85
- label: /* @__PURE__ */ l(d, { messageId: "components.strategyApyBreakdownCard.collateralApy" }),
86
- value: b == null ? i : a(b),
87
- subtext: y != null && t != null ? /* @__PURE__ */ l(
86
+ label: /* @__PURE__ */ t(p, { messageId: "components.strategyApyBreakdownCard.collateralApy" }),
87
+ value: y == null ? u : s(y),
88
+ subtext: f != null && o != null ? /* @__PURE__ */ t(
88
89
  g,
89
90
  {
90
- base: a(y),
91
- leverage: s(t)
91
+ base: s(f),
92
+ leverage: a(o)
92
93
  }
93
94
  ) : void 0
94
95
  }
95
96
  ),
96
- p.map((o, c) => /* @__PURE__ */ l(
97
- v,
97
+ d.map((l, c) => /* @__PURE__ */ t(
98
+ b,
98
99
  {
99
- label: /* @__PURE__ */ u("span", { className: "inline-flex items-center gap-1.5", children: [
100
- /* @__PURE__ */ l("span", { children: /* @__PURE__ */ l(
101
- d,
100
+ label: /* @__PURE__ */ i("span", { className: "inline-flex items-center gap-1.5", children: [
101
+ /* @__PURE__ */ t("span", { children: /* @__PURE__ */ t(
102
+ p,
102
103
  {
103
104
  messageId: "components.apyParts.extraAPY",
104
- values: { symbol: o.token.symbol }
105
+ values: { symbol: l.token.symbol }
105
106
  }
106
107
  ) }),
107
- /* @__PURE__ */ l(
108
- q,
108
+ /* @__PURE__ */ t(
109
+ P,
109
110
  {
110
- token: o.token,
111
- symbol: o.token.symbol,
111
+ token: l.token,
112
+ symbol: l.token.symbol,
112
113
  size: 16,
113
114
  className: "shrink-0"
114
115
  }
115
116
  )
116
117
  ] }),
117
- value: f[c] == null ? i : a(f[c]),
118
- subtext: o.supplyApr != null && t != null ? /* @__PURE__ */ l(
118
+ value: v[c] == null ? u : s(v[c]),
119
+ subtext: l.supplyApr != null && o != null ? /* @__PURE__ */ t(
119
120
  g,
120
121
  {
121
- base: a(o.supplyApr),
122
- leverage: s(t)
122
+ base: s(l.supplyApr),
123
+ leverage: a(o)
123
124
  }
124
125
  ) : void 0
125
126
  },
126
- `incentive-${o.token.address}-${o.supplyApr ?? 0}`
127
+ `incentive-${l.token.address}-${l.supplyApr ?? 0}`
127
128
  )),
128
- /* @__PURE__ */ l(
129
- v,
129
+ /* @__PURE__ */ t(
130
+ b,
130
131
  {
131
132
  muted: !0,
132
- label: /* @__PURE__ */ l(d, { messageId: "components.strategyApyBreakdownCard.borrowRate" }),
133
- value: N == null ? i : a(N),
134
- subtext: e.borrowApy != null && n != null ? /* @__PURE__ */ l(
133
+ label: /* @__PURE__ */ t(p, { messageId: "components.strategyApyBreakdownCard.borrowRate" }),
134
+ value: N == null ? u : s(N),
135
+ subtext: e.borrowApy != null && r != null ? /* @__PURE__ */ t(
135
136
  g,
136
137
  {
137
- base: a(-e.borrowApy),
138
- leverage: s(n.debtMultiplier)
138
+ base: s(-e.borrowApy),
139
+ leverage: a(r.debtMultiplier)
139
140
  }
140
141
  ) : void 0
141
142
  }
142
143
  ),
143
- x ? /* @__PURE__ */ l(
144
- v,
144
+ x ? /* @__PURE__ */ t(
145
+ b,
145
146
  {
146
147
  muted: !0,
147
- label: /* @__PURE__ */ l(d, { messageId: "components.strategyApyBreakdownCard.quotaRate" }),
148
- value: C == null ? i : a(C),
149
- subtext: B != null && t != null ? /* @__PURE__ */ l(
150
- g,
151
- {
152
- base: a(-B),
153
- leverage: s(t)
154
- }
148
+ label: /* @__PURE__ */ t(p, { messageId: "components.strategyApyBreakdownCard.quotaRate" }),
149
+ value: R == null ? u : s(R),
150
+ subtext: q != null && r != null ? (
151
+ // The quota is charged on the LT-weighted position, so this
152
+ // multiplier is not the leverage the row above uses.
153
+ /* @__PURE__ */ t(
154
+ g,
155
+ {
156
+ base: s(-q),
157
+ leverage: a(r.quotaMultiplier)
158
+ }
159
+ )
155
160
  ) : void 0
156
161
  }
157
162
  ) : null,
158
- k.length > 0 ? /* @__PURE__ */ u(M, { children: [
159
- /* @__PURE__ */ l("div", { className: "h-px w-full bg-divider" }),
160
- k.map((o) => {
161
- const c = o.multiplier != null && t != null ? o.multiplier * t : void 0;
162
- return /* @__PURE__ */ l(
163
- v,
163
+ k.length > 0 ? /* @__PURE__ */ i(B, { children: [
164
+ /* @__PURE__ */ t("div", { className: "h-px w-full bg-divider" }),
165
+ k.map((l) => {
166
+ const c = l.multiplier != null && o != null ? l.multiplier * o : void 0;
167
+ return /* @__PURE__ */ t(
168
+ b,
164
169
  {
165
- label: /* @__PURE__ */ u("span", { className: "inline-flex items-center gap-1.5", children: [
166
- /* @__PURE__ */ l("span", { children: /* @__PURE__ */ l(
167
- d,
170
+ label: /* @__PURE__ */ i("span", { className: "inline-flex items-center gap-1.5", children: [
171
+ /* @__PURE__ */ t("span", { children: /* @__PURE__ */ t(
172
+ p,
168
173
  {
169
174
  messageId: "components.yieldBreakdown.programPoints",
170
- values: { name: o.name }
175
+ values: { name: l.name }
171
176
  }
172
177
  ) }),
173
- /* @__PURE__ */ l(
174
- $,
178
+ /* @__PURE__ */ t(
179
+ I,
175
180
  {
176
- reward: { name: o.name, type: o.id },
181
+ reward: { name: l.name, type: l.id },
177
182
  size: 16,
178
183
  className: "shrink-0"
179
184
  }
180
185
  )
181
186
  ] }),
182
- value: c != null ? `${s(c)}×` : i,
183
- subtext: o.multiplier != null && t != null ? /* @__PURE__ */ l(
187
+ value: c != null ? `${a(c)}×` : u,
188
+ subtext: l.multiplier != null && o != null ? /* @__PURE__ */ t(
184
189
  g,
185
190
  {
186
- base: s(o.multiplier),
187
- leverage: s(t)
191
+ base: a(l.multiplier),
192
+ leverage: a(o)
188
193
  }
189
194
  ) : void 0
190
195
  },
191
- o.id
196
+ l.id
192
197
  );
193
198
  })
194
199
  ] }) : null
@@ -197,38 +202,38 @@ function oe({
197
202
  }
198
203
  );
199
204
  }
200
- function v({
205
+ function b({
201
206
  label: e,
202
- value: r,
203
- subtext: t,
207
+ value: n,
208
+ subtext: o,
204
209
  muted: m = !1
205
210
  }) {
206
- const p = m ? "text-muted-foreground" : "text-foreground";
207
- return /* @__PURE__ */ u(
211
+ const d = m ? "text-muted-foreground" : "text-foreground";
212
+ return /* @__PURE__ */ i(
208
213
  "div",
209
214
  {
210
215
  className: "flex items-start justify-between gap-3",
211
- "data-testid": h.row,
216
+ "data-testid": w.row,
212
217
  children: [
213
- /* @__PURE__ */ l("span", { className: w("min-w-0 text-sm font-semibold leading-5", p), children: e }),
214
- /* @__PURE__ */ u("span", { className: "flex shrink-0 flex-col items-end", children: [
215
- /* @__PURE__ */ l(
218
+ /* @__PURE__ */ t("span", { className: h("min-w-0 text-sm font-semibold leading-5", d), children: e }),
219
+ /* @__PURE__ */ i("span", { className: "flex shrink-0 flex-col items-end", children: [
220
+ /* @__PURE__ */ t(
216
221
  "span",
217
222
  {
218
- className: w(
223
+ className: h(
219
224
  "text-sm font-semibold leading-5 tabular-nums",
220
- r === i || m ? "text-muted-foreground" : "text-foreground"
225
+ n === u || m ? "text-muted-foreground" : "text-foreground"
221
226
  ),
222
- children: r
227
+ children: n
223
228
  }
224
229
  ),
225
- t != null ? /* @__PURE__ */ l("span", { className: "text-xs leading-4 text-muted-foreground", children: t }) : null
230
+ o != null ? /* @__PURE__ */ t("span", { className: "text-xs leading-4 text-muted-foreground", children: o }) : null
226
231
  ] })
227
232
  ]
228
233
  }
229
234
  );
230
235
  }
231
236
  export {
232
- oe as StrategyApyBreakdownCard,
233
- h as StrategyApyBreakdownCardTest
237
+ te as StrategyApyBreakdownCard,
238
+ w as StrategyApyBreakdownCardTest
234
239
  };
@@ -69,7 +69,7 @@ function E({
69
69
  maxLeverage: p,
70
70
  collateralApy: r,
71
71
  borrowApy: d,
72
- additionalBorrowApy: a,
72
+ quotaRate: a,
73
73
  decimals: m = 2,
74
74
  className: o
75
75
  }) {
@@ -89,7 +89,7 @@ function E({
89
89
  maxLeverage: p,
90
90
  collateralApy: r,
91
91
  borrowApy: d,
92
- additionalBorrowApy: a,
92
+ quotaRate: a,
93
93
  className: o,
94
94
  children: s()
95
95
  }
@@ -1,35 +1,34 @@
1
- import { jsxs as a, jsx as e, Fragment as P } from "react/jsx-runtime";
2
- import { PointsIcon as A } from "../points-icon/points-icon.js";
3
- import { TokenIcon as I } from "../token-icon/token-icon.js";
4
- import { SimpleTooltip as T } from "../tooltip/simple-tooltip.js";
1
+ import { jsxs as a, jsx as e, Fragment as k } from "react/jsx-runtime";
2
+ import { PointsIcon as N } from "../points-icon/points-icon.js";
3
+ import { TokenIcon as P } from "../token-icon/token-icon.js";
4
+ import { SimpleTooltip as A } from "../tooltip/simple-tooltip.js";
5
5
  import "../tooltip/tooltip.js";
6
6
  import { FormattedMessageTyped as s } from "../typed-intl/index.js";
7
7
  import "react";
8
- import { tokenRewardsOf as B, pointProgramsOf as R, totalApyOf as $ } from "../../utils/apy-breakdown.js";
8
+ import { tokenRewardsOf as I, pointProgramsOf as B, totalApyOf as T } from "../../utils/apy-breakdown.js";
9
9
  import "@gearbox-protocol/sdk";
10
- import { bpsToPercent as j } from "../../utils/bps.js";
10
+ import { bpsToPercent as $ } from "../../utils/bps.js";
11
11
  import { cn as p } from "../../utils/cn.js";
12
12
  import "sonner";
13
- import { formatLeverage as S } from "../../utils/format-leverage.js";
14
- import { formatCompactPercent as C } from "../../utils/format-money.js";
15
- import { strategyQuotaRate as O } from "../../utils/strategy-apy.js";
13
+ import { formatLeverage as j } from "../../utils/format-leverage.js";
14
+ import { formatCompactPercent as S } from "../../utils/format-money.js";
16
15
  import "@gearbox-protocol/sdk/common-utils";
17
16
  import "luxon";
18
17
  import "../../utils/z-index.js";
19
18
  function i(n) {
20
- const o = j(n), r = C(Math.abs(o));
19
+ const o = $(n), r = S(Math.abs(o));
21
20
  return o < 0 ? `-${r}` : r;
22
21
  }
23
- function L({
22
+ function V({
24
23
  supplyApy: n,
25
24
  maxLeverage: o,
26
25
  collateralApy: r,
27
26
  borrowApy: c,
28
- additionalBorrowApy: u,
27
+ quotaRate: u,
29
28
  children: h,
30
29
  className: f
31
30
  }) {
32
- const g = o !== void 0 && o > 0, l = r ?? n, y = B(l), w = R(n), b = $(n), v = c != null || u != null, k = O({ additionalBorrowApy: u, maxLeverage: o }), d = v ? -((c ?? 0) + k) : void 0, x = w.filter((t) => t.multiplier != null), N = /* @__PURE__ */ a(
31
+ const g = o !== void 0 && o > 0, l = r ?? n, w = I(l), y = B(n), b = T(n), d = c != null || u != null ? -((c ?? 0) + (u ?? 0)) : void 0, x = y.filter((t) => t.multiplier != null), v = /* @__PURE__ */ a(
33
32
  "div",
34
33
  {
35
34
  className: p(
@@ -47,7 +46,7 @@ function L({
47
46
  {
48
47
  messageId: "components.yieldBreakdown.titleNetAtLeverage",
49
48
  values: {
50
- leverage: S(o)
49
+ leverage: j(o)
51
50
  }
52
51
  }
53
52
  ) : /* @__PURE__ */ e(s, { messageId: "components.apyParts.totalAPY" }) }),
@@ -70,7 +69,7 @@ function L({
70
69
  value: i(l.organicApy)
71
70
  }
72
71
  ),
73
- y.map((t) => t.supplyApr == null ? null : /* @__PURE__ */ e(
72
+ w.map((t) => t.supplyApr == null ? null : /* @__PURE__ */ e(
74
73
  m,
75
74
  {
76
75
  muted: t.supplyApr < 0,
@@ -82,7 +81,7 @@ function L({
82
81
  values: { symbol: t.token.symbol }
83
82
  }
84
83
  ) }),
85
- /* @__PURE__ */ e(I, { token: t.token, size: 20 })
84
+ /* @__PURE__ */ e(P, { token: t.token, size: 20 })
86
85
  ] }),
87
86
  value: i(t.supplyApr)
88
87
  },
@@ -96,7 +95,7 @@ function L({
96
95
  value: i(d)
97
96
  }
98
97
  ),
99
- x.length > 0 && /* @__PURE__ */ a(P, { children: [
98
+ x.length > 0 && /* @__PURE__ */ a(k, { children: [
100
99
  /* @__PURE__ */ e("div", { className: "h-px w-full bg-divider" }),
101
100
  x.map((t) => /* @__PURE__ */ e(
102
101
  m,
@@ -110,7 +109,7 @@ function L({
110
109
  }
111
110
  ) }),
112
111
  /* @__PURE__ */ e(
113
- A,
112
+ N,
114
113
  {
115
114
  reward: {
116
115
  name: t.name,
@@ -129,7 +128,7 @@ function L({
129
128
  }
130
129
  );
131
130
  return /* @__PURE__ */ e(
132
- T,
131
+ A,
133
132
  {
134
133
  placement: "bottom",
135
134
  triangle: !1,
@@ -138,7 +137,7 @@ function L({
138
137
  maxWidth: "100%",
139
138
  title: /* @__PURE__ */ e("span", { className: f, children: h }),
140
139
  triggerClassName: f,
141
- children: N
140
+ children: v
142
141
  }
143
142
  );
144
143
  }
@@ -162,5 +161,5 @@ function m({
162
161
  ] });
163
162
  }
164
163
  export {
165
- L as YieldBreakdownTooltip
164
+ V as YieldBreakdownTooltip
166
165
  };