Skip to content

Commit dcceea3

Browse files
docs: spot_meta_and_asset_ctxs returns two non-parallel lists
universe (324) and assetCtxs (715) are not parallel; pair them through the universe entry's own `index` field. Positions 0-70 line up, which hides the mismatch during casual testing and returns another asset's prices past that point. The perp sibling meta_and_asset_ctxs() IS parallel, so the intuition does not carry over. Docstring only, no behaviour change. Closes #308.
1 parent 2fdb18f commit dcceea3

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

hyperliquid/info.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,29 @@ def spot_meta(self) -> SpotMeta:
359359

360360
def spot_meta_and_asset_ctxs(self) -> SpotMetaAndAssetCtxs:
361361
"""Retrieve exchange spot asset contexts
362+
362363
POST /info
364+
365+
Note:
366+
The two returned lists are NOT parallel. Pair a universe entry with its context
367+
through the entry's own `index` field, never through its position:
368+
369+
meta, ctxs = info.spot_meta_and_asset_ctxs()
370+
ctx = ctxs[entry["index"]] # correct
371+
ctx = ctxs[i] # wrong for i >= 71
372+
373+
On mainnet (2026-08-10) `universe` has 324 entries and `assetCtxs` has 715.
374+
Positions 0-70 happen to line up, so zipping the two looks correct on every asset
375+
you are likely to eyeball, and returns another asset's prices past that point:
376+
at position 71 (`@72`) zipping gives markPx 1.0 where the asset's own context
377+
says 0.72847.
378+
379+
Note this differs from `meta_and_asset_ctxs()` (perps), where the two lists ARE
380+
parallel and the asset id IS the list position. This class already encodes the
381+
distinction in `__init__` — perps use `enumerate(...)`, spot uses
382+
`spot_info["index"] + 10000` — so carrying the perp intuition over to spot is
383+
the mistake this note exists to prevent.
384+
363385
Returns:
364386
[
365387
{

0 commit comments

Comments
 (0)