View Source Hyperliquid.Api.Stats.Vaults (hyperliquid v0.2.2)

Vaults data from the Hyperliquid stats API.

Returns vault performance metrics, APR, PnL history, and summary information.

See: https://stats-data.hyperliquid.xyz/Mainnet/vaults

Usage

{:ok, vaults} = Vaults.request()
{:ok, vault} = Vaults.get_vault(vaults, "0x...")

Summary

Functions

Returns metadata about this endpoint.

Returns postgres table configurations (multi-table support).

Returns storage configuration for this endpoint.

Build a cache key from response data using the configured pattern. Returns nil if cache is not enabled or no pattern configured.

Get vaults sorted by APR (descending).

Get vaults sorted by TVL (descending).

Returns true if cache storage is enabled.

Returns the cache TTL if configured.

Creates a changeset for vaults data.

Fetch data and persist to configured storage backends.

Fetch data and persist. Raises on error.

Filter vaults by open/closed status.

Get a specific vault by address.

Get PnL for a specific time window from a vault.

Parse and validate the API response.

Returns true if postgres storage is enabled.

Returns the postgres table name if configured (primary table for legacy support).

Returns the upsert config for postgres (primary table for legacy support).

Get the rate limit cost for this endpoint.

Make the API request and parse the response.

Make the API request, raising on error.

Make the API request and return the raw response map (no key transformation).

Make the API request returning raw map, raising on error.

Returns true if any storage backend is enabled.

Get the number of vaults.

Types

@type t() :: %Hyperliquid.Api.Stats.Vaults{vaults: [vault()]}
@type vault() :: %{
  apr: float(),
  pnls: [{String.t(), [String.t()]}],
  summary: vault_summary()
}
@type vault_relationship() :: %{type: String.t()}
@type vault_summary() :: %{
  name: String.t(),
  vault_address: String.t(),
  leader: String.t(),
  tvl: String.t(),
  is_closed: boolean(),
  relationship: vault_relationship(),
  create_time_millis: non_neg_integer()
}

Functions

Returns metadata about this endpoint.

Example

iex> Hyperliquid.Api.Stats.Vaults.__endpoint_info__()
%{
  endpoint: "vaults",
  type: :stats,
  rate_limit_cost: 0,
  params: [],
  optional_params: [],
  doc: "Retrieve vault performance data",
  returns: "List of vaults with APR, PnL, and summary information"
}

Returns postgres table configurations (multi-table support).

Returns storage configuration for this endpoint.

Build a cache key from response data using the configured pattern. Returns nil if cache is not enabled or no pattern configured.

@spec by_apr(t()) :: [vault()]

Get vaults sorted by APR (descending).

Parameters

  • vaults: The vaults struct

Returns

  • [vault()]
@spec by_tvl(t()) :: [vault()]

Get vaults sorted by TVL (descending).

Parameters

  • vaults: The vaults struct

Returns

  • [vault()]

Returns true if cache storage is enabled.

Returns the cache TTL if configured.

Link to this function

changeset(vaults \\ %__MODULE__{}, attrs)

View Source
@spec changeset(t(), map()) :: Ecto.Changeset.t()

Creates a changeset for vaults data.

@spec fetch() :: {:ok, t()} | {:error, term()}

Fetch data and persist to configured storage backends.

This calls request/0 and then stores the result using Storage.Writer.

@spec fetch!() :: t()

Fetch data and persist. Raises on error.

Link to this function

filter_by_status(arg1, is_closed)

View Source
@spec filter_by_status(t(), boolean()) :: [vault()]

Filter vaults by open/closed status.

Parameters

  • vaults: The vaults struct
  • is_closed: true for closed vaults, false for open vaults

Returns

  • [vault()]
Link to this function

get_vault(arg1, address)

View Source
@spec get_vault(t(), String.t()) :: {:ok, vault()} | {:error, :not_found}

Get a specific vault by address.

Parameters

  • vaults: The vaults struct
  • address: Vault address (0x...)

Returns

  • {:ok, vault()} if found
  • {:error, :not_found} if not found
Link to this function

get_window_pnl(vault, window)

View Source
@spec get_window_pnl(vault(), String.t()) ::
  {:ok, [String.t()]} | {:error, :not_found}

Get PnL for a specific time window from a vault.

Parameters

  • vault: A vault map
  • window: Time window ("day", "week", "month", "allTime")

Returns

  • {:ok, [String.t()]} if found (list of PnL values)
  • {:error, :not_found} if window not found
@spec parse_response(map()) :: {:ok, t()} | {:error, term()}

Parse and validate the API response.

Returns true if postgres storage is enabled.

Returns the postgres table name if configured (primary table for legacy support).

Link to this function

postgres_upsert_config()

View Source

Returns the upsert config for postgres (primary table for legacy support).

@spec rate_limit_cost() :: non_neg_integer()

Get the rate limit cost for this endpoint.

@spec request() :: {:ok, t()} | {:error, term()}

Make the API request and parse the response.

@spec request!() :: t()

Make the API request, raising on error.

@spec request_raw() :: {:ok, map()} | {:error, term()}

Make the API request and return the raw response map (no key transformation).

@spec request_raw!() :: map()

Make the API request returning raw map, raising on error.

Returns true if any storage backend is enabled.

@spec vault_count(t()) :: non_neg_integer()

Get the number of vaults.

Parameters

  • vaults: The vaults struct

Returns

  • non_neg_integer()