@oydual31/more-vaults-sdk 0.2.2 → 0.2.3

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.
@@ -2039,9 +2039,12 @@ function useRedeemShares(vault, chainId) {
2039
2039
  };
2040
2040
  }
2041
2041
  function useVaultDistribution(vault) {
2042
- const chainId = wagmi.useChainId();
2043
- const publicClient = wagmi.usePublicClient();
2044
- const { topology } = useVaultTopology(vault);
2042
+ const { data: topology } = reactQuery.useQuery({
2043
+ queryKey: ["vaultTopology", vault],
2044
+ queryFn: () => discoverVaultTopology(vault),
2045
+ enabled: !!vault,
2046
+ staleTime: 5 * 60 * 1e3
2047
+ });
2045
2048
  const spokeClients = react.useMemo(() => {
2046
2049
  if (!topology) return {};
2047
2050
  const clients = {};
@@ -2052,13 +2055,13 @@ function useVaultDistribution(vault) {
2052
2055
  return clients;
2053
2056
  }, [topology]);
2054
2057
  const { data: distribution, isLoading } = reactQuery.useQuery({
2055
- queryKey: ["vaultDistribution", vault, chainId],
2056
- queryFn: () => getVaultDistribution(
2057
- asSdkClient(publicClient),
2058
- vault,
2059
- spokeClients
2060
- ),
2061
- enabled: !!vault && !!publicClient,
2058
+ queryKey: ["vaultDistribution", vault, topology?.hubChainId],
2059
+ queryFn: () => {
2060
+ const hubClient = createChainClient(topology.hubChainId);
2061
+ if (!hubClient) throw new Error(`No public RPC for hub chainId ${topology.hubChainId}`);
2062
+ return getVaultDistribution(hubClient, vault, spokeClients);
2063
+ },
2064
+ enabled: !!vault && !!topology && topology.role !== "local",
2062
2065
  staleTime: 3e4
2063
2066
  });
2064
2067
  return { distribution, isLoading };