@oydual31/more-vaults-sdk 0.4.0 → 0.4.2

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.
@@ -1,6 +1,7 @@
1
- import { Address, Hash, WalletClient, PublicClient } from 'viem';
1
+ import { V as VaultAddresses, A as AsyncRequestResult, D as DepositResult, S as SpokeDepositResult, C as ComposeData, R as RedeemResult, a as CuratorVaultStatus, P as PendingAction, b as VaultAnalysis, c as VaultAssetBreakdown, d as CuratorAction, e as SubmitActionsResult } from '../spokeRoutes-B8Lnk-t4.js';
2
+ export { f as ActionType, g as ActionTypeValue, h as AssetBalance, i as AssetInfo, j as AsyncRequestFinalResult, k as AsyncRequestStatus, l as AsyncRequestStatusInfo, B as BatchSwapParams, m as BridgeParams, n as CrossChainRequestInfo, o as DepositBlockReason, p as DepositEligibility, I as InboundRoute, q as InboundRouteWithBalance, M as MaxWithdrawable, r as MultiChainUserPosition, N as NATIVE_SYMBOL, O as OMNI_FACTORY_ADDRESS, s as OutboundRoute, t as SpokeBalance, u as SwapParams, U as UserBalances, v as UserPosition, w as VaultDistribution, x as VaultMetadata, y as VaultMode, z as VaultStatus, E as VaultSummary, F as VaultTopology, G as canDeposit, H as detectStargateOft, J as discoverVaultTopology, K as ensureAllowance, L as getAllVaultChainIds, Q as getAsyncRequestStatus, T as getAsyncRequestStatusLabel, W as getFullVaultTopology, X as getInboundRoutes, Y as getMaxWithdrawable, Z as getOutboundRoutes, _ as getUserBalances, $ as getUserBalancesForRoutes, a0 as getUserPosition, a1 as getUserPositionMultiChain, a2 as getVaultDistribution, a3 as getVaultDistributionWithTopology, a4 as getVaultMetadata, a5 as getVaultStatus, a6 as getVaultSummary, a7 as getVaultTopology, a8 as isAsyncMode, a9 as isOnHubChain, aa as previewDeposit, ab as previewRedeem, ac as quoteLzFee, ad as quoteRouteDepositFee, ae as waitForAsyncRequest, af as waitForTx } from '../spokeRoutes-B8Lnk-t4.js';
3
+ import { WalletClient, PublicClient, Address, Hash } from 'viem';
2
4
  export { PublicClient as SdkPublicClient } from 'viem';
3
- export { A as AsyncRequestFinalResult, a as AsyncRequestStatus, b as AsyncRequestStatusInfo, D as DepositBlockReason, c as DepositEligibility, I as InboundRoute, d as InboundRouteWithBalance, M as MaxWithdrawable, e as MultiChainUserPosition, N as NATIVE_SYMBOL, O as OMNI_FACTORY_ADDRESS, f as OutboundRoute, S as SpokeBalance, U as UserBalances, g as UserPosition, V as VaultDistribution, h as VaultMetadata, i as VaultMode, j as VaultStatus, k as VaultSummary, l as VaultTopology, m as canDeposit, n as detectStargateOft, o as discoverVaultTopology, p as ensureAllowance, q as getAllVaultChainIds, r as getAsyncRequestStatus, s as getAsyncRequestStatusLabel, t as getFullVaultTopology, u as getInboundRoutes, v as getMaxWithdrawable, w as getOutboundRoutes, x as getUserBalances, y as getUserBalancesForRoutes, z as getUserPosition, B as getUserPositionMultiChain, C as getVaultDistribution, E as getVaultDistributionWithTopology, F as getVaultMetadata, G as getVaultStatus, H as getVaultSummary, J as getVaultTopology, K as isAsyncMode, L as isOnHubChain, P as previewDeposit, Q as previewRedeem, R as quoteLzFee, T as quoteRouteDepositFee, W as waitForAsyncRequest, X as waitForTx } from '../spokeRoutes-BIafSbQ3.js';
4
5
 
5
6
  /** EVM Chain IDs for chains supported by MoreVaults */
6
7
  declare const CHAIN_IDS: {
@@ -1613,195 +1614,6 @@ declare const LZ_ENDPOINT_ABI: readonly [{
1613
1614
  readonly stateMutability: "payable";
1614
1615
  }];
1615
1616
 
1616
- interface VaultAddresses {
1617
- /** Hub vault address (diamond proxy) */
1618
- vault: Address;
1619
- /** MoreVaultsEscrow — holds locked tokens during async cross-chain flows */
1620
- escrow?: Address;
1621
- /** OFTAdapter for vault shares (cross-chain redeem only) */
1622
- shareOFT?: Address;
1623
- /** OFT for USDC bridging (cross-chain deposits from spoke) */
1624
- usdcOFT?: Address;
1625
- /**
1626
- * Expected EVM chain ID of the hub. When provided, SDK functions will
1627
- * throw a clear WrongChainError if the walletClient is on a different chain.
1628
- * Prevents silent failures when MetaMask is connected to the wrong network.
1629
- */
1630
- hubChainId?: number;
1631
- }
1632
- interface DepositResult {
1633
- txHash: Hash;
1634
- shares: bigint;
1635
- }
1636
- interface RedeemResult {
1637
- txHash: Hash;
1638
- assets: bigint;
1639
- }
1640
- interface AsyncRequestResult {
1641
- txHash: Hash;
1642
- /** Cross-chain request GUID to track via getRequestInfo / getFinalizationResult */
1643
- guid: `0x${string}`;
1644
- }
1645
- /**
1646
- * ActionType enum values matching MoreVaultsLib.ActionType on-chain.
1647
- * DEPOSIT=0, MINT=1, WITHDRAW=2, REDEEM=3, MULTI_ASSETS_DEPOSIT=4, ACCRUE_FEES=5
1648
- */
1649
- declare const ActionType: {
1650
- readonly DEPOSIT: 0;
1651
- readonly MINT: 1;
1652
- readonly WITHDRAW: 2;
1653
- readonly REDEEM: 3;
1654
- readonly MULTI_ASSETS_DEPOSIT: 4;
1655
- readonly ACCRUE_FEES: 5;
1656
- };
1657
- type ActionTypeValue = (typeof ActionType)[keyof typeof ActionType];
1658
- /**
1659
- * Data needed to execute a pending LZ compose on the hub chain.
1660
- * Returned by `depositFromSpoke` when the OFT is a Stargate V2 pool,
1661
- * because Stargate cannot forward ETH to the compose executor.
1662
- * The SDK user must call `executeCompose()` with this data as a second TX on the hub.
1663
- */
1664
- interface ComposeData {
1665
- /** LZ Endpoint address on the hub chain */
1666
- endpoint: Address;
1667
- /** The OFT/pool address that sent the compose (Stargate pool on hub) */
1668
- from: Address;
1669
- /** MoreVaultsComposer address on the hub */
1670
- to: Address;
1671
- /** LayerZero GUID from the original OFT.send() */
1672
- guid: `0x${string}`;
1673
- /** Compose index (always 0 for single-compose messages) */
1674
- index: number;
1675
- /** The full compose message bytes (reconstructed from composeMsg + OFT header) */
1676
- message: `0x${string}`;
1677
- /** Whether this is a Stargate OFT that requires a 2-TX flow */
1678
- isStargate: boolean;
1679
- /** Hub chain ID for creating the hub wallet/public client */
1680
- hubChainId: number;
1681
- /** Hub block number just before TX1 was sent — used as search start for ComposeSent events */
1682
- hubBlockStart: bigint;
1683
- }
1684
- /**
1685
- * Result from `depositFromSpoke`.
1686
- * When `composeData` is present, the user must call `executeCompose()` on the hub chain.
1687
- */
1688
- interface SpokeDepositResult {
1689
- txHash: Hash;
1690
- guid: `0x${string}`;
1691
- /** Present when OFT is Stargate V2 — user must execute compose on hub as TX2 */
1692
- composeData?: ComposeData;
1693
- }
1694
- interface CrossChainRequestInfo {
1695
- initiator: Address;
1696
- timestamp: bigint;
1697
- actionType: number;
1698
- actionCallData: `0x${string}`;
1699
- fulfilled: boolean;
1700
- finalized: boolean;
1701
- refunded: boolean;
1702
- totalAssets: bigint;
1703
- finalizationResult: bigint;
1704
- amountLimit: bigint;
1705
- }
1706
- interface SwapParams {
1707
- targetContract: Address;
1708
- tokenIn: Address;
1709
- tokenOut: Address;
1710
- maxAmountIn: bigint;
1711
- minAmountOut: bigint;
1712
- swapCallData: `0x${string}`;
1713
- }
1714
- interface BatchSwapParams {
1715
- swaps: SwapParams[];
1716
- }
1717
- interface BridgeParams {
1718
- oftToken: Address;
1719
- dstEid: number;
1720
- amount: bigint;
1721
- dstVault: Address;
1722
- refundAddress: Address;
1723
- }
1724
- interface PendingAction {
1725
- nonce: bigint;
1726
- actionsData: `0x${string}`[];
1727
- pendingUntil: bigint;
1728
- isExecutable: boolean;
1729
- }
1730
- interface SubmitActionsResult {
1731
- txHash: `0x${string}`;
1732
- nonce: bigint;
1733
- }
1734
- type CuratorAction = {
1735
- type: 'swap';
1736
- params: SwapParams;
1737
- } | {
1738
- type: 'batchSwap';
1739
- params: BatchSwapParams;
1740
- } | {
1741
- type: 'erc4626Deposit';
1742
- vault: Address;
1743
- assets: bigint;
1744
- } | {
1745
- type: 'erc4626Redeem';
1746
- vault: Address;
1747
- shares: bigint;
1748
- } | {
1749
- type: 'erc7540RequestDeposit';
1750
- vault: Address;
1751
- assets: bigint;
1752
- } | {
1753
- type: 'erc7540Deposit';
1754
- vault: Address;
1755
- assets: bigint;
1756
- } | {
1757
- type: 'erc7540RequestRedeem';
1758
- vault: Address;
1759
- shares: bigint;
1760
- } | {
1761
- type: 'erc7540Redeem';
1762
- vault: Address;
1763
- shares: bigint;
1764
- };
1765
- interface CuratorVaultStatus {
1766
- curator: Address;
1767
- timeLockPeriod: bigint;
1768
- maxSlippagePercent: bigint;
1769
- currentNonce: bigint;
1770
- availableAssets: Address[];
1771
- lzAdapter: Address;
1772
- paused: boolean;
1773
- }
1774
- interface AssetInfo {
1775
- address: Address;
1776
- symbol: string;
1777
- name: string;
1778
- decimals: number;
1779
- }
1780
- interface VaultAnalysis {
1781
- /** All tokens the vault can hold/swap (curator-managed) */
1782
- availableAssets: AssetInfo[];
1783
- /** Tokens users can deposit */
1784
- depositableAssets: AssetInfo[];
1785
- /** Whether deposit whitelist is enabled (restricts who can deposit) */
1786
- depositWhitelistEnabled: boolean;
1787
- /** Registry address for global protocol whitelist checks */
1788
- registryAddress: Address | null;
1789
- }
1790
- interface AssetBalance extends AssetInfo {
1791
- /** Raw balance held by the vault */
1792
- balance: bigint;
1793
- }
1794
- interface VaultAssetBreakdown {
1795
- /** Per-asset balances held by the vault on the hub chain */
1796
- assets: AssetBalance[];
1797
- /** totalAssets() as reported by the vault (all positions converted to underlying) */
1798
- totalAssets: bigint;
1799
- /** totalSupply() of vault shares */
1800
- totalSupply: bigint;
1801
- /** Vault underlying token decimals */
1802
- underlyingDecimals: number;
1803
- }
1804
-
1805
1617
  /**
1806
1618
  * Typed error classes for the MoreVaults SDK.
1807
1619
  *
@@ -2705,4 +2517,4 @@ declare function buildUniswapV3Swap(params: {
2705
2517
  */
2706
2518
  declare function asSdkClient(client: unknown): PublicClient;
2707
2519
 
2708
- export { ActionType, type ActionTypeValue, type AssetBalance, type AssetInfo, type AsyncRequestResult, BRIDGE_ABI, BRIDGE_FACET_ABI, type BatchSwapParams, type BridgeParams, CCManagerNotConfiguredError, CHAIN_IDS, CHAIN_ID_TO_EID, CONFIG_ABI, CURATOR_CONFIG_ABI, CapacityFullError, type ComposeData, type CrossChainRequestInfo, type CuratorAction, type CuratorVaultStatus, DEX_ABI, type DepositResult, EID_TO_CHAIN_ID, ERC20_ABI, ERC4626_FACET_ABI, ERC7540_FACET_ABI, EscrowNotConfiguredError, InsufficientLiquidityError, LZ_ADAPTER_ABI, LZ_EIDS, LZ_ENDPOINT_ABI, LZ_TIMEOUTS, METADATA_ABI, MULTICALL_ABI, MissingEscrowAddressError, MoreVaultsError, NotHubVaultError, NotWhitelistedError, OFT_ABI, OFT_ROUTES, type PendingAction, REGISTRY_ABI, type RedeemResult, STARGATE_TAXI_CMD, type SpokeDepositResult, type SpokeRedeemRoute, type SubmitActionsResult, type SwapParams, UNISWAP_V3_ROUTERS, USDC_STARGATE_OFT, USDC_TOKEN, VAULT_ABI, VAULT_ANALYSIS_ABI, type VaultAddresses, type VaultAnalysis, type VaultAssetBreakdown, VaultPausedError, WrongChainError, asSdkClient, bridgeAssetsToSpoke, bridgeSharesToHub, buildCuratorBatch, buildUniswapV3Swap, checkProtocolWhitelist, depositAsync, depositSimple as depositCrossChainOracleOn, depositFromSpoke, depositFromSpoke as depositFromSpokeAsync, depositMultiAsset, depositSimple, encodeCuratorAction, encodeUniswapV3SwapCalldata, executeActions, executeCompose, getCuratorVaultStatus, getPendingActions, getVaultAnalysis, getVaultAssetBreakdown, getWithdrawalRequest, isCurator, mintAsync, preflightAsync, preflightRedeemLiquidity, preflightSpokeDeposit, preflightSpokeRedeem, preflightSync, quoteComposeFee, quoteDepositFromSpokeFee, quoteShareBridgeFee, redeemAsync, redeemShares, requestRedeem, resolveRedeemAddresses, smartDeposit, smartRedeem, submitActions, vetoActions, waitForCompose, withdrawAssets };
2520
+ export { AsyncRequestResult, BRIDGE_ABI, BRIDGE_FACET_ABI, CCManagerNotConfiguredError, CHAIN_IDS, CHAIN_ID_TO_EID, CONFIG_ABI, CURATOR_CONFIG_ABI, CapacityFullError, ComposeData, CuratorAction, CuratorVaultStatus, DEX_ABI, DepositResult, EID_TO_CHAIN_ID, ERC20_ABI, ERC4626_FACET_ABI, ERC7540_FACET_ABI, EscrowNotConfiguredError, InsufficientLiquidityError, LZ_ADAPTER_ABI, LZ_EIDS, LZ_ENDPOINT_ABI, LZ_TIMEOUTS, METADATA_ABI, MULTICALL_ABI, MissingEscrowAddressError, MoreVaultsError, NotHubVaultError, NotWhitelistedError, OFT_ABI, OFT_ROUTES, PendingAction, REGISTRY_ABI, RedeemResult, STARGATE_TAXI_CMD, SpokeDepositResult, type SpokeRedeemRoute, SubmitActionsResult, UNISWAP_V3_ROUTERS, USDC_STARGATE_OFT, USDC_TOKEN, VAULT_ABI, VAULT_ANALYSIS_ABI, VaultAddresses, VaultAnalysis, VaultAssetBreakdown, VaultPausedError, WrongChainError, asSdkClient, bridgeAssetsToSpoke, bridgeSharesToHub, buildCuratorBatch, buildUniswapV3Swap, checkProtocolWhitelist, depositAsync, depositSimple as depositCrossChainOracleOn, depositFromSpoke, depositFromSpoke as depositFromSpokeAsync, depositMultiAsset, depositSimple, encodeCuratorAction, encodeUniswapV3SwapCalldata, executeActions, executeCompose, getCuratorVaultStatus, getPendingActions, getVaultAnalysis, getVaultAssetBreakdown, getWithdrawalRequest, isCurator, mintAsync, preflightAsync, preflightRedeemLiquidity, preflightSpokeDeposit, preflightSpokeRedeem, preflightSync, quoteComposeFee, quoteDepositFromSpokeFee, quoteShareBridgeFee, redeemAsync, redeemShares, requestRedeem, resolveRedeemAddresses, smartDeposit, smartRedeem, submitActions, vetoActions, waitForCompose, withdrawAssets };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oydual31/more-vaults-sdk",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "TypeScript SDK for MoreVaults protocol — viem/wagmi and ethers.js",
5
5
  "type": "module",
6
6
  "exports": {
@@ -37,3 +37,28 @@ export { useSmartRedeem } from './useSmartRedeem.js'
37
37
 
38
38
  // --- Inbound Routes ---
39
39
  export { useInboundRoutes, getRouteTokenDecimals } from './useInboundRoutes.js'
40
+
41
+ // --- Curator Read hooks ---
42
+ export { useCuratorVaultStatus } from './useCuratorVaultStatus.js'
43
+ export type { CuratorVaultStatus } from './useCuratorVaultStatus.js'
44
+
45
+ export { useVaultAnalysis } from './useVaultAnalysis.js'
46
+ export type { VaultAnalysis } from './useVaultAnalysis.js'
47
+
48
+ export { useVaultAssetBreakdown } from './useVaultAssetBreakdown.js'
49
+ export type { VaultAssetBreakdown } from './useVaultAssetBreakdown.js'
50
+
51
+ export { usePendingActions } from './usePendingActions.js'
52
+ export type { PendingAction } from './usePendingActions.js'
53
+
54
+ export { useIsCurator } from './useIsCurator.js'
55
+
56
+ export { useProtocolWhitelist } from './useProtocolWhitelist.js'
57
+
58
+ // --- Curator Write hooks ---
59
+ export { useSubmitActions } from './useSubmitActions.js'
60
+ export type { CuratorAction } from './useSubmitActions.js'
61
+
62
+ export { useExecuteActions } from './useExecuteActions.js'
63
+
64
+ export { useVetoActions } from './useVetoActions.js'
@@ -0,0 +1,32 @@
1
+ import { useQuery } from '@tanstack/react-query'
2
+ import { usePublicClient } from 'wagmi'
3
+ import { asSdkClient, getCuratorVaultStatus } from '../viem/index.js'
4
+ import type { CuratorVaultStatus } from '../viem/index.js'
5
+
6
+ export type { CuratorVaultStatus }
7
+
8
+ interface UseCuratorVaultStatusOptions {
9
+ /** Refetch interval in ms. Default: 30_000 (30s) */
10
+ refetchInterval?: number
11
+ }
12
+
13
+ /**
14
+ * Read the curator vault status snapshot.
15
+ *
16
+ * @example
17
+ * const { data: status, isLoading } = useCuratorVaultStatus('0xVAULT', 747)
18
+ */
19
+ export function useCuratorVaultStatus(
20
+ vault: `0x${string}` | undefined,
21
+ chainId: number,
22
+ options?: UseCuratorVaultStatusOptions,
23
+ ) {
24
+ const publicClient = usePublicClient({ chainId })
25
+ return useQuery({
26
+ queryKey: ['curatorVaultStatus', vault, chainId],
27
+ queryFn: () => getCuratorVaultStatus(asSdkClient(publicClient), vault!),
28
+ enabled: !!vault && !!publicClient,
29
+ refetchInterval: options?.refetchInterval ?? 30_000,
30
+ staleTime: 15_000,
31
+ })
32
+ }
@@ -0,0 +1,23 @@
1
+ import { useMutation } from '@tanstack/react-query'
2
+ import { usePublicClient, useWalletClient } from 'wagmi'
3
+ import { asSdkClient, executeActions } from '../viem/index.js'
4
+
5
+ /**
6
+ * Execute a pending curator action batch by nonce.
7
+ *
8
+ * @example
9
+ * const { mutateAsync } = useExecuteActions('0xVAULT', 747)
10
+ * await mutateAsync({ nonce: 1n })
11
+ */
12
+ export function useExecuteActions(vault: `0x${string}`, chainId: number) {
13
+ const publicClient = usePublicClient({ chainId })
14
+ const { data: walletClient } = useWalletClient({ chainId })
15
+
16
+ return useMutation({
17
+ mutationFn: async ({ nonce }: { nonce: bigint }) => {
18
+ if (!walletClient || !publicClient) throw new Error('Wallet or public client not available')
19
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
+ return executeActions(walletClient as any, asSdkClient(publicClient), vault, nonce)
21
+ },
22
+ })
23
+ }
@@ -0,0 +1,30 @@
1
+ import { useQuery } from '@tanstack/react-query'
2
+ import { usePublicClient } from 'wagmi'
3
+ import { asSdkClient, isCurator } from '../viem/index.js'
4
+
5
+ interface UseIsCuratorOptions {
6
+ /** Refetch interval in ms. Default: 30_000 (30s) */
7
+ refetchInterval?: number
8
+ }
9
+
10
+ /**
11
+ * Check whether an address is a curator of a vault.
12
+ *
13
+ * @example
14
+ * const { data: curator, isLoading } = useIsCurator('0xVAULT', 747, '0xADDR')
15
+ */
16
+ export function useIsCurator(
17
+ vault: `0x${string}` | undefined,
18
+ chainId: number,
19
+ address: `0x${string}` | undefined,
20
+ options?: UseIsCuratorOptions,
21
+ ) {
22
+ const publicClient = usePublicClient({ chainId })
23
+ return useQuery({
24
+ queryKey: ['isCurator', vault, chainId, address],
25
+ queryFn: () => isCurator(asSdkClient(publicClient), vault!, address!),
26
+ enabled: !!vault && !!publicClient && !!address,
27
+ refetchInterval: options?.refetchInterval ?? 30_000,
28
+ staleTime: 15_000,
29
+ })
30
+ }
@@ -0,0 +1,33 @@
1
+ import { useQuery } from '@tanstack/react-query'
2
+ import { usePublicClient } from 'wagmi'
3
+ import { asSdkClient, getPendingActions } from '../viem/index.js'
4
+ import type { PendingAction } from '../viem/index.js'
5
+
6
+ export type { PendingAction }
7
+
8
+ interface UsePendingActionsOptions {
9
+ /** Refetch interval in ms. Default: 30_000 (30s) */
10
+ refetchInterval?: number
11
+ }
12
+
13
+ /**
14
+ * Read pending curator actions for a vault by nonce.
15
+ *
16
+ * @example
17
+ * const { data: pending, isLoading } = usePendingActions('0xVAULT', 747, 1n)
18
+ */
19
+ export function usePendingActions(
20
+ vault: `0x${string}` | undefined,
21
+ chainId: number,
22
+ nonce: bigint | undefined,
23
+ options?: UsePendingActionsOptions,
24
+ ) {
25
+ const publicClient = usePublicClient({ chainId })
26
+ return useQuery({
27
+ queryKey: ['pendingActions', vault, chainId, nonce?.toString()],
28
+ queryFn: () => getPendingActions(asSdkClient(publicClient), vault!, nonce!),
29
+ enabled: !!vault && !!publicClient && nonce !== undefined,
30
+ refetchInterval: options?.refetchInterval ?? 30_000,
31
+ staleTime: 15_000,
32
+ })
33
+ }
@@ -0,0 +1,30 @@
1
+ import { useQuery } from '@tanstack/react-query'
2
+ import { usePublicClient } from 'wagmi'
3
+ import { asSdkClient, checkProtocolWhitelist } from '../viem/index.js'
4
+
5
+ interface UseProtocolWhitelistOptions {
6
+ /** Refetch interval in ms. Default: 30_000 (30s) */
7
+ refetchInterval?: number
8
+ }
9
+
10
+ /**
11
+ * Check which protocols are whitelisted for a vault.
12
+ *
13
+ * @example
14
+ * const { data: whitelist, isLoading } = useProtocolWhitelist('0xVAULT', 747, ['0xPROTOCOL'])
15
+ */
16
+ export function useProtocolWhitelist(
17
+ vault: `0x${string}` | undefined,
18
+ chainId: number,
19
+ protocols: `0x${string}`[],
20
+ options?: UseProtocolWhitelistOptions,
21
+ ) {
22
+ const publicClient = usePublicClient({ chainId })
23
+ return useQuery({
24
+ queryKey: ['protocolWhitelist', vault, chainId, protocols],
25
+ queryFn: () => checkProtocolWhitelist(asSdkClient(publicClient), vault!, protocols),
26
+ enabled: !!vault && !!publicClient,
27
+ refetchInterval: options?.refetchInterval ?? 30_000,
28
+ staleTime: 15_000,
29
+ })
30
+ }
@@ -0,0 +1,27 @@
1
+ import { useMutation } from '@tanstack/react-query'
2
+ import { usePublicClient, useWalletClient } from 'wagmi'
3
+ import { asSdkClient, submitActions, buildCuratorBatch } from '../viem/index.js'
4
+ import type { CuratorAction } from '../viem/index.js'
5
+
6
+ export type { CuratorAction }
7
+
8
+ /**
9
+ * Submit a batch of curator actions to the vault.
10
+ *
11
+ * @example
12
+ * const { mutateAsync } = useSubmitActions('0xVAULT', 747)
13
+ * await mutateAsync({ actions: [{ type: 'erc4626Deposit', vault: '0x...', assets: 100n }] })
14
+ */
15
+ export function useSubmitActions(vault: `0x${string}`, chainId: number) {
16
+ const publicClient = usePublicClient({ chainId })
17
+ const { data: walletClient } = useWalletClient({ chainId })
18
+
19
+ return useMutation({
20
+ mutationFn: async ({ actions }: { actions: CuratorAction[] }) => {
21
+ if (!walletClient || !publicClient) throw new Error('Wallet or public client not available')
22
+ const encodedActions = buildCuratorBatch(actions)
23
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
24
+ return submitActions(walletClient as any, asSdkClient(publicClient), vault, encodedActions)
25
+ },
26
+ })
27
+ }
@@ -0,0 +1,32 @@
1
+ import { useQuery } from '@tanstack/react-query'
2
+ import { usePublicClient } from 'wagmi'
3
+ import { asSdkClient, getVaultAnalysis } from '../viem/index.js'
4
+ import type { VaultAnalysis } from '../viem/index.js'
5
+
6
+ export type { VaultAnalysis }
7
+
8
+ interface UseVaultAnalysisOptions {
9
+ /** Refetch interval in ms. Default: 30_000 (30s) */
10
+ refetchInterval?: number
11
+ }
12
+
13
+ /**
14
+ * Read a detailed analysis of a vault.
15
+ *
16
+ * @example
17
+ * const { data: analysis, isLoading } = useVaultAnalysis('0xVAULT', 747)
18
+ */
19
+ export function useVaultAnalysis(
20
+ vault: `0x${string}` | undefined,
21
+ chainId: number,
22
+ options?: UseVaultAnalysisOptions,
23
+ ) {
24
+ const publicClient = usePublicClient({ chainId })
25
+ return useQuery({
26
+ queryKey: ['vaultAnalysis', vault, chainId],
27
+ queryFn: () => getVaultAnalysis(asSdkClient(publicClient), vault!),
28
+ enabled: !!vault && !!publicClient,
29
+ refetchInterval: options?.refetchInterval ?? 30_000,
30
+ staleTime: 15_000,
31
+ })
32
+ }
@@ -0,0 +1,32 @@
1
+ import { useQuery } from '@tanstack/react-query'
2
+ import { usePublicClient } from 'wagmi'
3
+ import { asSdkClient, getVaultAssetBreakdown } from '../viem/index.js'
4
+ import type { VaultAssetBreakdown } from '../viem/index.js'
5
+
6
+ export type { VaultAssetBreakdown }
7
+
8
+ interface UseVaultAssetBreakdownOptions {
9
+ /** Refetch interval in ms. Default: 30_000 (30s) */
10
+ refetchInterval?: number
11
+ }
12
+
13
+ /**
14
+ * Read the asset breakdown of a vault.
15
+ *
16
+ * @example
17
+ * const { data: breakdown, isLoading } = useVaultAssetBreakdown('0xVAULT', 747)
18
+ */
19
+ export function useVaultAssetBreakdown(
20
+ vault: `0x${string}` | undefined,
21
+ chainId: number,
22
+ options?: UseVaultAssetBreakdownOptions,
23
+ ) {
24
+ const publicClient = usePublicClient({ chainId })
25
+ return useQuery({
26
+ queryKey: ['vaultAssetBreakdown', vault, chainId],
27
+ queryFn: () => getVaultAssetBreakdown(asSdkClient(publicClient), vault!),
28
+ enabled: !!vault && !!publicClient,
29
+ refetchInterval: options?.refetchInterval ?? 30_000,
30
+ staleTime: 15_000,
31
+ })
32
+ }
@@ -0,0 +1,23 @@
1
+ import { useMutation } from '@tanstack/react-query'
2
+ import { usePublicClient, useWalletClient } from 'wagmi'
3
+ import { asSdkClient, vetoActions } from '../viem/index.js'
4
+
5
+ /**
6
+ * Guardian-only: cancel (veto) one or more pending curator action batches.
7
+ *
8
+ * @example
9
+ * const { mutateAsync } = useVetoActions('0xVAULT', 747)
10
+ * await mutateAsync({ nonces: [1n, 2n] })
11
+ */
12
+ export function useVetoActions(vault: `0x${string}`, chainId: number) {
13
+ const publicClient = usePublicClient({ chainId })
14
+ const { data: walletClient } = useWalletClient({ chainId })
15
+
16
+ return useMutation({
17
+ mutationFn: async ({ nonces }: { nonces: bigint[] }) => {
18
+ if (!walletClient || !publicClient) throw new Error('Wallet or public client not available')
19
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
+ return vetoActions(walletClient as any, asSdkClient(publicClient), vault, nonces)
21
+ },
22
+ })
23
+ }