Description
Since SDK version 0.23, Info.__init__() crashes with IndexError: list index out of range
when the spotMeta API returns a spot market whose token index exceeds the length of the
tokens list.
Steps to reproduce
from hyperliquid.info import Info
info = Info('https://api.hyperliquid.xyz', skip_ws=True)
Traceback:
File ".../hyperliquid/info.py", line 48, in init
base_info = spot_meta["tokens"][base]
IndexError: list index out of range
Root cause
The spotMeta API currently returns a market named @367 in universe with
tokens: [479, 0], but the tokens list has only 464 entries (indices 0–463).
So spot_meta["tokens"][479] raises IndexError.
Verified with:
import requests
resp = requests.post('https://api.hyperliquid.xyz/info', json={'type': 'spotMeta'})
data = resp.json()
for u in data['universe']:
base, quote = u['tokens']
if base >= len(data['tokens']) or quote >= len(data['tokens']):
print('OUT OF RANGE:', u['name'], 'base=', base, 'quote=', quote, 'tokens len=', len(data['tokens']))
# OUT OF RANGE: @367 base= 479 quote= 0 tokens len= 464
Suggested fix
Wrap the offending lines in a try/except IndexError: continue to skip incomplete
markets gracefully:
base, quote = spot_info["tokens"]
try:
base_info = spot_meta["tokens"][base]
quote_info = spot_meta["tokens"][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:
self.name_to_coin[name] = spot_info["name"]
except IndexError:
continue
Impact
This bug makes the SDK completely unusable — Info() crashes on import,
breaking all read and trading operations.
Environment
hyperliquid-python-sdk version: 0.23
- Python: 3.10
Description
Since SDK version 0.23,
Info.__init__()crashes withIndexError: list index out of rangewhen the
spotMetaAPI returns a spot market whose token index exceeds the length of thetokenslist.Steps to reproduce
Traceback:
File ".../hyperliquid/info.py", line 48, in init
base_info = spot_meta["tokens"][base]
IndexError: list index out of range
Root cause
The
spotMetaAPI currently returns a market named@367inuniversewithtokens: [479, 0], but thetokenslist has only 464 entries (indices 0–463).So
spot_meta["tokens"][479]raisesIndexError.Verified with:
Suggested fix
Wrap the offending lines in a
try/except IndexError: continueto skip incompletemarkets gracefully:
Impact
This bug makes the SDK completely unusable —
Info()crashes on import,breaking all read and trading operations.
Environment
hyperliquid-python-sdkversion: 0.23