diff --git a/hyperliquid/info.py b/hyperliquid/info.py index 39945771..df0aa4fd 100644 --- a/hyperliquid/info.py +++ b/hyperliquid/info.py @@ -1,5 +1,5 @@ from hyperliquid.api import API -from hyperliquid.utils.types import Any, Callable, Meta, SpotMeta, Optional, Subscription, cast, Cloid +from hyperliquid.utils.types import Any, Callable, Meta, SpotMeta, SpotMetaAndAssetCtxs, Optional, Subscription, cast, Cloid from hyperliquid.websocket_manager import WebsocketManager @@ -179,24 +179,68 @@ def spot_meta(self) -> SpotMeta: Returns: { - tokens: [ + universe: [ { + tokens: [int, int], name: str, - szDecimals: int, - weiDecimals: int + index: int, + isCanonical: bool }, ... - ], - universe: [ + ] + tokens: [ { name: str, - tokens: [int, int] + szDecimals: int, + weiDecimals: int, + index: int, + tokenId: str, + isCanonical: bool }, ... - ] + ], } """ return cast(SpotMeta, self.post("/info", {"type": "spotMeta"})) + + def spot_meta_and_asset_ctxs(self) -> SpotMetaAndAssetCtxs: + """Retrieve exchange spot asset contexts + + POST /info + + Returns: + [ + { + universe: [ + { + name: str, + tokens: [int, int] + } + ... + ], + tokens: [ + { + name: str, + szDecimals: int, + weiDecimals int + }, + ... + ] + }, + [ + { + dayNtlVlm: float, + markPx: float, + midPx: float, + prevDayPx: float, + circulatingSupply: float, + coin: str + } + ... + ] + ] + """ + return cast(SpotMetaAndAssetCtxs, self.post("/info", {"type": "spotMetaAndAssetCtxs"})) def funding_history(self, coin: str, startTime: int, endTime: Optional[int] = None) -> Any: """Retrieve funding history for a given coin diff --git a/hyperliquid/utils/types.py b/hyperliquid/utils/types.py index b1f4e3fa..48e4c91a 100644 --- a/hyperliquid/utils/types.py +++ b/hyperliquid/utils/types.py @@ -29,6 +29,9 @@ ) SpotMeta = TypedDict("SpotMeta", {"universe": List[SpotAssetInfo], "tokens": List[SpotTokenInfo]}) +SpotAssetCtx = TypedDict("SpotAssetCtx", {"dayNtlVlm": str, "markPx": str, "midPx": Optional[str], "prevDayPx": str, "circulatingSupply": str, "coin": str}) +SpotMetaAndAssetCtxs = Tuple[SpotMeta, List[SpotAssetCtx]] + AllMidsSubscription = TypedDict("AllMidsSubscription", {"type": Literal["allMids"]}) L2BookSubscription = TypedDict("L2BookSubscription", {"type": Literal["l2Book"], "coin": str}) TradesSubscription = TypedDict("TradesSubscription", {"type": Literal["trades"], "coin": str})