@gearbox-protocol/ui-kit 4.0.0-next.15 → 4.0.0-next.16
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/base/stat-badge/constants.cjs +1 -1
- package/dist/cjs/components/base/stat-badge/stat-badge.cjs +1 -1
- package/dist/cjs/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.cjs +1 -1
- package/dist/cjs/components/base/tabber/tabber.cjs +1 -1
- package/dist/cjs/components/yield-breakdown-tooltip/yield-breakdown-tooltip.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/locale/en.json.cjs +1 -1
- package/dist/cjs/utils/index.cjs +1 -1
- package/dist/cjs/utils/strategy-apy.cjs +1 -0
- package/dist/esm/components/base/stat-badge/constants.js +1 -0
- package/dist/esm/components/base/stat-badge/stat-badge.js +87 -52
- package/dist/esm/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.js +130 -110
- package/dist/esm/components/base/tabber/tabber.js +67 -64
- package/dist/esm/components/yield-breakdown-tooltip/yield-breakdown-tooltip.js +20 -19
- package/dist/esm/index.js +234 -230
- package/dist/esm/locale/en.json.js +2 -1
- package/dist/esm/utils/index.js +64 -60
- package/dist/esm/utils/strategy-apy.js +41 -0
- package/dist/types/components/base/stat-badge/constants.d.ts +1 -0
- package/dist/types/components/base/stat-badge/stat-badge.d.ts +11 -1
- package/dist/types/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.d.ts +12 -0
- package/dist/types/components/base/tabber/tabber.d.ts +2 -2
- package/dist/types/locale/en.json.d.ts +2 -1
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/strategy-apy.d.ts +37 -0
- package/package.json +1 -1
|
@@ -179,7 +179,8 @@ const e = {
|
|
|
179
179
|
"components.strategyApyBreakdownCard.collateralApy": "Collateral APY",
|
|
180
180
|
"components.strategyApyBreakdownCard.incentiveApy": "Incentive APY",
|
|
181
181
|
"components.strategyApyBreakdownCard.borrowRate": "Borrow Rate",
|
|
182
|
-
"components.strategyApyBreakdownCard.
|
|
182
|
+
"components.strategyApyBreakdownCard.quotaRate": "Quota Rate",
|
|
183
|
+
"components.strategyApyBreakdownCard.formula": "{leverage} × {base}",
|
|
183
184
|
"components.leveragePresetChips.label": "Leverage:",
|
|
184
185
|
"components.liquidationParamsTable.lt": "Liquidation threshold",
|
|
185
186
|
"components.liquidationParamsTable.penalty": "Liquidation discount",
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -1,113 +1,117 @@
|
|
|
1
1
|
import { generateId as r, useFormFieldIds as t } from "./a11y.js";
|
|
2
|
-
import { pointProgramsOf as m, positiveTokenRewardsOf as n, tokenRewardsOf as
|
|
3
|
-
import { bnToInputView as
|
|
2
|
+
import { pointProgramsOf as m, positiveTokenRewardsOf as n, tokenRewardsOf as p, totalApyOf as i } from "./apy-breakdown.js";
|
|
3
|
+
import { bnToInputView as s } from "./bn-to-input-view.js";
|
|
4
4
|
import { bnToPrettyView as x } from "./bn-to-pretty-view.js";
|
|
5
|
-
import { bpsToPercent as
|
|
5
|
+
import { bpsToPercent as g } from "./bps.js";
|
|
6
6
|
import { cn as S, cn as d } from "./cn.js";
|
|
7
|
-
import { generateColorsFromBase as h, getCSSVariable as
|
|
7
|
+
import { generateColorsFromBase as h, getCSSVariable as A, hexToRgba as v, hslToHex as y, resolveCSSColor as P } from "./colors.js";
|
|
8
8
|
import { copyToClipboard as N } from "./copy.js";
|
|
9
|
-
import { convertPercent as
|
|
9
|
+
import { convertPercent as I, formatBytecodeSize as k, formatBytecodeVersion as C, formatTimestamp as w, shortenHash as F, significantTrunc as D } from "./format.js";
|
|
10
10
|
import { formatAssetAmount as V } from "./format-asset-amount.js";
|
|
11
|
-
import { formatLeverage as
|
|
11
|
+
import { formatLeverage as B } from "./format-leverage.js";
|
|
12
12
|
import { formatCompactPercent as _, formatMoney as E, formatMoneyAmount as H, formatPercentAmount as W, percentTemplate as Z, percentageTemplate as z } from "./format-money.js";
|
|
13
|
-
import { FORMAT_CONSTANTS as X, formatNumberWithSuffix as q, formatPrice as
|
|
13
|
+
import { FORMAT_CONSTANTS as X, formatNumberWithSuffix as q, formatPrice as Q, getAdaptiveDecimals as j, isBelowDisplayThreshold as G, isEffectivelyZero as J, toSignificantDigits as K } from "./format-number.js";
|
|
14
14
|
import { slippageTemplate as $ } from "./format-slippage.js";
|
|
15
15
|
import { formatChipLeverage as oe, leveragePresets as re } from "./leverage-presets.js";
|
|
16
16
|
import { allLoaded as ae, loadingProgress as me, round5 as ne } from "./loading.js";
|
|
17
|
-
import { decimalsToStep as
|
|
18
|
-
import { getNetworkIcon as
|
|
19
|
-
import { bnToLiquidationPriceView as de, isPositiveFloat as ue, parseInputToBN as he, parseSmallNumber as
|
|
20
|
-
import { pluralize as
|
|
17
|
+
import { decimalsToStep as ie, findClosestPoint as fe, formatWithDecimals as se, formatWithoutDecimals as le, splitInterval as xe, validateMinMax as Te } from "./math.js";
|
|
18
|
+
import { getNetworkIcon as ce } from "./network-icons.js";
|
|
19
|
+
import { bnToLiquidationPriceView as de, isPositiveFloat as ue, parseInputToBN as he, parseSmallNumber as Ae } from "./parse-input-to-bn.js";
|
|
20
|
+
import { pluralize as ye, selectPluralString as Pe } from "./plural.js";
|
|
21
21
|
import { getAvailableRanges as Ne } from "./ranges.js";
|
|
22
|
-
import { extractTextFromLabel as
|
|
22
|
+
import { extractTextFromLabel as Ie, serializeValue as ke } from "./react.js";
|
|
23
23
|
import { searchInString as we } from "./search.js";
|
|
24
24
|
import { createTokenSearchFilter as De, searchInToken as Oe } from "./search-in-token.js";
|
|
25
|
-
import { shortSHA as
|
|
26
|
-
import { isLongString as
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
25
|
+
import { shortSHA as Re } from "./short-sha.js";
|
|
26
|
+
import { isLongString as Me, shortenString as _e } from "./shorten-string.js";
|
|
27
|
+
import { strategyApyPartsAtLeverage as He, strategyNetApyAtLeverage as We, strategyQuotaRate as Ze } from "./strategy-apy.js";
|
|
28
|
+
import { negativeTokenTemplate as Ue, tokenTemplate as Xe, tokenTemplateNumber as qe, tokenTemplateString as Qe } from "./templates.js";
|
|
29
|
+
import { getTokenIcon as Ge, parseShareTokenUnderlying as Je } from "./token-icon-source.js";
|
|
30
|
+
import { TTL_CONSTANTS as Ye, getTTLZones as $e, ttlFromTimestamp as eo, ttlLeft as oo, ttlLeftHuman as ro } from "./ttl.js";
|
|
31
|
+
import { openInNewWindow as ao } from "./window.js";
|
|
32
|
+
import { Z_INDEX as no, Z_INDEX_VALUES as po } from "./z-index.js";
|
|
32
33
|
export {
|
|
33
34
|
X as FORMAT_CONSTANTS,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
Ye as TTL_CONSTANTS,
|
|
36
|
+
no as Z_INDEX,
|
|
37
|
+
po as Z_INDEX_VALUES,
|
|
37
38
|
ae as allLoaded,
|
|
38
|
-
|
|
39
|
+
s as bnToInputView,
|
|
39
40
|
de as bnToLiquidationPriceView,
|
|
40
41
|
x as bnToPrettyView,
|
|
41
|
-
|
|
42
|
+
g as bpsToPercent,
|
|
42
43
|
S as cn,
|
|
43
|
-
|
|
44
|
+
I as convertPercent,
|
|
44
45
|
N as copyToClipboard,
|
|
45
46
|
De as createTokenSearchFilter,
|
|
46
|
-
|
|
47
|
+
ie as decimalsToStep,
|
|
47
48
|
d as default,
|
|
48
|
-
|
|
49
|
+
Ie as extractTextFromLabel,
|
|
49
50
|
fe as findClosestPoint,
|
|
50
51
|
V as formatAssetAmount,
|
|
51
|
-
|
|
52
|
+
k as formatBytecodeSize,
|
|
52
53
|
C as formatBytecodeVersion,
|
|
53
54
|
oe as formatChipLeverage,
|
|
54
55
|
_ as formatCompactPercent,
|
|
55
|
-
|
|
56
|
+
B as formatLeverage,
|
|
56
57
|
E as formatMoney,
|
|
57
58
|
H as formatMoneyAmount,
|
|
58
59
|
q as formatNumberWithSuffix,
|
|
59
60
|
W as formatPercentAmount,
|
|
60
|
-
|
|
61
|
+
Q as formatPrice,
|
|
61
62
|
w as formatTimestamp,
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
se as formatWithDecimals,
|
|
64
|
+
le as formatWithoutDecimals,
|
|
64
65
|
h as generateColorsFromBase,
|
|
65
66
|
r as generateId,
|
|
66
|
-
|
|
67
|
+
j as getAdaptiveDecimals,
|
|
67
68
|
Ne as getAvailableRanges,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
A as getCSSVariable,
|
|
70
|
+
ce as getNetworkIcon,
|
|
71
|
+
$e as getTTLZones,
|
|
72
|
+
Ge as getTokenIcon,
|
|
73
|
+
v as hexToRgba,
|
|
74
|
+
y as hslToHex,
|
|
75
|
+
G as isBelowDisplayThreshold,
|
|
76
|
+
J as isEffectivelyZero,
|
|
77
|
+
Me as isLongString,
|
|
77
78
|
ue as isPositiveFloat,
|
|
78
79
|
re as leveragePresets,
|
|
79
80
|
me as loadingProgress,
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
Ue as negativeTokenTemplate,
|
|
82
|
+
ao as openInNewWindow,
|
|
82
83
|
he as parseInputToBN,
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
Je as parseShareTokenUnderlying,
|
|
85
|
+
Ae as parseSmallNumber,
|
|
85
86
|
Z as percentTemplate,
|
|
86
87
|
z as percentageTemplate,
|
|
87
|
-
|
|
88
|
+
ye as pluralize,
|
|
88
89
|
m as pointProgramsOf,
|
|
89
90
|
n as positiveTokenRewardsOf,
|
|
90
|
-
|
|
91
|
+
P as resolveCSSColor,
|
|
91
92
|
ne as round5,
|
|
92
93
|
we as searchInString,
|
|
93
94
|
Oe as searchInToken,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
Pe as selectPluralString,
|
|
96
|
+
ke as serializeValue,
|
|
97
|
+
Re as shortSHA,
|
|
97
98
|
F as shortenHash,
|
|
98
99
|
_e as shortenString,
|
|
99
100
|
D as significantTrunc,
|
|
100
101
|
$ as slippageTemplate,
|
|
101
102
|
xe as splitInterval,
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
Qe as
|
|
110
|
-
|
|
103
|
+
He as strategyApyPartsAtLeverage,
|
|
104
|
+
We as strategyNetApyAtLeverage,
|
|
105
|
+
Ze as strategyQuotaRate,
|
|
106
|
+
K as toSignificantDigits,
|
|
107
|
+
p as tokenRewardsOf,
|
|
108
|
+
Xe as tokenTemplate,
|
|
109
|
+
qe as tokenTemplateNumber,
|
|
110
|
+
Qe as tokenTemplateString,
|
|
111
|
+
i as totalApyOf,
|
|
112
|
+
eo as ttlFromTimestamp,
|
|
113
|
+
oo as ttlLeft,
|
|
114
|
+
ro as ttlLeftHuman,
|
|
111
115
|
t as useFormFieldIds,
|
|
112
116
|
Te as validateMinMax
|
|
113
117
|
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
function e({
|
|
2
|
+
additionalBorrowApy: o = 0,
|
|
3
|
+
maxLeverage: t
|
|
4
|
+
}) {
|
|
5
|
+
return t != null && t > 0 ? o / t : 0;
|
|
6
|
+
}
|
|
7
|
+
function i({
|
|
8
|
+
leverage: o,
|
|
9
|
+
maxLeverage: t,
|
|
10
|
+
borrowApy: r = 0,
|
|
11
|
+
additionalBorrowApy: u = 0
|
|
12
|
+
}) {
|
|
13
|
+
const n = Math.max(o - 1, 0), s = r * n, a = e({ additionalBorrowApy: u, maxLeverage: t }), c = a * o;
|
|
14
|
+
return {
|
|
15
|
+
debtMultiplier: n,
|
|
16
|
+
borrowCost: s,
|
|
17
|
+
quotaRate: a,
|
|
18
|
+
quotaCost: c,
|
|
19
|
+
totalCost: s + c
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function y({
|
|
23
|
+
collateralApy: o,
|
|
24
|
+
leverage: t,
|
|
25
|
+
maxLeverage: r,
|
|
26
|
+
borrowApy: u,
|
|
27
|
+
additionalBorrowApy: n
|
|
28
|
+
}) {
|
|
29
|
+
const { totalCost: s } = i({
|
|
30
|
+
leverage: t,
|
|
31
|
+
maxLeverage: r,
|
|
32
|
+
borrowApy: u,
|
|
33
|
+
additionalBorrowApy: n
|
|
34
|
+
});
|
|
35
|
+
return o * t - s;
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
i as strategyApyPartsAtLeverage,
|
|
39
|
+
y as strategyNetApyAtLeverage,
|
|
40
|
+
e as strategyQuotaRate
|
|
41
|
+
};
|
|
@@ -3,10 +3,20 @@ import { TitleText } from '../text';
|
|
|
3
3
|
import { StatBadgeTest } from './constants';
|
|
4
4
|
export { StatBadgeTest };
|
|
5
5
|
export type StatBadgeSize = "sm" | "md" | "default";
|
|
6
|
+
export interface StatBadgeDelta {
|
|
7
|
+
/** Formatted change, e.g. `"12.50%"`. Sign is taken from `value`, not this string. */
|
|
8
|
+
readonly label: ReactNode;
|
|
9
|
+
/** Signed change; `> 0` is success, `< 0` is destructive. */
|
|
10
|
+
readonly value: number;
|
|
11
|
+
/** Period hint shown on hover, e.g. `"7D"`. */
|
|
12
|
+
readonly tooltip?: ReactNode;
|
|
13
|
+
}
|
|
6
14
|
export interface StatBadgeProps {
|
|
7
15
|
/** A messageId (formatted here) or a node. */
|
|
8
16
|
readonly title: TitleText;
|
|
9
17
|
readonly value: React.ReactNode;
|
|
18
|
+
/** Optional change chip in the top-right of the card. Hidden while `isLoading`. */
|
|
19
|
+
readonly delta?: StatBadgeDelta;
|
|
10
20
|
/** Optional control in the top-right of the card, e.g. a Claim button. */
|
|
11
21
|
readonly action?: ReactNode;
|
|
12
22
|
readonly className?: string;
|
|
@@ -16,7 +26,7 @@ export interface StatBadgeProps {
|
|
|
16
26
|
readonly testId?: string;
|
|
17
27
|
readonly size?: StatBadgeSize;
|
|
18
28
|
}
|
|
19
|
-
export declare function StatBadge({ title, value, isLoading, size, action, className, testId, }: StatBadgeProps): React.ReactElement;
|
|
29
|
+
export declare function StatBadge({ title, value, isLoading, size, delta, action, className, testId, }: StatBadgeProps): React.ReactElement;
|
|
20
30
|
export interface StatBadgeGridProps {
|
|
21
31
|
readonly cols?: 1 | 2 | 3 | 4;
|
|
22
32
|
readonly colsLg?: 1 | 2 | 3 | 4;
|
package/dist/types/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.d.ts
CHANGED
|
@@ -7,6 +7,18 @@ export interface StrategyApyBreakdownData {
|
|
|
7
7
|
readonly borrowApy?: Bps;
|
|
8
8
|
readonly additionalBorrowApy?: Bps;
|
|
9
9
|
readonly maxLeverage?: Leverage;
|
|
10
|
+
/**
|
|
11
|
+
* SDK net at {@link maxLeverage}. Used for the net chip when the selected
|
|
12
|
+
* leverage is max, so the chip matches the Max APY badge instead of a
|
|
13
|
+
* client-side reconstruction.
|
|
14
|
+
*/
|
|
15
|
+
readonly maxLeverageApy?: ApyBreakdown;
|
|
16
|
+
/**
|
|
17
|
+
* SDK net at the displayed {@link StrategyApyBreakdownCardProps.leverage}
|
|
18
|
+
* (e.g. a position's `netApy`). Preferred over both `maxLeverageApy` and
|
|
19
|
+
* the reconstructed formula.
|
|
20
|
+
*/
|
|
21
|
+
readonly netApy?: ApyBreakdown;
|
|
10
22
|
}
|
|
11
23
|
export interface StrategyApyBreakdownCardProps {
|
|
12
24
|
readonly data: StrategyApyBreakdownData;
|
|
@@ -10,8 +10,8 @@ export interface TabberSectionProps {
|
|
|
10
10
|
readonly actions?: React.ReactNode;
|
|
11
11
|
readonly children?: React.ReactNode;
|
|
12
12
|
/**
|
|
13
|
-
* Render this section above the sticky tab bar (overview badges). The
|
|
14
|
-
*
|
|
13
|
+
* Render this section above the sticky tab bar (overview badges). The
|
|
14
|
+
* section is not listed in the bar; scroll-spy tracks only sections below it.
|
|
15
15
|
*/
|
|
16
16
|
readonly beforeBar?: boolean;
|
|
17
17
|
/** Skip the in-section h2 — overview has badges, not a heading. */
|
|
@@ -220,7 +220,8 @@ declare const _default: {
|
|
|
220
220
|
"components.strategyApyBreakdownCard.collateralApy": "Collateral APY",
|
|
221
221
|
"components.strategyApyBreakdownCard.incentiveApy": "Incentive APY",
|
|
222
222
|
"components.strategyApyBreakdownCard.borrowRate": "Borrow Rate",
|
|
223
|
-
"components.strategyApyBreakdownCard.
|
|
223
|
+
"components.strategyApyBreakdownCard.quotaRate": "Quota Rate",
|
|
224
|
+
"components.strategyApyBreakdownCard.formula": "{leverage} × {base}",
|
|
224
225
|
|
|
225
226
|
"components.leveragePresetChips.label": "Leverage:",
|
|
226
227
|
|
|
@@ -27,6 +27,7 @@ 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';
|
|
30
31
|
export * from './templates';
|
|
31
32
|
export * from './token-icon-source';
|
|
32
33
|
export * from './ttl';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Bps, Leverage } from '@gearbox-protocol/sdk/model';
|
|
2
|
+
/**
|
|
3
|
+
* Quota rate at 1x. `additionalBorrowApy` from the SDK is already scaled to
|
|
4
|
+
* {@link maxLeverage} (`quotaRate × (1 + feeInterest) × maxLeverage`).
|
|
5
|
+
*/
|
|
6
|
+
export declare function strategyQuotaRate({ additionalBorrowApy, maxLeverage, }: {
|
|
7
|
+
readonly additionalBorrowApy?: Bps;
|
|
8
|
+
readonly maxLeverage?: Leverage;
|
|
9
|
+
}): Bps;
|
|
10
|
+
/**
|
|
11
|
+
* Borrow + quota cost of a strategy at leverage `l`, in bps.
|
|
12
|
+
*
|
|
13
|
+
* `cost = borrowApy × max(l − 1, 0) + quotaRate × l`
|
|
14
|
+
*/
|
|
15
|
+
export declare function strategyApyPartsAtLeverage({ leverage, maxLeverage, borrowApy, additionalBorrowApy, }: {
|
|
16
|
+
readonly leverage: Leverage;
|
|
17
|
+
readonly maxLeverage?: Leverage;
|
|
18
|
+
readonly borrowApy?: Bps;
|
|
19
|
+
readonly additionalBorrowApy?: Bps;
|
|
20
|
+
}): {
|
|
21
|
+
readonly debtMultiplier: number;
|
|
22
|
+
readonly borrowCost: Bps;
|
|
23
|
+
readonly quotaRate: Bps;
|
|
24
|
+
readonly quotaCost: Bps;
|
|
25
|
+
readonly totalCost: Bps;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Net strategy APY at leverage `l`, in bps:
|
|
29
|
+
* `collateralApy × l − cost(l)`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function strategyNetApyAtLeverage({ collateralApy, leverage, maxLeverage, borrowApy, additionalBorrowApy, }: {
|
|
32
|
+
readonly collateralApy: Bps;
|
|
33
|
+
readonly leverage: Leverage;
|
|
34
|
+
readonly maxLeverage?: Leverage;
|
|
35
|
+
readonly borrowApy?: Bps;
|
|
36
|
+
readonly additionalBorrowApy?: Bps;
|
|
37
|
+
}): Bps;
|