@compass-labs/widgets 0.1.47 → 0.1.49

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 CHANGED
@@ -478,12 +478,14 @@ interface EarnAccountProps {
478
478
  chain?: string;
479
479
  /** Fixed height for the widget container @default '600px' */
480
480
  height?: string;
481
+ /** Minimum TVL in USD for vault filtering (server-side). @default 1_000_000 */
482
+ minTvlUsd?: number;
481
483
  }
482
484
 
483
485
  /**
484
486
  * EarnAccount widget - A beautiful banking-style USDC savings account.
485
487
  */
486
- declare function EarnAccount({ showHeader, showInterestRate, showTopUpButton, compact, title, onDeposit, onWithdraw, defaultMarketTab, allowedVariableMarkets, allowedFixedMarkets, tokenSymbols, chain: chainProp, height, }: EarnAccountProps): react_jsx_runtime.JSX.Element;
488
+ declare function EarnAccount({ showHeader, showInterestRate, showTopUpButton, compact, title, onDeposit, onWithdraw, defaultMarketTab, allowedVariableMarkets, allowedFixedMarkets, tokenSymbols, chain: chainProp, height, minTvlUsd, }: EarnAccountProps): react_jsx_runtime.JSX.Element;
487
489
 
488
490
  interface CreditAccountProps {
489
491
  /** Custom title for the header @default "Credit Account" */
@@ -658,6 +660,12 @@ declare function useSwapQuote({ fromToken, toToken, amount, enabled }: UseSwapQu
658
660
  refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<SwapQuote | null, Error>>;
659
661
  };
660
662
 
663
+ declare function useRefreshBalances(): {
664
+ refreshBalances: () => void;
665
+ refreshPositions: () => void;
666
+ refreshAll: () => void;
667
+ };
668
+
661
669
  /**
662
670
  * Theme Presets for Compass Embeddable Widgets
663
671
  *
@@ -1014,4 +1022,4 @@ interface ChainConfig {
1014
1022
  }
1015
1023
  declare const CHAINS: Record<SupportedChainId, ChainConfig>;
1016
1024
 
1017
- export { AccountBalancesModal, type AccountBalancesModalProps, type AccountSummary, ActionModal, ApiProvider, CHAINS, type ChainConfig, ChainSwitcher, type CollateralPosition, CompassEarnWidget, type CompassEarnWidgetProps, CompassProvider, type CompassProviderProps, type CompassTheme, CopyableAddress, type CopyableAddressProps, CreditAccount, type CreditAccountContextValue, CreditAccountGuard, type CreditAccountProps, type CreditPositionsResponse, type TokenBalance as CreditTokenBalance, type DebtPosition, DepositWithdrawForm, EarnAccount, EarnAccountBalance, type EarnAccountBalanceProps, type EarnAccountContextValue, EarnAccountGuard, type EarnAccountProps, type FeaturePreset, type FundWalletParams, type IdleBalance, PnLSummary, type PortfolioPosition, type PortfolioState, type RebalanceAction, type RebalanceActionType, type RebalancePlan, RebalancingWidget, type RebalancingWidgetProps, type SendTransactionParams, type SupportedChain, type SupportedChainId, SwapForm, type SwapFormProps, type SwapQuote, type TabConfig, type TabId, type TargetAllocation, type ThemeInput, type ThemeMode, type ThemePresetName, ThemeProvider, type TokenBalance$1 as TokenBalance, TransactionHistory, type TypedDataToSign, type VenueType$1 as VenueType, type WalletAdapter, WalletStatus, themePresets, useChain, useCompassApi, useCompassChain, useCompassWallet, useCreditAccount, useEarnAccount, useEmbeddableApi, useEmbeddableWallet, useRebalancingData, useSwapQuote, useTheme };
1025
+ export { AccountBalancesModal, type AccountBalancesModalProps, type AccountSummary, ActionModal, ApiProvider, CHAINS, type ChainConfig, ChainSwitcher, type CollateralPosition, CompassEarnWidget, type CompassEarnWidgetProps, CompassProvider, type CompassProviderProps, type CompassTheme, CopyableAddress, type CopyableAddressProps, CreditAccount, type CreditAccountContextValue, CreditAccountGuard, type CreditAccountProps, type CreditPositionsResponse, type TokenBalance as CreditTokenBalance, type DebtPosition, DepositWithdrawForm, EarnAccount, EarnAccountBalance, type EarnAccountBalanceProps, type EarnAccountContextValue, EarnAccountGuard, type EarnAccountProps, type FeaturePreset, type FundWalletParams, type IdleBalance, PnLSummary, type PortfolioPosition, type PortfolioState, type RebalanceAction, type RebalanceActionType, type RebalancePlan, RebalancingWidget, type RebalancingWidgetProps, type SendTransactionParams, type SupportedChain, type SupportedChainId, SwapForm, type SwapFormProps, type SwapQuote, type TabConfig, type TabId, type TargetAllocation, type ThemeInput, type ThemeMode, type ThemePresetName, ThemeProvider, type TokenBalance$1 as TokenBalance, TransactionHistory, type TypedDataToSign, type VenueType$1 as VenueType, type WalletAdapter, WalletStatus, themePresets, useChain, useCompassApi, useCompassChain, useCompassWallet, useCreditAccount, useEarnAccount, useEmbeddableApi, useEmbeddableWallet, useRebalancingData, useRefreshBalances, useSwapQuote, useTheme };
package/dist/index.d.ts CHANGED
@@ -478,12 +478,14 @@ interface EarnAccountProps {
478
478
  chain?: string;
479
479
  /** Fixed height for the widget container @default '600px' */
480
480
  height?: string;
481
+ /** Minimum TVL in USD for vault filtering (server-side). @default 1_000_000 */
482
+ minTvlUsd?: number;
481
483
  }
482
484
 
483
485
  /**
484
486
  * EarnAccount widget - A beautiful banking-style USDC savings account.
485
487
  */
486
- declare function EarnAccount({ showHeader, showInterestRate, showTopUpButton, compact, title, onDeposit, onWithdraw, defaultMarketTab, allowedVariableMarkets, allowedFixedMarkets, tokenSymbols, chain: chainProp, height, }: EarnAccountProps): react_jsx_runtime.JSX.Element;
488
+ declare function EarnAccount({ showHeader, showInterestRate, showTopUpButton, compact, title, onDeposit, onWithdraw, defaultMarketTab, allowedVariableMarkets, allowedFixedMarkets, tokenSymbols, chain: chainProp, height, minTvlUsd, }: EarnAccountProps): react_jsx_runtime.JSX.Element;
487
489
 
488
490
  interface CreditAccountProps {
489
491
  /** Custom title for the header @default "Credit Account" */
@@ -658,6 +660,12 @@ declare function useSwapQuote({ fromToken, toToken, amount, enabled }: UseSwapQu
658
660
  refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<SwapQuote | null, Error>>;
659
661
  };
660
662
 
663
+ declare function useRefreshBalances(): {
664
+ refreshBalances: () => void;
665
+ refreshPositions: () => void;
666
+ refreshAll: () => void;
667
+ };
668
+
661
669
  /**
662
670
  * Theme Presets for Compass Embeddable Widgets
663
671
  *
@@ -1014,4 +1022,4 @@ interface ChainConfig {
1014
1022
  }
1015
1023
  declare const CHAINS: Record<SupportedChainId, ChainConfig>;
1016
1024
 
1017
- export { AccountBalancesModal, type AccountBalancesModalProps, type AccountSummary, ActionModal, ApiProvider, CHAINS, type ChainConfig, ChainSwitcher, type CollateralPosition, CompassEarnWidget, type CompassEarnWidgetProps, CompassProvider, type CompassProviderProps, type CompassTheme, CopyableAddress, type CopyableAddressProps, CreditAccount, type CreditAccountContextValue, CreditAccountGuard, type CreditAccountProps, type CreditPositionsResponse, type TokenBalance as CreditTokenBalance, type DebtPosition, DepositWithdrawForm, EarnAccount, EarnAccountBalance, type EarnAccountBalanceProps, type EarnAccountContextValue, EarnAccountGuard, type EarnAccountProps, type FeaturePreset, type FundWalletParams, type IdleBalance, PnLSummary, type PortfolioPosition, type PortfolioState, type RebalanceAction, type RebalanceActionType, type RebalancePlan, RebalancingWidget, type RebalancingWidgetProps, type SendTransactionParams, type SupportedChain, type SupportedChainId, SwapForm, type SwapFormProps, type SwapQuote, type TabConfig, type TabId, type TargetAllocation, type ThemeInput, type ThemeMode, type ThemePresetName, ThemeProvider, type TokenBalance$1 as TokenBalance, TransactionHistory, type TypedDataToSign, type VenueType$1 as VenueType, type WalletAdapter, WalletStatus, themePresets, useChain, useCompassApi, useCompassChain, useCompassWallet, useCreditAccount, useEarnAccount, useEmbeddableApi, useEmbeddableWallet, useRebalancingData, useSwapQuote, useTheme };
1025
+ export { AccountBalancesModal, type AccountBalancesModalProps, type AccountSummary, ActionModal, ApiProvider, CHAINS, type ChainConfig, ChainSwitcher, type CollateralPosition, CompassEarnWidget, type CompassEarnWidgetProps, CompassProvider, type CompassProviderProps, type CompassTheme, CopyableAddress, type CopyableAddressProps, CreditAccount, type CreditAccountContextValue, CreditAccountGuard, type CreditAccountProps, type CreditPositionsResponse, type TokenBalance as CreditTokenBalance, type DebtPosition, DepositWithdrawForm, EarnAccount, EarnAccountBalance, type EarnAccountBalanceProps, type EarnAccountContextValue, EarnAccountGuard, type EarnAccountProps, type FeaturePreset, type FundWalletParams, type IdleBalance, PnLSummary, type PortfolioPosition, type PortfolioState, type RebalanceAction, type RebalanceActionType, type RebalancePlan, RebalancingWidget, type RebalancingWidgetProps, type SendTransactionParams, type SupportedChain, type SupportedChainId, SwapForm, type SwapFormProps, type SwapQuote, type TabConfig, type TabId, type TargetAllocation, type ThemeInput, type ThemeMode, type ThemePresetName, ThemeProvider, type TokenBalance$1 as TokenBalance, TransactionHistory, type TypedDataToSign, type VenueType$1 as VenueType, type WalletAdapter, WalletStatus, themePresets, useChain, useCompassApi, useCompassChain, useCompassWallet, useCreditAccount, useEarnAccount, useEmbeddableApi, useEmbeddableWallet, useRebalancingData, useRefreshBalances, useSwapQuote, useTheme };
package/dist/index.js CHANGED
@@ -4349,6 +4349,27 @@ function WidgetFooter() {
4349
4349
  }
4350
4350
  );
4351
4351
  }
4352
+ var CHAINS = {
4353
+ ethereum: {
4354
+ id: "ethereum",
4355
+ name: "Ethereum",
4356
+ viemChain: chains.mainnet,
4357
+ icon: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png"
4358
+ },
4359
+ base: {
4360
+ id: "base",
4361
+ name: "Base",
4362
+ viemChain: chains.base,
4363
+ icon: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/base/info/logo.png"
4364
+ },
4365
+ arbitrum: {
4366
+ id: "arbitrum",
4367
+ name: "Arbitrum",
4368
+ viemChain: chains.arbitrum,
4369
+ icon: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/arbitrum/info/logo.png"
4370
+ }
4371
+ };
4372
+ var DEFAULT_MIN_TVL_USD = 1e6;
4352
4373
  function getTypeLabel(type) {
4353
4374
  switch (type) {
4354
4375
  case "aave":
@@ -4376,7 +4397,7 @@ function MarketSelector({
4376
4397
  }) {
4377
4398
  const [isExpanded, setIsExpanded] = react.useState(false);
4378
4399
  const filteredMarkets = react.useMemo(() => {
4379
- return markets.filter((m) => m.type === "aave" || m.type === "pendle" || m.tvl >= 1e3).sort((a, b) => b.apy - a.apy);
4400
+ return [...markets].sort((a, b) => b.apy - a.apy);
4380
4401
  }, [markets]);
4381
4402
  const otherMarkets = selectedMarket ? filteredMarkets.filter((m) => m.id !== selectedMarket.id) : filteredMarkets;
4382
4403
  if (isLoading) {
@@ -4964,7 +4985,8 @@ function EarnAccount({
4964
4985
  allowedFixedMarkets,
4965
4986
  tokenSymbols,
4966
4987
  chain: chainProp,
4967
- height = "600px"
4988
+ height = "600px",
4989
+ minTvlUsd = DEFAULT_MIN_TVL_USD
4968
4990
  }) {
4969
4991
  const { address, isConnected, login, logout, signTypedData, switchChain, walletChainId, fundWallet, hasExternalWallet, sendTransaction } = useEmbeddableWallet();
4970
4992
  const { isDeployed, earnAccountAddress } = useEarnAccount();
@@ -5165,9 +5187,9 @@ function EarnAccount({
5165
5187
  staleTime: 60 * 1e3
5166
5188
  });
5167
5189
  const vaultsQuery = reactQuery.useQuery({
5168
- queryKey: ["morphoVaults", CHAIN_ID],
5190
+ queryKey: ["morphoVaults", CHAIN_ID, minTvlUsd],
5169
5191
  queryFn: async () => {
5170
- const response = await fetch(`/api/compass/vaults?chain=${CHAIN_ID}&limit=200&orderBy=apy_7d&direction=desc`);
5192
+ const response = await fetch(`/api/compass/vaults?chain=${CHAIN_ID}&limit=200&orderBy=apy_7d&direction=desc&minTvlUsd=${minTvlUsd}`);
5171
5193
  if (!response.ok) {
5172
5194
  console.warn("[EarnAccount] Morpho vaults fetch failed:", response.status, response.statusText);
5173
5195
  return [];
@@ -10775,7 +10797,7 @@ function useRebalancingData(chainOverride) {
10775
10797
  queryKey: ["rebalancing", "venues", chainId],
10776
10798
  queryFn: async () => {
10777
10799
  const [vaultsRes, aaveRes, pendleRes] = await Promise.all([
10778
- fetch(`/api/compass/vaults?chain=${chainId}&orderBy=apy_7d&direction=desc&limit=200`),
10800
+ fetch(`/api/compass/vaults?chain=${chainId}&orderBy=apy_7d&direction=desc&limit=200&minTvlUsd=${DEFAULT_MIN_TVL_USD}`),
10779
10801
  fetch(`/api/compass/aave/markets?chain=${chainId}`),
10780
10802
  fetch(`/api/compass/pendle/markets?chain=${chainId}&orderBy=implied_apy&direction=desc&limit=200`)
10781
10803
  ]);
@@ -12588,26 +12610,41 @@ function CompassEarnWidget({
12588
12610
  ] })
12589
12611
  ] });
12590
12612
  }
12591
- var CHAINS = {
12592
- ethereum: {
12593
- id: "ethereum",
12594
- name: "Ethereum",
12595
- viemChain: chains.mainnet,
12596
- icon: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png"
12597
- },
12598
- base: {
12599
- id: "base",
12600
- name: "Base",
12601
- viemChain: chains.base,
12602
- icon: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/base/info/logo.png"
12603
- },
12604
- arbitrum: {
12605
- id: "arbitrum",
12606
- name: "Arbitrum",
12607
- viemChain: chains.arbitrum,
12608
- icon: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/arbitrum/info/logo.png"
12609
- }
12610
- };
12613
+ var BALANCE_QUERY_KEYS = [
12614
+ ["earnAccountBalances"],
12615
+ ["eoaBalances"],
12616
+ ["walletBalance"],
12617
+ ["walletTokenBalance"],
12618
+ ["creditBalances"],
12619
+ ["earnAccountTokenBalance"],
12620
+ ["embeddedWalletBalance"]
12621
+ ];
12622
+ var POSITION_QUERY_KEYS = [
12623
+ ["allEarnPositions"],
12624
+ ["earnAccountAllPositions"],
12625
+ ["creditPositions"],
12626
+ ["rebalancing"]
12627
+ ];
12628
+ var ALL_QUERY_KEYS = [...BALANCE_QUERY_KEYS, ...POSITION_QUERY_KEYS];
12629
+ function useRefreshBalances() {
12630
+ const queryClient = reactQuery.useQueryClient();
12631
+ const refreshBalances = react.useCallback(() => {
12632
+ for (const key of BALANCE_QUERY_KEYS) {
12633
+ queryClient.invalidateQueries({ queryKey: key });
12634
+ }
12635
+ }, [queryClient]);
12636
+ const refreshPositions = react.useCallback(() => {
12637
+ for (const key of POSITION_QUERY_KEYS) {
12638
+ queryClient.invalidateQueries({ queryKey: key });
12639
+ }
12640
+ }, [queryClient]);
12641
+ const refreshAll = react.useCallback(() => {
12642
+ for (const key of ALL_QUERY_KEYS) {
12643
+ queryClient.invalidateQueries({ queryKey: key });
12644
+ }
12645
+ }, [queryClient]);
12646
+ return { refreshBalances, refreshPositions, refreshAll };
12647
+ }
12611
12648
 
12612
12649
  exports.AccountBalancesModal = AccountBalancesModal;
12613
12650
  exports.ActionModal = ActionModal;
@@ -12639,6 +12676,7 @@ exports.useEarnAccount = useEarnAccount;
12639
12676
  exports.useEmbeddableApi = useEmbeddableApi;
12640
12677
  exports.useEmbeddableWallet = useEmbeddableWallet;
12641
12678
  exports.useRebalancingData = useRebalancingData;
12679
+ exports.useRefreshBalances = useRefreshBalances;
12642
12680
  exports.useSwapQuote = useSwapQuote;
12643
12681
  exports.useTheme = useTheme;
12644
12682
  //# sourceMappingURL=index.js.map