View Source Hyperliquid.Api.Info.Delegations (hyperliquid v0.2.2)

User's staking delegations.

Returns the list of validators a user has delegated to, with amounts and lock times.

See: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-delegations

Usage

{:ok, delegations} = Delegations.request("0x1234...")
{:ok, total} = Delegations.total_delegated(delegations)

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.

Build the request payload.

Returns true if cache storage is enabled.

Returns the cache TTL if configured.

Creates a changeset for delegations data.

Fetch is an alias for request when no storage is configured.

Get delegations that are currently locked.

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 delegation to a specific validator.

Get total delegated amount.

Get delegations that are unlocked.

Get all unique validators.

Types

@type t() :: %Hyperliquid.Api.Info.Delegations{delegations: [Delegation.t()]}

Functions

Returns metadata about this endpoint.

Example

iex> Hyperliquid.Api.Info.Delegations.__endpoint_info__()
%{
  endpoint: "delegations",
  type: :info,
  rate_limit_cost: 2,
  params: [:user],
  optional_params: [],
  doc: "Retrieve user's staking delegations",
  returns: "List of validators user has delegated to with amounts and lock times"
}

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 build_request(term()) :: map()

Build the request payload.

Returns true if cache storage is enabled.

Returns the cache TTL if configured.

Link to this function

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

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

Creates a changeset for delegations data.

Parameters

  • delegations: The delegations struct
  • attrs: Map with delegations key

Returns

  • Ecto.Changeset.t()

Fetch is an alias for request when no storage is configured.

Link to this function

locked(delegations, current_time)

View Source
@spec locked(t(), non_neg_integer()) :: [map()]

Get delegations that are currently locked.

Parameters

  • delegations: The delegations struct
  • current_time: Current time in milliseconds

Returns

  • List of locked delegations
@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(term()) :: {:ok, t()} | {:error, term()}

Make the API request and parse the response.

@spec request!(term()) :: t()

Make the API request, raising on error.

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

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

@spec request_raw!(term()) :: map()

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

Returns true if any storage backend is enabled.

Link to this function

to_validator(delegations, validator)

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

Get delegation to a specific validator.

Parameters

  • delegations: The delegations struct
  • validator: Validator address

Returns

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

total_delegated(delegations)

View Source
@spec total_delegated(t()) :: {:ok, float()} | {:error, :parse_error}

Get total delegated amount.

Parameters

  • delegations: The delegations struct

Returns

  • {:ok, float()} - Total amount
  • {:error, :parse_error} - If parsing fails
Link to this function

unlocked(delegations, current_time)

View Source
@spec unlocked(t(), non_neg_integer()) :: [map()]

Get delegations that are unlocked.

Parameters

  • delegations: The delegations struct
  • current_time: Current time in milliseconds

Returns

  • List of unlocked delegations
@spec validators(t()) :: [String.t()]

Get all unique validators.

Parameters

  • delegations: The delegations struct

Returns

  • List of validator addresses