Repository navigation
Add websocket models and parsing for Hyperliquid - #907
Conversation
Introduces websocket message models and parsing logic in gem_hypercore for handling Hyperliquid websocket channels, including clearinghouse state, open orders, and subscription responses. Adds corresponding mapping and diffing utilities in gemstone to process and compare positions and orders from websocket data.
Changed Files
|
Summary of ChangesHello @DRadmir, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the system's ability to interact with the Hyperliquid exchange by integrating its WebSocket API. It establishes robust data models and parsing logic for real-time market and user-specific information, such as clearinghouse states, open orders, and detailed candlestick data. The changes also introduce mechanisms within Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces models and parsing logic for Hyperliquid websockets, along with adding an interval field to candlestick-related models. The changes are generally well-structured. However, I've identified a critical issue with a duplicate type definition that will prevent compilation. Additionally, I've provided suggestions to refactor some repetitive code and improve error handling for better maintainability and clarity. Addressing these points will enhance the quality of the code.
51b6801 to
a63faf6
Compare
Introduces an interval field to candlestick and chart models, updates related conversions, and adds support for handling candle messages over WebSocket. This enables interval-aware candlestick data processing and transmission throughout the system.
a63faf6 to
7d064f8
Compare
Introduces handling for the AllMids WebSocket channel, including parsing and mapping of mid prices as a HashMap<String, f64>. Updates relevant models and message enums to support this new channel.
Moved the logic for diffing clearinghouse and open order positions from the Gemstone layer into the gem_hypercore provider module. Introduced the PositionsDiff struct and related functions in gem_hypercore, updated WebSocketMessage to be generic, and adjusted usages in Gemstone to call the new provider functions. This improves code reuse and separation of concerns.
Added a generic parse method to WebSocketMessage for deserializing JSON. Updated websocket_mapper functions to use the new parse method, reducing code duplication and improving readability.
| pub summary: PerpetualPositionsSummary, | ||
| } | ||
|
|
||
| #[derive(Debug)] |
| Ok(WebSocketMessage::<serde_json::Value>::parse(json)?.channel) | ||
| } | ||
|
|
||
| pub fn parse_clearinghouse_state(json: &str) -> Result<ClearinghouseResult, serde_json::Error> { |
There was a problem hiding this comment.
why do you need all those parse methods? does not make much sense to have a separate method
| Self {} | ||
| } | ||
|
|
||
| pub fn parse_websocket_data(&self, data: Vec<u8>) -> Result<GemHyperliquidSocketMessage, crate::GemstoneError> { |
There was a problem hiding this comment.
can we move parse_websocket_data to hyperliquid lib?
Unified websocket message parsing into a single function returning a typed enum, replacing multiple parsing functions. Added comprehensive tests and JSON fixtures for all supported websocket message types. Updated dependent code to use the new parsing API and type alias for GemHyperliquidSocketMessage.
Introduces websocket message models and parsing logic in gem_hypercore for handling Hyperliquid websocket channels, including clearinghouse state, open orders, and subscription responses. Adds corresponding mapping and diffing utilities in gemstone to process and compare positions and orders from websocket data.
Introduces an interval field to candlestick and chart models, updates related conversions, and adds support for handling candle messages over WebSocket. This enables interval-aware candlestick data processing and transmission throughout the system.