View Source Hyperliquid.Cache (hyperliquid v0.1.0)
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.
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.
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
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.