@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.
- package/dist/ethers/index.cjs +3 -2
- package/dist/ethers/index.cjs.map +1 -1
- package/dist/ethers/index.js +3 -2
- package/dist/ethers/index.js.map +1 -1
- package/dist/react/index.cjs +1109 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +382 -0
- package/dist/react/index.d.ts +382 -0
- package/dist/react/index.js +1098 -0
- package/dist/react/index.js.map +1 -0
- package/dist/userHelpers-CZLB9oQ4.d.cts +286 -0
- package/dist/userHelpers-CZLB9oQ4.d.ts +286 -0
- package/dist/viem/index.cjs +3 -2
- package/dist/viem/index.cjs.map +1 -1
- package/dist/viem/index.d.cts +2 -284
- package/dist/viem/index.d.ts +2 -284
- package/dist/viem/index.js +3 -2
- package/dist/viem/index.js.map +1 -1
- package/package.json +26 -5
- package/src/ethers/utils.ts +7 -3
- package/src/react/index.ts +26 -0
- package/src/react/useAsyncRequestStatus.ts +36 -0
- package/src/react/useDepositSimple.ts +76 -0
- package/src/react/useLzFee.ts +27 -0
- package/src/react/useOmniDeposit.ts +97 -0
- package/src/react/useOmniRedeem.ts +96 -0
- package/src/react/useRedeemShares.ts +77 -0
- package/src/react/useSmartDeposit.ts +70 -0
- package/src/react/useUserPosition.ts +29 -0
- package/src/react/useVaultMetadata.ts +29 -0
- package/src/react/useVaultStatus.ts +34 -0
- package/src/viem/utils.ts +7 -3
|
@@ -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
|
|
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
|
|
181
|
-
const
|
|
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
|