@gearbox-protocol/ui-kit 4.0.0-next.20 → 4.0.0-next.22

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 (36) hide show
  1. package/dist/cjs/components/base/position-assets/position-assets.cjs +1 -1
  2. package/dist/cjs/components/base/strategy-apy-breakdown-card/constants.cjs +1 -1
  3. package/dist/cjs/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.cjs +1 -1
  4. package/dist/cjs/components/base/values/scalars.cjs +1 -1
  5. package/dist/cjs/components/composites/pool-assets-table/pool-assets-table-row.cjs +1 -1
  6. package/dist/cjs/components/composites/pool-assets-table/pool-assets-table.cjs +1 -1
  7. package/dist/cjs/components/compound-apy/compound-apy.cjs +1 -1
  8. package/dist/cjs/components/yield-breakdown-tooltip/yield-breakdown-tooltip.cjs +1 -1
  9. package/dist/cjs/index.cjs +1 -1
  10. package/dist/cjs/locale/en.json.cjs +1 -1
  11. package/dist/cjs/utils/index.cjs +1 -1
  12. package/dist/esm/components/base/position-assets/position-assets.js +62 -39
  13. package/dist/esm/components/base/strategy-apy-breakdown-card/constants.js +7 -3
  14. package/dist/esm/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.js +140 -166
  15. package/dist/esm/components/base/values/scalars.js +40 -35
  16. package/dist/esm/components/composites/pool-assets-table/pool-assets-table-row.js +60 -61
  17. package/dist/esm/components/composites/pool-assets-table/pool-assets-table.js +22 -24
  18. package/dist/esm/components/compound-apy/compound-apy.js +24 -23
  19. package/dist/esm/components/yield-breakdown-tooltip/yield-breakdown-tooltip.js +15 -15
  20. package/dist/esm/index.js +88 -91
  21. package/dist/esm/locale/en.json.js +3 -7
  22. package/dist/esm/utils/index.js +48 -51
  23. package/dist/globals.css +1 -1
  24. package/dist/types/components/base/position-assets/position-assets.d.ts +19 -13
  25. package/dist/types/components/base/strategy-apy-breakdown-card/constants.d.ts +5 -1
  26. package/dist/types/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.d.ts +39 -14
  27. package/dist/types/components/base/values/scalars.d.ts +17 -2
  28. package/dist/types/components/composites/pool-assets-table/pool-assets-table-row.d.ts +1 -2
  29. package/dist/types/components/composites/pool-assets-table/pool-assets-table.d.ts +1 -2
  30. package/dist/types/components/compound-apy/compound-apy.d.ts +11 -1
  31. package/dist/types/locale/en.json.d.ts +1 -6
  32. package/dist/types/utils/index.d.ts +0 -1
  33. package/package.json +1 -1
  34. package/dist/cjs/utils/strategy-apy.cjs +0 -1
  35. package/dist/esm/utils/strategy-apy.js +0 -51
  36. package/dist/types/utils/strategy-apy.d.ts +0 -40
@@ -3,15 +3,13 @@ import { default as React } from 'react';
3
3
  import { PositionAssetsTest } from './constants';
4
4
  export { PositionAssetsTest };
5
5
  export interface PositionAssetsProps {
6
- /** What this side holds. */
6
+ /** What the position holds. */
7
7
  readonly assets?: readonly TokenAmount[];
8
8
  /**
9
- * The list this one is shown against the other slot of the same row.
10
- * Never rendered: it only joins the row set and the order, so two lists in
11
- * `value` and `valueTo` list the same tokens in the same order and their
12
- * rows line up. Pass each side the other one.
9
+ * What those holdings become. Given, every row reads `before after` and
10
+ * names its token once for the pair; omitted, the rows are plain holdings.
13
11
  */
14
- readonly against?: readonly TokenAmount[];
12
+ readonly to?: readonly TokenAmount[];
15
13
  /** Rendered in place of the rows when nothing survives the dust filter. */
16
14
  readonly empty?: React.ReactNode;
17
15
  readonly testId?: string;
@@ -19,7 +17,13 @@ export interface PositionAssetsProps {
19
17
  /**
20
18
  * Holdings token by token, most valuable first — the position itself rather
21
19
  * than the one number its collateral adds up to. A right-aligned column, so it
22
- * reads as the value of the `InfoLine` a caller drops it into, in either slot.
20
+ * reads as the value of the `InfoLine` a caller drops it into.
21
+ *
22
+ * The whole of a change belongs in the one slot: a row carries both amounts
23
+ * with the arrow between them, rather than the caller putting one list in
24
+ * `value` and another in `valueTo`. Two lists would name the same token twice
25
+ * and draw its icon twice, which is what pushes a long symbol out of a narrow
26
+ * dialog; they would also have to be kept in the same order by hand.
23
27
  *
24
28
  * The rows carry no label of their own, which is why they are not `InfoLine`s:
25
29
  * `VerticalIndicator` leaves out its left column entirely when no label is
@@ -30,12 +34,14 @@ export interface PositionAssetsProps {
30
34
  * rounding, and listing them buries the holdings that matter. A token the
31
35
  * oracle cannot price is never dust — an unknown value is not a small one.
32
36
  */
33
- export declare function PositionAssets({ assets, against, empty, testId, }: PositionAssetsProps): React.ReactElement;
34
- /** One token as a side lists it. */
37
+ export declare function PositionAssets({ assets, to, empty, testId, }: PositionAssetsProps): React.ReactElement;
38
+ /** One token across both sides of a change. */
35
39
  export interface AssetRow {
36
40
  readonly token: TokenAmount["token"];
37
- /** What this side holds — zero for a token only the other side has. */
41
+ /** What the position holds now — zero for a token only the other side has. */
38
42
  readonly value: bigint;
43
+ /** What it becomes — zero where the projection drops the token. */
44
+ readonly valueTo: bigint;
39
45
  /**
40
46
  * What the token is worth at its richer side, which is what decides both
41
47
  * dust and order. `null` when a side the oracle cannot price is involved.
@@ -43,7 +49,7 @@ export interface AssetRow {
43
49
  readonly worth: number | null;
44
50
  }
45
51
  /**
46
- * What earns a row, most valuable first — decided across both sides, so the
47
- * order is a property of the pair rather than of the side that renders it.
52
+ * What earns a row, most valuable first — decided across both sides, so a
53
+ * token either side holds is listed once, in one place.
48
54
  */
49
- export declare function visibleAssets(assets: readonly TokenAmount[] | undefined, against?: readonly TokenAmount[]): AssetRow[];
55
+ export declare function visibleAssets(assets: readonly TokenAmount[] | undefined, to?: readonly TokenAmount[]): AssetRow[];
@@ -1,5 +1,9 @@
1
1
  export declare class StrategyApyBreakdownCardTest {
2
2
  static root: string;
3
- static row: string;
4
3
  static net: string;
4
+ static collateral: string;
5
+ static borrow: string;
6
+ static value: string;
7
+ static points: string;
8
+ static caption: string;
5
9
  }
@@ -1,23 +1,48 @@
1
- import { ApyBreakdown, Leverage } from '@gearbox-protocol/sdk/model';
1
+ import { ApyBreakdown, Bps, Leverage } from '@gearbox-protocol/sdk/model';
2
2
  import { default as React } from 'react';
3
- import { StrategyApyRates } from '../../../utils/strategy-apy';
4
3
  import { StrategyApyBreakdownCardTest } from './constants';
5
4
  export { StrategyApyBreakdownCardTest };
6
- export interface StrategyApyBreakdownData extends StrategyApyRates {
7
- readonly collateralApy?: ApyBreakdown;
8
- /** Leverage the card falls back to when the toolbar names none. */
9
- readonly maxLeverage?: Leverage;
5
+ export interface StrategyApyBreakdownData {
6
+ /** Leverage every figure below is quoted at. */
7
+ readonly leverage: Leverage;
8
+ /**
9
+ * **N** — the strategy's net rate on the user's equity, as
10
+ * `calcNetStrategyApy` returns it. Passed in rather than reconstructed:
11
+ * this is the same figure the badge and the list cell print, and it stays
12
+ * the same figure by being handed over, not by two formulas agreeing.
13
+ */
14
+ readonly netApy: ApyBreakdown;
10
15
  /**
11
- * Net rate the caller already knows a position's own `netApy`. Preferred
12
- * over the rows' arithmetic, which answers for the strategy rather than for
13
- * one account inside it.
16
+ * **B** cost of the credit behind the position, quota folded in, as
17
+ * `calcEffectiveBorrowApy` returns it. Positive; the card negates it.
14
18
  */
15
- readonly netApy?: ApyBreakdown;
19
+ readonly borrowCost: Bps;
20
+ /** The collateral yield the net was computed from, for its incentive rows. */
21
+ readonly collateralApy?: ApyBreakdown;
16
22
  }
17
23
  export interface StrategyApyBreakdownCardProps {
18
24
  readonly data: StrategyApyBreakdownData;
19
- /** Selected leverage from the chart toolbar chips. Falls back to max. */
20
- readonly leverage?: Leverage;
25
+ /**
26
+ * Multiplier caption under each figure — `11.18 × 3.11%` and the like.
27
+ *
28
+ * On beside a chart, where the card is the derivation and there is room for
29
+ * it. Off in a tooltip, where it is a glance.
30
+ */
31
+ readonly showFormula?: boolean;
21
32
  }
22
- /** Net APY formula beside the strategy yield chart. Chart itself is unchanged. */
23
- export declare function StrategyApyBreakdownCard({ data, leverage: leverageProp, }: StrategyApyBreakdownCardProps): React.ReactElement;
33
+ /**
34
+ * How a strategy's net APY is arrived at: collateral yield on the leveraged
35
+ * position, less what the credit behind it costs.
36
+ *
37
+ * The card computes no rate of its own. **N** (`netApy`) and **B**
38
+ * (`borrowCost`) arrive already calculated, and the collateral row is their
39
+ * sum — which is exactly `round(leverage × collateralApy)`, because the SDK
40
+ * subtracts an integer `B` inside its own rounding. Deriving the third value
41
+ * instead of recomputing it is what makes `N = C − B` hold to the basis point
42
+ * rather than approximately.
43
+ *
44
+ * Incentive rows are levered individually and the collateral row takes the
45
+ * remainder, so the column adds up to the chip even when each reward rounds
46
+ * its own way.
47
+ */
48
+ export declare function StrategyApyBreakdownCard({ data, showFormula, }: StrategyApyBreakdownCardProps): React.ReactElement;
@@ -12,13 +12,23 @@ export declare function bps(value: Bps): string;
12
12
  export interface ApyValueProps {
13
13
  /** A breakdown (tooltip-able) or a bare rate; `undefined` renders a dash. */
14
14
  readonly data: ApyBreakdown | Bps | undefined;
15
+ /**
16
+ * Whether a breakdown carries its yield tooltip on hover. Off where the
17
+ * figure is already explained — a badge that states one rate, or a figure
18
+ * wrapped in a tooltip of its own, which would otherwise stack two.
19
+ *
20
+ * A bare `Bps` has no tooltip to begin with, so this does not reach it.
21
+ *
22
+ * @default true
23
+ */
24
+ readonly tooltip?: boolean;
15
25
  }
16
26
  /**
17
27
  * Any APY the model carries, in one place: `supplyApy`, `netApy`, `borrowApy`.
18
28
  * A breakdown renders the reference chip (reward icons + breakdown tooltip)
19
29
  * via `CompoundAPY`; a bare `Bps` stays a plain percentage.
20
30
  */
21
- export declare function ApyValue({ data }: ApyValueProps): React.ReactElement;
31
+ export declare function ApyValue({ data, tooltip, }: ApyValueProps): React.ReactElement;
22
32
  export declare function UsdValue({ data, }: {
23
33
  readonly data: number | null | undefined;
24
34
  }): React.ReactElement;
@@ -41,7 +51,12 @@ export declare function HealthFactorValue({ data, }: {
41
51
  * tooltip — a metrics row reads better short, and nothing is lost: the figure
42
52
  * behind the rounding stays a hover away.
43
53
  */
44
- export declare function TokenBigint({ data, token, }: {
54
+ export declare function TokenBigint({ data, token, showSymbol, }: {
45
55
  readonly data: bigint | undefined;
46
56
  readonly token: Token | undefined;
57
+ /**
58
+ * Off where the row names the token itself — a `before → after` pair prints
59
+ * the symbol once for both amounts rather than twice.
60
+ */
61
+ readonly showSymbol?: boolean;
47
62
  }): React.ReactElement;
@@ -1,7 +1,6 @@
1
1
  import { QuotaAsset, Token } from '@gearbox-protocol/sdk/model';
2
2
  import { default as React } from 'react';
3
3
  export interface PoolAssetsTableRowProps {
4
- readonly poolName: string;
5
4
  readonly asset: QuotaAsset;
6
5
  readonly underlyingToken: Token;
7
6
  readonly last: boolean;
@@ -12,4 +11,4 @@ export interface PoolAssetsTableRowProps {
12
11
  /**
13
12
  * Single data row: token name, exposure (amount + pie), cap, and cap utilization.
14
13
  */
15
- export declare function PoolAssetsTableRow({ poolName, asset, underlyingToken, last, isCompact, totalUsed, colorIndex, }: PoolAssetsTableRowProps): React.ReactElement;
14
+ export declare function PoolAssetsTableRow({ asset, underlyingToken, last, isCompact, totalUsed, colorIndex, }: PoolAssetsTableRowProps): React.ReactElement;
@@ -3,7 +3,6 @@ import { default as React } from 'react';
3
3
  import { PoolAssetsTableSort } from './types';
4
4
  export interface PoolAssetsTableProps {
5
5
  readonly list: ReadonlyArray<QuotaAsset>;
6
- readonly poolName: string;
7
6
  readonly sort: PoolAssetsTableSort;
8
7
  readonly underlyingToken: Token;
9
8
  }
@@ -11,4 +10,4 @@ export interface PoolAssetsTableProps {
11
10
  * Grid table of pool asset quotas: exposure, cap, and cap utilization.
12
11
  * Collapses into stacked cards below {@link COMPACT_WIDTH_THRESHOLD}.
13
12
  */
14
- export declare function PoolAssetsTable({ list, poolName, sort, underlyingToken, }: PoolAssetsTableProps): React.ReactElement | null;
13
+ export declare function PoolAssetsTable({ list, sort, underlyingToken, }: PoolAssetsTableProps): React.ReactElement | null;
@@ -23,6 +23,16 @@ export interface CompoundAPYProps {
23
23
  * @default 2
24
24
  */
25
25
  decimals?: number;
26
+ /**
27
+ * Whether the figure carries the yield breakdown on hover.
28
+ *
29
+ * Off where the number is already explained — a badge that states one rate
30
+ * and stops, or a figure something else already wraps in a tooltip of its
31
+ * own. The incentives icon stays either way; only the hover goes.
32
+ *
33
+ * @default true
34
+ */
35
+ tooltip?: boolean;
26
36
  className?: string;
27
37
  }
28
38
  /**
@@ -31,4 +41,4 @@ export interface CompoundAPYProps {
31
41
  * No `tokensList`, no external APY, no 7D history, no "soon" points state.
32
42
  * For the legacy percent-based API see {@link CompoundAPYLegacy}.
33
43
  */
34
- export declare function CompoundAPY({ apy, maxLeverage, collateralApy, borrowApy, quotaRate, decimals, className, }: CompoundAPYProps): import("react/jsx-runtime").JSX.Element;
44
+ export declare function CompoundAPY({ apy, maxLeverage, collateralApy, borrowApy, quotaRate, decimals, tooltip, className, }: CompoundAPYProps): import("react/jsx-runtime").JSX.Element;
@@ -215,13 +215,8 @@ declare const _default: {
215
215
  "components.poolApyBreakdownCard.title": "APY Breakdown",
216
216
  "components.poolApyBreakdownCard.organicApy": "Pool organic APY",
217
217
  "components.poolApyBreakdownCard.incentiveApy": "Incentive APY",
218
-
219
- "components.strategyApyBreakdownCard.titleAtLeverage": "APY at {leverage}× Leverage",
220
- "components.strategyApyBreakdownCard.collateralApy": "Collateral APY",
221
- "components.strategyApyBreakdownCard.incentiveApy": "Incentive APY",
222
- "components.strategyApyBreakdownCard.borrowRate": "Borrow Rate",
223
- "components.strategyApyBreakdownCard.quotaRate": "Quota Rate",
224
218
  "components.strategyApyBreakdownCard.formula": "{leverage} × {base}",
219
+ "components.strategyApyBreakdownCard.borrowFormula": "{debtMultiplier} × {borrowBase} + {quotaMultiplier} × {quotaBase}",
225
220
 
226
221
  "components.leveragePresetChips.label": "Leverage:",
227
222
 
@@ -27,7 +27,6 @@ export * from './search-in-token';
27
27
  export * from './short-sha';
28
28
  export * from './shorten-string';
29
29
  export type { SortField as UtilsSortField, SortType } from './sort';
30
- export * from './strategy-apy';
31
30
  export * from './templates';
32
31
  export * from './token-icon-source';
33
32
  export * from './ttl';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/ui-kit",
3
- "version": "4.0.0-next.20",
3
+ "version": "4.0.0-next.22",
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"});const u=require("@gearbox-protocol/sdk");function o(t,r,e){switch(e){case"min":return Math.max(t-1,0);case"aggressive":return 1.05*Math.max(t-1,0);default:return t*r/1e4}}function y({leverage:t,borrowApy:r=0,quotaRate:e=0,liquidationThreshold:s=0,quotaMode:a="safe"}){const c={borrowApy:r,quotaRate:e,liquidationThreshold:s},n=Math.max(t-1,0),i=o(t,s,a);return{debtMultiplier:n,quotaMultiplier:i,borrowCost:r*n,quotaRate:e,quotaCost:e*i,totalCost:u.calcEffectiveBorrowApy(c,t,a)}}function p({collateralApy:t,leverage:r,borrowApy:e=0,quotaRate:s=0,liquidationThreshold:a=0,quotaMode:c="safe"}){return u.calcNetStrategyApy({borrowApy:e,quotaRate:s,liquidationThreshold:a},t,r,c)}exports.strategyApyPartsAtLeverage=y;exports.strategyNetApyAtLeverage=p;
@@ -1,51 +0,0 @@
1
- import { calcEffectiveBorrowApy as o, calcNetStrategyApy as u } from "@gearbox-protocol/sdk";
2
- function f(t, e, r) {
3
- switch (r) {
4
- case "min":
5
- return Math.max(t - 1, 0);
6
- case "aggressive":
7
- return 1.05 * Math.max(t - 1, 0);
8
- default:
9
- return t * e / 1e4;
10
- }
11
- }
12
- function m({
13
- leverage: t,
14
- borrowApy: e = 0,
15
- quotaRate: r = 0,
16
- liquidationThreshold: s = 0,
17
- quotaMode: a = "safe"
18
- }) {
19
- const c = {
20
- borrowApy: e,
21
- quotaRate: r,
22
- liquidationThreshold: s
23
- }, n = Math.max(t - 1, 0), i = f(t, s, a);
24
- return {
25
- debtMultiplier: n,
26
- quotaMultiplier: i,
27
- borrowCost: e * n,
28
- quotaRate: r,
29
- quotaCost: r * i,
30
- totalCost: o(c, t, a)
31
- };
32
- }
33
- function l({
34
- collateralApy: t,
35
- leverage: e,
36
- borrowApy: r = 0,
37
- quotaRate: s = 0,
38
- liquidationThreshold: a = 0,
39
- quotaMode: c = "safe"
40
- }) {
41
- return u(
42
- { borrowApy: r, quotaRate: s, liquidationThreshold: a },
43
- t,
44
- e,
45
- c
46
- );
47
- }
48
- export {
49
- m as strategyApyPartsAtLeverage,
50
- l as strategyNetApyAtLeverage
51
- };
@@ -1,40 +0,0 @@
1
- import { QuotaMode, StrategyRateInputs } from '@gearbox-protocol/sdk';
2
- import { Bps, Leverage } from '@gearbox-protocol/sdk/model';
3
- /**
4
- * The rates a strategy's cost of credit is made of — the SDK's own
5
- * `StrategyRateInputs`, spelled the same way so a caller hands over the fields
6
- * of a `StrategyOpportunity` rather than a translation of them.
7
- *
8
- * Optional only because a card may be rendered before its strategy has loaded;
9
- * the SDK requires all three, and so does the arithmetic.
10
- */
11
- export type StrategyApyRates = Readonly<Partial<StrategyRateInputs>> & {
12
- /** How much quota the position quotes; the SDK's `"safe"` unless told. */
13
- readonly quotaMode?: QuotaMode;
14
- };
15
- /**
16
- * Borrow and quota cost of a strategy at one leverage, split so each can have
17
- * its own row.
18
- *
19
- * `totalCost` comes from `calcEffectiveBorrowApy` rather than from adding the
20
- * two parts up here: the SDK rounds once, at the end, and a card whose rows
21
- * sum to something other than its own total is the bug this replaced.
22
- */
23
- export declare function strategyApyPartsAtLeverage({ leverage, borrowApy, quotaRate, liquidationThreshold, quotaMode, }: StrategyApyRates & {
24
- readonly leverage: Leverage;
25
- }): {
26
- readonly debtMultiplier: number;
27
- readonly quotaMultiplier: number;
28
- readonly borrowCost: Bps;
29
- readonly quotaRate: Bps;
30
- readonly quotaCost: Bps;
31
- readonly totalCost: Bps;
32
- };
33
- /**
34
- * Net strategy APY at one leverage, straight from the SDK — the same call the
35
- * app makes for the badge beside this card, so the two cannot disagree.
36
- */
37
- export declare function strategyNetApyAtLeverage({ collateralApy, leverage, borrowApy, quotaRate, liquidationThreshold, quotaMode, }: StrategyApyRates & {
38
- readonly collateralApy: Bps;
39
- readonly leverage: Leverage;
40
- }): Bps;