From bc81bdfb294861e065f3eed132ea8acb37bc797a Mon Sep 17 00:00:00 2001 From: huangwei Date: Sat, 7 Mar 2026 17:27:25 +0800 Subject: [PATCH] fix: token info retrieval in Info and readme --- README.md | 5 ++++- hyperliquid/info.py | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3184e5db..41a9cb05 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,10 @@ python examples/basic_order.py - Note that Poetry v2 is not supported, so you'll need to specify a specific version e.g. curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.4.1 python3 - 2. Point poetry to correct version of python. For development we require python 3.10 exactly. Some dependencies have issues on 3.11, while older versions don't have correct typing support. -`brew install python@3.10 && poetry env use /opt/homebrew/Cellar/python@3.10/3.10.16/bin/python3.10` +``` +brew install python@3.10 && poetry env use 3.10 +``` + - You can also bind the environment directly to the Homebrew path using:`poetry env use $(brew --prefix python@3.10)/bin/python3.10` 3. Install dependencies: diff --git a/hyperliquid/info.py b/hyperliquid/info.py index a86ac807..81d756db 100644 --- a/hyperliquid/info.py +++ b/hyperliquid/info.py @@ -39,14 +39,16 @@ def __init__( self.name_to_coin = {} self.asset_to_sz_decimals = {} + token_index_to_token_info = {token_info["index"]: token_info for token_info in spot_meta["tokens"]} + # spot assets start at 10000 for spot_info in spot_meta["universe"]: asset = spot_info["index"] + 10000 self.coin_to_asset[spot_info["name"]] = asset self.name_to_coin[spot_info["name"]] = spot_info["name"] base, quote = spot_info["tokens"] - base_info = spot_meta["tokens"][base] - quote_info = spot_meta["tokens"][quote] + base_info = token_index_to_token_info[base] + quote_info = token_index_to_token_info[quote] self.asset_to_sz_decimals[asset] = base_info["szDecimals"] name = f'{base_info["name"]}/{quote_info["name"]}' if name not in self.name_to_coin: