View Source Hyperliquid.Cache (hyperliquid v0.1.3)

Application cache for storing asset lists and exchange meta information.

This module provides functions to initialize and manage a cache for Hyperliquid-related data, including asset information, exchange metadata, and utility functions for retrieving and manipulating cached data.

The cache is implemented using Cachex and stores various pieces of information such as:

  • Exchange metadata
  • Spot market metadata
  • Asset mappings
  • Decimal precision information
  • Token information

It also provides utility functions for working with assets, tokens, and other cached data.

Summary

Functions

Retrieves the asset index for a given coin symbol.

Clears all entries in the cache.

Decrements a key's value in the cache by a given amount.

Removes a key from the cache.

Checks if a key exists in the cache.

Retrieves a value from the cache by key.

Gets a value from the cache and updates it using the provided function.

Increments a key's value in the cache by a given amount.

Initializes the cache with api information.

Puts a key-value pair into the cache.

Executes a transaction for a set of keys.

Functions

Retrieves the asset index for a given coin symbol.

Parameters

  • coin: The coin symbol (e.g., "BTC", "ETH")

Returns

The asset index corresponding to the given coin symbol, or nil if not found.

Example

iex> Hyperliquid.Cache.asset_from_coin("SOL")
5

Clears all entries in the cache.

Link to this function

decimals_from_coin(coin)

View Source

Decrements a key's value in the cache by a given amount.

Removes a key from the cache.

Checks if a key exists in the cache.

Retrieves a value from the cache by key.

Link to this function

get_and_update(key, func)

View Source

Gets a value from the cache and updates it using the provided function.

Link to this function

get_token_by_address(address)

View Source
Link to this function

get_token_by_index(index)

View Source
Link to this function

get_token_name_by_index(index)

View Source

Increments a key's value in the cache by a given amount.

Initializes the cache with api information.

Puts a key-value pair into the cache.

Executes a transaction for a set of keys.