@gearbox-protocol/ui-kit 4.0.0-next.14 → 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/checkbox/checkbox-labeled.cjs +1 -1
- package/dist/cjs/components/client-adapters/styled-rounded-image/styled-rounded-image.cjs +1 -1
- package/dist/cjs/components/index.cjs +1 -1
- package/dist/cjs/components/sdk-status-pill/constants.cjs +1 -0
- package/dist/cjs/components/sdk-status-pill/index.cjs +1 -0
- package/dist/cjs/components/sdk-status-pill/sdk-status-pill.cjs +1 -0
- package/dist/cjs/components/sdk-status-pill/sdk-status.cjs +1 -0
- package/dist/cjs/components/with-copy/with-copy.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/checkbox/checkbox-labeled.js +1 -1
- package/dist/esm/components/client-adapters/styled-rounded-image/styled-rounded-image.js +1 -1
- package/dist/esm/components/index.js +234 -235
- package/dist/esm/components/sdk-status-pill/constants.js +8 -0
- package/dist/esm/components/sdk-status-pill/index.js +8 -0
- package/dist/esm/components/sdk-status-pill/sdk-status-pill.js +59 -0
- package/dist/esm/components/sdk-status-pill/sdk-status.js +6 -0
- package/dist/esm/components/with-copy/with-copy.js +1 -1
- package/dist/esm/components/yield-breakdown-tooltip/yield-breakdown-tooltip.js +20 -19
- package/dist/esm/index.js +567 -564
- package/dist/esm/locale/en.json.js +5 -9
- 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/components/index.d.ts +1 -1
- package/dist/types/components/sdk-status-pill/constants.d.ts +5 -0
- package/dist/types/components/sdk-status-pill/index.d.ts +3 -0
- package/dist/types/components/sdk-status-pill/sdk-status-pill.d.ts +27 -0
- package/dist/types/components/sdk-status-pill/sdk-status.d.ts +11 -0
- package/dist/types/index.d.ts +1 -2
- package/dist/types/locale/en.json.d.ts +5 -9
- package/dist/types/types/index.d.ts +0 -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
- package/dist/cjs/components/sync-status-pill/constants.cjs +0 -1
- package/dist/cjs/components/sync-status-pill/get-sync-status.cjs +0 -1
- package/dist/cjs/components/sync-status-pill/index.cjs +0 -1
- package/dist/cjs/components/sync-status-pill/sync-status-pill.cjs +0 -1
- package/dist/cjs/types/footer.cjs +0 -1
- package/dist/esm/components/sync-status-pill/constants.js +0 -10
- package/dist/esm/components/sync-status-pill/get-sync-status.js +0 -78
- package/dist/esm/components/sync-status-pill/index.js +0 -9
- package/dist/esm/components/sync-status-pill/sync-status-pill.js +0 -137
- package/dist/esm/types/footer.js +0 -1
- package/dist/types/components/sync-status-pill/constants.d.ts +0 -7
- package/dist/types/components/sync-status-pill/get-sync-status.d.ts +0 -100
- package/dist/types/components/sync-status-pill/index.d.ts +0 -3
- package/dist/types/components/sync-status-pill/sync-status-pill.d.ts +0 -42
- package/dist/types/types/footer.d.ts +0 -7
|
@@ -17,14 +17,9 @@ const e = {
|
|
|
17
17
|
"components.footer.gearbox": "Copyright © Gearbox Foundation 2023-2026.",
|
|
18
18
|
"components.footer.built": "Built at ETHGlobal MarketMake hackathon.",
|
|
19
19
|
"components.footer.version": "Version {value}",
|
|
20
|
-
"components.
|
|
21
|
-
"components.
|
|
22
|
-
"components.
|
|
23
|
-
"components.syncStatus.none": "No data",
|
|
24
|
-
"components.syncStatus.unavailable": "Unavailable",
|
|
25
|
-
"components.syncStatus.ago": "{age} ago",
|
|
26
|
-
"components.syncStatus.sourceOutdated": "{source} data outdated",
|
|
27
|
-
"components.syncStatus.sourceMissing": "no {source} data",
|
|
20
|
+
"components.sdkStatus.connecting": "Connecting…",
|
|
21
|
+
"components.sdkStatus.connected": "Connected",
|
|
22
|
+
"components.sdkStatus.disconnected": "Not connected",
|
|
28
23
|
"components.creditAccountHistory.table.protocol": "Protocol",
|
|
29
24
|
"components.creditAccountHistory.table.operation": "Operation",
|
|
30
25
|
"components.creditAccountHistory.table.details": "Details",
|
|
@@ -184,7 +179,8 @@ const e = {
|
|
|
184
179
|
"components.strategyApyBreakdownCard.collateralApy": "Collateral APY",
|
|
185
180
|
"components.strategyApyBreakdownCard.incentiveApy": "Incentive APY",
|
|
186
181
|
"components.strategyApyBreakdownCard.borrowRate": "Borrow Rate",
|
|
187
|
-
"components.strategyApyBreakdownCard.
|
|
182
|
+
"components.strategyApyBreakdownCard.quotaRate": "Quota Rate",
|
|
183
|
+
"components.strategyApyBreakdownCard.formula": "{leverage} × {base}",
|
|
188
184
|
"components.leveragePresetChips.label": "Leverage:",
|
|
189
185
|
"components.liquidationParamsTable.lt": "Liquidation threshold",
|
|
190
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. */
|
|
@@ -55,6 +55,7 @@ export * from './pool-points-indicator';
|
|
|
55
55
|
export * from './rounded-image';
|
|
56
56
|
export * from './rwa-feature';
|
|
57
57
|
export * from './rwa-styles';
|
|
58
|
+
export * from './sdk-status-pill';
|
|
58
59
|
export * from './search-line';
|
|
59
60
|
export * from './segmented-control';
|
|
60
61
|
export * from './select';
|
|
@@ -69,7 +70,6 @@ export * from './spinner-loader';
|
|
|
69
70
|
export * from './split-list';
|
|
70
71
|
export * from './status-dot';
|
|
71
72
|
export * from './status-elements';
|
|
72
|
-
export * from './sync-status-pill';
|
|
73
73
|
export * from './tab-control';
|
|
74
74
|
export * from './table';
|
|
75
75
|
export * from './tabs';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SdkAttachStatus } from './sdk-status';
|
|
2
|
+
import type * as React from "react";
|
|
3
|
+
export interface SdkStatusPillProps {
|
|
4
|
+
/** Where the SDK is in its attach lifecycle. */
|
|
5
|
+
status: SdkAttachStatus;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* SdkStatusPill — whether the SDK is connected, as one dot in an app footer.
|
|
9
|
+
*
|
|
10
|
+
* Deliberately narrow: it reports the **SDK's attach lifecycle** and nothing
|
|
11
|
+
* else. It is not a data-freshness indicator — it will not go grey because a
|
|
12
|
+
* chain lagged or the backend failed, and it says nothing about what is on
|
|
13
|
+
* screen. Screens surface their own failures.
|
|
14
|
+
*
|
|
15
|
+
* Two constraints, both product decisions:
|
|
16
|
+
*
|
|
17
|
+
* - **The palette is green and muted grey only**, never red or amber. See
|
|
18
|
+
* {@link sdkStatusDotVariant}.
|
|
19
|
+
* - **No visible label**, so the tooltip carries the wording and is mirrored
|
|
20
|
+
* into `aria-label` — a screen reader cannot see the colour.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* <AppFooter status={<SdkStatusPill status={attach.status} />} />
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function SdkStatusPill({ status, }: SdkStatusPillProps): React.ReactElement;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Where the SDK is in its attach lifecycle. */
|
|
2
|
+
export type SdkAttachStatus = "loading" | "error" | "ready";
|
|
3
|
+
/** Dot variants this indicator is allowed to use. */
|
|
4
|
+
export type SdkStatusDotVariant = "success" | "default";
|
|
5
|
+
/**
|
|
6
|
+
* The palette rule, as a function rather than a comment: green once the SDK is
|
|
7
|
+
* usable, muted grey otherwise. Never `alert` or `warning` — an alarming dot in
|
|
8
|
+
* permanent view teaches people to ignore it, and the screens surface their own
|
|
9
|
+
* failures. Exported so the rule is pinned by a test rather than by review.
|
|
10
|
+
*/
|
|
11
|
+
export declare function sdkStatusDotVariant(status: SdkAttachStatus): SdkStatusDotVariant;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -57,6 +57,7 @@ export * from './components/pool-points-indicator';
|
|
|
57
57
|
export * from './components/rounded-image';
|
|
58
58
|
export * from './components/rwa-feature';
|
|
59
59
|
export * from './components/rwa-styles';
|
|
60
|
+
export * from './components/sdk-status-pill';
|
|
60
61
|
export * from './components/search-line';
|
|
61
62
|
export * from './components/segmented-control';
|
|
62
63
|
export * from './components/select';
|
|
@@ -71,7 +72,6 @@ export * from './components/spinner-loader';
|
|
|
71
72
|
export * from './components/split-list';
|
|
72
73
|
export * from './components/status-dot';
|
|
73
74
|
export * from './components/status-elements';
|
|
74
|
-
export * from './components/sync-status-pill';
|
|
75
75
|
export * from './components/tab-control';
|
|
76
76
|
export * from './components/table';
|
|
77
77
|
export * from './components/tabs';
|
|
@@ -96,7 +96,6 @@ export * from './configs/variants';
|
|
|
96
96
|
export * from './hooks';
|
|
97
97
|
export type { LocaleKeys } from './locale';
|
|
98
98
|
export * from './locale';
|
|
99
|
-
export type { NetworkById } from './types/footer';
|
|
100
99
|
export { EnglishLocale };
|
|
101
100
|
export * from './utils';
|
|
102
101
|
export * from './utils/a11y';
|
|
@@ -20,14 +20,9 @@ declare const _default: {
|
|
|
20
20
|
"components.footer.built": "Built at ETHGlobal MarketMake hackathon.",
|
|
21
21
|
"components.footer.version": "Version {value}",
|
|
22
22
|
|
|
23
|
-
"components.
|
|
24
|
-
"components.
|
|
25
|
-
"components.
|
|
26
|
-
"components.syncStatus.none": "No data",
|
|
27
|
-
"components.syncStatus.unavailable": "Unavailable",
|
|
28
|
-
"components.syncStatus.ago": "{age} ago",
|
|
29
|
-
"components.syncStatus.sourceOutdated": "{source} data outdated",
|
|
30
|
-
"components.syncStatus.sourceMissing": "no {source} data",
|
|
23
|
+
"components.sdkStatus.connecting": "Connecting…",
|
|
24
|
+
"components.sdkStatus.connected": "Connected",
|
|
25
|
+
"components.sdkStatus.disconnected": "Not connected",
|
|
31
26
|
|
|
32
27
|
"components.creditAccountHistory.table.protocol": "Protocol",
|
|
33
28
|
"components.creditAccountHistory.table.operation": "Operation",
|
|
@@ -225,7 +220,8 @@ declare const _default: {
|
|
|
225
220
|
"components.strategyApyBreakdownCard.collateralApy": "Collateral APY",
|
|
226
221
|
"components.strategyApyBreakdownCard.incentiveApy": "Incentive APY",
|
|
227
222
|
"components.strategyApyBreakdownCard.borrowRate": "Borrow Rate",
|
|
228
|
-
"components.strategyApyBreakdownCard.
|
|
223
|
+
"components.strategyApyBreakdownCard.quotaRate": "Quota Rate",
|
|
224
|
+
"components.strategyApyBreakdownCard.formula": "{leverage} × {base}",
|
|
229
225
|
|
|
230
226
|
"components.leveragePresetChips.label": "Leverage:",
|
|
231
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;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class t{static root="sync-status-pill-root";static dot="sync-status-pill-dot";static tooltip="sync-status-pill-tooltip";static headline="sync-status-pill-headline";static chainRow="sync-status-pill-chain-row"}exports.SyncStatusPillTest=t;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function h({onchain:t,offchain:e,attach:n="ready",now:r,staleAfterMs:a}){if(n==="loading")return{health:"starting",chains:[],syncedAt:void 0};if(n==="error")return{health:"none",chains:[],syncedAt:void 0};const i=f({onchain:t,offchain:e,now:r,staleAfterMs:a});if(i.length===0)return{health:"starting",chains:i,syncedAt:void 0};const u=v(i);return{health:u,chains:i,syncedAt:g(u,t,e)}}function f({onchain:t,offchain:e,now:n,staleAfterMs:r}){const a=d(t.meta),i=d(e.meta);return[...new Set([...a.keys(),...i.keys()])].map(o=>{const s=l(a.get(o),t.updatedAt,n,r),c=l(i.get(o),e.updatedAt,n,r);return{chainId:o,onchain:s,offchain:c,health:y(s,c)}})}function d(t){const e=new Map;for(const n of t?.chains??[])e.set(n.chainId,n);return e}function l(t,e,n,r){return t?t.status==="error"?"failed":!e||n-e>r||n-t.timestamp*1e3>r?"stale":"ok":"unknown"}function y(t,e){return t==="ok"?"live":t==="stale"||e==="ok"||e==="stale"?"cached":"none"}function v(t){return t.every(e=>e.health==="none")?"none":t.some(e=>e.health==="live")?"live":"cached"}function g(t,e,n){if(t==="live")return e.updatedAt||void 0;if(t==="cached"){const r=[e.updatedAt,n.updatedAt].filter(a=>!!a);return r.length?Math.max(...r):void 0}}function p(t){return t==="live"?"success":"default"}exports.getSyncStatus=h;exports.syncStatusDotVariant=p;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./constants.cjs"),t=require("./get-sync-status.cjs"),n=require("./sync-status-pill.cjs");exports.SyncStatusPillTest=s.SyncStatusPillTest;exports.getSyncStatus=t.getSyncStatus;exports.syncStatusDotVariant=t.syncStatusDotVariant;exports.SyncStatusPill=n.SyncStatusPill;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),d=require("react"),f=require("../status-dot/status-dot.cjs"),x=require("../tooltip/simple-tooltip.cjs");require("../tooltip/tooltip.cjs");const g=require("../typed-intl/index.cjs");require("@gearbox-protocol/sdk/common-utils");const _=require("../../hooks/use-media-query.cjs"),c=require("./constants.cjs"),p=require("./get-sync-status.cjs"),I=6e4*2.5,v=1e3,w="(hover: none)";function T({onchain:e,offchain:t,attach:s,isSyncing:u=!1,networkById:r}){const{formatMessage:n}=g.useIntlTyped(),l=$(),y=!_.useMediaQuery(w),o=d.useMemo(()=>p.getSyncStatus({onchain:e,offchain:t,attach:s,now:l,staleAfterMs:I}),[e,t,s,l]),S=n({messageId:q[o.health]}),m=o.syncedAt?`${S} · ${n({messageId:"components.syncStatus.ago"},{age:j(l-o.syncedAt)})}`:S,h=a.jsx("output",{className:"-m-1.5 flex size-6 cursor-pointer items-center justify-center","data-testid":c.SyncStatusPillTest.root,"aria-label":m,children:a.jsx(f.StatusDot,{variant:p.syncStatusDotVariant(o.health),size:"xs",pulse:o.health==="starting"||u,"data-testid":c.SyncStatusPillTest.dot})});return a.jsx(x.SimpleTooltip,{title:h,trigger:y?"hover":"click",placement:"top",maxWidth:"280px",children:a.jsxs("div",{className:"flex flex-col gap-1 text-left text-xs","data-testid":c.SyncStatusPillTest.tooltip,children:[a.jsx("span",{className:"font-medium","data-testid":c.SyncStatusPillTest.headline,children:m}),o.chains.map(i=>a.jsx("span",{className:"text-muted-foreground","data-testid":c.SyncStatusPillTest.chainRow,children:`${r[i.chainId]??String(i.chainId)} ${M(i,n)}`},i.chainId))]})})}const q={live:"components.syncStatus.live",starting:"components.syncStatus.starting",cached:"components.syncStatus.cached",none:"components.syncStatus.none"};function M(e,t){if(e.health==="none")return t({messageId:"components.syncStatus.unavailable"});const[s,u,r]=e.health==="live"?[t({messageId:"components.syncStatus.live"}),"offchain",e.offchain]:[t({messageId:"components.syncStatus.cached"}),"onchain",e.onchain],n=P(u,r,t);return n?`${s} · ${n}`:s}function P(e,t,s){if(t==="stale")return s({messageId:"components.syncStatus.sourceOutdated"},{source:e});if(t==="failed"||t==="unknown")return s({messageId:"components.syncStatus.sourceMissing"},{source:e})}function j(e){const t=Math.max(0,Math.round(e/1e3));return t<60?`${t}s`:t<3600?`${Math.round(t/60)}m`:`${Math.round(t/3600)}h`}function $(){const[e,t]=d.useState(()=>Date.now());return d.useEffect(()=>{const s=window.setInterval(()=>t(Date.now()),v);return()=>window.clearInterval(s)},[]),e}exports.SyncStatusPill=T;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
class s {
|
|
2
|
-
static root = "sync-status-pill-root";
|
|
3
|
-
static dot = "sync-status-pill-dot";
|
|
4
|
-
static tooltip = "sync-status-pill-tooltip";
|
|
5
|
-
static headline = "sync-status-pill-headline";
|
|
6
|
-
static chainRow = "sync-status-pill-chain-row";
|
|
7
|
-
}
|
|
8
|
-
export {
|
|
9
|
-
s as SyncStatusPillTest
|
|
10
|
-
};
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
function p({
|
|
2
|
-
onchain: t,
|
|
3
|
-
offchain: e,
|
|
4
|
-
attach: n = "ready",
|
|
5
|
-
now: r,
|
|
6
|
-
staleAfterMs: a
|
|
7
|
-
}) {
|
|
8
|
-
if (n === "loading")
|
|
9
|
-
return { health: "starting", chains: [], syncedAt: void 0 };
|
|
10
|
-
if (n === "error")
|
|
11
|
-
return { health: "none", chains: [], syncedAt: void 0 };
|
|
12
|
-
const i = f({ onchain: t, offchain: e, now: r, staleAfterMs: a });
|
|
13
|
-
if (i.length === 0)
|
|
14
|
-
return { health: "starting", chains: i, syncedAt: void 0 };
|
|
15
|
-
const u = v(i);
|
|
16
|
-
return { health: u, chains: i, syncedAt: y(u, t, e) };
|
|
17
|
-
}
|
|
18
|
-
function f({
|
|
19
|
-
onchain: t,
|
|
20
|
-
offchain: e,
|
|
21
|
-
now: n,
|
|
22
|
-
staleAfterMs: r
|
|
23
|
-
}) {
|
|
24
|
-
const a = d(t.meta), i = d(e.meta);
|
|
25
|
-
return [
|
|
26
|
-
.../* @__PURE__ */ new Set([...a.keys(), ...i.keys()])
|
|
27
|
-
].map((o) => {
|
|
28
|
-
const c = h(
|
|
29
|
-
a.get(o),
|
|
30
|
-
t.updatedAt,
|
|
31
|
-
n,
|
|
32
|
-
r
|
|
33
|
-
), s = h(
|
|
34
|
-
i.get(o),
|
|
35
|
-
e.updatedAt,
|
|
36
|
-
n,
|
|
37
|
-
r
|
|
38
|
-
);
|
|
39
|
-
return {
|
|
40
|
-
chainId: o,
|
|
41
|
-
onchain: c,
|
|
42
|
-
offchain: s,
|
|
43
|
-
health: l(c, s)
|
|
44
|
-
};
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
function d(t) {
|
|
48
|
-
const e = /* @__PURE__ */ new Map();
|
|
49
|
-
for (const n of t?.chains ?? [])
|
|
50
|
-
e.set(n.chainId, n);
|
|
51
|
-
return e;
|
|
52
|
-
}
|
|
53
|
-
function h(t, e, n, r) {
|
|
54
|
-
return t ? t.status === "error" ? "failed" : !e || n - e > r || n - t.timestamp * 1e3 > r ? "stale" : "ok" : "unknown";
|
|
55
|
-
}
|
|
56
|
-
function l(t, e) {
|
|
57
|
-
return t === "ok" ? "live" : t === "stale" || e === "ok" || e === "stale" ? "cached" : "none";
|
|
58
|
-
}
|
|
59
|
-
function v(t) {
|
|
60
|
-
return t.every((e) => e.health === "none") ? "none" : t.some((e) => e.health === "live") ? "live" : "cached";
|
|
61
|
-
}
|
|
62
|
-
function y(t, e, n) {
|
|
63
|
-
if (t === "live")
|
|
64
|
-
return e.updatedAt || void 0;
|
|
65
|
-
if (t === "cached") {
|
|
66
|
-
const r = [e.updatedAt, n.updatedAt].filter(
|
|
67
|
-
(a) => !!a
|
|
68
|
-
);
|
|
69
|
-
return r.length ? Math.max(...r) : void 0;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
function g(t) {
|
|
73
|
-
return t === "live" ? "success" : "default";
|
|
74
|
-
}
|
|
75
|
-
export {
|
|
76
|
-
p as getSyncStatus,
|
|
77
|
-
g as syncStatusDotVariant
|
|
78
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { SyncStatusPillTest as r } from "./constants.js";
|
|
2
|
-
import { getSyncStatus as a, syncStatusDotVariant as s } from "./get-sync-status.js";
|
|
3
|
-
import { SyncStatusPill as n } from "./sync-status-pill.js";
|
|
4
|
-
export {
|
|
5
|
-
n as SyncStatusPill,
|
|
6
|
-
r as SyncStatusPillTest,
|
|
7
|
-
a as getSyncStatus,
|
|
8
|
-
s as syncStatusDotVariant
|
|
9
|
-
};
|