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

User's staking rewards history.

Returns delegation and commission rewards with timestamps.

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

Usage

{:ok, rewards} = DelegatorRewards.request("0x1234...")
{:ok, total} = DelegatorRewards.total_rewards(rewards)

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.

Get rewards by source type.

Returns true if cache storage is enabled.

Returns the cache TTL if configured.

Creates a changeset for delegator rewards data.

Get commission rewards only.

Get delegation rewards only.

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

Get rewards within a time range.

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 total rewards by source.

Get total rewards across all entries.

Get valid reward sources.

Types

@type t() :: %Hyperliquid.Api.Info.DelegatorRewards{rewards: [Reward.t()]}

Functions

Returns metadata about this endpoint.

Example

iex> Hyperliquid.Api.Info.DelegatorRewards.__endpoint_info__()
%{
  endpoint: "delegatorRewards",
  type: :info,
  rate_limit_cost: 2,
  params: [:user],
  optional_params: [],
  doc: "Retrieve user's staking rewards history",
  returns: "Delegation and commission rewards with timestamps"
}

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.

Link to this function

by_source(delegator_rewards, source)

View Source
@spec by_source(t(), String.t()) :: [map()]

Get rewards by source type.

Parameters

  • rewards: The delegator rewards struct
  • source: Source type ("delegation" or "commission")

Returns

  • List of rewards from the source

Returns true if cache storage is enabled.

Returns the cache TTL if configured.

Link to this function

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

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

Creates a changeset for delegator rewards data.

Parameters

  • rewards: The delegator rewards struct
  • attrs: Map with rewards key

Returns

  • Ecto.Changeset.t()
Link to this function

commission_rewards(rewards)

View Source
@spec commission_rewards(t()) :: [map()]

Get commission rewards only.

Parameters

  • rewards: The delegator rewards struct

Returns

  • List of commission rewards
Link to this function

delegation_rewards(rewards)

View Source
@spec delegation_rewards(t()) :: [map()]

Get delegation rewards only.

Parameters

  • rewards: The delegator rewards struct

Returns

  • List of delegation rewards

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

Link to this function

in_range(delegator_rewards, start_time, end_time)

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

Get rewards within a time range.

Parameters

  • rewards: The delegator rewards struct
  • start_time: Start timestamp in ms
  • end_time: End timestamp in ms

Returns

  • List of rewards in range
@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

total_by_source(dr, source)

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

Get total rewards by source.

Parameters

  • rewards: The delegator rewards struct
  • source: Source type

Returns

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

total_rewards(delegator_rewards)

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

Get total rewards across all entries.

Parameters

  • rewards: The delegator rewards struct

Returns

  • {:ok, float()} - Total rewards
  • {:error, :parse_error} - If parsing fails
@spec valid_sources() :: [String.t()]

Get valid reward sources.

Returns

  • List of valid source strings