@compass-labs/widgets 0.1.33 → 0.1.34
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/index.d.mts +15 -2
- package/dist/index.d.ts +15 -2
- package/dist/index.js +170 -85
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +171 -87
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -703,6 +703,18 @@ declare function useEarnAccount(): EarnAccountContextValue;
|
|
|
703
703
|
|
|
704
704
|
declare function ChainSwitcher(): react_jsx_runtime.JSX.Element;
|
|
705
705
|
|
|
706
|
+
interface CopyableAddressProps {
|
|
707
|
+
/** The full address to copy */
|
|
708
|
+
address: string;
|
|
709
|
+
/** Label shown above the address (e.g., "Wallet", "Product Account") */
|
|
710
|
+
label?: string;
|
|
711
|
+
/** Show truncated address (default: true) */
|
|
712
|
+
truncate?: boolean;
|
|
713
|
+
/** Text size class (default: 'text-xs') */
|
|
714
|
+
textSize?: string;
|
|
715
|
+
}
|
|
716
|
+
declare function CopyableAddress({ address, label, truncate, textSize, }: CopyableAddressProps): react_jsx_runtime.JSX.Element;
|
|
717
|
+
|
|
706
718
|
interface WalletStatusProps {
|
|
707
719
|
/** Show full address or truncated */
|
|
708
720
|
showFullAddress?: boolean;
|
|
@@ -812,8 +824,9 @@ interface AccountBalancesModalProps {
|
|
|
812
824
|
totalUsdValue: string;
|
|
813
825
|
isLoading?: boolean;
|
|
814
826
|
earnAccountAddress?: string;
|
|
827
|
+
walletAddress?: string;
|
|
815
828
|
}
|
|
816
|
-
declare function AccountBalancesModal({ isOpen, onClose, balances, totalUsdValue, isLoading, }: AccountBalancesModalProps): react_jsx_runtime.JSX.Element;
|
|
829
|
+
declare function AccountBalancesModal({ isOpen, onClose, balances, totalUsdValue, isLoading, earnAccountAddress, walletAddress, }: AccountBalancesModalProps): react_jsx_runtime.JSX.Element;
|
|
817
830
|
|
|
818
831
|
interface SwapFormProps {
|
|
819
832
|
/** Tokens the user holds (shown in "from" dropdown) */
|
|
@@ -843,4 +856,4 @@ interface ChainConfig {
|
|
|
843
856
|
}
|
|
844
857
|
declare const CHAINS: Record<SupportedChainId, ChainConfig>;
|
|
845
858
|
|
|
846
|
-
export { AccountBalancesModal, type AccountBalancesModalProps, ActionModal, ApiProvider, CHAINS, type ChainConfig, ChainSwitcher, CompassEarnWidget, type CompassEarnWidgetProps, CompassProvider, type CompassProviderProps, type CompassTheme, DepositWithdrawForm, EarnAccount, EarnAccountBalance, type EarnAccountBalanceProps, type EarnAccountContextValue, EarnAccountGuard, type EarnAccountProps, type FeaturePreset, type IdleBalance, PnLSummary, type PortfolioPosition, type PortfolioState, type RebalanceAction, type RebalanceActionType, type RebalancePlan, RebalancingWidget, type RebalancingWidgetProps, type SupportedChain, type SupportedChainId, SwapForm, type SwapFormProps, type SwapQuote, type TabConfig, type TabId, type TargetAllocation, type ThemeInput, type ThemeMode, type ThemePresetName, ThemeProvider, type TokenBalance, TransactionHistory, type TypedDataToSign, type VenueType$1 as VenueType, type WalletAdapter, WalletStatus, themePresets, useChain, useCompassApi, useCompassChain, useCompassWallet, useEarnAccount, useEmbeddableApi, useEmbeddableWallet, useRebalancingData, useSwapQuote, useTheme };
|
|
859
|
+
export { AccountBalancesModal, type AccountBalancesModalProps, ActionModal, ApiProvider, CHAINS, type ChainConfig, ChainSwitcher, CompassEarnWidget, type CompassEarnWidgetProps, CompassProvider, type CompassProviderProps, type CompassTheme, CopyableAddress, type CopyableAddressProps, DepositWithdrawForm, EarnAccount, EarnAccountBalance, type EarnAccountBalanceProps, type EarnAccountContextValue, EarnAccountGuard, type EarnAccountProps, type FeaturePreset, type IdleBalance, PnLSummary, type PortfolioPosition, type PortfolioState, type RebalanceAction, type RebalanceActionType, type RebalancePlan, RebalancingWidget, type RebalancingWidgetProps, type SupportedChain, type SupportedChainId, SwapForm, type SwapFormProps, type SwapQuote, type TabConfig, type TabId, type TargetAllocation, type ThemeInput, type ThemeMode, type ThemePresetName, ThemeProvider, type TokenBalance, TransactionHistory, type TypedDataToSign, type VenueType$1 as VenueType, type WalletAdapter, WalletStatus, themePresets, useChain, useCompassApi, useCompassChain, useCompassWallet, useEarnAccount, useEmbeddableApi, useEmbeddableWallet, useRebalancingData, useSwapQuote, useTheme };
|
package/dist/index.d.ts
CHANGED
|
@@ -703,6 +703,18 @@ declare function useEarnAccount(): EarnAccountContextValue;
|
|
|
703
703
|
|
|
704
704
|
declare function ChainSwitcher(): react_jsx_runtime.JSX.Element;
|
|
705
705
|
|
|
706
|
+
interface CopyableAddressProps {
|
|
707
|
+
/** The full address to copy */
|
|
708
|
+
address: string;
|
|
709
|
+
/** Label shown above the address (e.g., "Wallet", "Product Account") */
|
|
710
|
+
label?: string;
|
|
711
|
+
/** Show truncated address (default: true) */
|
|
712
|
+
truncate?: boolean;
|
|
713
|
+
/** Text size class (default: 'text-xs') */
|
|
714
|
+
textSize?: string;
|
|
715
|
+
}
|
|
716
|
+
declare function CopyableAddress({ address, label, truncate, textSize, }: CopyableAddressProps): react_jsx_runtime.JSX.Element;
|
|
717
|
+
|
|
706
718
|
interface WalletStatusProps {
|
|
707
719
|
/** Show full address or truncated */
|
|
708
720
|
showFullAddress?: boolean;
|
|
@@ -812,8 +824,9 @@ interface AccountBalancesModalProps {
|
|
|
812
824
|
totalUsdValue: string;
|
|
813
825
|
isLoading?: boolean;
|
|
814
826
|
earnAccountAddress?: string;
|
|
827
|
+
walletAddress?: string;
|
|
815
828
|
}
|
|
816
|
-
declare function AccountBalancesModal({ isOpen, onClose, balances, totalUsdValue, isLoading, }: AccountBalancesModalProps): react_jsx_runtime.JSX.Element;
|
|
829
|
+
declare function AccountBalancesModal({ isOpen, onClose, balances, totalUsdValue, isLoading, earnAccountAddress, walletAddress, }: AccountBalancesModalProps): react_jsx_runtime.JSX.Element;
|
|
817
830
|
|
|
818
831
|
interface SwapFormProps {
|
|
819
832
|
/** Tokens the user holds (shown in "from" dropdown) */
|
|
@@ -843,4 +856,4 @@ interface ChainConfig {
|
|
|
843
856
|
}
|
|
844
857
|
declare const CHAINS: Record<SupportedChainId, ChainConfig>;
|
|
845
858
|
|
|
846
|
-
export { AccountBalancesModal, type AccountBalancesModalProps, ActionModal, ApiProvider, CHAINS, type ChainConfig, ChainSwitcher, CompassEarnWidget, type CompassEarnWidgetProps, CompassProvider, type CompassProviderProps, type CompassTheme, DepositWithdrawForm, EarnAccount, EarnAccountBalance, type EarnAccountBalanceProps, type EarnAccountContextValue, EarnAccountGuard, type EarnAccountProps, type FeaturePreset, type IdleBalance, PnLSummary, type PortfolioPosition, type PortfolioState, type RebalanceAction, type RebalanceActionType, type RebalancePlan, RebalancingWidget, type RebalancingWidgetProps, type SupportedChain, type SupportedChainId, SwapForm, type SwapFormProps, type SwapQuote, type TabConfig, type TabId, type TargetAllocation, type ThemeInput, type ThemeMode, type ThemePresetName, ThemeProvider, type TokenBalance, TransactionHistory, type TypedDataToSign, type VenueType$1 as VenueType, type WalletAdapter, WalletStatus, themePresets, useChain, useCompassApi, useCompassChain, useCompassWallet, useEarnAccount, useEmbeddableApi, useEmbeddableWallet, useRebalancingData, useSwapQuote, useTheme };
|
|
859
|
+
export { AccountBalancesModal, type AccountBalancesModalProps, ActionModal, ApiProvider, CHAINS, type ChainConfig, ChainSwitcher, CompassEarnWidget, type CompassEarnWidgetProps, CompassProvider, type CompassProviderProps, type CompassTheme, CopyableAddress, type CopyableAddressProps, DepositWithdrawForm, EarnAccount, EarnAccountBalance, type EarnAccountBalanceProps, type EarnAccountContextValue, EarnAccountGuard, type EarnAccountProps, type FeaturePreset, type IdleBalance, PnLSummary, type PortfolioPosition, type PortfolioState, type RebalanceAction, type RebalanceActionType, type RebalancePlan, RebalancingWidget, type RebalancingWidgetProps, type SupportedChain, type SupportedChainId, SwapForm, type SwapFormProps, type SwapQuote, type TabConfig, type TabId, type TargetAllocation, type ThemeInput, type ThemeMode, type ThemePresetName, ThemeProvider, type TokenBalance, TransactionHistory, type TypedDataToSign, type VenueType$1 as VenueType, type WalletAdapter, WalletStatus, themePresets, useChain, useCompassApi, useCompassChain, useCompassWallet, useEarnAccount, useEmbeddableApi, useEmbeddableWallet, useRebalancingData, useSwapQuote, useTheme };
|
package/dist/index.js
CHANGED
|
@@ -992,9 +992,52 @@ function ChainSwitcher() {
|
|
|
992
992
|
}
|
|
993
993
|
);
|
|
994
994
|
}
|
|
995
|
-
function
|
|
995
|
+
function truncateAddr(address) {
|
|
996
996
|
return `${address.slice(0, 6)}...${address.slice(-4)}`;
|
|
997
997
|
}
|
|
998
|
+
function CopyableAddress({
|
|
999
|
+
address,
|
|
1000
|
+
label,
|
|
1001
|
+
truncate = true,
|
|
1002
|
+
textSize = "text-xs"
|
|
1003
|
+
}) {
|
|
1004
|
+
const [copied, setCopied] = react.useState(false);
|
|
1005
|
+
const handleCopy = react.useCallback(() => {
|
|
1006
|
+
navigator.clipboard.writeText(address);
|
|
1007
|
+
setCopied(true);
|
|
1008
|
+
setTimeout(() => setCopied(false), 1500);
|
|
1009
|
+
}, [address]);
|
|
1010
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", style: { gap: "2px" }, children: [
|
|
1011
|
+
label && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1012
|
+
"span",
|
|
1013
|
+
{
|
|
1014
|
+
className: "text-xs",
|
|
1015
|
+
style: { color: "var(--compass-color-text-tertiary)", fontSize: "10px" },
|
|
1016
|
+
children: label
|
|
1017
|
+
}
|
|
1018
|
+
),
|
|
1019
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1020
|
+
"button",
|
|
1021
|
+
{
|
|
1022
|
+
onClick: handleCopy,
|
|
1023
|
+
className: `inline-flex items-center font-mono ${textSize}`,
|
|
1024
|
+
style: {
|
|
1025
|
+
color: "var(--compass-color-text-secondary)",
|
|
1026
|
+
background: "none",
|
|
1027
|
+
border: "none",
|
|
1028
|
+
cursor: "pointer",
|
|
1029
|
+
padding: 0,
|
|
1030
|
+
gap: "4px"
|
|
1031
|
+
},
|
|
1032
|
+
title: copied ? "Copied!" : `Copy: ${address}`,
|
|
1033
|
+
children: [
|
|
1034
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: truncate ? truncateAddr(address) : address }),
|
|
1035
|
+
copied ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { size: 10, className: "flex-shrink-0", style: { color: "var(--compass-color-success)" } }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Copy, { size: 10, className: "flex-shrink-0", style: { color: "var(--compass-color-text-tertiary)" } })
|
|
1036
|
+
]
|
|
1037
|
+
}
|
|
1038
|
+
)
|
|
1039
|
+
] });
|
|
1040
|
+
}
|
|
998
1041
|
function WalletStatus({
|
|
999
1042
|
showFullAddress = false,
|
|
1000
1043
|
showLogout = true,
|
|
@@ -1071,11 +1114,11 @@ function WalletStatus({
|
|
|
1071
1114
|
}
|
|
1072
1115
|
),
|
|
1073
1116
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1074
|
-
|
|
1117
|
+
CopyableAddress,
|
|
1075
1118
|
{
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1119
|
+
address,
|
|
1120
|
+
truncate: !showFullAddress,
|
|
1121
|
+
textSize: compact ? "text-xs" : "text-sm"
|
|
1079
1122
|
}
|
|
1080
1123
|
),
|
|
1081
1124
|
showLogout && disconnectFn !== null && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2239,82 +2282,97 @@ function AccountBalancesModal({
|
|
|
2239
2282
|
onClose,
|
|
2240
2283
|
balances,
|
|
2241
2284
|
totalUsdValue,
|
|
2242
|
-
isLoading = false
|
|
2285
|
+
isLoading = false,
|
|
2286
|
+
earnAccountAddress,
|
|
2287
|
+
walletAddress
|
|
2243
2288
|
}) {
|
|
2244
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ActionModal, { isOpen, onClose, title: "Balance Breakdown", children: /* @__PURE__ */ jsxRuntime.
|
|
2245
|
-
|
|
2246
|
-
{
|
|
2247
|
-
size: 24,
|
|
2248
|
-
className: "animate-spin",
|
|
2249
|
-
style: { color: "var(--compass-color-primary)" }
|
|
2250
|
-
}
|
|
2251
|
-
) }) : balances.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2252
|
-
"div",
|
|
2253
|
-
{
|
|
2254
|
-
className: "text-center py-4",
|
|
2255
|
-
style: { color: "var(--compass-color-text-tertiary)" },
|
|
2256
|
-
children: "No tokens in account"
|
|
2257
|
-
}
|
|
2258
|
-
) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2259
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
2260
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2261
|
-
"span",
|
|
2262
|
-
{
|
|
2263
|
-
className: "text-xs font-medium uppercase tracking-wide",
|
|
2264
|
-
style: { color: "var(--compass-color-text-tertiary)" },
|
|
2265
|
-
children: "Available in Account"
|
|
2266
|
-
}
|
|
2267
|
-
),
|
|
2268
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2269
|
-
"div",
|
|
2270
|
-
{
|
|
2271
|
-
className: "flex flex-col gap-2",
|
|
2272
|
-
style: {
|
|
2273
|
-
maxHeight: "50vh",
|
|
2274
|
-
overflowY: "auto",
|
|
2275
|
-
scrollbarWidth: "none"
|
|
2276
|
-
},
|
|
2277
|
-
children: balances.map((token) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2278
|
-
"div",
|
|
2279
|
-
{
|
|
2280
|
-
className: "flex items-center justify-between p-3 rounded-lg",
|
|
2281
|
-
style: {
|
|
2282
|
-
backgroundColor: "var(--compass-color-surface)",
|
|
2283
|
-
border: "1px solid var(--compass-color-border)",
|
|
2284
|
-
flexShrink: 0
|
|
2285
|
-
},
|
|
2286
|
-
children: [
|
|
2287
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", style: { color: "var(--compass-color-text)" }, children: token.symbol }),
|
|
2288
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-end", children: [
|
|
2289
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono font-medium", style: { color: "var(--compass-color-text)" }, children: formatAmount(token.balance) }),
|
|
2290
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs", style: { color: "var(--compass-color-text-tertiary)" }, children: formatUSD(token.usdValue) })
|
|
2291
|
-
] })
|
|
2292
|
-
]
|
|
2293
|
-
},
|
|
2294
|
-
token.symbol
|
|
2295
|
-
))
|
|
2296
|
-
}
|
|
2297
|
-
)
|
|
2298
|
-
] }),
|
|
2299
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2289
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ActionModal, { isOpen, onClose, title: "Balance Breakdown", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
2290
|
+
(walletAddress || earnAccountAddress) && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2300
2291
|
"div",
|
|
2301
2292
|
{
|
|
2302
|
-
className: "flex
|
|
2303
|
-
style: {
|
|
2293
|
+
className: "flex flex-col gap-2 pb-3",
|
|
2294
|
+
style: { borderBottom: "1px solid var(--compass-color-border)" },
|
|
2304
2295
|
children: [
|
|
2305
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2306
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2307
|
-
"span",
|
|
2308
|
-
{
|
|
2309
|
-
className: "font-bold text-xl",
|
|
2310
|
-
style: { color: "var(--compass-color-text)" },
|
|
2311
|
-
children: formatUSD(totalUsdValue)
|
|
2312
|
-
}
|
|
2313
|
-
)
|
|
2296
|
+
walletAddress && /* @__PURE__ */ jsxRuntime.jsx(CopyableAddress, { address: walletAddress, label: "Wallet" }),
|
|
2297
|
+
earnAccountAddress && /* @__PURE__ */ jsxRuntime.jsx(CopyableAddress, { address: earnAccountAddress, label: "Product Account" })
|
|
2314
2298
|
]
|
|
2315
2299
|
}
|
|
2316
|
-
)
|
|
2317
|
-
|
|
2300
|
+
),
|
|
2301
|
+
isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2302
|
+
lucideReact.Loader2,
|
|
2303
|
+
{
|
|
2304
|
+
size: 24,
|
|
2305
|
+
className: "animate-spin",
|
|
2306
|
+
style: { color: "var(--compass-color-primary)" }
|
|
2307
|
+
}
|
|
2308
|
+
) }) : balances.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2309
|
+
"div",
|
|
2310
|
+
{
|
|
2311
|
+
className: "text-center py-4",
|
|
2312
|
+
style: { color: "var(--compass-color-text-tertiary)" },
|
|
2313
|
+
children: "No tokens in account"
|
|
2314
|
+
}
|
|
2315
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2316
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
2317
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2318
|
+
"span",
|
|
2319
|
+
{
|
|
2320
|
+
className: "text-xs font-medium uppercase tracking-wide",
|
|
2321
|
+
style: { color: "var(--compass-color-text-tertiary)" },
|
|
2322
|
+
children: "Available in Account"
|
|
2323
|
+
}
|
|
2324
|
+
),
|
|
2325
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2326
|
+
"div",
|
|
2327
|
+
{
|
|
2328
|
+
className: "flex flex-col gap-2",
|
|
2329
|
+
style: {
|
|
2330
|
+
maxHeight: "50vh",
|
|
2331
|
+
overflowY: "auto",
|
|
2332
|
+
scrollbarWidth: "none"
|
|
2333
|
+
},
|
|
2334
|
+
children: balances.map((token) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2335
|
+
"div",
|
|
2336
|
+
{
|
|
2337
|
+
className: "flex items-center justify-between p-3 rounded-lg",
|
|
2338
|
+
style: {
|
|
2339
|
+
backgroundColor: "var(--compass-color-surface)",
|
|
2340
|
+
border: "1px solid var(--compass-color-border)",
|
|
2341
|
+
flexShrink: 0
|
|
2342
|
+
},
|
|
2343
|
+
children: [
|
|
2344
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", style: { color: "var(--compass-color-text)" }, children: token.symbol }),
|
|
2345
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-end", children: [
|
|
2346
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono font-medium", style: { color: "var(--compass-color-text)" }, children: formatAmount(token.balance) }),
|
|
2347
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs", style: { color: "var(--compass-color-text-tertiary)" }, children: formatUSD(token.usdValue) })
|
|
2348
|
+
] })
|
|
2349
|
+
]
|
|
2350
|
+
},
|
|
2351
|
+
token.symbol
|
|
2352
|
+
))
|
|
2353
|
+
}
|
|
2354
|
+
)
|
|
2355
|
+
] }),
|
|
2356
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2357
|
+
"div",
|
|
2358
|
+
{
|
|
2359
|
+
className: "flex items-center justify-between pt-3 mt-2",
|
|
2360
|
+
style: { borderTop: "2px solid var(--compass-color-border)" },
|
|
2361
|
+
children: [
|
|
2362
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-semibold", style: { color: "var(--compass-color-text)" }, children: "Total" }),
|
|
2363
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2364
|
+
"span",
|
|
2365
|
+
{
|
|
2366
|
+
className: "font-bold text-xl",
|
|
2367
|
+
style: { color: "var(--compass-color-text)" },
|
|
2368
|
+
children: formatUSD(totalUsdValue)
|
|
2369
|
+
}
|
|
2370
|
+
)
|
|
2371
|
+
]
|
|
2372
|
+
}
|
|
2373
|
+
)
|
|
2374
|
+
] })
|
|
2375
|
+
] }) });
|
|
2318
2376
|
}
|
|
2319
2377
|
var TRANSFER_TOKENS = ["USDC", "SBC"];
|
|
2320
2378
|
var EarnAccountBalance = react.forwardRef(function EarnAccountBalance2({
|
|
@@ -2634,7 +2692,8 @@ var EarnAccountBalance = react.forwardRef(function EarnAccountBalance2({
|
|
|
2634
2692
|
balances: tokenBalances,
|
|
2635
2693
|
totalUsdValue: totalUsdValue.toString(),
|
|
2636
2694
|
isLoading: balancesLoading,
|
|
2637
|
-
earnAccountAddress: earnAccountAddress ?? void 0
|
|
2695
|
+
earnAccountAddress: earnAccountAddress ?? void 0,
|
|
2696
|
+
walletAddress: address ?? void 0
|
|
2638
2697
|
}
|
|
2639
2698
|
),
|
|
2640
2699
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -6829,6 +6888,7 @@ function PortfolioBalanceCard({
|
|
|
6829
6888
|
totalIdleUsd,
|
|
6830
6889
|
idleBalances,
|
|
6831
6890
|
earnAccountAddress,
|
|
6891
|
+
walletAddress,
|
|
6832
6892
|
onViewPositions,
|
|
6833
6893
|
positionCount,
|
|
6834
6894
|
totalEarned = 0,
|
|
@@ -7000,7 +7060,8 @@ function PortfolioBalanceCard({
|
|
|
7000
7060
|
onClose: () => setShowBalancesModal(false),
|
|
7001
7061
|
balances: tokenBalances,
|
|
7002
7062
|
totalUsdValue: totalIdleUsd.toString(),
|
|
7003
|
-
earnAccountAddress
|
|
7063
|
+
earnAccountAddress,
|
|
7064
|
+
walletAddress
|
|
7004
7065
|
}
|
|
7005
7066
|
)
|
|
7006
7067
|
] });
|
|
@@ -7026,10 +7087,11 @@ function formatPercent(value) {
|
|
|
7026
7087
|
function PercentInput({ value, onChange }) {
|
|
7027
7088
|
const [localValue, setLocalValue] = react.useState(value.toString());
|
|
7028
7089
|
const [isFocused, setIsFocused] = react.useState(false);
|
|
7029
|
-
|
|
7090
|
+
const roundedStr = parseFloat(value.toFixed(2)).toString();
|
|
7091
|
+
if (!isFocused && localValue !== roundedStr) {
|
|
7030
7092
|
const parsed = parseFloat(localValue);
|
|
7031
7093
|
if (isNaN(parsed) || Math.abs(parsed - value) > 1e-3) {
|
|
7032
|
-
setLocalValue(
|
|
7094
|
+
setLocalValue(roundedStr);
|
|
7033
7095
|
}
|
|
7034
7096
|
}
|
|
7035
7097
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -7040,7 +7102,7 @@ function PercentInput({ value, onChange }) {
|
|
|
7040
7102
|
value: isFocused ? localValue : formatPercent(value).replace("%", ""),
|
|
7041
7103
|
onFocus: () => {
|
|
7042
7104
|
setIsFocused(true);
|
|
7043
|
-
setLocalValue(value.toString());
|
|
7105
|
+
setLocalValue(parseFloat(value.toFixed(2)).toString());
|
|
7044
7106
|
},
|
|
7045
7107
|
onChange: (e) => {
|
|
7046
7108
|
const raw = e.target.value;
|
|
@@ -7164,7 +7226,7 @@ function AllocationEditor({
|
|
|
7164
7226
|
currentPos && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
7165
7227
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-mono", style: { color: "var(--compass-color-text-secondary)", fontSize: "10px" }, children: formatUSD(currentPos.usdValue) }),
|
|
7166
7228
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: { color: "var(--compass-color-success)", fontSize: "10px" }, children: [
|
|
7167
|
-
currentPos.apy.toFixed(
|
|
7229
|
+
currentPos.apy.toFixed(2),
|
|
7168
7230
|
"%"
|
|
7169
7231
|
] })
|
|
7170
7232
|
] }),
|
|
@@ -7294,6 +7356,7 @@ function RebalancingWidget({
|
|
|
7294
7356
|
const { chainId: contextChainId, setChainId } = useChain();
|
|
7295
7357
|
const CHAIN_ID = chain || contextChainId;
|
|
7296
7358
|
const { address, signTypedData, isConnected, login, switchChain, walletChainId } = useEmbeddableWallet();
|
|
7359
|
+
const { earnAccountAddress } = useEarnAccount();
|
|
7297
7360
|
const queryClient = reactQuery.useQueryClient();
|
|
7298
7361
|
const { portfolio, earnAccountMarkets, isMarketsLoading, isLoading, isError, error, refetch } = useRebalancingData(chain);
|
|
7299
7362
|
const allowedVariableMarketIds = react.useMemo(() => {
|
|
@@ -7366,7 +7429,7 @@ function RebalancingWidget({
|
|
|
7366
7429
|
venueAddress: p.venueAddress,
|
|
7367
7430
|
venueName: p.venueName,
|
|
7368
7431
|
token: p.token,
|
|
7369
|
-
targetPercent: p.allocationPercent
|
|
7432
|
+
targetPercent: parseFloat(p.allocationPercent.toFixed(2))
|
|
7370
7433
|
}))
|
|
7371
7434
|
);
|
|
7372
7435
|
setHasInitializedTargets(true);
|
|
@@ -7406,7 +7469,7 @@ function RebalancingWidget({
|
|
|
7406
7469
|
venueAddress: p.venueAddress,
|
|
7407
7470
|
venueName: p.venueName,
|
|
7408
7471
|
token: p.token,
|
|
7409
|
-
targetPercent: p.allocationPercent
|
|
7472
|
+
targetPercent: parseFloat(p.allocationPercent.toFixed(2))
|
|
7410
7473
|
}))
|
|
7411
7474
|
);
|
|
7412
7475
|
setPreviewPlan(null);
|
|
@@ -7422,7 +7485,8 @@ function RebalancingWidget({
|
|
|
7422
7485
|
setTargets((prev) => prev.filter((_, i) => i !== index));
|
|
7423
7486
|
}, []);
|
|
7424
7487
|
const handleUpdatePercent = react.useCallback((index, value) => {
|
|
7425
|
-
|
|
7488
|
+
const rounded = parseFloat(Math.max(0, Math.min(100, value)).toFixed(2));
|
|
7489
|
+
setTargets((prev) => prev.map((t, i) => i === index ? { ...t, targetPercent: rounded } : t));
|
|
7426
7490
|
}, []);
|
|
7427
7491
|
const ensureCorrectChain = react.useCallback(async () => {
|
|
7428
7492
|
const targetChainId = EVM_CHAIN_IDS2[CHAIN_ID];
|
|
@@ -7847,6 +7911,8 @@ function RebalancingWidget({
|
|
|
7847
7911
|
totalUsd: portfolio.totalUsd,
|
|
7848
7912
|
totalIdleUsd: portfolio.totalIdleUsd,
|
|
7849
7913
|
idleBalances: portfolio.idleBalances,
|
|
7914
|
+
earnAccountAddress: earnAccountAddress ?? void 0,
|
|
7915
|
+
walletAddress: address ?? void 0,
|
|
7850
7916
|
onViewPositions: () => setIsEarningsModalOpen(true),
|
|
7851
7917
|
positionCount: portfolio.positions.length,
|
|
7852
7918
|
totalEarned,
|
|
@@ -8153,7 +8219,25 @@ function RebalancingWidget({
|
|
|
8153
8219
|
children: [
|
|
8154
8220
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { size: 24, className: "mx-auto mb-2", style: { color: "var(--compass-color-success)" } }),
|
|
8155
8221
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-semibold mb-1", style: { color: "var(--compass-color-success)" }, children: "Rebalance Complete" }),
|
|
8156
|
-
/* @__PURE__ */ jsxRuntime.
|
|
8222
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
8223
|
+
"button",
|
|
8224
|
+
{
|
|
8225
|
+
onClick: () => navigator.clipboard.writeText(txHash),
|
|
8226
|
+
className: "inline-flex items-center justify-center gap-1.5 text-xs font-mono break-all mx-auto",
|
|
8227
|
+
style: {
|
|
8228
|
+
color: "var(--compass-color-text-secondary)",
|
|
8229
|
+
background: "none",
|
|
8230
|
+
border: "none",
|
|
8231
|
+
cursor: "pointer",
|
|
8232
|
+
padding: 0
|
|
8233
|
+
},
|
|
8234
|
+
title: "Copy transaction hash",
|
|
8235
|
+
children: [
|
|
8236
|
+
txHash,
|
|
8237
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Copy, { size: 12, className: "flex-shrink-0", style: { color: "var(--compass-color-text-tertiary)" } })
|
|
8238
|
+
]
|
|
8239
|
+
}
|
|
8240
|
+
)
|
|
8157
8241
|
]
|
|
8158
8242
|
}
|
|
8159
8243
|
),
|
|
@@ -8505,6 +8589,7 @@ exports.CHAINS = CHAINS;
|
|
|
8505
8589
|
exports.ChainSwitcher = ChainSwitcher;
|
|
8506
8590
|
exports.CompassEarnWidget = CompassEarnWidget;
|
|
8507
8591
|
exports.CompassProvider = CompassProvider;
|
|
8592
|
+
exports.CopyableAddress = CopyableAddress;
|
|
8508
8593
|
exports.DepositWithdrawForm = DepositWithdrawForm;
|
|
8509
8594
|
exports.EarnAccount = EarnAccount;
|
|
8510
8595
|
exports.EarnAccountBalance = EarnAccountBalance;
|