@oydual31/more-vaults-sdk 0.1.2 → 0.1.4

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.
@@ -0,0 +1,34 @@
1
+ import { useQuery } from '@tanstack/react-query'
2
+ import { usePublicClient } from 'wagmi'
3
+ import { asSdkClient, getVaultStatus } from '../viem/index.js'
4
+ import type { VaultStatus } from '../viem/index.js'
5
+
6
+ export type { VaultStatus }
7
+
8
+ interface UseVaultStatusOptions {
9
+ /** Refetch interval in ms. Default: 30_000 (30s) */
10
+ refetchInterval?: number
11
+ }
12
+
13
+ /**
14
+ * Read the full vault status snapshot.
15
+ * Automatically refetches on a configurable interval.
16
+ *
17
+ * @example
18
+ * const { data: status, isLoading } = useVaultStatus('0xVAULT', 747)
19
+ * if (status?.mode === 'cross-chain-async') { ... }
20
+ */
21
+ export function useVaultStatus(
22
+ vault: `0x${string}` | undefined,
23
+ chainId: number,
24
+ options?: UseVaultStatusOptions,
25
+ ) {
26
+ const publicClient = usePublicClient({ chainId })
27
+ return useQuery({
28
+ queryKey: ['vaultStatus', vault, chainId],
29
+ queryFn: () => getVaultStatus(asSdkClient(publicClient), vault!),
30
+ enabled: !!vault && !!publicClient,
31
+ refetchInterval: options?.refetchInterval ?? 30_000,
32
+ staleTime: 15_000,
33
+ })
34
+ }
package/src/viem/utils.ts CHANGED
@@ -175,10 +175,14 @@ export async function getVaultStatus(
175
175
 
176
176
  const spokesDeployedBalance = totalAssets > hubLiquidBalance ? totalAssets - hubLiquidBalance : 0n
177
177
 
178
- // null = maxDeposit reverted → whitelist/ACL vault
178
+ // null = maxDeposit reverted.
179
+ // For cross-chain-async hubs this is expected — the contract reverts with
180
+ // NotAnERC4626CompatibleVault because maxDeposit is not meaningful in async mode.
181
+ // Only treat the revert as "whitelist/ACL" when the vault is NOT a hub.
179
182
  const MAX_UINT256 = BigInt('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff')
180
- const depositAccessRestricted = maxDepositRaw === null
181
- const effectiveCapacity: bigint = depositAccessRestricted ? MAX_UINT256 : maxDepositRaw
183
+ const isCrossChainAsync = isHub && !oraclesEnabled
184
+ const depositAccessRestricted = maxDepositRaw === null && !isCrossChainAsync
185
+ const effectiveCapacity: bigint = (maxDepositRaw === null) ? MAX_UINT256 : maxDepositRaw
182
186
 
183
187
  // ── Derive mode ────────────────────────────────────────────────────────────
184
188
  let mode: VaultMode