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

Referral information for a user.

Returns referral stats, rewards, and referrer state.

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

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 referral data.

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

Check if user has unclaimed rewards.

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.

Get the referral code if user is a referrer.

Get the referrer address.

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 (claimed + unclaimed).

Check if user was referred.

Types

@type t() :: %Hyperliquid.Api.Info.Referral{
  builder_rewards: String.t(),
  claimed_rewards: String.t(),
  cum_vlm: String.t(),
  referred_by: ReferredBy.t() | nil,
  referrer_state: ReferrerState.t() | nil,
  reward_history: [map()],
  token_to_state: [map()],
  unclaimed_rewards: String.t()
}

Functions

Returns metadata about this endpoint.

Example

iex> Hyperliquid.Api.Info.Referral.__endpoint_info__()
%{
  endpoint: "referral",
  type: :info,
  rate_limit_cost: 1,
  params: [:user],
  optional_params: [],
  doc: "Retrieve referral information for a user",
  returns: "Referral stats, rewards, and referrer state"
}

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(referral \\ %__MODULE__{}, attrs)

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

Creates a changeset for referral data.

Parameters

  • referral: The referral struct
  • attrs: Map of attributes to validate

Returns

  • Ecto.Changeset.t()

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

Link to this function

has_unclaimed_rewards?(referral)

View Source
@spec has_unclaimed_rewards?(t()) :: boolean()

Check if user has unclaimed rewards.

Parameters

  • referral: The referral struct

Returns

  • boolean()
@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 referral_code(t()) :: {:ok, String.t()} | {:error, :no_code}

Get the referral code if user is a referrer.

Parameters

  • referral: The referral struct

Returns

  • {:ok, String.t()} if has code
  • {:error, :no_code} if not a referrer
@spec referrer(t()) :: {:ok, String.t()} | {:error, :not_referred}

Get the referrer address.

Parameters

  • referral: The referral struct

Returns

  • {:ok, String.t()} if referred
  • {:error, :not_referred} if not referred
@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.

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

Get total rewards (claimed + unclaimed).

Parameters

  • referral: The referral struct

Returns

  • {:ok, float()} - Total rewards
  • {:error, :parse_error} - If parsing fails
@spec was_referred?(t()) :: boolean()

Check if user was referred.

Parameters

  • referral: The referral struct

Returns

  • boolean()