Skip to content

Conversation

@Basicker
Copy link

2 collections were introduced in the Cache module:assets_name_to_coin_map and assets_name_to_index_map and two new functions asset_name_to_coin/1 and asset_name_to_index/1.

  • assets_name_to_coin_map maps perp assets (e.g: BTC, ETH; SOL, etc...) to their respective coin (BTC, ETH, SOL, ...) and spot assets (e.g: PURR/USDC, HFUN/USDC, JEFF/USDC, etc...) to their respective coin (PURR/USDC, @1, @4, @...)

The naming coin is in line with the official doc https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#perpetuals-vs-spot

The endpoints in this section as well as websocket subscriptions work for both Perpetuals and Spot. For perpetuals coin is the name returned in the meta response. For Spot, coin should be PURR/USDC for PURR, and @{index} e.g. @1 for all other spot tokens where index is the index in the universe field of the spotMeta response.

  • assets_name_to_index_map maps perp assets (e.g: BTC, ETH; SOL, etc...) to their respective index (0, 1, 5, etc...) and spot assets (e.g: PURR/USDC, HFUN/USDC, JEFF/USDC, etc...) to their respective index (10_000, 10_001, 10_004, etc...)

The following modules lib/hyperliquid/orders/order_wire.ex and lib/hyperliquid/orders/orders.ex were also updated to use the new functions.

I am open to any discussion on the naming and improvements to the functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant