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

Leaderboard data from the Hyperliquid stats API.

Returns trading leaderboard with account values, performance metrics, and rankings.

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

Usage

{:ok, leaderboard} = Leaderboard.request()
{:ok, trader} = Leaderboard.get_trader(leaderboard, "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.

Returns true if cache storage is enabled.

Returns the cache TTL if configured.

Creates a changeset for leaderboard data.

Fetch data and persist to configured storage backends.

Fetch data and persist. Raises on error.

Get a specific trader's row by address.

Get performance for a specific time window from a trader's row.

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 top N traders from the leaderboard.

Get the number of traders on the leaderboard.

Types

@type leaderboard_row() :: %{
  eth_address: String.t(),
  account_value: String.t(),
  window_performances: [{String.t(), window_performance()}],
  prize: non_neg_integer(),
  display_name: String.t() | nil
}
@type t() :: %Hyperliquid.Api.Stats.Leaderboard{leaderboard_rows: [leaderboard_row()]}
@type window_performance() :: %{pnl: String.t(), roi: String.t(), vlm: String.t()}

Functions

Returns metadata about this endpoint.

Example

iex> Hyperliquid.Api.Stats.Leaderboard.__endpoint_info__()
%{
  endpoint: "leaderboard",
  type: :stats,
  rate_limit_cost: 0,
  params: [],
  optional_params: [],
  doc: "Retrieve trading leaderboard",
  returns: "Leaderboard with trader rankings and performance metrics"
}

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.

Returns true if cache storage is enabled.

Returns the cache TTL if configured.

Link to this function

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

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

Creates a changeset for leaderboard 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

get_trader(arg1, address)

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

Get a specific trader's row by address.

Parameters

  • leaderboard: The leaderboard struct
  • address: Ethereum address (0x...)

Returns

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

get_window_performance(row, window)

View Source
@spec get_window_performance(leaderboard_row(), String.t()) ::
  {:ok, window_performance()} | {:error, :not_found}

Get performance for a specific time window from a trader's row.

Parameters

  • row: A leaderboard row
  • window: Time window ("day", "week", "month", "allTime")

Returns

  • {:ok, window_performance()} if found
  • {: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 top_traders(t(), non_neg_integer()) :: [leaderboard_row()]

Get top N traders from the leaderboard.

Parameters

  • leaderboard: The leaderboard struct
  • n: Number of top traders to return

Returns

  • [leaderboard_row()]
@spec trader_count(t()) :: non_neg_integer()

Get the number of traders on the leaderboard.

Parameters

  • leaderboard: The leaderboard struct

Returns

  • non_neg_integer()