@gearbox-protocol/permissionless-ui 1.4.3 → 1.4.4

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.
@@ -42,8 +42,7 @@ const BAD_HF = 11e3;
42
42
  const CRITICAL_HF = 10500;
43
43
  const getHFZones = (hf) => {
44
44
  if (!hf) return void 0;
45
- const numHf = Number(hf);
46
- const hfInBasisPoints = numHf < 1e3 ? numHf * import_format_money.PERCENTAGE_FACTOR : numHf;
45
+ const hfInBasisPoints = Number(hf);
47
46
  if (hfInBasisPoints >= GOOD_HF) return "good";
48
47
  if (hfInBasisPoints > BAD_HF) return "medium";
49
48
  if (hfInBasisPoints > CRITICAL_HF) return "bad";
@@ -84,8 +83,7 @@ function HealthFactor({
84
83
  const renderValue = () => {
85
84
  if (zeroDebt) return "N/A";
86
85
  const numValue = Number(value);
87
- const hfInBasisPoints = numValue < 1e3 ? numValue * import_format_money.PERCENTAGE_FACTOR : numValue;
88
- const hfDecimal = hfInBasisPoints / import_format_money.PERCENTAGE_FACTOR;
86
+ const hfDecimal = numValue / import_format_money.PERCENTAGE_FACTOR;
89
87
  const formatted = (0, import_format_money.formatPercentAmount)(hfDecimal, decimals);
90
88
  return String(formatted);
91
89
  };
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
  var liquidation_graph_exports = {};
30
20
  __export(liquidation_graph_exports, {
@@ -33,23 +23,12 @@ __export(liquidation_graph_exports, {
33
23
  module.exports = __toCommonJS(liquidation_graph_exports);
34
24
  var import_jsx_runtime = require("react/jsx-runtime");
35
25
  var import_react = require("react");
36
- var ColorHeatmapModule = __toESM(require("reactochart/ColorHeatmap"));
37
- var XAxisModule = __toESM(require("reactochart/XAxis"));
38
- var XLineModule = __toESM(require("reactochart/XLine"));
39
- var XYPlotModule = __toESM(require("reactochart/XYPlot"));
40
- var YAxisModule = __toESM(require("reactochart/YAxis"));
41
- var YLineModule = __toESM(require("reactochart/YLine"));
42
26
  var import_use_hf = require('../../hooks/use-hf.js');
43
27
  var import_use_liquidation = require('../../hooks/use-liquidation/index.js');
28
+ var import_reactochart_compat = require('../../utils/reactochart-compat.js');
44
29
  var import_vspace = require('../vspace.js');
45
30
  var import_liquidation_graph_legend = require('./liquidation-graph-legend.js');
46
31
  var import_liquidation_graph_tip = require('./liquidation-graph-tip.js');
47
- const ColorHeatmap = ColorHeatmapModule.default || ColorHeatmapModule;
48
- const XAxis = XAxisModule.default || XAxisModule;
49
- const XLine = XLineModule.default || XLineModule;
50
- const XYPlot = XYPlotModule.default || XYPlotModule;
51
- const YAxis = YAxisModule.default || YAxisModule;
52
- const YLine = YLineModule.default || YLineModule;
53
32
  const WIDTH = 300;
54
33
  const HEIGHT = 300;
55
34
  const CROSSHAIR_X = "rct-crosshair-x";
@@ -156,7 +135,7 @@ function LiquidationGraph({
156
135
  ) }),
157
136
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_vspace.VSpace, { height: 16 }),
158
137
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "w-full liquidation-graph-container", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
159
- XYPlot,
138
+ import_reactochart_compat.XYPlot,
160
139
  {
161
140
  width,
162
141
  height,
@@ -166,7 +145,7 @@ function LiquidationGraph({
166
145
  onMouseLeave: handleMouseLeave,
167
146
  children: [
168
147
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
169
- XAxis,
148
+ import_reactochart_compat.XAxis,
170
149
  {
171
150
  showLine: false,
172
151
  title: (0, import_use_liquidation.formatAxisTipLabel)(xLabel, underlyingToken, xOrder),
@@ -180,7 +159,7 @@ function LiquidationGraph({
180
159
  }
181
160
  ),
182
161
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
183
- YAxis,
162
+ import_reactochart_compat.YAxis,
184
163
  {
185
164
  showLine: false,
186
165
  title: (0, import_use_liquidation.formatAxisTipLabel)(yLabel, underlyingToken, yOrder),
@@ -194,7 +173,7 @@ function LiquidationGraph({
194
173
  }
195
174
  ),
196
175
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
197
- ColorHeatmap,
176
+ import_reactochart_compat.ColorHeatmap,
198
177
  {
199
178
  data: heatmap,
200
179
  value: (d) => d.value,
@@ -205,8 +184,8 @@ function LiquidationGraph({
205
184
  rectClassName: (p) => (0, import_use_liquidation.getCellClass)(p, currentPoint, activePointX, activePointY)
206
185
  }
207
186
  ),
208
- activePointX !== void 0 && activePointX !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(XLine, { value: activePointX, className: CROSSHAIR_X }),
209
- activePointY !== void 0 && activePointY !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(YLine, { value: activePointY, className: CROSSHAIR_Y })
187
+ activePointX !== void 0 && activePointX !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_reactochart_compat.XLine, { value: activePointX, className: CROSSHAIR_X }),
188
+ activePointY !== void 0 && activePointY !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_reactochart_compat.YLine, { value: activePointY, className: CROSSHAIR_Y })
210
189
  ]
211
190
  }
212
191
  ) }),
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var reactochart_compat_exports = {};
30
+ __export(reactochart_compat_exports, {
31
+ ColorHeatmap: () => ColorHeatmap,
32
+ XAxis: () => XAxis,
33
+ XLine: () => XLine,
34
+ XYPlot: () => XYPlot,
35
+ YAxis: () => YAxis,
36
+ YLine: () => YLine
37
+ });
38
+ module.exports = __toCommonJS(reactochart_compat_exports);
39
+ var import_ColorHeatmap = __toESM(require("reactochart/ColorHeatmap"));
40
+ var import_XAxis = __toESM(require("reactochart/XAxis"));
41
+ var import_XLine = __toESM(require("reactochart/XLine"));
42
+ var import_XYPlot = __toESM(require("reactochart/XYPlot"));
43
+ var import_YAxis = __toESM(require("reactochart/YAxis"));
44
+ var import_YLine = __toESM(require("reactochart/YLine"));
45
+ function resolveDefault(mod) {
46
+ return mod.default || mod;
47
+ }
48
+ const ColorHeatmap = resolveDefault(import_ColorHeatmap.default);
49
+ const XAxis = resolveDefault(import_XAxis.default);
50
+ const XLine = resolveDefault(import_XLine.default);
51
+ const XYPlot = resolveDefault(import_XYPlot.default);
52
+ const YAxis = resolveDefault(import_YAxis.default);
53
+ const YLine = resolveDefault(import_YLine.default);
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ ColorHeatmap,
57
+ XAxis,
58
+ XLine,
59
+ XYPlot,
60
+ YAxis,
61
+ YLine
62
+ });
@@ -6,8 +6,7 @@ const BAD_HF = 11e3;
6
6
  const CRITICAL_HF = 10500;
7
7
  const getHFZones = (hf) => {
8
8
  if (!hf) return void 0;
9
- const numHf = Number(hf);
10
- const hfInBasisPoints = numHf < 1e3 ? numHf * PERCENTAGE_FACTOR : numHf;
9
+ const hfInBasisPoints = Number(hf);
11
10
  if (hfInBasisPoints >= GOOD_HF) return "good";
12
11
  if (hfInBasisPoints > BAD_HF) return "medium";
13
12
  if (hfInBasisPoints > CRITICAL_HF) return "bad";
@@ -48,8 +47,7 @@ function HealthFactor({
48
47
  const renderValue = () => {
49
48
  if (zeroDebt) return "N/A";
50
49
  const numValue = Number(value);
51
- const hfInBasisPoints = numValue < 1e3 ? numValue * PERCENTAGE_FACTOR : numValue;
52
- const hfDecimal = hfInBasisPoints / PERCENTAGE_FACTOR;
50
+ const hfDecimal = numValue / PERCENTAGE_FACTOR;
53
51
  const formatted = formatPercentAmount(hfDecimal, decimals);
54
52
  return String(formatted);
55
53
  };
@@ -1,11 +1,5 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useCallback } from "react";
3
- import * as ColorHeatmapModule from "reactochart/ColorHeatmap";
4
- import * as XAxisModule from "reactochart/XAxis";
5
- import * as XLineModule from "reactochart/XLine";
6
- import * as XYPlotModule from "reactochart/XYPlot";
7
- import * as YAxisModule from "reactochart/YAxis";
8
- import * as YLineModule from "reactochart/YLine";
9
3
  import { useHF } from "../../hooks/use-hf.js";
10
4
  import {
11
5
  DEFAULT_AXIS_MAX,
@@ -19,15 +13,17 @@ import {
19
13
  useLiquidationHeatmap,
20
14
  useWithLiquidationGraphActivePrices
21
15
  } from "../../hooks/use-liquidation/index.js";
16
+ import {
17
+ ColorHeatmap,
18
+ XAxis,
19
+ XLine,
20
+ XYPlot,
21
+ YAxis,
22
+ YLine
23
+ } from "../../utils/reactochart-compat.js";
22
24
  import { VSpace } from "../vspace.js";
23
25
  import { LiquidationGraphLegend } from "./liquidation-graph-legend.js";
24
26
  import { LiquidationGraphTip } from "./liquidation-graph-tip.js";
25
- const ColorHeatmap = ColorHeatmapModule.default || ColorHeatmapModule;
26
- const XAxis = XAxisModule.default || XAxisModule;
27
- const XLine = XLineModule.default || XLineModule;
28
- const XYPlot = XYPlotModule.default || XYPlotModule;
29
- const YAxis = YAxisModule.default || YAxisModule;
30
- const YLine = YLineModule.default || YLineModule;
31
27
  const WIDTH = 300;
32
28
  const HEIGHT = 300;
33
29
  const CROSSHAIR_X = "rct-crosshair-x";
@@ -0,0 +1,23 @@
1
+ function resolveDefault(mod) {
2
+ return mod.default || mod;
3
+ }
4
+ import ColorHeatmapImport from "reactochart/ColorHeatmap";
5
+ import XAxisImport from "reactochart/XAxis";
6
+ import XLineImport from "reactochart/XLine";
7
+ import XYPlotImport from "reactochart/XYPlot";
8
+ import YAxisImport from "reactochart/YAxis";
9
+ import YLineImport from "reactochart/YLine";
10
+ const ColorHeatmap = resolveDefault(ColorHeatmapImport);
11
+ const XAxis = resolveDefault(XAxisImport);
12
+ const XLine = resolveDefault(XLineImport);
13
+ const XYPlot = resolveDefault(XYPlotImport);
14
+ const YAxis = resolveDefault(YAxisImport);
15
+ const YLine = resolveDefault(YLineImport);
16
+ export {
17
+ ColorHeatmap,
18
+ XAxis,
19
+ XLine,
20
+ XYPlot,
21
+ YAxis,
22
+ YLine
23
+ };
@@ -4,17 +4,15 @@ export declare const GOOD_HF = 15000;
4
4
  export declare const BAD_HF = 11000;
5
5
  /**
6
6
  * Determines the health factor zone based on the value
7
- * @param hf - Health factor value (in basis points if >= 1000, otherwise as decimal)
7
+ * @param hf - Health factor value in basis points (e.g., 15000 for 1.5)
8
8
  * @returns The health factor zone or undefined
9
9
  */
10
10
  export declare const getHFZones: (hf: number | bigint | undefined) => HFZones | undefined;
11
11
  export interface HealthFactorProps extends React.HTMLAttributes<HTMLDivElement> {
12
12
  /**
13
- * The health factor value
14
- * Can be provided as:
15
- * - Decimal value (e.g., 1.5 for 150%)
16
- * - Basis points (e.g., 15000 for 150%)
17
- * Values >= 1000 are treated as basis points, < 1000 as decimal
13
+ * The health factor value in basis points
14
+ * For example: 15000 for health factor 1.5, 500 for health factor 0.05
15
+ * (SDK always returns health factor in basis points: 10000 = 1.0)
18
16
  */
19
17
  value: number | bigint;
20
18
  /**
@@ -49,15 +47,13 @@ export interface HealthFactorProps extends React.HTMLAttributes<HTMLDivElement>
49
47
  *
50
48
  * @example
51
49
  * ```tsx
52
- * // Using decimal value
53
- * <HealthFactor value={1.5} debt={1000000n} /> // Shows "1.500" in green
54
- * <HealthFactor value={1.2} debt={1000000n} decimals={2} /> // Shows "1.20" in yellow
55
- *
56
- * // Using basis points
50
+ * // Health factor in basis points (SDK format)
57
51
  * <HealthFactor value={15000} debt={1000000n} /> // Shows "1.500" in green
52
+ * <HealthFactor value={12000} debt={1000000n} decimals={2} /> // Shows "1.20" in yellow
53
+ * <HealthFactor value={500} debt={1000000n} /> // Shows "0.050" in red
58
54
  *
59
55
  * // Zero debt shows N/A
60
- * <HealthFactor value={1.5} debt={0n} /> // Shows "N/A"
56
+ * <HealthFactor value={15000} debt={0n} /> // Shows "N/A"
61
57
  * ```
62
58
  */
63
59
  export declare function HealthFactor({ value, debt, decimals, zone, showColor, className, ...props }: HealthFactorProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Compatibility layer for reactochart CommonJS modules in ESM context
3
+ * Handles the default export resolution for CommonJS modules
4
+ */
5
+ import ColorHeatmapImport from "reactochart/ColorHeatmap";
6
+ import XAxisImport from "reactochart/XAxis";
7
+ import XLineImport from "reactochart/XLine";
8
+ import XYPlotImport from "reactochart/XYPlot";
9
+ import YAxisImport from "reactochart/YAxis";
10
+ import YLineImport from "reactochart/YLine";
11
+ export declare const ColorHeatmap: typeof ColorHeatmapImport;
12
+ export declare const XAxis: typeof XAxisImport;
13
+ export declare const XLine: typeof XLineImport;
14
+ export declare const XYPlot: typeof XYPlotImport;
15
+ export declare const YAxis: typeof YAxisImport;
16
+ export declare const YLine: typeof YLineImport;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/permissionless-ui",
3
- "version": "1.4.3",
3
+ "version": "1.4.4",
4
4
  "description": "Internal UI components",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/index.js",
@@ -65,7 +65,6 @@
65
65
  "react-infinite-scroll-component": "^6.1.0",
66
66
  "react-markdown": "^9.0.3",
67
67
  "react-markdown-math": "^1.0.2",
68
- "reactochart": "^6.1.1",
69
68
  "remark-gfm": "^4.0.0",
70
69
  "sonner": "^1.7.2",
71
70
  "tailwind-merge": "^2.6.0",
@@ -82,6 +81,7 @@
82
81
  "react-dom": "^18 || ^19",
83
82
  "react-intl": "^6.0.0 || ^7.0.0",
84
83
  "react-router-dom": "^6.0.0 || ^7.0.0",
84
+ "reactochart": "^6.1.1",
85
85
  "viem": "^2.0.0",
86
86
  "wagmi": "^2.0.0"
87
87
  },
@@ -122,6 +122,7 @@
122
122
  "react-dom": "^19.1.1",
123
123
  "react-intl": "^6.7.4",
124
124
  "react-router-dom": "^7.9.6",
125
+ "reactochart": "^6.1.1",
125
126
  "tailwindcss": "^4.1.14",
126
127
  "tsup": "^8.5.0",
127
128
  "typescript": "^5.9.3",