@gearbox-protocol/ui-kit 4.0.0-next.23 → 4.0.0-next.24

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 (38) hide show
  1. package/dist/cjs/components/base/history-chart/history-chart.cjs +1 -1
  2. package/dist/cjs/components/base/pool-apy-breakdown-card/pool-apy-breakdown-card.cjs +1 -1
  3. package/dist/cjs/components/graph/default-config.cjs +1 -1
  4. package/dist/cjs/components/graph/formatters.cjs +1 -1
  5. package/dist/cjs/components/graph/graph-current-value.cjs +1 -1
  6. package/dist/cjs/components/graph/graph-tooltip.cjs +1 -1
  7. package/dist/cjs/components/graph/graph.cjs +1 -1
  8. package/dist/cjs/components/graph/index.cjs +1 -1
  9. package/dist/cjs/components/graph/y-axis-scale.cjs +1 -0
  10. package/dist/cjs/components/index.cjs +1 -1
  11. package/dist/cjs/components/trading-view/trading-view.cjs +1 -1
  12. package/dist/cjs/components/yield-breakdown-tooltip/yield-breakdown-tooltip.cjs +1 -1
  13. package/dist/cjs/index.cjs +1 -1
  14. package/dist/cjs/locale/en.json.cjs +1 -1
  15. package/dist/esm/components/base/history-chart/history-chart.js +16 -15
  16. package/dist/esm/components/base/pool-apy-breakdown-card/pool-apy-breakdown-card.js +41 -25
  17. package/dist/esm/components/graph/default-config.js +44 -24
  18. package/dist/esm/components/graph/formatters.js +123 -128
  19. package/dist/esm/components/graph/graph-current-value.js +11 -11
  20. package/dist/esm/components/graph/graph-tooltip.js +6 -6
  21. package/dist/esm/components/graph/graph.js +597 -547
  22. package/dist/esm/components/graph/index.js +32 -27
  23. package/dist/esm/components/graph/y-axis-scale.js +112 -0
  24. package/dist/esm/components/index.js +496 -491
  25. package/dist/esm/components/trading-view/trading-view.js +83 -82
  26. package/dist/esm/components/yield-breakdown-tooltip/yield-breakdown-tooltip.js +94 -55
  27. package/dist/esm/index.js +649 -644
  28. package/dist/esm/locale/en.json.js +16 -4
  29. package/dist/types/components/base/history-chart/history-chart.d.ts +2 -1
  30. package/dist/types/components/base/pool-apy-breakdown-card/pool-apy-breakdown-card.d.ts +4 -2
  31. package/dist/types/components/graph/default-config.d.ts +23 -0
  32. package/dist/types/components/graph/formatters.d.ts +5 -1
  33. package/dist/types/components/graph/graph.d.ts +12 -4
  34. package/dist/types/components/graph/y-axis-scale.d.ts +48 -0
  35. package/dist/types/components/trading-view/trading-view.d.ts +5 -1
  36. package/dist/types/components/yield-breakdown-tooltip/yield-breakdown-tooltip.d.ts +4 -2
  37. package/dist/types/locale/en.json.d.ts +14 -2
  38. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- const o = {
1
+ const e = {
2
2
  "errors.networkError": "Network error. Can't fetch data",
3
3
  "errors.incorrectAddressError": "Incorrect address. Please, check url",
4
4
  "errors.noOpenedAccountsError": "You have no opened Credit Accounts. Perhaps, you have recently been liquidated? Check notification centre to see more.",
@@ -70,9 +70,18 @@ const o = {
70
70
  "components.apyParts.points": "{symbol} Incentive",
71
71
  "components.apyParts.points.condition.crossDeposit": "For cross-chain deposits made via Omni",
72
72
  "components.yieldBreakdown.titleNetAtLeverage": "Net APY at {leverage}× Leverage",
73
+ "components.yieldBreakdown.titleNetAtLeverage7d": "Net APY at {leverage}× Leverage (7d)",
74
+ "components.yieldBreakdown.titleNet": "Net APY",
75
+ "components.yieldBreakdown.titleNet7d": "Net APY (7d)",
73
76
  "components.yieldBreakdown.collateralApy": "Collateral APY",
77
+ "components.yieldBreakdown.collateralApy7d": "Collateral APY (7d)",
78
+ "components.yieldBreakdown.baseApy": "Base APY",
79
+ "components.yieldBreakdown.baseApy7d": "Base APY (7d)",
74
80
  "components.yieldBreakdown.incentive": "Incentive",
81
+ "components.yieldBreakdown.incentiveApy": "Incentive APY",
82
+ "components.yieldBreakdown.incentiveApy7d": "Incentive APY (7d)",
75
83
  "components.yieldBreakdown.borrowRate": "Borrow Rate",
84
+ "components.yieldBreakdown.borrowRate7d": "Borrow Rate (7d)",
76
85
  "components.yieldBreakdown.programPoints": "{name} Points",
77
86
  "components.yieldBreakdown.points": "Points",
78
87
  "components.openCopyButtons.copy": "Copy to clipboard",
@@ -172,9 +181,12 @@ const o = {
172
181
  "components.titleMeta.unknownCurator": "Curator",
173
182
  "components.moreAccordion.more": "More details",
174
183
  "components.moreAccordion.less": "Less details",
175
- "components.poolApyBreakdownCard.title": "APY Breakdown",
176
- "components.poolApyBreakdownCard.organicApy": "Pool organic APY",
184
+ "components.poolApyBreakdownCard.title": "Net APY",
185
+ "components.poolApyBreakdownCard.title7d": "Net APY (7d)",
186
+ "components.poolApyBreakdownCard.organicApy": "Base APY",
187
+ "components.poolApyBreakdownCard.organicApy7d": "Base APY (7d)",
177
188
  "components.poolApyBreakdownCard.incentiveApy": "Incentive APY",
189
+ "components.poolApyBreakdownCard.incentiveApy7d": "Incentive APY (7d)",
178
190
  "components.strategyApyBreakdownCard.formula": "{leverage} × {base}",
179
191
  "components.strategyApyBreakdownCard.borrowFormula": "{debtMultiplier} × {borrowBase} + {quotaMultiplier} × {quotaBase}",
180
192
  "components.leveragePresetChips.label": "Leverage:",
@@ -192,5 +204,5 @@ const o = {
192
204
  "components.transactionConfirm.previewErrorTitle": "Preview error"
193
205
  };
194
206
  export {
195
- o as default
207
+ e as default
196
208
  };
@@ -49,7 +49,8 @@ export interface HistoryChartProps {
49
49
  readonly trailing?: React.ReactNode;
50
50
  /**
51
51
  * Force a second Y-axis. When omitted, the chart splits axes only if
52
- * `yMeasureUnit` lists more than one distinct unit.
52
+ * `yMeasureUnit` lists more than one distinct unit. Same-unit series share
53
+ * one scale and show its labels.
53
54
  */
54
55
  readonly dualYAxis?: boolean;
55
56
  }
@@ -8,6 +8,8 @@ export interface PoolApyBreakdownCardProps {
8
8
  readonly organicApy?: Bps;
9
9
  readonly incentiveApy?: Bps;
10
10
  };
11
+ /** When `"7d"`, labels carry the averaging-window suffix. */
12
+ readonly period?: "7d";
11
13
  }
12
- /** Organic vs incentive APY next to the pool APY chart. Missing values render as dashes. */
13
- export declare function PoolApyBreakdownCard({ data, }: PoolApyBreakdownCardProps): React.ReactElement;
14
+ /** Organic vs incentive APY next to the pool APY chart. Missing organic renders as a dash; incentive is 0% when omitted. */
15
+ export declare function PoolApyBreakdownCard({ data, period, }: PoolApyBreakdownCardProps): React.ReactElement;
@@ -2,6 +2,29 @@ import { AreaSeriesPartialOptions, ChartOptions, DeepPartial } from 'lightweight
2
2
  import { VertLineOptions } from './plugins/vertical-line';
3
3
  export declare const DEFAULT_AREA_SERIES: AreaSeriesPartialOptions;
4
4
  export declare const DEFAULT_VERTICAL_LINE: Partial<VertLineOptions>;
5
+ /** Matches UI `text-sm` so axis tick labels read with the rest of the chrome. */
6
+ export declare const AXIS_FONT_SIZE = 14;
7
+ /**
8
+ * Price-scale tick density. Higher → more space between labels (fewer ticks).
9
+ * Lightweight-charts defaults to 2.5, which packs ~12 labels onto a 460px pane.
10
+ */
11
+ export declare const AXIS_TICK_MARK_DENSITY = 5;
12
+ /**
13
+ * Pixel inset so a tick sitting on the pane edge is drawn fully inside the
14
+ * canvas (half the font plus a couple of pixels of breathing room).
15
+ */
16
+ export declare const AXIS_EDGE_LABEL_PADDING_PX: number;
17
+ /**
18
+ * Extra air above the top tick so the label does not sit flush with the
19
+ * chart frame. Larger than the bottom inset because the top edge has no
20
+ * time-axis chrome to separate it from the container.
21
+ */
22
+ export declare const AXIS_TOP_LABEL_PADDING_PX: number;
23
+ /**
24
+ * Horizontal inset so a centred date label (`dd MMM`, ~50px) sits fully
25
+ * inside the time-scale canvas with a few pixels of air on each side.
26
+ */
27
+ export declare const AXIS_TIME_EDGE_PADDING_PX = 40;
5
28
  /**
6
29
  * Gets the default chart options with resolved CSS colors
7
30
  * Call this at runtime to ensure CSS variables are properly resolved
@@ -27,6 +27,11 @@ export interface AdaptiveYAxisFormatterOptions {
27
27
  * stay bare so charts without a real unit don't render a placeholder.
28
28
  */
29
29
  export declare function withYAxisUnit(label: string, unit: YMeasureUnits): string;
30
+ /**
31
+ * Ratio units (`base / quote`) stay off axis ticks, the crosshair pill, and
32
+ * tooltip values — the pair belongs in the series title, not after the number.
33
+ */
34
+ export declare function isRatioUnit(unit: YMeasureUnits): boolean;
30
35
  /**
31
36
  * Creates an adaptive Y-axis formatter that determines precision dynamically
32
37
  * based on visible range to ensure unique labels on the axis.
@@ -37,7 +42,6 @@ export declare function createAdaptiveYAxisFormatter(initialValues: number[], un
37
42
  formatter: (price: number) => string;
38
43
  tickmarksFormatter: (prices: number[]) => string[];
39
44
  updateVisibleRange: (visibleValues: number[]) => void;
40
- updateLastValues: (lastValues: number[]) => void;
41
45
  };
42
46
  export type XMeasureUnits = "time" | "%";
43
47
  type XFormatter = (time: Time, symbol: XMeasureUnits | undefined) => string;
@@ -6,6 +6,12 @@ export type SeriesPriceScaleId = "left" | "right";
6
6
  export type SeriesChartType = "area" | "line";
7
7
  export interface SeriesConfig {
8
8
  data: Array<Point>;
9
+ /**
10
+ * Stable chart-instance key. Prefer this over `label` so renaming the legend
11
+ * (e.g. interpolating leverage into the title) updates the existing series
12
+ * instead of destroying it — which shuffles `seriesRefs` and breaks tooltips.
13
+ */
14
+ id?: string;
9
15
  label: string;
10
16
  /** Line color (area stroke). Alias: prefer `lineColor` for clarity; if both set, `lineColor` wins. */
11
17
  color?: string;
@@ -23,6 +29,8 @@ export interface SeriesConfig {
23
29
  /** Line dash style (line series only). */
24
30
  lineStyle?: LineStyle;
25
31
  }
32
+ /** Chart-instance key: stable `id` when set, otherwise the display `label`. */
33
+ export declare function seriesIdentity(series: Pick<SeriesConfig, "id" | "label">): string;
26
34
  export type VerticalLineOptions = Partial<{
27
35
  color: string;
28
36
  labelText: string;
@@ -51,8 +59,8 @@ export interface PriceLineConfig {
51
59
  /** Y value (price) where the horizontal line is drawn. */
52
60
  price: number;
53
61
  /**
54
- * Label of the series to attach the line to. When omitted, the line is
55
- * attached to the first series that has data (its price scale is used).
62
+ * `id` (preferred) or display `label` of the series to attach the line to.
63
+ * When omitted, the line is attached to the first series that has data.
56
64
  */
57
65
  seriesLabel?: string;
58
66
  /** Line color. Defaults to the destructive theme color. */
@@ -80,8 +88,8 @@ export interface PriceZoneConfig {
80
88
  /** Fill color — use a translucent value. Defaults to a translucent destructive tint. */
81
89
  color?: string;
82
90
  /**
83
- * Label of the series whose price scale the band is drawn against. When
84
- * omitted, the first series with data is used.
91
+ * `id` (preferred) or display `label` of the series whose price scale the
92
+ * band is drawn against. When omitted, the first series with data is used.
85
93
  */
86
94
  seriesLabel?: string;
87
95
  }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Nice Y-axis range: a tick step from the same 1 / 2 / 2.5 / 5 × 10^n family
3
+ * that lightweight-charts uses, with min/max snapped onto that grid so the
4
+ * first and last labels sit on the pane edges.
5
+ */
6
+ export interface PickTickSpanArgs {
7
+ min: number;
8
+ max: number;
9
+ scaleHeightPx: number;
10
+ fontSizePx: number;
11
+ tickMarkDensity: number;
12
+ minMove: number;
13
+ }
14
+ export interface NiceAxisRangeArgs {
15
+ min: number;
16
+ max: number;
17
+ /** Hard floor (e.g. `yScaleMin`, or 0 when the series never goes negative). */
18
+ floor?: number;
19
+ scaleHeightPx: number;
20
+ fontSizePx: number;
21
+ tickMarkDensity: number;
22
+ minMove?: number;
23
+ /** Pixel inset lightweight-charts will add via AutoscaleInfo.margins.below. */
24
+ edgePaddingPx?: number;
25
+ /** Pixel inset for AutoscaleInfo.margins.above. Defaults to `edgePaddingPx`. */
26
+ edgePaddingTopPx?: number;
27
+ }
28
+ export interface NiceAxisRange {
29
+ min: number;
30
+ max: number;
31
+ step: number;
32
+ }
33
+ /**
34
+ * Smallest price increment the scale should resolve. One thousandth of the
35
+ * data span, snapped down to a power of ten — coarse enough to stay stable,
36
+ * fine enough not to cap the tick step the way a hardcoded `0.01` does on
37
+ * narrow ratio charts.
38
+ */
39
+ export declare function pickMinMove(range: number): number;
40
+ /**
41
+ * Tick step lightweight-charts would pick for this visible range.
42
+ */
43
+ export declare function pickTickSpan({ min, max, scaleHeightPx, fontSizePx, tickMarkDensity, minMove, }: PickTickSpanArgs): number;
44
+ /**
45
+ * Expand `[min, max]` onto the tick grid so both edges are labelled, matching
46
+ * the step the library will use once pixel edge-padding is applied.
47
+ */
48
+ export declare function niceAxisRange({ min: rawMin, max: rawMax, floor, scaleHeightPx, fontSizePx, tickMarkDensity, minMove: minMoveArg, edgePaddingPx, edgePaddingTopPx, }: NiceAxisRangeArgs): NiceAxisRange;
@@ -15,7 +15,11 @@ export interface GraphDataPoint {
15
15
  * Graph data structure with title and data points
16
16
  */
17
17
  export interface GraphData {
18
- /** Stable identifier used for color mapping. Should match `GraphDropdownItem.value`. */
18
+ /**
19
+ * Stable identifier used for color mapping and as the chart series key.
20
+ * Should match `GraphDropdownItem.value`. Keep this fixed when only `title`
21
+ * changes, otherwise the series is recreated and hover tooltips break.
22
+ */
19
23
  id?: string;
20
24
  title?: string;
21
25
  data: GraphDataPoint[];
@@ -20,11 +20,13 @@ export interface YieldBreakdownTooltipProps {
20
20
  borrowApy?: Bps;
21
21
  /** Strategy quota rate in bps, at 1x (folded into Borrow Rate). */
22
22
  quotaRate?: Bps;
23
+ /** When `"7d"`, labels carry the averaging-window suffix. */
24
+ period?: "7d";
23
25
  children?: React.ReactNode;
24
26
  className?: string;
25
27
  }
26
28
  /**
27
29
  * Earn APY tooltip — strategy (`Net APY at Nx Leverage`) and pool
28
- * (`Overall APY`) layouts from SDK `ApyBreakdown`.
30
+ * (`Net APY`) layouts from SDK `ApyBreakdown`.
29
31
  */
30
- export declare function YieldBreakdownTooltip({ supplyApy, maxLeverage, collateralApy, borrowApy, quotaRate, children, className, }: YieldBreakdownTooltipProps): import("react/jsx-runtime").JSX.Element;
32
+ export declare function YieldBreakdownTooltip({ supplyApy, maxLeverage, collateralApy, borrowApy, quotaRate, period, children, className, }: YieldBreakdownTooltipProps): import("react/jsx-runtime").JSX.Element;
@@ -87,9 +87,18 @@ declare const _default: {
87
87
  "components.apyParts.points.condition.crossDeposit": "For cross-chain deposits made via Omni",
88
88
 
89
89
  "components.yieldBreakdown.titleNetAtLeverage": "Net APY at {leverage}× Leverage",
90
+ "components.yieldBreakdown.titleNetAtLeverage7d": "Net APY at {leverage}× Leverage (7d)",
91
+ "components.yieldBreakdown.titleNet": "Net APY",
92
+ "components.yieldBreakdown.titleNet7d": "Net APY (7d)",
90
93
  "components.yieldBreakdown.collateralApy": "Collateral APY",
94
+ "components.yieldBreakdown.collateralApy7d": "Collateral APY (7d)",
95
+ "components.yieldBreakdown.baseApy": "Base APY",
96
+ "components.yieldBreakdown.baseApy7d": "Base APY (7d)",
91
97
  "components.yieldBreakdown.incentive": "Incentive",
98
+ "components.yieldBreakdown.incentiveApy": "Incentive APY",
99
+ "components.yieldBreakdown.incentiveApy7d": "Incentive APY (7d)",
92
100
  "components.yieldBreakdown.borrowRate": "Borrow Rate",
101
+ "components.yieldBreakdown.borrowRate7d": "Borrow Rate (7d)",
93
102
  "components.yieldBreakdown.programPoints": "{name} Points",
94
103
  "components.yieldBreakdown.points": "Points",
95
104
 
@@ -212,9 +221,12 @@ declare const _default: {
212
221
  "components.moreAccordion.more": "More details",
213
222
  "components.moreAccordion.less": "Less details",
214
223
 
215
- "components.poolApyBreakdownCard.title": "APY Breakdown",
216
- "components.poolApyBreakdownCard.organicApy": "Pool organic APY",
224
+ "components.poolApyBreakdownCard.title": "Net APY",
225
+ "components.poolApyBreakdownCard.title7d": "Net APY (7d)",
226
+ "components.poolApyBreakdownCard.organicApy": "Base APY",
227
+ "components.poolApyBreakdownCard.organicApy7d": "Base APY (7d)",
217
228
  "components.poolApyBreakdownCard.incentiveApy": "Incentive APY",
229
+ "components.poolApyBreakdownCard.incentiveApy7d": "Incentive APY (7d)",
218
230
  "components.strategyApyBreakdownCard.formula": "{leverage} × {base}",
219
231
  "components.strategyApyBreakdownCard.borrowFormula": "{debtMultiplier} × {borrowBase} + {quotaMultiplier} × {quotaBase}",
220
232
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/ui-kit",
3
- "version": "4.0.0-next.23",
3
+ "version": "4.0.0-next.24",
4
4
  "description": "Internal UI components",
5
5
  "repository": {
6
6
  "type": "git",
@@ -55,8 +55,8 @@
55
55
  "build-storybook": "storybook build"
56
56
  },
57
57
  "dependencies": {
58
- "@fortawesome/fontawesome-svg-core": "^7.1.0",
59
- "@fortawesome/free-solid-svg-icons": "^7.1.0",
58
+ "@fortawesome/fontawesome-svg-core": "^7.3.1",
59
+ "@fortawesome/free-solid-svg-icons": "^7.3.1",
60
60
  "@fortawesome/react-fontawesome": "^3.1.1",
61
61
  "@gearbox-protocol/static": "^1.117.2",
62
62
  "@radix-ui/react-accordion": "^1.2.2",