@@ -2,6 +2,7 @@ import { useCluster } from "@/hooks/cluster/use-cluster";
22import { useClusterSnapshot } from "@/hooks/cluster/use-cluster-snapshot" ;
33import { useIsClusterLiquidated } from "@/hooks/cluster/use-is-cluster-liquidated" ;
44import { useGetEffectiveBalance } from "@/lib/contract-interactions/hooks/getter" ;
5+ import { bigintMax } from "@/lib/utils/bigint" ;
56import { keepPreviousData } from "@tanstack/react-query" ;
67
78/**
@@ -10,9 +11,10 @@ import { keepPreviousData } from "@tanstack/react-query";
1011 *
1112 * Only meaningful for migrated (ETH) clusters — the contract call is disabled
1213 * for liquidated clusters. While the contract call is in flight, disabled or
13- * failing, `data` falls back to the API field `cluster.data.effectiveBalance`
14- * (0 until the cluster itself has loaded). The contract query's own status
15- * fields (isError, fetchStatus, …) are passed through unchanged.
14+ * failing, `data` falls back to the API field `cluster.data.effectiveBalance`,
15+ * floored at 32 ETH per validator like `useClusterRunway` (0 until the cluster
16+ * itself has loaded). The contract query's own status fields (isError,
17+ * fetchStatus, …) are passed through unchanged.
1618 */
1719export const useClusterEffectiveBalance = (
1820 hash : string ,
@@ -36,8 +38,15 @@ export const useClusterEffectiveBalance = (
3638 enabled : Boolean ( cluster . data && enabled && ! isLiquidated . data ) ,
3739 } ) ;
3840
41+ // The API reports "0" until the indexer catches up (e.g. a freshly migrated
42+ // cluster); calculateRunway would then price it as a single 32 ETH validator.
43+ const apiEffectiveBalance = bigintMax (
44+ BigInt ( cluster . data ?. effectiveBalance ?? 0 ) ,
45+ BigInt ( cluster . data ?. validatorCount ?? 0 ) * 32n ,
46+ ) ;
47+
3948 return {
4049 ...effectiveBalance ,
41- data : effectiveBalance . data ?? BigInt ( cluster . data ?. effectiveBalance ?? 0 ) ,
50+ data : effectiveBalance . data ?? apiEffectiveBalance ,
4251 } ;
4352} ;
0 commit comments