@gearbox-protocol/ui-kit 4.0.0-next.63 → 4.0.0-next.65
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/leverage-input/leverage-input.cjs +1 -1
- package/dist/cjs/components/base/leverage-preset-chips/leverage-preset-chips.cjs +1 -1
- package/dist/cjs/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.cjs +1 -1
- package/dist/cjs/components/graph/graph.cjs +1 -1
- package/dist/cjs/components/graph/series-config.cjs +1 -1
- package/dist/cjs/components/index.cjs +1 -1
- package/dist/cjs/components/trading-view/constants.cjs +1 -0
- package/dist/cjs/components/trading-view/index.cjs +1 -1
- package/dist/cjs/components/trading-view/price-scale-titles.cjs +1 -0
- package/dist/cjs/components/trading-view/trading-view.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/locale/en.json.cjs +1 -1
- package/dist/cjs/utils/format-leverage.cjs +1 -1
- package/dist/cjs/utils/index.cjs +1 -1
- package/dist/cjs/utils/leverage-presets.cjs +1 -1
- package/dist/esm/components/base/leverage-input/leverage-input.js +31 -31
- package/dist/esm/components/base/leverage-preset-chips/leverage-preset-chips.js +6 -6
- package/dist/esm/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.js +30 -30
- package/dist/esm/components/graph/graph.js +257 -266
- package/dist/esm/components/graph/series-config.js +10 -1
- package/dist/esm/components/index.js +70 -68
- package/dist/esm/components/trading-view/constants.js +7 -0
- package/dist/esm/components/trading-view/index.js +4 -2
- package/dist/esm/components/trading-view/price-scale-titles.js +52 -0
- package/dist/esm/components/trading-view/trading-view.js +119 -115
- package/dist/esm/index.js +230 -227
- package/dist/esm/locale/en.json.js +1 -1
- package/dist/esm/utils/format-leverage.js +8 -3
- package/dist/esm/utils/index.js +18 -17
- package/dist/esm/utils/leverage-presets.js +4 -6
- package/dist/globals.css +1 -1
- package/dist/types/components/base/leverage-input/leverage-input.d.ts +2 -2
- package/dist/types/components/graph/graph.d.ts +1 -5
- package/dist/types/components/graph/series-config.d.ts +13 -0
- package/dist/types/components/trading-view/constants.d.ts +4 -0
- package/dist/types/components/trading-view/index.d.ts +1 -0
- package/dist/types/components/trading-view/price-scale-titles.d.ts +16 -0
- package/dist/types/components/trading-view/trading-view.d.ts +1 -1
- package/dist/types/locale/en.json.d.ts +1 -1
- package/dist/types/utils/format-leverage.d.ts +9 -1
- package/dist/types/utils/leverage-presets.d.ts +3 -1
- package/package.json +1 -1
- package/dist/cjs/components/base/leverage-preset-chips/format-chip-leverage.cjs +0 -1
- package/dist/esm/components/base/leverage-preset-chips/format-chip-leverage.js +0 -6
- package/dist/types/components/base/leverage-preset-chips/format-chip-leverage.d.ts +0 -5
|
@@ -8,59 +8,59 @@ import { TextButton as O } from "../../text-button/text-button.js";
|
|
|
8
8
|
import { SimpleTooltip as R } from "../../tooltip/simple-tooltip.js";
|
|
9
9
|
import "../../tooltip/tooltip.js";
|
|
10
10
|
import { useIntlTyped as _, FormattedMessageTyped as b } from "../../typed-intl/index.js";
|
|
11
|
-
import { cn as
|
|
12
|
-
import {
|
|
11
|
+
import { cn as A } from "../../../utils/cn.js";
|
|
12
|
+
import { formatLeverageExact as T } from "../../../utils/format-leverage.js";
|
|
13
13
|
import "@gearbox-protocol/sdk/onchain";
|
|
14
14
|
import "../../../utils/z-index.js";
|
|
15
15
|
import { LeverageInputTest as l } from "./constants.js";
|
|
16
|
-
const
|
|
16
|
+
const n = 100, B = 10, D = 10, P = {
|
|
17
17
|
sm: "text-[14px] mb-[14px]",
|
|
18
18
|
default: "text-body mb-[18px]",
|
|
19
19
|
md: "text-lg mb-[22px]",
|
|
20
20
|
lg: "text-[21px] mb-[22px]"
|
|
21
21
|
};
|
|
22
22
|
function z({
|
|
23
|
-
title:
|
|
23
|
+
title: r,
|
|
24
24
|
children: a,
|
|
25
|
-
size:
|
|
25
|
+
size: o = "default"
|
|
26
26
|
}) {
|
|
27
27
|
return /* @__PURE__ */ s("div", { className: "flex flex-col", children: [
|
|
28
|
-
/* @__PURE__ */ t("div", { className:
|
|
28
|
+
/* @__PURE__ */ t("div", { className: A("font-medium text-foreground", P[o]), children: r }),
|
|
29
29
|
a !== void 0 && /* @__PURE__ */ t("div", { children: a })
|
|
30
30
|
] });
|
|
31
31
|
}
|
|
32
32
|
function re({
|
|
33
|
-
value:
|
|
33
|
+
value: r,
|
|
34
34
|
onChange: a,
|
|
35
|
-
max:
|
|
35
|
+
max: o,
|
|
36
36
|
min: m = 1,
|
|
37
|
-
title:
|
|
38
|
-
hint:
|
|
37
|
+
title: c,
|
|
38
|
+
hint: d,
|
|
39
39
|
reset: i,
|
|
40
|
-
colorIntervals:
|
|
41
|
-
colorIntervalLabel:
|
|
42
|
-
size:
|
|
40
|
+
colorIntervals: E,
|
|
41
|
+
colorIntervalLabel: N,
|
|
42
|
+
size: S = "sm"
|
|
43
43
|
}) {
|
|
44
|
-
const
|
|
44
|
+
const w = _(), L = V(), p = E ?? [], C = N ?? (p.length > 0 ? w.formatMessage({
|
|
45
45
|
messageId: "components.leverageInput.available"
|
|
46
|
-
}) : void 0), [M, u] = h(void 0), [f, x] = h(""), g = M ??
|
|
47
|
-
a(
|
|
46
|
+
}) : void 0), [M, u] = h(void 0), [f, x] = h(""), g = M ?? r, v = (e) => {
|
|
47
|
+
a(G(e, m, o)), u(void 0);
|
|
48
48
|
}, k = () => {
|
|
49
49
|
const e = Number.parseFloat(f.replace(",", "."));
|
|
50
50
|
Number.isFinite(e) && v(e);
|
|
51
51
|
}, y = p.map((e) => ({
|
|
52
52
|
...e,
|
|
53
|
-
start: e.start *
|
|
54
|
-
end: e.end *
|
|
53
|
+
start: e.start * n,
|
|
54
|
+
end: e.end * n
|
|
55
55
|
}));
|
|
56
56
|
return /* @__PURE__ */ t("div", { "data-testid": l.root, children: /* @__PURE__ */ t(
|
|
57
57
|
z,
|
|
58
58
|
{
|
|
59
|
-
size:
|
|
59
|
+
size: S,
|
|
60
60
|
title: /* @__PURE__ */ s(I, { direction: "row", align: "center", justify: "between", gap: "sm", children: [
|
|
61
61
|
/* @__PURE__ */ s("span", { className: "font-normal", children: [
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
c !== void 0 ? L(c) : /* @__PURE__ */ t(b, { messageId: "components.leverageInput.label" }),
|
|
63
|
+
d ? /* @__PURE__ */ t("span", { className: "text-muted-foreground ml-1", children: d }) : null
|
|
64
64
|
] }),
|
|
65
65
|
/* @__PURE__ */ s(I, { direction: "row", align: "center", gap: "sm", children: [
|
|
66
66
|
/* @__PURE__ */ t("div", { className: "flex w-[90px] flex-row flex-nowrap items-center", children: /* @__PURE__ */ t(
|
|
@@ -74,7 +74,7 @@ function re({
|
|
|
74
74
|
},
|
|
75
75
|
"data-testid": l.value,
|
|
76
76
|
onEditModeChange: (e) => {
|
|
77
|
-
e && x(T(
|
|
77
|
+
e && x(T(r));
|
|
78
78
|
},
|
|
79
79
|
onChange: (e) => x(e.target.value),
|
|
80
80
|
onSubmit: k
|
|
@@ -105,23 +105,23 @@ function re({
|
|
|
105
105
|
children: /* @__PURE__ */ t(
|
|
106
106
|
F,
|
|
107
107
|
{
|
|
108
|
-
from: m *
|
|
109
|
-
to:
|
|
110
|
-
precision:
|
|
111
|
-
value: g *
|
|
108
|
+
from: m * n,
|
|
109
|
+
to: o * n,
|
|
110
|
+
precision: B,
|
|
111
|
+
value: g * n,
|
|
112
112
|
colorIntervals: y,
|
|
113
113
|
colorIntervalLabel: C,
|
|
114
|
-
markerStep:
|
|
114
|
+
markerStep: o > D ? 200 : 100,
|
|
115
115
|
"data-testid": l.slider,
|
|
116
|
-
onChangeValue: (e) => u(e /
|
|
117
|
-
onSubmitValue: (e) => v(e /
|
|
116
|
+
onChangeValue: (e) => u(e / n),
|
|
117
|
+
onSubmitValue: (e) => v(e / n)
|
|
118
118
|
}
|
|
119
119
|
)
|
|
120
120
|
}
|
|
121
121
|
) });
|
|
122
122
|
}
|
|
123
|
-
function
|
|
124
|
-
return Math.min(Math.max(
|
|
123
|
+
function G(r, a, o) {
|
|
124
|
+
return Math.min(Math.max(r, a), o);
|
|
125
125
|
}
|
|
126
126
|
export {
|
|
127
127
|
re as LeverageInput,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as n, jsx as m } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { SegmentedTabs as g } from "../segmented-tabs/segmented-tabs.js";
|
|
3
|
+
import { FormattedMessageTyped as d } from "../../typed-intl/index.js";
|
|
4
|
+
import { formatLeverage as l } from "../../../utils/format-leverage.js";
|
|
5
5
|
import { LeveragePresetChipsTest as s } from "./constants.js";
|
|
6
6
|
function u({
|
|
7
7
|
options: e,
|
|
@@ -16,13 +16,13 @@ function u({
|
|
|
16
16
|
className: "flex items-center gap-2",
|
|
17
17
|
"data-testid": s.root,
|
|
18
18
|
children: [
|
|
19
|
-
/* @__PURE__ */ m("span", { className: "text-sm text-muted-foreground", children: /* @__PURE__ */ m(
|
|
19
|
+
/* @__PURE__ */ m("span", { className: "text-sm text-muted-foreground", children: /* @__PURE__ */ m(d, { messageId: "components.leveragePresetChips.label" }) }),
|
|
20
20
|
/* @__PURE__ */ m(
|
|
21
|
-
|
|
21
|
+
g,
|
|
22
22
|
{
|
|
23
23
|
items: e.map((t) => ({
|
|
24
24
|
id: String(t),
|
|
25
|
-
item: `${
|
|
25
|
+
item: `${l(t)}×`,
|
|
26
26
|
testId: s.chip
|
|
27
27
|
})),
|
|
28
28
|
activeTab: i,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsxs as A, jsx as e, Fragment as C } from "react/jsx-runtime";
|
|
2
|
-
import { calcNetStrategyApy as
|
|
3
|
-
import { ApyBreakdownBody as P, formatBreakdownRate as i, ApyBreakdownRow as v, periodMessageId as
|
|
4
|
-
import { NoValue as
|
|
5
|
-
import { PointsIcon as
|
|
6
|
-
import { TokenIcon as
|
|
2
|
+
import { calcNetStrategyApy as R, calcEffectiveBorrowApy as D } from "@gearbox-protocol/sdk/onchain";
|
|
3
|
+
import { ApyBreakdownBody as P, formatBreakdownRate as i, ApyBreakdownRow as v, periodMessageId as f, ApyBreakdownDivider as q, BREAKDOWN_DASH as L } from "../apy-breakdown-body/apy-breakdown-body.js";
|
|
4
|
+
import { NoValue as k } from "../../no-value/no-value.js";
|
|
5
|
+
import { PointsIcon as O } from "../../points-icon/points-icon.js";
|
|
6
|
+
import { TokenIcon as S } from "../../token-icon/token-icon.js";
|
|
7
7
|
import { FormattedMessageTyped as s } from "../../typed-intl/index.js";
|
|
8
|
-
import { formatLeverage as
|
|
8
|
+
import { formatLeverageExact as c, formatLeverage as E } from "../../../utils/format-leverage.js";
|
|
9
9
|
import { totalApyOf as M, positiveTokenRewardsOf as $, pointProgramsOf as j } from "../../../utils/internal/apy-breakdown.js";
|
|
10
10
|
import { StrategyApyBreakdownCardTest as n } from "./constants.js";
|
|
11
11
|
function z(m) {
|
|
@@ -16,28 +16,28 @@ function z(m) {
|
|
|
16
16
|
liquidationThreshold: r
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function U({
|
|
20
20
|
data: m,
|
|
21
21
|
leverage: t,
|
|
22
22
|
showFormula: d = !1,
|
|
23
23
|
period: r
|
|
24
24
|
}) {
|
|
25
|
-
const a = z(m), l = a && m.collateralApyAvg7D ? m.collateralApyAvg7D : void 0,
|
|
26
|
-
organicApy:
|
|
25
|
+
const a = z(m), l = a && m.collateralApyAvg7D ? m.collateralApyAvg7D : void 0, b = a !== null && l !== void 0, g = b && a && l ? {
|
|
26
|
+
organicApy: R(
|
|
27
27
|
a,
|
|
28
28
|
l.organicApy,
|
|
29
29
|
t
|
|
30
30
|
),
|
|
31
|
-
totalApy:
|
|
31
|
+
totalApy: R(
|
|
32
32
|
a,
|
|
33
33
|
l.totalApy ?? l.organicApy,
|
|
34
34
|
t
|
|
35
35
|
),
|
|
36
36
|
...l.rewards ? { rewards: l.rewards } : {}
|
|
37
|
-
} : null,
|
|
37
|
+
} : null, p = b && a ? D(a, t) : null, u = g === null ? null : M(g), I = u === null || p === null ? null : u + p, N = l ? $(l) : [], B = l ? j(l) : [], T = N.map((o) => ({
|
|
38
38
|
reward: o,
|
|
39
39
|
value: Math.round(t * (o.supplyApr ?? 0))
|
|
40
|
-
})), y = I === null ? null : I - T.reduce((o, w) => o + w.value, 0), h = y !== null && t > 0 ? y / t : void 0,
|
|
40
|
+
})), y = I === null ? null : I - T.reduce((o, w) => o + w.value, 0), h = y !== null && t > 0 ? y / t : void 0, x = a && p !== null && t > 0 ? (p - a.borrowApy * (t - 1)) / t : void 0;
|
|
41
41
|
return /* @__PURE__ */ A(
|
|
42
42
|
P,
|
|
43
43
|
{
|
|
@@ -45,15 +45,15 @@ function Q({
|
|
|
45
45
|
title: /* @__PURE__ */ e(
|
|
46
46
|
s,
|
|
47
47
|
{
|
|
48
|
-
messageId:
|
|
48
|
+
messageId: f(
|
|
49
49
|
r,
|
|
50
50
|
"components.yieldBreakdown.titleNetAtLeverage",
|
|
51
51
|
"components.yieldBreakdown.titleNetAtLeverage7d"
|
|
52
52
|
),
|
|
53
|
-
values: { leverage:
|
|
53
|
+
values: { leverage: E(t) }
|
|
54
54
|
}
|
|
55
55
|
),
|
|
56
|
-
chip: u === null ? /* @__PURE__ */ e(
|
|
56
|
+
chip: u === null ? /* @__PURE__ */ e(k, { reason: r }) : i(u),
|
|
57
57
|
chipPositive: (u ?? 0) > 0,
|
|
58
58
|
chipTestId: n.net,
|
|
59
59
|
children: [
|
|
@@ -66,20 +66,20 @@ function Q({
|
|
|
66
66
|
label: /* @__PURE__ */ e(
|
|
67
67
|
s,
|
|
68
68
|
{
|
|
69
|
-
messageId:
|
|
69
|
+
messageId: f(
|
|
70
70
|
r,
|
|
71
71
|
"components.yieldBreakdown.collateralApy",
|
|
72
72
|
"components.yieldBreakdown.collateralApy7d"
|
|
73
73
|
)
|
|
74
74
|
}
|
|
75
75
|
),
|
|
76
|
-
value: y === null ? /* @__PURE__ */ e(
|
|
76
|
+
value: y === null ? /* @__PURE__ */ e(k, { reason: r }) : i(y),
|
|
77
77
|
subtext: d && h !== void 0 ? /* @__PURE__ */ e(
|
|
78
78
|
s,
|
|
79
79
|
{
|
|
80
80
|
messageId: "components.strategyApyBreakdownCard.formula",
|
|
81
81
|
values: {
|
|
82
|
-
leverage:
|
|
82
|
+
leverage: c(t),
|
|
83
83
|
base: i(h)
|
|
84
84
|
}
|
|
85
85
|
}
|
|
@@ -100,7 +100,7 @@ function Q({
|
|
|
100
100
|
}
|
|
101
101
|
) }),
|
|
102
102
|
/* @__PURE__ */ e(
|
|
103
|
-
|
|
103
|
+
S,
|
|
104
104
|
{
|
|
105
105
|
token: o.token,
|
|
106
106
|
symbol: o.token.symbol,
|
|
@@ -115,7 +115,7 @@ function Q({
|
|
|
115
115
|
{
|
|
116
116
|
messageId: "components.strategyApyBreakdownCard.formula",
|
|
117
117
|
values: {
|
|
118
|
-
leverage:
|
|
118
|
+
leverage: c(t),
|
|
119
119
|
base: i(o.supplyApr ?? 0)
|
|
120
120
|
}
|
|
121
121
|
}
|
|
@@ -133,24 +133,24 @@ function Q({
|
|
|
133
133
|
label: /* @__PURE__ */ e(
|
|
134
134
|
s,
|
|
135
135
|
{
|
|
136
|
-
messageId:
|
|
136
|
+
messageId: f(
|
|
137
137
|
r,
|
|
138
138
|
"components.yieldBreakdown.borrowRate",
|
|
139
139
|
"components.yieldBreakdown.borrowRate7d"
|
|
140
140
|
)
|
|
141
141
|
}
|
|
142
142
|
),
|
|
143
|
-
value:
|
|
144
|
-
subtext: d && a &&
|
|
143
|
+
value: p === null ? /* @__PURE__ */ e(k, { reason: r }) : i(-p),
|
|
144
|
+
subtext: d && a && x !== void 0 ? /* @__PURE__ */ e(
|
|
145
145
|
s,
|
|
146
146
|
{
|
|
147
147
|
messageId: "components.strategyApyBreakdownCard.borrowFormula",
|
|
148
148
|
values: {
|
|
149
|
-
leverage:
|
|
149
|
+
leverage: c(t),
|
|
150
150
|
// What the position is charged per unit of itself: base
|
|
151
151
|
// interest plus the quota, added before either is rounded, so
|
|
152
152
|
// the caption is not the sum of two figures it also printed.
|
|
153
|
-
totalRate: i(a.borrowApy +
|
|
153
|
+
totalRate: i(a.borrowApy + x),
|
|
154
154
|
// Magnitudes, not signed rates: the row above already carries
|
|
155
155
|
// the minus, and `− −0.88%` reads as arithmetic to decode
|
|
156
156
|
// rather than a cost to understand.
|
|
@@ -176,7 +176,7 @@ function Q({
|
|
|
176
176
|
}
|
|
177
177
|
) }),
|
|
178
178
|
/* @__PURE__ */ e(
|
|
179
|
-
|
|
179
|
+
O,
|
|
180
180
|
{
|
|
181
181
|
reward: { name: o.name, type: o.id },
|
|
182
182
|
size: 16,
|
|
@@ -184,14 +184,14 @@ function Q({
|
|
|
184
184
|
}
|
|
185
185
|
)
|
|
186
186
|
] }),
|
|
187
|
-
value: o.multiplier != null ? `${
|
|
187
|
+
value: o.multiplier != null ? `${c(o.multiplier * t)}×` : L,
|
|
188
188
|
subtext: d && o.multiplier != null ? /* @__PURE__ */ e(
|
|
189
189
|
s,
|
|
190
190
|
{
|
|
191
191
|
messageId: "components.strategyApyBreakdownCard.formula",
|
|
192
192
|
values: {
|
|
193
|
-
leverage:
|
|
194
|
-
base:
|
|
193
|
+
leverage: c(t),
|
|
194
|
+
base: c(o.multiplier)
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
) : void 0
|
|
@@ -204,6 +204,6 @@ function Q({
|
|
|
204
204
|
);
|
|
205
205
|
}
|
|
206
206
|
export {
|
|
207
|
-
|
|
207
|
+
U as StrategyApyBreakdownCard,
|
|
208
208
|
n as StrategyApyBreakdownCardTest
|
|
209
209
|
};
|