@gearbox-protocol/ui-kit 4.0.0-next.4 → 4.0.0-next.6
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/assets-list-cell/assets-list-cell.cjs +1 -1
- package/dist/cjs/components/badge/badge.cjs +1 -1
- package/dist/cjs/components/badge/chip.cjs +1 -0
- package/dist/cjs/components/badge/index.cjs +1 -1
- package/dist/cjs/components/base/borrow-rate-block/borrow-rate-block.cjs +1 -1
- package/dist/cjs/components/base/chart-with-side-card/chart-with-side-card.cjs +1 -1
- package/dist/cjs/components/base/history-chart/history-chart.cjs +1 -1
- package/dist/cjs/components/base/index.cjs +1 -1
- package/dist/cjs/components/base/info-list/info-list.cjs +1 -1
- package/dist/cjs/components/base/leverage-input/leverage-input.cjs +1 -1
- package/dist/cjs/components/base/leverage-preset-chips/constants.cjs +1 -0
- package/dist/cjs/components/base/leverage-preset-chips/index.cjs +1 -0
- package/dist/cjs/components/base/leverage-preset-chips/leverage-preset-chips.cjs +1 -0
- package/dist/cjs/components/base/pool-apy-breakdown-card/pool-apy-breakdown-card.cjs +1 -1
- package/dist/cjs/components/base/strategy-apy-breakdown-card/constants.cjs +1 -1
- package/dist/cjs/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.cjs +1 -1
- package/dist/cjs/components/base/title-meta/constants.cjs +1 -1
- package/dist/cjs/components/base/title-meta/title-meta.cjs +1 -1
- package/dist/cjs/components/base/values/index.cjs +1 -1
- package/dist/cjs/components/base/values/position-status-badge.cjs +1 -0
- package/dist/cjs/components/base/values/position-type-badge.cjs +1 -1
- package/dist/cjs/components/base-table/base-table-line.cjs +1 -0
- package/dist/cjs/components/base-table/base-table.cjs +1 -0
- package/dist/cjs/components/base-table/constants.cjs +1 -0
- package/dist/cjs/components/base-table/index.cjs +1 -0
- package/dist/cjs/components/base-table/types.cjs +1 -0
- package/dist/cjs/components/block-sync-pill/block-sync-pill.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/collateral-allocation-tooltip/allocation-wheel.cjs +1 -0
- package/dist/cjs/components/collateral-allocation-tooltip/collateral-allocation-tooltip.cjs +1 -0
- package/dist/cjs/components/collateral-allocation-tooltip/constants.cjs +1 -0
- package/dist/cjs/components/collateral-allocation-tooltip/index.cjs +1 -0
- package/dist/cjs/components/composites/index.cjs +1 -1
- package/dist/cjs/components/composites/pool-assets-table/constants.cjs +1 -0
- package/dist/cjs/components/composites/pool-assets-table/index.cjs +1 -1
- package/dist/cjs/components/composites/pool-assets-table/pool-assets-table-head.cjs +1 -1
- package/dist/cjs/components/composites/pool-assets-table/pool-assets-table-row.cjs +1 -1
- package/dist/cjs/components/composites/pool-assets-table/pool-assets-table.cjs +1 -1
- package/dist/cjs/components/composites/tx-preview/confirm/dialog/TransactionConfirmShell.cjs +1 -1
- package/dist/cjs/components/composites/tx-preview/confirm/dialog/index.cjs +1 -1
- package/dist/cjs/components/composites/tx-preview/confirm/dialog/transactionConfirmShellTypes.cjs +1 -0
- package/dist/cjs/components/composites/tx-preview/confirm/index.cjs +1 -1
- package/dist/cjs/components/composites/tx-preview/index.cjs +1 -1
- package/dist/cjs/components/compound-apy/compound-apy.cjs +1 -1
- package/dist/cjs/components/filter/filter-chip.cjs +1 -1
- package/dist/cjs/components/graph/default-config.cjs +1 -1
- package/dist/cjs/components/graph/graph-view.cjs +1 -1
- package/dist/cjs/components/graph/graph.cjs +1 -1
- package/dist/cjs/components/hf-indicator/hf-indicator.cjs +1 -0
- package/dist/cjs/components/hf-indicator/index.cjs +1 -0
- package/dist/cjs/components/index.cjs +1 -1
- package/dist/cjs/components/infinite-scroll/index.cjs +1 -0
- package/dist/cjs/components/infinite-scroll/infinite-scroll-wrapper.cjs +1 -0
- package/dist/cjs/components/name-cell/index.cjs +1 -0
- package/dist/cjs/components/name-cell/name-cell.cjs +1 -0
- package/dist/cjs/components/network-icon/index.cjs +1 -1
- package/dist/cjs/components/network-icon/network-indicator.cjs +1 -0
- package/dist/cjs/components/trading-view/trading-view.cjs +1 -1
- 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/configs/tailwind-preset.cjs +1 -1
- package/dist/cjs/hooks/index.cjs +1 -1
- package/dist/cjs/hooks/use-observed-width-key.cjs +1 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/locale/en.json.cjs +1 -1
- package/dist/cjs/utils/format-money.cjs +1 -1
- package/dist/cjs/utils/index.cjs +1 -1
- package/dist/cjs/utils/leverage-presets.cjs +1 -0
- package/dist/esm/components/assets-list-cell/assets-list-cell.js +161 -159
- package/dist/esm/components/badge/badge.js +14 -8
- package/dist/esm/components/badge/chip.js +47 -0
- package/dist/esm/components/badge/index.js +8 -3
- package/dist/esm/components/base/borrow-rate-block/borrow-rate-block.js +3 -2
- package/dist/esm/components/base/chart-with-side-card/chart-with-side-card.js +6 -6
- package/dist/esm/components/base/history-chart/history-chart.js +86 -46
- package/dist/esm/components/base/index.js +144 -138
- package/dist/esm/components/base/info-list/info-list.js +7 -8
- package/dist/esm/components/base/leverage-input/leverage-input.js +1 -1
- package/dist/esm/components/base/leverage-preset-chips/constants.js +7 -0
- package/dist/esm/components/base/leverage-preset-chips/index.js +6 -0
- package/dist/esm/components/base/leverage-preset-chips/leverage-preset-chips.js +39 -0
- package/dist/esm/components/base/pool-apy-breakdown-card/pool-apy-breakdown-card.js +23 -30
- package/dist/esm/components/base/strategy-apy-breakdown-card/constants.js +3 -2
- package/dist/esm/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.js +194 -32
- package/dist/esm/components/base/title-meta/constants.js +1 -0
- package/dist/esm/components/base/title-meta/title-meta.js +53 -33
- package/dist/esm/components/base/values/index.js +16 -14
- package/dist/esm/components/base/values/position-status-badge.js +26 -0
- package/dist/esm/components/base/values/position-type-badge.js +7 -6
- package/dist/esm/components/base-table/base-table-line.js +117 -0
- package/dist/esm/components/base-table/base-table.js +110 -0
- package/dist/esm/components/base-table/constants.js +12 -0
- package/dist/esm/components/base-table/index.js +9 -0
- package/dist/esm/components/base-table/types.js +1 -0
- package/dist/esm/components/block-sync-pill/block-sync-pill.js +9 -6
- package/dist/esm/components/checkbox/checkbox-labeled.js +7 -4
- package/dist/esm/components/client-adapters/styled-rounded-image/styled-rounded-image.js +7 -4
- package/dist/esm/components/collateral-allocation-tooltip/allocation-wheel.js +71 -0
- package/dist/esm/components/collateral-allocation-tooltip/collateral-allocation-tooltip.js +102 -0
- package/dist/esm/components/collateral-allocation-tooltip/constants.js +12 -0
- package/dist/esm/components/collateral-allocation-tooltip/index.js +9 -0
- package/dist/esm/components/composites/index.js +31 -31
- package/dist/esm/components/composites/pool-assets-table/constants.js +9 -0
- package/dist/esm/components/composites/pool-assets-table/index.js +8 -6
- package/dist/esm/components/composites/pool-assets-table/pool-assets-table-head.js +52 -30
- package/dist/esm/components/composites/pool-assets-table/pool-assets-table-row.js +108 -76
- package/dist/esm/components/composites/pool-assets-table/pool-assets-table.js +44 -26
- package/dist/esm/components/composites/tx-preview/confirm/dialog/TransactionConfirmShell.js +109 -52
- package/dist/esm/components/composites/tx-preview/confirm/dialog/index.js +8 -10
- package/dist/esm/components/composites/tx-preview/confirm/dialog/transactionConfirmShellTypes.js +1 -0
- package/dist/esm/components/composites/tx-preview/confirm/index.js +24 -26
- package/dist/esm/components/composites/tx-preview/index.js +24 -26
- package/dist/esm/components/compound-apy/compound-apy.js +85 -80
- package/dist/esm/components/filter/filter-chip.js +1 -0
- package/dist/esm/components/graph/default-config.js +20 -18
- package/dist/esm/components/graph/graph-view.js +32 -31
- package/dist/esm/components/graph/graph.js +459 -458
- package/dist/esm/components/hf-indicator/hf-indicator.js +33 -0
- package/dist/esm/components/hf-indicator/index.js +4 -0
- package/dist/esm/components/index.js +732 -701
- package/dist/esm/components/infinite-scroll/index.js +4 -0
- package/dist/esm/components/infinite-scroll/infinite-scroll-wrapper.js +30 -0
- package/dist/esm/components/name-cell/index.js +4 -0
- package/dist/esm/components/name-cell/name-cell.js +35 -0
- package/dist/esm/components/network-icon/index.js +4 -2
- package/dist/esm/components/network-icon/network-indicator.js +82 -0
- package/dist/esm/components/trading-view/trading-view.js +193 -155
- package/dist/esm/components/with-copy/with-copy.js +7 -4
- package/dist/esm/components/yield-breakdown-tooltip/yield-breakdown-tooltip.js +112 -169
- package/dist/esm/configs/tailwind-preset.js +13 -1
- package/dist/esm/hooks/index.js +20 -18
- package/dist/esm/hooks/use-observed-width-key.js +24 -0
- package/dist/esm/index.js +881 -842
- package/dist/esm/locale/en.json.js +21 -18
- package/dist/esm/utils/format-money.js +59 -41
- package/dist/esm/utils/index.js +87 -83
- package/dist/esm/utils/leverage-presets.js +13 -0
- package/dist/globals.css +1 -1
- package/dist/types/components/assets-list-cell/assets-list-cell.d.ts +3 -0
- package/dist/types/components/badge/badge.d.ts +2 -1
- package/dist/types/components/badge/chip.d.ts +22 -0
- package/dist/types/components/badge/index.d.ts +1 -0
- package/dist/types/components/base/history-chart/history-chart.d.ts +13 -3
- package/dist/types/components/base/index.d.ts +1 -0
- package/dist/types/components/base/leverage-input/leverage-input.d.ts +1 -1
- package/dist/types/components/base/leverage-preset-chips/constants.d.ts +4 -0
- package/dist/types/components/base/leverage-preset-chips/index.d.ts +2 -0
- package/dist/types/components/base/leverage-preset-chips/leverage-preset-chips.d.ts +13 -0
- package/dist/types/components/base/liquidation-params-table/liquidation-params-table.d.ts +2 -2
- package/dist/types/components/base/pool-apy-breakdown-card/pool-apy-breakdown-card.d.ts +4 -5
- package/dist/types/components/base/strategy-apy-breakdown-card/constants.d.ts +1 -0
- package/dist/types/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.d.ts +12 -4
- package/dist/types/components/base/title-meta/constants.d.ts +1 -0
- package/dist/types/components/base/title-meta/title-meta.d.ts +9 -1
- package/dist/types/components/base/values/index.d.ts +1 -0
- package/dist/types/components/base/values/position-status-badge.d.ts +7 -0
- package/dist/types/components/base/values/position-type-badge.d.ts +1 -1
- package/dist/types/components/base-table/base-table-line.d.ts +21 -0
- package/dist/types/components/base-table/base-table.d.ts +19 -0
- package/dist/types/components/base-table/constants.d.ts +8 -0
- package/dist/types/components/base-table/index.d.ts +3 -0
- package/dist/types/components/base-table/types.d.ts +37 -0
- package/dist/types/components/collateral-allocation-tooltip/allocation-wheel.d.ts +10 -0
- package/dist/types/components/collateral-allocation-tooltip/collateral-allocation-tooltip.d.ts +23 -0
- package/dist/types/components/collateral-allocation-tooltip/constants.d.ts +8 -0
- package/dist/types/components/collateral-allocation-tooltip/index.d.ts +3 -0
- package/dist/types/components/composites/pool-assets-table/constants.d.ts +6 -0
- package/dist/types/components/composites/pool-assets-table/index.d.ts +1 -0
- package/dist/types/components/composites/pool-assets-table/pool-assets-table-head.d.ts +1 -2
- package/dist/types/components/composites/pool-assets-table/pool-assets-table-row.d.ts +8 -8
- package/dist/types/components/composites/pool-assets-table/pool-assets-table.d.ts +7 -20
- package/dist/types/components/composites/pool-assets-table/types.d.ts +4 -12
- package/dist/types/components/composites/tx-preview/confirm/dialog/TransactionConfirmShell.d.ts +23 -19
- package/dist/types/components/composites/tx-preview/confirm/dialog/index.d.ts +2 -2
- package/dist/types/components/composites/tx-preview/confirm/dialog/transactionConfirmPhase.d.ts +0 -3
- package/dist/types/components/composites/tx-preview/confirm/dialog/transactionConfirmShellTypes.d.ts +97 -0
- package/dist/types/components/graph/graph-view.d.ts +1 -1
- package/dist/types/components/graph/graph.d.ts +4 -0
- package/dist/types/components/hf-indicator/hf-indicator.d.ts +8 -0
- package/dist/types/components/hf-indicator/index.d.ts +1 -0
- package/dist/types/components/index.d.ts +5 -0
- package/dist/types/components/infinite-scroll/index.d.ts +1 -0
- package/dist/types/components/infinite-scroll/infinite-scroll-wrapper.d.ts +11 -0
- package/dist/types/components/name-cell/index.d.ts +1 -0
- package/dist/types/components/name-cell/name-cell.d.ts +13 -0
- package/dist/types/components/network-icon/index.d.ts +1 -0
- package/dist/types/components/network-icon/network-indicator.d.ts +23 -0
- package/dist/types/components/trading-view/trading-view.d.ts +10 -3
- package/dist/types/components/yield-breakdown-tooltip/yield-breakdown-tooltip.d.ts +6 -8
- package/dist/types/configs/tailwind-preset.d.ts +12 -0
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/hooks/use-observed-width-key.d.ts +8 -0
- package/dist/types/index.d.ts +6 -1
- package/dist/types/locale/en.json.d.ts +23 -18
- package/dist/types/utils/format-money.d.ts +11 -5
- package/dist/types/utils/index.d.ts +2 -1
- package/dist/types/utils/leverage-presets.d.ts +7 -0
- package/package.json +1 -1
- package/src/styles/base.css +30 -0
- package/src/styles/theme.css +16 -0
- package/dist/cjs/components/composites/tx-preview/confirm/dialog/TransactionConfirmModalView.cjs +0 -1
- package/dist/cjs/components/composites/tx-preview/confirm/dialog/TransactionConfirmPageView.cjs +0 -1
- package/dist/esm/components/composites/tx-preview/confirm/dialog/TransactionConfirmModalView.js +0 -177
- package/dist/esm/components/composites/tx-preview/confirm/dialog/TransactionConfirmPageView.js +0 -54
- package/dist/types/components/composites/tx-preview/confirm/dialog/TransactionConfirmModalView.d.ts +0 -17
- package/dist/types/components/composites/tx-preview/confirm/dialog/TransactionConfirmPageView.d.ts +0 -16
|
@@ -6,6 +6,8 @@ const e = {
|
|
|
6
6
|
"errors.tooManyRequests": "Too many requests",
|
|
7
7
|
"errors.incorrectAddress": "Incorrect address",
|
|
8
8
|
"components.errorMessage.oops": "Oops...",
|
|
9
|
+
"components.networkIndicator.title": "Network",
|
|
10
|
+
"components.infiniteScrollWrapper.showMore": "Show more",
|
|
9
11
|
"components.alertModal.ok": "Ok",
|
|
10
12
|
"components.footer.privacy": "Privacy Notice",
|
|
11
13
|
"components.footer.terms": "Terms of Service",
|
|
@@ -67,19 +69,18 @@ const e = {
|
|
|
67
69
|
"components.apyParts.totalAPY": "Overall APY",
|
|
68
70
|
"components.apyParts.points": "{symbol} Incentive",
|
|
69
71
|
"components.apyParts.points.condition.crossDeposit": "For cross-chain deposits made via Omni",
|
|
70
|
-
"components.yieldBreakdown.
|
|
71
|
-
"components.yieldBreakdown.
|
|
72
|
-
"components.yieldBreakdown.
|
|
73
|
-
"components.yieldBreakdown.incentiveYield": "Incentive Yield",
|
|
72
|
+
"components.yieldBreakdown.titleNetAtLeverage": "Net APY at {leverage}× Leverage",
|
|
73
|
+
"components.yieldBreakdown.collateralApy": "Collateral APY",
|
|
74
|
+
"components.yieldBreakdown.incentive": "Incentive",
|
|
74
75
|
"components.yieldBreakdown.borrowRate": "Borrow Rate",
|
|
75
|
-
"components.yieldBreakdown.
|
|
76
|
-
"components.yieldBreakdown.additionalRate": "Additional Rate",
|
|
77
|
-
"components.yieldBreakdown.netYield": "Net Yield",
|
|
76
|
+
"components.yieldBreakdown.programPoints": "{name} Points",
|
|
78
77
|
"components.yieldBreakdown.points": "Points",
|
|
79
78
|
"components.openCopyButtons.copy": "Copy to clipboard",
|
|
80
|
-
"components.poolAssetsTable.asset": "
|
|
79
|
+
"components.poolAssetsTable.asset": "Name",
|
|
81
80
|
"components.poolAssetsTable.rate": "Effective rate",
|
|
82
|
-
"components.poolAssetsTable.
|
|
81
|
+
"components.poolAssetsTable.exposure": "Exposure",
|
|
82
|
+
"components.poolAssetsTable.cap": "Cap",
|
|
83
|
+
"components.poolAssetsTable.capUtilization": "Cap utilization",
|
|
83
84
|
"components.poolAssetsTable.usage": "{amount} of {total}",
|
|
84
85
|
"components.poolAssetsTable.head.name": "Credit Manager",
|
|
85
86
|
"components.poolAssetsTable.head.currentDebt": "Current Debt",
|
|
@@ -162,23 +163,25 @@ const e = {
|
|
|
162
163
|
"components.timeToLiquidationBlock.tip": "Time to liquidation estimates how long the account can stay open if prices remain constant and no yield is earned—only accounting for borrow interest accrual.",
|
|
163
164
|
"components.historyChart.error": "Couldn't load chart data",
|
|
164
165
|
"components.historyChart.empty": "No data",
|
|
165
|
-
"components.positionTypeBadge.pool": "
|
|
166
|
+
"components.positionTypeBadge.pool": "LP",
|
|
166
167
|
"components.positionTypeBadge.strategy": "Strategy",
|
|
167
168
|
"components.positionTypeBadge.liquidation": "Liquidation",
|
|
169
|
+
"components.positionStatusBadge.active": "Active",
|
|
170
|
+
"components.positionStatusBadge.repaid": "Repaid",
|
|
168
171
|
"components.titleMeta.unknownCurator": "Curator",
|
|
169
172
|
"components.moreAccordion.more": "More details",
|
|
170
173
|
"components.moreAccordion.less": "Less details",
|
|
171
174
|
"components.poolApyBreakdownCard.title": "APY Breakdown",
|
|
172
|
-
"components.poolApyBreakdownCard.
|
|
173
|
-
"components.poolApyBreakdownCard.
|
|
174
|
-
"components.
|
|
175
|
-
"components.strategyApyBreakdownCard.title": "APY Breakdown",
|
|
176
|
-
"components.strategyApyBreakdownCard.formula": "How strategy APY is calculated: Collateral APY x Leverage - Base borrow rate x (Leverage - 1) - Additional borrow rate x Leverage x 1.05",
|
|
175
|
+
"components.poolApyBreakdownCard.organicApy": "Pool organic APY",
|
|
176
|
+
"components.poolApyBreakdownCard.incentiveApy": "Incentive APY",
|
|
177
|
+
"components.strategyApyBreakdownCard.titleAtLeverage": "APY at {leverage}× Leverage",
|
|
177
178
|
"components.strategyApyBreakdownCard.collateralApy": "Collateral APY",
|
|
178
|
-
"components.strategyApyBreakdownCard.
|
|
179
|
-
"components.strategyApyBreakdownCard.
|
|
179
|
+
"components.strategyApyBreakdownCard.incentiveApy": "Incentive APY",
|
|
180
|
+
"components.strategyApyBreakdownCard.borrowRate": "Borrow Rate",
|
|
181
|
+
"components.strategyApyBreakdownCard.formula": "{base} × {leverage} Lev.",
|
|
182
|
+
"components.leveragePresetChips.label": "Leverage:",
|
|
180
183
|
"components.liquidationParamsTable.lt": "Liquidation threshold",
|
|
181
|
-
"components.liquidationParamsTable.penalty": "Liquidation
|
|
184
|
+
"components.liquidationParamsTable.penalty": "Liquidation discount",
|
|
182
185
|
"components.liquidationParamsTable.premium": "Liquidation premium",
|
|
183
186
|
"components.liquidationParamsTable.fee": "Liquidation fee",
|
|
184
187
|
"components.borrowRateBlock.label": "Borrow rate",
|
|
@@ -1,32 +1,49 @@
|
|
|
1
|
-
import { formatBN as
|
|
2
|
-
import { BigIntMath as
|
|
1
|
+
import { formatBN as b, WAD_DECIMALS_POW as g, PERCENTAGE_FACTOR as h } from "@gearbox-protocol/sdk";
|
|
2
|
+
import { BigIntMath as E } from "@gearbox-protocol/sdk/common-utils";
|
|
3
3
|
import "react";
|
|
4
|
-
import { bnToInputView as
|
|
4
|
+
import { bnToInputView as x } from "./bn-to-input-view.js";
|
|
5
5
|
import "clsx";
|
|
6
6
|
import "tailwind-merge";
|
|
7
7
|
import "sonner";
|
|
8
8
|
import "react/jsx-runtime";
|
|
9
9
|
import "luxon";
|
|
10
10
|
import "./z-index.js";
|
|
11
|
-
const
|
|
11
|
+
const A = 10000000000000000n;
|
|
12
12
|
function F(t) {
|
|
13
13
|
return BigInt(t.toFixed(18).replace(".", ""));
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
const
|
|
15
|
+
function V(t, e) {
|
|
16
|
+
const r = typeof t == "number" && t < 0 || typeof t == "bigint" && t < 0n ? "-" : "", f = typeof t == "number" ? F(Math.abs(t)) : E.abs(t), u = f < A && f > 0n, a = u ? "0.01" : b(f, g, e), o = `${r}$${a}`;
|
|
17
17
|
return u ? `< ${o}` : o;
|
|
18
18
|
}
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
const C = 1e3, P = [
|
|
20
|
+
{ div: 1e12, suffix: "T" },
|
|
21
|
+
{ div: 1e9, suffix: "B" },
|
|
22
|
+
{ div: 1e6, suffix: "M" },
|
|
23
|
+
{ div: 1e3, suffix: "K" }
|
|
24
|
+
];
|
|
25
|
+
function _(t) {
|
|
26
|
+
return t.replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "");
|
|
23
27
|
}
|
|
24
|
-
function
|
|
25
|
-
|
|
28
|
+
function d(t, e) {
|
|
29
|
+
for (const { div: i, suffix: r } of P)
|
|
30
|
+
if (t >= i)
|
|
31
|
+
return `${_((t / i).toFixed(e))}${r}`;
|
|
32
|
+
return t.toFixed(e);
|
|
26
33
|
}
|
|
27
|
-
function
|
|
28
|
-
|
|
29
|
-
|
|
34
|
+
function B(t, e = 2) {
|
|
35
|
+
return !Number.isFinite(t) || t === 0 ? "0%" : `${t < 0 ? "-" : ""}${d(Math.abs(t), e)}%`;
|
|
36
|
+
}
|
|
37
|
+
function D(t, e, i = !0) {
|
|
38
|
+
const r = typeof t == "number" ? t : Number(t);
|
|
39
|
+
return Number.isNaN(r) || r === void 0 || r === null ? "0" : r === 0 ? 0 : i && Math.abs(r) >= C ? `${r < 0 ? "-" : ""}${d(Math.abs(r), e)}` : r.toFixed(e);
|
|
40
|
+
}
|
|
41
|
+
function W(t, e = 2) {
|
|
42
|
+
return B(t, e);
|
|
43
|
+
}
|
|
44
|
+
function w(t, e = 2) {
|
|
45
|
+
const i = Number(t) / Number(h);
|
|
46
|
+
return `${D(i, e)}%`;
|
|
30
47
|
}
|
|
31
48
|
const c = {
|
|
32
49
|
minimumFractionDigits: 2,
|
|
@@ -36,42 +53,43 @@ const c = {
|
|
|
36
53
|
minExponentialThreshold: 1e-4,
|
|
37
54
|
maxExponentialThreshold: 1e6,
|
|
38
55
|
locale: "en-US"
|
|
39
|
-
},
|
|
56
|
+
}, Y = ({
|
|
40
57
|
amount: t,
|
|
41
|
-
format:
|
|
58
|
+
format: e = "full",
|
|
42
59
|
maximumFractionDigits: i = c.maximumFractionDigits,
|
|
43
|
-
minimumFractionDigits:
|
|
44
|
-
decimalPrecision:
|
|
60
|
+
minimumFractionDigits: r = c.minimumFractionDigits,
|
|
61
|
+
decimalPrecision: f = c.decimalPrecision,
|
|
45
62
|
minDecimalThreshold: u = c.minDecimalThreshold,
|
|
46
|
-
minExponentialThreshold:
|
|
63
|
+
minExponentialThreshold: a = c.minExponentialThreshold,
|
|
47
64
|
maxExponentialThreshold: o = c.maxExponentialThreshold,
|
|
48
|
-
locale:
|
|
65
|
+
locale: l = c.locale
|
|
49
66
|
}) => {
|
|
50
|
-
const
|
|
51
|
-
if (
|
|
52
|
-
const T =
|
|
53
|
-
const
|
|
54
|
-
return `${T}${
|
|
67
|
+
const s = typeof t == "bigint" ? Number(x(t, 8)) : t, n = Math.abs(s);
|
|
68
|
+
if (e === "short") {
|
|
69
|
+
const T = s < 0 ? "-" : "", m = (p, N) => {
|
|
70
|
+
const $ = p >= 100 ? 0 : i, M = p.toFixed($).replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "");
|
|
71
|
+
return `${T}${M}${N}`;
|
|
55
72
|
};
|
|
56
|
-
if (
|
|
57
|
-
return
|
|
58
|
-
if (
|
|
59
|
-
return
|
|
60
|
-
if (
|
|
61
|
-
return
|
|
62
|
-
if (
|
|
63
|
-
return
|
|
73
|
+
if (n >= 1e9 && n <= o)
|
|
74
|
+
return m(n / 1e9, "B");
|
|
75
|
+
if (n >= 1e6 && n <= o)
|
|
76
|
+
return m(n / 1e6, "M");
|
|
77
|
+
if (n >= 1e3 && n <= o)
|
|
78
|
+
return m(n / 1e3, "K");
|
|
79
|
+
if (n > o)
|
|
80
|
+
return m(n / o, "M+");
|
|
64
81
|
}
|
|
65
|
-
return
|
|
66
|
-
minimumFractionDigits:
|
|
82
|
+
return n > o && e === "full" ? `${(s / c.maxExponentialThreshold).toFixed(r)}M` : n < a && n > 0 ? s.toFixed(Math.max(10, i)) : n < u && n > 0 ? s.toPrecision(f) : s.toLocaleString(l, {
|
|
83
|
+
minimumFractionDigits: r,
|
|
67
84
|
maximumFractionDigits: i
|
|
68
85
|
});
|
|
69
86
|
};
|
|
70
87
|
export {
|
|
71
88
|
c as DEFAULT_FORMAT_MONEY_CONSTANTS,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
W as
|
|
89
|
+
B as formatCompactPercent,
|
|
90
|
+
V as formatMoney,
|
|
91
|
+
Y as formatMoneyAmount,
|
|
92
|
+
D as formatPercentAmount,
|
|
93
|
+
W as percentTemplate,
|
|
94
|
+
w as percentageTemplate
|
|
77
95
|
};
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -4,106 +4,110 @@ import { bnToInputView as l } from "./bn-to-input-view.js";
|
|
|
4
4
|
import { bnToPrettyView as x } from "./bn-to-pretty-view.js";
|
|
5
5
|
import { bpsToPercent as c } from "./bps.js";
|
|
6
6
|
import { cn as S, cn as d } from "./cn.js";
|
|
7
|
-
import { generateColorsFromBase as h, getCSSVariable as
|
|
8
|
-
import { copyToClipboard as
|
|
9
|
-
import { convertPercent as
|
|
7
|
+
import { generateColorsFromBase as h, getCSSVariable as v, hexToRgba as P, hslToHex as b, resolveCSSColor as A } from "./colors.js";
|
|
8
|
+
import { copyToClipboard as N } from "./copy.js";
|
|
9
|
+
import { convertPercent as L, formatBytecodeSize as y, 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
11
|
import { formatLeverage as M } from "./format-leverage.js";
|
|
12
|
-
import {
|
|
13
|
-
import { FORMAT_CONSTANTS as
|
|
14
|
-
import { slippageTemplate as
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
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 j, getAdaptiveDecimals as G, isBelowDisplayThreshold as J, isEffectivelyZero as K, toSignificantDigits as Q } from "./format-number.js";
|
|
14
|
+
import { slippageTemplate as $ } from "./format-slippage.js";
|
|
15
|
+
import { formatChipLeverage as oe, leveragePresets as re } from "./leverage-presets.js";
|
|
16
|
+
import { allLoaded as ae, loadingProgress as me, round5 as ne } from "./loading.js";
|
|
17
|
+
import { decimalsToStep as pe, findClosestPoint as fe, formatWithDecimals as le, formatWithoutDecimals as se, splitInterval as xe, validateMinMax as Te } from "./math.js";
|
|
18
|
+
import { getNetworkIcon as ge } from "./network-icons.js";
|
|
19
|
+
import { bnToLiquidationPriceView as de, isPositiveFloat as ue, parseInputToBN as he, parseSmallNumber as ve } from "./parse-input-to-bn.js";
|
|
20
|
+
import { pluralize as be, selectPluralString as Ae } from "./plural.js";
|
|
21
|
+
import { getAvailableRanges as Ne } from "./ranges.js";
|
|
22
|
+
import { extractTextFromLabel as Le, serializeValue as ye } from "./react.js";
|
|
23
|
+
import { searchInString as we } from "./search.js";
|
|
24
|
+
import { createTokenSearchFilter as De, searchInToken as Oe } from "./search-in-token.js";
|
|
25
|
+
import { shortSHA as Be } from "./short-sha.js";
|
|
26
|
+
import { isLongString as Re, shortenString as _e } from "./shorten-string.js";
|
|
27
|
+
import { negativeTokenTemplate as He, tokenTemplate as We, tokenTemplateNumber as Ze, tokenTemplateString as ze } from "./templates.js";
|
|
28
|
+
import { getTokenIcon as Xe, parseShareTokenUnderlying as qe } from "./token-icon-source.js";
|
|
29
|
+
import { TTL_CONSTANTS as Ge, getTTLZones as Je, ttlFromTimestamp as Ke, ttlLeft as Qe, ttlLeftHuman as Ye } from "./ttl.js";
|
|
30
|
+
import { openInNewWindow as eo } from "./window.js";
|
|
31
|
+
import { Z_INDEX as ro, Z_INDEX_VALUES as to } from "./z-index.js";
|
|
31
32
|
export {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
X as FORMAT_CONSTANTS,
|
|
34
|
+
Ge as TTL_CONSTANTS,
|
|
35
|
+
ro as Z_INDEX,
|
|
36
|
+
to as Z_INDEX_VALUES,
|
|
37
|
+
ae as allLoaded,
|
|
37
38
|
l as bnToInputView,
|
|
38
|
-
|
|
39
|
+
de as bnToLiquidationPriceView,
|
|
39
40
|
x as bnToPrettyView,
|
|
40
41
|
c as bpsToPercent,
|
|
41
42
|
S as cn,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
L as convertPercent,
|
|
44
|
+
N as copyToClipboard,
|
|
45
|
+
De as createTokenSearchFilter,
|
|
46
|
+
pe as decimalsToStep,
|
|
46
47
|
d as default,
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
Le as extractTextFromLabel,
|
|
49
|
+
fe as findClosestPoint,
|
|
49
50
|
V as formatAssetAmount,
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
y as formatBytecodeSize,
|
|
52
|
+
C as formatBytecodeVersion,
|
|
53
|
+
oe as formatChipLeverage,
|
|
54
|
+
_ as formatCompactPercent,
|
|
52
55
|
M as formatLeverage,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
E as formatMoney,
|
|
57
|
+
H as formatMoneyAmount,
|
|
58
|
+
q as formatNumberWithSuffix,
|
|
59
|
+
W as formatPercentAmount,
|
|
60
|
+
j as formatPrice,
|
|
61
|
+
w as formatTimestamp,
|
|
62
|
+
le as formatWithDecimals,
|
|
63
|
+
se as formatWithoutDecimals,
|
|
61
64
|
h as generateColorsFromBase,
|
|
62
65
|
r as generateId,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
Z as
|
|
83
|
-
|
|
66
|
+
G as getAdaptiveDecimals,
|
|
67
|
+
Ne as getAvailableRanges,
|
|
68
|
+
v as getCSSVariable,
|
|
69
|
+
ge as getNetworkIcon,
|
|
70
|
+
Je as getTTLZones,
|
|
71
|
+
Xe as getTokenIcon,
|
|
72
|
+
P as hexToRgba,
|
|
73
|
+
b as hslToHex,
|
|
74
|
+
J as isBelowDisplayThreshold,
|
|
75
|
+
K as isEffectivelyZero,
|
|
76
|
+
Re as isLongString,
|
|
77
|
+
ue as isPositiveFloat,
|
|
78
|
+
re as leveragePresets,
|
|
79
|
+
me as loadingProgress,
|
|
80
|
+
He as negativeTokenTemplate,
|
|
81
|
+
eo as openInNewWindow,
|
|
82
|
+
he as parseInputToBN,
|
|
83
|
+
qe as parseShareTokenUnderlying,
|
|
84
|
+
ve as parseSmallNumber,
|
|
85
|
+
Z as percentTemplate,
|
|
86
|
+
z as percentageTemplate,
|
|
87
|
+
be as pluralize,
|
|
84
88
|
m as pointProgramsOf,
|
|
85
89
|
n as positiveTokenRewardsOf,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
A as resolveCSSColor,
|
|
91
|
+
ne as round5,
|
|
92
|
+
we as searchInString,
|
|
93
|
+
Oe as searchInToken,
|
|
94
|
+
Ae as selectPluralString,
|
|
95
|
+
ye as serializeValue,
|
|
96
|
+
Be as shortSHA,
|
|
93
97
|
F as shortenHash,
|
|
94
|
-
|
|
98
|
+
_e as shortenString,
|
|
95
99
|
D as significantTrunc,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
100
|
+
$ as slippageTemplate,
|
|
101
|
+
xe as splitInterval,
|
|
102
|
+
Q as toSignificantDigits,
|
|
99
103
|
i as tokenRewardsOf,
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
104
|
+
We as tokenTemplate,
|
|
105
|
+
Ze as tokenTemplateNumber,
|
|
106
|
+
ze as tokenTemplateString,
|
|
103
107
|
p as totalApyOf,
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
108
|
+
Ke as ttlFromTimestamp,
|
|
109
|
+
Qe as ttlLeft,
|
|
110
|
+
Ye as ttlLeftHuman,
|
|
107
111
|
t as useFormFieldIds,
|
|
108
|
-
|
|
112
|
+
Te as validateMinMax
|
|
109
113
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function n(e) {
|
|
2
|
+
const r = (t) => Math.round(t * 2) / 2;
|
|
3
|
+
return [
|
|
4
|
+
.../* @__PURE__ */ new Set([r(1 + 0.3 * (e - 1)), r(1 + 0.7 * (e - 1)), e])
|
|
5
|
+
];
|
|
6
|
+
}
|
|
7
|
+
function o(e) {
|
|
8
|
+
return e.toFixed(2).replace(/\.?0+$/, "");
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
o as formatChipLeverage,
|
|
12
|
+
n as leveragePresets
|
|
13
|
+
};
|