fetch_user_vault_equity
Documentation for eth_defi.hyperliquid.api.fetch_user_vault_equity function.
- fetch_user_vault_equity(session, user, vault_address, cache_timeout=900, timeout=10.0, bypass_cache=False)
Fetch a user’s equity in a single Hypercore vault, with caching.
Convenience wrapper around
fetch_user_vault_equities()that fetches all vault positions, caches the result, and returns the one matching vault_address.The cache is keyed by
(api_url, user)and entries expire after cache_timeout seconds (default 15 minutes).Example:
from eth_defi.hyperliquid.api import fetch_user_vault_equity from eth_defi.hyperliquid.session import create_hyperliquid_session session = create_hyperliquid_session() eq = fetch_user_vault_equity(session, user="0xAbc...", vault_address="0xDef...") if eq is not None: print(f"Equity: {eq.equity} USDC")- Parameters
session (eth_defi.hyperliquid.session.HyperliquidSession) – Session from
create_hyperliquid_session().user (Union[eth_typing.evm.HexAddress, str]) – On-chain address (the Safe address for Lagoon vaults).
vault_address (Union[eth_typing.evm.HexAddress, str]) – Hypercore vault address to look up.
cache_timeout (float) – How long cached results stay valid, in seconds. Defaults to
DEFAULT_VAULT_EQUITY_CACHE_TIMEOUT(15 minutes).timeout (float) – HTTP request timeout in seconds (passed to the underlying API call).
bypass_cache (bool) – If
True, skip the cache and always fetch fresh data from the API. The fresh result is still stored in the cache for subsequent calls.
- Returns
The user’s equity in the vault, or
Noneif the user has no position in the given vault.- Return type