@gearbox-protocol/ui-kit 4.0.0-next.64 → 4.0.0-next.66

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 (27) hide show
  1. package/dist/cjs/components/base/leverage-input/leverage-input.cjs +1 -1
  2. package/dist/cjs/components/base/leverage-preset-chips/leverage-preset-chips.cjs +1 -1
  3. package/dist/cjs/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.cjs +1 -1
  4. package/dist/cjs/index.cjs +1 -1
  5. package/dist/cjs/locale/en.json.cjs +1 -1
  6. package/dist/cjs/utils/format-leverage.cjs +1 -1
  7. package/dist/cjs/utils/format-price.cjs +1 -1
  8. package/dist/cjs/utils/index.cjs +1 -1
  9. package/dist/cjs/utils/leverage-presets.cjs +1 -1
  10. package/dist/esm/components/base/leverage-input/leverage-input.js +31 -31
  11. package/dist/esm/components/base/leverage-preset-chips/leverage-preset-chips.js +6 -6
  12. package/dist/esm/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.js +30 -30
  13. package/dist/esm/index.js +189 -188
  14. package/dist/esm/locale/en.json.js +1 -1
  15. package/dist/esm/utils/format-leverage.js +8 -3
  16. package/dist/esm/utils/format-price.js +4 -7
  17. package/dist/esm/utils/index.js +18 -17
  18. package/dist/esm/utils/leverage-presets.js +4 -6
  19. package/dist/types/components/base/leverage-input/leverage-input.d.ts +2 -2
  20. package/dist/types/locale/en.json.d.ts +1 -1
  21. package/dist/types/utils/format-leverage.d.ts +9 -1
  22. package/dist/types/utils/format-price.d.ts +6 -3
  23. package/dist/types/utils/leverage-presets.d.ts +3 -1
  24. package/package.json +1 -1
  25. package/dist/cjs/components/base/leverage-preset-chips/format-chip-leverage.cjs +0 -1
  26. package/dist/esm/components/base/leverage-preset-chips/format-chip-leverage.js +0 -6
  27. package/dist/types/components/base/leverage-preset-chips/format-chip-leverage.d.ts +0 -5
@@ -1,6 +1,11 @@
1
- function r(e) {
2
- return (Math.round(e * 100) / 100).toFixed(2);
1
+ function r(t) {
2
+ return (Math.round(t * 10) / 10).toFixed(1);
3
+ }
4
+ function n(t) {
5
+ const e = Math.round(t * 100);
6
+ return (e / 100).toFixed(e % 10 === 0 ? 1 : 2);
3
7
  }
4
8
  export {
5
- r as formatLeverage
9
+ r as formatLeverage,
10
+ n as formatLeverageExact
6
11
  };
@@ -1,10 +1,7 @@
1
- function s(i) {
2
- const t = Math.abs(i) >= 1e3 ? 0 : 2;
3
- return `${i < 0 ? "-" : ""}$${Math.abs(i).toLocaleString("en-US", {
4
- minimumFractionDigits: t,
5
- maximumFractionDigits: t
6
- })}`;
1
+ function o(t) {
2
+ const i = Math.abs(t), s = t < 0 ? "-" : "", n = i >= 1e3 ? 0 : 2, m = i > 0 && i < 1 ? { minimumSignificantDigits: 2, maximumSignificantDigits: 2 } : { minimumFractionDigits: n, maximumFractionDigits: n };
3
+ return `${s}$${i.toLocaleString("en-US", m)}`;
7
4
  }
8
5
  export {
9
- s as formatUsdPrice
6
+ o as formatUsdPrice
10
7
  };
@@ -1,31 +1,32 @@
1
1
  import { cn as o, cn as t } from "./cn.js";
2
- import { APPROXIMATE_SYMBOL as m, formatTimestamp as a, shortenHash as f } from "./format.js";
3
- import { formatLeverage as x } from "./format-leverage.js";
4
- import { formatMoney as s, percentageTemplate as T } from "./format-money.js";
2
+ import { APPROXIMATE_SYMBOL as p, formatTimestamp as a, shortenHash as f } from "./format.js";
3
+ import { formatLeverage as x, formatLeverageExact as i } from "./format-leverage.js";
4
+ import { formatMoney as g, percentageTemplate as T } from "./format-money.js";
5
5
  import { formatUsdPrice as l } from "./format-price.js";
6
- import { slippageTemplate as P } from "./format-slippage.js";
7
- import { leveragePresets as I } from "./leverage-presets.js";
8
- import { bnToLiquidationPriceView as u, parseInputToBN as w } from "./parse-input-to-bn.js";
9
- import { shortenString as M } from "./shorten-string.js";
10
- import { tokenTemplateString as S } from "./templates.js";
6
+ import { slippageTemplate as d } from "./format-slippage.js";
7
+ import { leveragePresets as L } from "./leverage-presets.js";
8
+ import { bnToLiquidationPriceView as u, parseInputToBN as v } from "./parse-input-to-bn.js";
9
+ import { shortenString as E } from "./shorten-string.js";
10
+ import { tokenTemplateString as N } from "./templates.js";
11
11
  import { openInNewWindow as A } from "./window.js";
12
- import { Z_INDEX as E } from "./z-index.js";
12
+ import { Z_INDEX as O } from "./z-index.js";
13
13
  export {
14
- m as APPROXIMATE_SYMBOL,
15
- E as Z_INDEX,
14
+ p as APPROXIMATE_SYMBOL,
15
+ O as Z_INDEX,
16
16
  u as bnToLiquidationPriceView,
17
17
  o as cn,
18
18
  t as default,
19
19
  x as formatLeverage,
20
- s as formatMoney,
20
+ i as formatLeverageExact,
21
+ g as formatMoney,
21
22
  a as formatTimestamp,
22
23
  l as formatUsdPrice,
23
- I as leveragePresets,
24
+ L as leveragePresets,
24
25
  A as openInNewWindow,
25
- w as parseInputToBN,
26
+ v as parseInputToBN,
26
27
  T as percentageTemplate,
27
28
  f as shortenHash,
28
- M as shortenString,
29
- P as slippageTemplate,
30
- S as tokenTemplateString
29
+ E as shortenString,
30
+ d as slippageTemplate,
31
+ N as tokenTemplateString
31
32
  };
@@ -1,9 +1,7 @@
1
- function t(e) {
2
- const n = (r) => Math.round(r * 2) / 2;
3
- return [
4
- .../* @__PURE__ */ new Set([n(1 + 0.3 * (e - 1)), n(1 + 0.7 * (e - 1)), e])
5
- ];
1
+ function r(e) {
2
+ const t = (n) => Math.min(Math.round((1 + n * (e - 1)) * 2) / 2, e);
3
+ return [.../* @__PURE__ */ new Set([t(0.3), t(0.7), e])];
6
4
  }
7
5
  export {
8
- t as leveragePresets
6
+ r as leveragePresets
9
7
  };
@@ -16,7 +16,6 @@ export interface LeverageInputProps {
16
16
  readonly onChange: (value: Leverage) => void;
17
17
  readonly max: Leverage;
18
18
  readonly min?: Leverage;
19
- readonly step?: number;
20
19
  /** Label above the slider; defaults to the "Leverage" locale string. */
21
20
  readonly title?: TitleText;
22
21
  /** Muted note rendered right after the label. */
@@ -37,7 +36,8 @@ export interface LeverageInputProps {
37
36
  type TitleSize = "sm" | "default" | "md" | "lg";
38
37
  /**
39
38
  * Target leverage of a position, bounded by what the strategy allows.
40
- * Title row carries an inline-editable value (`N.NNx`) and an optional reset;
39
+ * Title row carries an inline-editable value (`N.Nx`, hundredths kept where the
40
+ * value has them) and an optional reset;
41
41
  * the slider below can show risk bands via `colorIntervals`.
42
42
  */
43
43
  export declare function LeverageInput({ value, onChange, max, min, title, hint, reset, colorIntervals, colorIntervalLabel, size, }: LeverageInputProps): React.ReactElement;
@@ -30,7 +30,7 @@ declare const _default: {
30
30
  "components.apyParts.totalAPY": "Overall APY",
31
31
 
32
32
  "components.yieldBreakdown.titleNetAtLeverage": "Net APY at {leverage}× Leverage",
33
- "components.yieldBreakdown.titleNetAtLeverage7d": "Net APY at {leverage}× Leverage (7d)",
33
+ "components.yieldBreakdown.titleNetAtLeverage7d": "Net APY (7d) at {leverage}× Leverage",
34
34
  "components.yieldBreakdown.titleNet": "Net APY",
35
35
  "components.yieldBreakdown.titleNet7d": "Net APY (7d)",
36
36
  "components.yieldBreakdown.collateralApy": "Collateral APY",
@@ -1,5 +1,13 @@
1
1
  /**
2
- * Display leverage with two decimal places, e.g. `5.79` for `5.7857…`.
2
+ * Display leverage with one decimal place, e.g. `5.8` for `5.7857…`.
3
3
  * The suffix (`x`) / prefix (`×`) stays at the call site.
4
4
  */
5
5
  export declare function formatLeverage(value: number): string;
6
+ /**
7
+ * Leverage keeping the hundredths a value actually carries: `9` → `9.0`,
8
+ * `9.57` → `9.57`. For the slider, whose track ends on an exact `maxLeverage`,
9
+ * and for its edit field, whose text is parsed back into the target: the
10
+ * protocol's own resolution is 0.01, so `formatLeverage` there would silently
11
+ * move the position.
12
+ */
13
+ export declare function formatLeverageExact(value: number): string;
@@ -1,14 +1,17 @@
1
1
  /**
2
2
  * A price as a table shows it: no `K`/`M` abbreviation, and precision that
3
- * follows magnitude — cents below a thousand, whole units at or above it.
3
+ * follows magnitude — whole units at or above a thousand, cents down to one,
4
+ * and two significant digits below that, where cents would round everything
5
+ * to `$0.00`.
4
6
  *
5
7
  * `formatMoney` cannot do this: it routes through the SDK's `formatBN`, which
6
8
  * abbreviates unconditionally and has no switch.
7
9
  *
8
10
  * @example
9
11
  * ```ts
10
- * formatUsdPrice(4.2055) // "$4.21"
11
- * formatUsdPrice(3412.5) // "$3,413"
12
+ * formatUsdPrice(4.2055) // "$4.21"
13
+ * formatUsdPrice(3412.5) // "$3,413"
14
+ * formatUsdPrice(0.0004205) // "$0.00042"
12
15
  * ```
13
16
  */
14
17
  export declare function formatUsdPrice(value: number): string;
@@ -1,5 +1,7 @@
1
1
  /**
2
2
  * Leverage chips beside the strategy yield chart: 30% and 70% of the
3
- * (1 → max) span, rounded to 0.5, plus max itself.
3
+ * (1 → max) span, rounded to 0.5, plus max itself. The 0.5 rounding can
4
+ * overshoot a fractional `max` (1.4 would yield a 1.5 chip), so each step is
5
+ * capped — the dialogs seed their initial leverage from this list.
4
6
  */
5
7
  export declare function leveragePresets(max: number): number[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/ui-kit",
3
- "version": "4.0.0-next.64",
3
+ "version": "4.0.0-next.66",
4
4
  "description": "Internal UI components",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function r(e){return e.toFixed(2).replace(/\.?0+$/,"")}exports.formatChipLeverage=r;
@@ -1,6 +0,0 @@
1
- function r(e) {
2
- return e.toFixed(2).replace(/\.?0+$/, "");
3
- }
4
- export {
5
- r as formatChipLeverage
6
- };
@@ -1,5 +0,0 @@
1
- /**
2
- * Chip / subtitle leverage without trailing zeros: `5`, `5.5`, `9.54`.
3
- * Its own module: LeveragePresetChips reads it, no consumer does.
4
- */
5
- export declare function formatChipLeverage(leverage: number): string;