@gearbox-protocol/permissionless-ui 1.22.0-next.41 → 1.22.0-next.43
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/block-sync/block-sync.cjs +1 -1
- package/dist/cjs/components/checkbox/checkbox-labeled.cjs +1 -1
- package/dist/cjs/components/client-adapters/styled-rounded-image/styled-rounded-image.cjs +1 -1
- package/dist/cjs/components/complex-input/complex-input.cjs +1 -1
- package/dist/cjs/components/complex-input/index.cjs +1 -1
- package/dist/cjs/components/currency-button/currency-button.cjs +1 -1
- package/dist/cjs/components/help-tip/help-tip.cjs +1 -1
- package/dist/cjs/components/index.cjs +1 -1
- package/dist/cjs/components/smart-number-input/balance-indicator.cjs +1 -0
- package/dist/cjs/components/smart-number-input/index.cjs +1 -1
- package/dist/cjs/components/smart-number-input/smart-number-input.cjs +1 -1
- package/dist/cjs/hooks/index.cjs +1 -1
- package/dist/cjs/hooks/use-debounce-call.cjs +1 -1
- package/dist/cjs/hooks/use-hf.cjs +1 -1
- package/dist/cjs/hooks/use-media-query.cjs +1 -1
- package/dist/cjs/hooks/use-smart-number-input.cjs +1 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/utils/format-money.cjs +1 -1
- package/dist/esm/components/block-sync/block-sync.js +7 -5
- package/dist/esm/components/checkbox/checkbox-labeled.js +5 -3
- package/dist/esm/components/client-adapters/styled-rounded-image/styled-rounded-image.js +5 -3
- package/dist/esm/components/complex-input/complex-input.js +57 -102
- package/dist/esm/components/complex-input/index.js +2 -3
- package/dist/esm/components/currency-button/currency-button.js +96 -74
- package/dist/esm/components/help-tip/help-tip.js +19 -19
- package/dist/esm/components/index.js +456 -455
- package/dist/esm/components/smart-number-input/balance-indicator.js +60 -0
- package/dist/esm/components/smart-number-input/index.js +4 -2
- package/dist/esm/components/smart-number-input/smart-number-input.js +139 -146
- package/dist/esm/hooks/index.js +38 -35
- package/dist/esm/hooks/use-debounce-call.js +7 -14
- package/dist/esm/hooks/use-hf.js +33 -25
- package/dist/esm/hooks/use-media-query.js +12 -11
- package/dist/esm/hooks/use-smart-number-input.js +10 -0
- package/dist/esm/index.js +590 -586
- package/dist/esm/utils/format-money.js +3 -5
- package/dist/globals.css +1 -1
- package/dist/types/components/complex-input/complex-input.d.ts +1 -33
- package/dist/types/components/currency-button/currency-button.d.ts +26 -61
- package/dist/types/components/smart-number-input/balance-indicator.d.ts +41 -0
- package/dist/types/components/smart-number-input/index.d.ts +1 -0
- package/dist/types/components/smart-number-input/smart-number-input.d.ts +29 -102
- package/dist/types/components/token-template/token-template.d.ts +2 -5
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/hooks/use-debounce-call.d.ts +1 -19
- package/dist/types/hooks/use-hf.d.ts +2 -1
- package/dist/types/hooks/use-media-query.d.ts +4 -0
- package/dist/types/hooks/use-smart-number-input.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsxs as s, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { cva as x } from "class-variance-authority";
|
|
3
|
+
import { TextButton as u } from "../text-button/text-button.js";
|
|
4
|
+
import { TokenTemplate as f } from "../token-template/token-template.js";
|
|
5
|
+
import "react";
|
|
6
|
+
import "@gearbox-protocol/sdk";
|
|
7
|
+
import { cn as a } from "../../utils/cn.js";
|
|
8
|
+
import "sonner";
|
|
9
|
+
const b = x("font-normal leading-[130%] text-foreground", {
|
|
10
|
+
variants: {
|
|
11
|
+
size: {
|
|
12
|
+
sm: "text-xs",
|
|
13
|
+
md: "text-sm"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
defaultVariants: { size: "md" }
|
|
17
|
+
});
|
|
18
|
+
function j({
|
|
19
|
+
title: m = "Balance",
|
|
20
|
+
className: i,
|
|
21
|
+
maxAmount: l,
|
|
22
|
+
token: c,
|
|
23
|
+
disabled: d,
|
|
24
|
+
maxButton: p = !0,
|
|
25
|
+
onMaxButtonClick: r,
|
|
26
|
+
size: e = "sm"
|
|
27
|
+
}) {
|
|
28
|
+
const o = !d && p, n = /* @__PURE__ */ t(f, { value: l, token: c, showSymbol: !1 });
|
|
29
|
+
return /* @__PURE__ */ s(
|
|
30
|
+
"div",
|
|
31
|
+
{
|
|
32
|
+
className: a("flex shrink-0 basis-auto items-center", i),
|
|
33
|
+
"data-testid": "balance-indicator",
|
|
34
|
+
children: [
|
|
35
|
+
/* @__PURE__ */ s("span", { className: a(b({ size: e })), children: [
|
|
36
|
+
m,
|
|
37
|
+
": ",
|
|
38
|
+
o && e === "sm" ? /* @__PURE__ */ t(u, { onClick: r, children: n }) : n
|
|
39
|
+
] }),
|
|
40
|
+
o && e !== "sm" && /* @__PURE__ */ t("div", { className: "ml-2", children: /* @__PURE__ */ t(
|
|
41
|
+
"button",
|
|
42
|
+
{
|
|
43
|
+
type: "button",
|
|
44
|
+
onClick: r,
|
|
45
|
+
"data-testid": "balance-max",
|
|
46
|
+
className: a(
|
|
47
|
+
"rounded-[6px] border-0 py-[3px] px-1 text-[11px]! leading-[13px]!",
|
|
48
|
+
"text-center uppercase text-foreground",
|
|
49
|
+
"bg-gray-70 hover:bg-gray-90 transition-colors"
|
|
50
|
+
),
|
|
51
|
+
children: "max"
|
|
52
|
+
}
|
|
53
|
+
) })
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
j as BalanceIndicator
|
|
60
|
+
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BalanceIndicator as t } from "./balance-indicator.js";
|
|
2
|
+
import { SmartNumberInput as e } from "./smart-number-input.js";
|
|
2
3
|
export {
|
|
3
|
-
t as
|
|
4
|
+
t as BalanceIndicator,
|
|
5
|
+
e as SmartNumberInput
|
|
4
6
|
};
|
|
@@ -1,136 +1,131 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import "
|
|
4
|
-
import {
|
|
5
|
-
import "
|
|
6
|
-
import "../
|
|
7
|
-
import "
|
|
8
|
-
import "
|
|
1
|
+
import { jsxs as d, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { cva as u } from "class-variance-authority";
|
|
3
|
+
import * as g from "react";
|
|
4
|
+
import { CurrencyButton as E } from "../currency-button/currency-button.js";
|
|
5
|
+
import { faXmark as G } from "@fortawesome/free-solid-svg-icons";
|
|
6
|
+
import { FaIcon as H } from "../icons/fa-icon.js";
|
|
7
|
+
import { useIsMobile as J, useIsTablet as K, useIsDesktop as O } from "../../hooks/use-media-query.js";
|
|
8
|
+
import { bnToInputView as P } from "../../utils/bn-to-input-view.js";
|
|
9
9
|
import "@gearbox-protocol/sdk";
|
|
10
|
-
import {
|
|
10
|
+
import { parseInputToBN as Q } from "../../utils/parse-input-to-bn.js";
|
|
11
|
+
import { cn as x } from "../../utils/cn.js";
|
|
11
12
|
import "sonner";
|
|
12
|
-
import "
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
try {
|
|
21
|
-
const e = t.split("."), a = e[0] || "0", p = (e[1] || "").slice(0, r).padEnd(r, "0");
|
|
22
|
-
return [BigInt(a + p), t];
|
|
23
|
-
} catch {
|
|
24
|
-
return [null, null];
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function T(n, r) {
|
|
28
|
-
const t = n.toString().padStart(r + 1, "0"), e = t.slice(0, -r) || "0", a = t.slice(-r).replace(/0+$/, "");
|
|
29
|
-
return a ? `${e}.${a}` : e;
|
|
30
|
-
}
|
|
31
|
-
function W(n, r) {
|
|
32
|
-
const t = T(n, r), e = Number.parseFloat(t);
|
|
33
|
-
return e === 0 ? "0" : e < 1e-4 ? "< 0.0001" : e.toLocaleString(void 0, { maximumFractionDigits: 4 });
|
|
34
|
-
}
|
|
35
|
-
const Y = G.forwardRef(
|
|
36
|
-
({
|
|
37
|
-
amount: n,
|
|
38
|
-
tokenSymbol: r,
|
|
39
|
-
tokenIcon: t,
|
|
40
|
-
token: e,
|
|
41
|
-
label: a = "Amount",
|
|
42
|
-
maxBalance: p,
|
|
43
|
-
maxAmount: o,
|
|
44
|
-
maxAmountLimit: m,
|
|
45
|
-
maxButtonLabel: $ = "Max",
|
|
46
|
-
showMaxButton: j,
|
|
47
|
-
maxButton: z,
|
|
48
|
-
chainId: Z,
|
|
49
|
-
network: L,
|
|
50
|
-
disabled: i = !1,
|
|
51
|
-
active: y = !1,
|
|
52
|
-
size: N = "default",
|
|
53
|
-
onAmountChange: b,
|
|
54
|
-
onSetAmount: c,
|
|
55
|
-
onMaxClick: x,
|
|
56
|
-
onTokenSelect: M,
|
|
57
|
-
onShowSelectDialog: P,
|
|
58
|
-
onRemove: w,
|
|
59
|
-
onFocus: S,
|
|
60
|
-
onBlur: F,
|
|
61
|
-
className: V
|
|
62
|
-
}, _) => {
|
|
63
|
-
const D = j ?? z ?? !0, h = r ?? e?.symbol, I = t ?? (e?.symbol ? /* @__PURE__ */ s(Q, { symbol: e.symbol, size: 24 }) : void 0), v = e?.decimals ?? 18, B = p ?? (o !== void 0 ? W(o, v) : void 0), f = M ?? P, E = {
|
|
64
|
-
sm: "p-3",
|
|
65
|
-
md: "p-3.5",
|
|
66
|
-
default: "p-4",
|
|
67
|
-
lg: "p-5"
|
|
68
|
-
}, O = {
|
|
69
|
-
sm: "text-lg",
|
|
70
|
-
md: "text-xl",
|
|
71
|
-
default: "text-2xl",
|
|
72
|
-
lg: "text-3xl"
|
|
73
|
-
}, R = (u) => {
|
|
74
|
-
const l = u.target.value;
|
|
75
|
-
if (!(!/^[0-9]*\.?[0-9]*$/.test(l) && l !== "") && (b && b(l), c)) {
|
|
76
|
-
const [k, C] = U(l, v);
|
|
77
|
-
k !== null && C !== null && c(k, C);
|
|
13
|
+
import { BalanceIndicator as U } from "./balance-indicator.js";
|
|
14
|
+
const W = u(
|
|
15
|
+
"relative w-full text-foreground bg-gray-20 border border-gray-30 transition-[background-color] duration-100 ease-linear [&:hover]:bg-gray-30 [&:hover]:border-gray-40 data-[active=true]:bg-gray-30 data-[active=true]:outline data-[active=true]:outline-2 data-[active=true]:outline-primary data-[active=true]:outline-offset-[-2px] data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[disabled=true]:cursor-not-allowed",
|
|
16
|
+
{
|
|
17
|
+
variants: {
|
|
18
|
+
size: {
|
|
19
|
+
sm: "px-3 py-[7px] h-[60px] rounded-[8px]",
|
|
20
|
+
md: "pl-4 pr-3 py-[10px] h-[82px] rounded-lg"
|
|
78
21
|
}
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
22
|
+
},
|
|
23
|
+
defaultVariants: { size: "md" }
|
|
24
|
+
}
|
|
25
|
+
), Y = u("font-medium text-foreground", {
|
|
26
|
+
variants: {
|
|
27
|
+
size: {
|
|
28
|
+
sm: "text-xs",
|
|
29
|
+
md: "text-sm"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
defaultVariants: { size: "md" }
|
|
33
|
+
}), Z = u(
|
|
34
|
+
"w-full p-0 bg-transparent border-none outline-none text-foreground placeholder:text-secondary-foreground focus:outline-none",
|
|
35
|
+
{
|
|
36
|
+
variants: {
|
|
37
|
+
size: {
|
|
38
|
+
sm: "text-[18px]! leading-[21px]!",
|
|
39
|
+
md: "text-[28px]! leading-[33px]!"
|
|
83
40
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
41
|
+
},
|
|
42
|
+
defaultVariants: { size: "md" }
|
|
43
|
+
}
|
|
44
|
+
), _ = g.forwardRef(
|
|
45
|
+
({
|
|
46
|
+
amount: v,
|
|
47
|
+
token: t,
|
|
48
|
+
label: y = "Amount",
|
|
49
|
+
maxAmount: a,
|
|
50
|
+
maxAmountLimit: o,
|
|
51
|
+
maxButtonLabel: w,
|
|
52
|
+
chainId: z,
|
|
53
|
+
network: N,
|
|
54
|
+
maxButton: C = !0,
|
|
55
|
+
disabled: n = !1,
|
|
56
|
+
active: V = !1,
|
|
57
|
+
size: I = "md",
|
|
58
|
+
onSetAmount: r,
|
|
59
|
+
onShowSelectDialog: c,
|
|
60
|
+
onRemove: m,
|
|
61
|
+
onFocus: B,
|
|
62
|
+
onBlur: k
|
|
63
|
+
}, M) => {
|
|
64
|
+
const p = t?.decimals ?? 18, j = (i) => {
|
|
65
|
+
const l = i.target.value, [b, h] = Q(l, p);
|
|
66
|
+
b === null || h === null || r && r(b, h);
|
|
67
|
+
}, F = () => {
|
|
68
|
+
if (r) {
|
|
69
|
+
const i = a && o && a > o ? o : a || 0n, l = P(i, p);
|
|
70
|
+
r(i, l);
|
|
87
71
|
}
|
|
88
|
-
},
|
|
72
|
+
}, [L, f] = g.useState(!1), T = () => {
|
|
73
|
+
f(!0), B?.();
|
|
74
|
+
}, D = () => {
|
|
75
|
+
f(!1), k?.();
|
|
76
|
+
}, s = I ?? "md", R = J(), S = K(), X = O(), $ = R ? 20 : S ? 30 : X ? 26 : 30, q = !!(t || c);
|
|
89
77
|
return /* @__PURE__ */ d(
|
|
90
78
|
"div",
|
|
91
79
|
{
|
|
92
|
-
ref:
|
|
93
|
-
className:
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
E[N],
|
|
98
|
-
V
|
|
99
|
-
),
|
|
100
|
-
"data-active": y,
|
|
101
|
-
"data-disabled": i,
|
|
80
|
+
ref: M,
|
|
81
|
+
className: W({ size: s }),
|
|
82
|
+
"data-testid": "smart-number-input-root",
|
|
83
|
+
"data-active": L,
|
|
84
|
+
"data-disabled": n,
|
|
102
85
|
children: [
|
|
103
|
-
|
|
104
|
-
"
|
|
86
|
+
m && /* @__PURE__ */ e(
|
|
87
|
+
"div",
|
|
105
88
|
{
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
),
|
|
112
|
-
/* @__PURE__ */ d("div", { className: "flex items-center justify-between mb-2", children: [
|
|
113
|
-
/* @__PURE__ */ s("span", { className: "text-sm text-muted-foreground", children: a }),
|
|
114
|
-
B !== void 0 && /* @__PURE__ */ d("div", { className: "flex items-center gap-2", children: [
|
|
115
|
-
/* @__PURE__ */ d("span", { className: "text-sm text-muted-foreground", children: [
|
|
116
|
-
"Balance: ",
|
|
117
|
-
B
|
|
118
|
-
] }),
|
|
119
|
-
q && /* @__PURE__ */ s(
|
|
120
|
-
H,
|
|
89
|
+
className: "absolute top-0 right-0 flex h-5 w-5 translate-x-1/2 -translate-y-1/2 items-center justify-center",
|
|
90
|
+
"data-testid": "smart-number-input-close",
|
|
91
|
+
children: /* @__PURE__ */ e(
|
|
92
|
+
"button",
|
|
121
93
|
{
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
className: "text-primary hover:text-primary/80",
|
|
127
|
-
children: $
|
|
94
|
+
type: "button",
|
|
95
|
+
onClick: m,
|
|
96
|
+
className: "flex h-5 w-5 items-center justify-center rounded-full bg-muted hover:bg-muted/80 text-muted-foreground",
|
|
97
|
+
children: /* @__PURE__ */ e(H, { icon: G, className: "size-3" })
|
|
128
98
|
}
|
|
129
99
|
)
|
|
130
|
-
|
|
100
|
+
}
|
|
101
|
+
),
|
|
102
|
+
/* @__PURE__ */ d("div", { className: "mb-2 flex justify-between text-sm leading-[120%]", children: [
|
|
103
|
+
/* @__PURE__ */ e(
|
|
104
|
+
"span",
|
|
105
|
+
{
|
|
106
|
+
className: x(
|
|
107
|
+
Y({ size: s }),
|
|
108
|
+
"grow shrink-0 basis-0"
|
|
109
|
+
),
|
|
110
|
+
"data-testid": "smart-number-input-label",
|
|
111
|
+
children: y
|
|
112
|
+
}
|
|
113
|
+
),
|
|
114
|
+
a !== void 0 && t && /* @__PURE__ */ e(
|
|
115
|
+
U,
|
|
116
|
+
{
|
|
117
|
+
title: w,
|
|
118
|
+
token: t,
|
|
119
|
+
maxAmount: a,
|
|
120
|
+
size: s,
|
|
121
|
+
disabled: n,
|
|
122
|
+
maxButton: C,
|
|
123
|
+
onMaxButtonClick: F
|
|
124
|
+
}
|
|
125
|
+
)
|
|
131
126
|
] }),
|
|
132
|
-
/* @__PURE__ */ d("div", { className: "flex items-center
|
|
133
|
-
/* @__PURE__ */
|
|
127
|
+
/* @__PURE__ */ d("div", { className: "flex w-full max-w-full shrink-0 basis-full items-center", children: [
|
|
128
|
+
/* @__PURE__ */ e("div", { className: "mr-3 grow shrink-0 basis-0", children: /* @__PURE__ */ e(
|
|
134
129
|
"input",
|
|
135
130
|
{
|
|
136
131
|
type: "text",
|
|
@@ -140,41 +135,39 @@ const Y = G.forwardRef(
|
|
|
140
135
|
spellCheck: "false",
|
|
141
136
|
pattern: "^[0-9]*[.,]?[0-9]*$",
|
|
142
137
|
placeholder: "0",
|
|
143
|
-
value:
|
|
144
|
-
onChange:
|
|
145
|
-
onFocus:
|
|
146
|
-
onBlur:
|
|
147
|
-
disabled:
|
|
148
|
-
className:
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
138
|
+
value: v,
|
|
139
|
+
onChange: j,
|
|
140
|
+
onFocus: T,
|
|
141
|
+
onBlur: D,
|
|
142
|
+
disabled: n || !r,
|
|
143
|
+
className: x(Z({ size: s })),
|
|
144
|
+
"data-testid": "smart-number-input-input",
|
|
145
|
+
minLength: 1,
|
|
146
|
+
maxLength: 79,
|
|
147
|
+
title: "Amount"
|
|
152
148
|
}
|
|
153
|
-
),
|
|
154
|
-
|
|
155
|
-
|
|
149
|
+
) }),
|
|
150
|
+
q ? /* @__PURE__ */ e(
|
|
151
|
+
E,
|
|
156
152
|
{
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
disabled:
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
children:
|
|
166
|
-
I,
|
|
167
|
-
h && /* @__PURE__ */ s("span", { children: h })
|
|
168
|
-
]
|
|
153
|
+
active: V,
|
|
154
|
+
size: s,
|
|
155
|
+
disabled: n,
|
|
156
|
+
token: t,
|
|
157
|
+
showSelectDialog: c,
|
|
158
|
+
chainId: z,
|
|
159
|
+
network: N,
|
|
160
|
+
maxLength: $,
|
|
161
|
+
children: t?.symbol ?? "Select token"
|
|
169
162
|
}
|
|
170
|
-
)
|
|
163
|
+
) : null
|
|
171
164
|
] })
|
|
172
165
|
]
|
|
173
166
|
}
|
|
174
167
|
);
|
|
175
168
|
}
|
|
176
169
|
);
|
|
177
|
-
|
|
170
|
+
_.displayName = "SmartNumberInput";
|
|
178
171
|
export {
|
|
179
|
-
|
|
172
|
+
_ as SmartNumberInput
|
|
180
173
|
};
|
package/dist/esm/hooks/index.js
CHANGED
|
@@ -2,51 +2,54 @@ import { useCheckboxSelect as t } from "./use-checkbox-select.js";
|
|
|
2
2
|
import { useControllableState as i } from "./use-controllable-state.js";
|
|
3
3
|
import { useDebounce as u } from "./use-debounce.js";
|
|
4
4
|
import { useDebounceCall as l } from "./use-debounce-call.js";
|
|
5
|
-
import { getSortForField as
|
|
6
|
-
import { useHF as
|
|
7
|
-
import { useEditPriceManually as
|
|
8
|
-
import { useIsDesktop as b, useIsMobile as D, useIsTablet as F, useMediaQuery as
|
|
9
|
-
import { useOpenedState as
|
|
10
|
-
import { usePrevious as
|
|
11
|
-
import {
|
|
5
|
+
import { getSortForField as L, useFilterAllSelected as m, useRangeFilter as x, useSelectFilter as n, useSort as A } from "./use-filter.js";
|
|
6
|
+
import { useHF as I } from "./use-hf.js";
|
|
7
|
+
import { useEditPriceManually as C, useLiquidationGraphParams as E, useLiquidationHeatmap as d } from "./use-liquidation/index.js";
|
|
8
|
+
import { useIsDesktop as b, useIsExtraSmall as _, useIsMobile as D, useIsTablet as F, useMediaQuery as P } from "./use-media-query.js";
|
|
9
|
+
import { useOpenedState as h } from "./use-opened-state.js";
|
|
10
|
+
import { usePrevious as q } from "./use-previous.js";
|
|
11
|
+
import { useSmartNumberInput as G } from "./use-smart-number-input.js";
|
|
12
|
+
import { CELL_BAD as N, CELL_CURRENT as R, CELL_GOOD as U, CELL_HOVERED as g, CELL_LIQUIDATION as H, CELL_OK as X, DEFAULT_AXIS_MAX as k, DEFAULT_AXIS_MIN as y, formatAxisLabel as Q, formatAxisTipLabel as V, formatAxisTipPrice as B, getCellClass as K, isPointInCell as W, useAxis as j, useFixedAssets as w, useIsAxisInRelativeUnits as z, useLiquidationGraphActivePrice as J, useLiquidationGraphCurrentActiveValue as Y, usePriceInNumber as Z, useWithLiquidationGraphActivePrices as $ } from "./use-liquidation/utils.js";
|
|
12
13
|
export {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
14
|
+
N as CELL_BAD,
|
|
15
|
+
R as CELL_CURRENT,
|
|
16
|
+
U as CELL_GOOD,
|
|
17
|
+
g as CELL_HOVERED,
|
|
18
|
+
H as CELL_LIQUIDATION,
|
|
19
|
+
X as CELL_OK,
|
|
20
|
+
k as DEFAULT_AXIS_MAX,
|
|
21
|
+
y as DEFAULT_AXIS_MIN,
|
|
22
|
+
Q as formatAxisLabel,
|
|
23
|
+
V as formatAxisTipLabel,
|
|
24
|
+
B as formatAxisTipPrice,
|
|
25
|
+
K as getCellClass,
|
|
26
|
+
L as getSortForField,
|
|
27
|
+
W as isPointInCell,
|
|
28
|
+
j as useAxis,
|
|
28
29
|
t as useCheckboxSelect,
|
|
29
30
|
i as useControllableState,
|
|
30
31
|
u as useDebounce,
|
|
31
32
|
l as useDebounceCall,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
C as useEditPriceManually,
|
|
34
|
+
m as useFilterAllSelected,
|
|
35
|
+
w as useFixedAssets,
|
|
36
|
+
I as useHF,
|
|
37
|
+
z as useIsAxisInRelativeUnits,
|
|
37
38
|
b as useIsDesktop,
|
|
39
|
+
_ as useIsExtraSmall,
|
|
38
40
|
D as useIsMobile,
|
|
39
41
|
F as useIsTablet,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
J as useLiquidationGraphActivePrice,
|
|
43
|
+
Y as useLiquidationGraphCurrentActiveValue,
|
|
42
44
|
E as useLiquidationGraphParams,
|
|
43
45
|
d as useLiquidationHeatmap,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
P as useMediaQuery,
|
|
47
|
+
h as useOpenedState,
|
|
48
|
+
q as usePrevious,
|
|
49
|
+
Z as usePriceInNumber,
|
|
50
|
+
x as useRangeFilter,
|
|
49
51
|
n as useSelectFilter,
|
|
52
|
+
G as useSmartNumberInput,
|
|
50
53
|
A as useSort,
|
|
51
|
-
|
|
54
|
+
$ as useWithLiquidationGraphActivePrices
|
|
52
55
|
};
|
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}, r);
|
|
8
|
-
},
|
|
9
|
-
[r]
|
|
10
|
-
);
|
|
11
|
-
return o(() => () => {
|
|
12
|
-
e.current && clearTimeout(e.current);
|
|
13
|
-
}, []), t;
|
|
1
|
+
import "react";
|
|
2
|
+
import { useDebounce as o } from "./use-debounce.js";
|
|
3
|
+
import "@gearbox-protocol/sdk";
|
|
4
|
+
const n = (e) => e();
|
|
5
|
+
function b(e) {
|
|
6
|
+
return o(n, e);
|
|
14
7
|
}
|
|
15
8
|
export {
|
|
16
|
-
|
|
9
|
+
b as useDebounceCall
|
|
17
10
|
};
|
package/dist/esm/hooks/use-hf.js
CHANGED
|
@@ -1,35 +1,43 @@
|
|
|
1
|
-
import { CreditAccountData_Legacy as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
function
|
|
4
|
-
assets:
|
|
1
|
+
import { CreditAccountData_Legacy as l } from "@gearbox-protocol/sdk";
|
|
2
|
+
import { useMemo as p } from "react";
|
|
3
|
+
function _({
|
|
4
|
+
assets: e,
|
|
5
5
|
quotas: c,
|
|
6
|
-
prices:
|
|
7
|
-
liquidationThresholds:
|
|
6
|
+
prices: n,
|
|
7
|
+
liquidationThresholds: u,
|
|
8
8
|
underlyingToken: f,
|
|
9
|
-
debt:
|
|
10
|
-
quotasInfo:
|
|
11
|
-
|
|
9
|
+
debt: t,
|
|
10
|
+
quotasInfo: o,
|
|
11
|
+
allowZeroDebt: m = !1,
|
|
12
|
+
tokensList: a
|
|
12
13
|
}) {
|
|
13
|
-
return { hf:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
return { hf: p(() => {
|
|
15
|
+
try {
|
|
16
|
+
return t === 0n && !m ? 0 : l.calcHealthFactor({
|
|
17
|
+
assets: e,
|
|
18
|
+
quotas: c,
|
|
19
|
+
prices: n,
|
|
20
|
+
liquidationThresholds: u,
|
|
21
|
+
underlyingToken: f,
|
|
22
|
+
debt: t,
|
|
23
|
+
quotasInfo: o,
|
|
24
|
+
tokensList: a
|
|
25
|
+
});
|
|
26
|
+
} catch (r) {
|
|
27
|
+
return typeof r == "object" && r !== null && "reason" in r && r.reason === "overflow" ? Number.MAX_SAFE_INTEGER : 0;
|
|
28
|
+
}
|
|
29
|
+
}, [
|
|
30
|
+
e,
|
|
24
31
|
c,
|
|
25
|
-
|
|
26
|
-
|
|
32
|
+
n,
|
|
33
|
+
u,
|
|
27
34
|
f,
|
|
35
|
+
t,
|
|
28
36
|
o,
|
|
29
|
-
|
|
30
|
-
|
|
37
|
+
m,
|
|
38
|
+
a
|
|
31
39
|
]) };
|
|
32
40
|
}
|
|
33
41
|
export {
|
|
34
|
-
|
|
42
|
+
_ as useHF
|
|
35
43
|
};
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { useState as c, useEffect as
|
|
2
|
-
function
|
|
3
|
-
const [
|
|
4
|
-
return
|
|
1
|
+
import { useState as c, useEffect as m } from "react";
|
|
2
|
+
function t(n) {
|
|
3
|
+
const [s, a] = c(!1);
|
|
4
|
+
return m(() => {
|
|
5
5
|
const e = window.matchMedia(n);
|
|
6
|
-
e.matches !==
|
|
6
|
+
e.matches !== s && a(e.matches);
|
|
7
7
|
const i = () => a(e.matches);
|
|
8
8
|
return e.addEventListener("change", i), () => e.removeEventListener("change", i);
|
|
9
|
-
}, [
|
|
9
|
+
}, [s, n]), s;
|
|
10
10
|
}
|
|
11
|
-
const h = () =>
|
|
11
|
+
const h = () => t("(max-width: 500px)"), d = () => t("(max-width: 768px)"), r = () => t("(min-width: 768px) and (max-width: 1024px)"), u = () => t("(min-width: 1024px)");
|
|
12
12
|
export {
|
|
13
|
-
|
|
14
|
-
h as
|
|
15
|
-
d as
|
|
16
|
-
|
|
13
|
+
u as useIsDesktop,
|
|
14
|
+
h as useIsExtraSmall,
|
|
15
|
+
d as useIsMobile,
|
|
16
|
+
r as useIsTablet,
|
|
17
|
+
t as useMediaQuery
|
|
17
18
|
};
|