Refactor Perpetuals to use HyperliquidObserverService#1635
Conversation
Replaces PerpetualObserverService with HyperliquidObserverService for perpetuals observation and updates related dependency injection, protocols, and usages throughout the codebase. Removes periodic polling in favor of WebSocket-based updates, adds Hyperliquid-specific protocol and types, and updates wallet/account accessors. Also updates WebSocketConnectable to support sending string messages and adds a PerpetualService mock for testing.
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 refactors the perpetuals feature by migrating its data observation mechanism from a polling-based system to a real-time WebSocket-driven approach using Hyperliquid's services. The change aims to provide users with more immediate and accurate updates for perpetuals, including live chart data, by establishing persistent connections and handling streaming messages. This improves responsiveness and efficiency by eliminating the need for frequent manual data fetches. 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 successfully refactors the perpetuals observation mechanism from periodic polling to a more efficient WebSocket-based approach using HyperliquidObserverService. The changes introduce real-time candlestick chart updates, update dependency injection across various services and views, and streamline wallet/account accessors. The new HyperliquidChartService and related types are well-integrated, and the PerpetualServiceMock provides good test coverage. Overall, the implementation demonstrates a robust shift towards real-time data handling and improved resource management.
fd99d7f to
6014b47
Compare
Introduces real-time candlestick chart updates for perpetuals by integrating HyperliquidChartService and chart subscription management in PerpetualSceneViewModel. Updates the observer service to handle candle messages, adds ChartCandleStick interval support, and wires dependencies through navigation and environment. This enables live chart data streaming and proper subscription lifecycle handling.
6014b47 to
589861c
Compare
Advanced the core submodule reference to commit f706ce21a167f0c9b58ae2b8717eebc09d22febf. This pulls in the latest changes from the core repository.
…ockets-for-perpetuals # Conflicts: # core
…ockets-for-perpetuals
…ockets-for-perpetuals # Conflicts: # core
Added dynamic axis tick count and price formatting to ChartBounds. Updated CandlestickChartView to use the new axis formatting and display a highlighted label for the current price with color based on price movement.
Introduces AllMids price subscription handling in HyperliquidObserverService and PerpetualsSceneViewModel, enabling real-time price updates for perpetuals. PerpetualService and PerpetualStore now support updating prices, with update frequency throttled via Preferences. Updates related protocols, mocks, and dependency injection to support the new functionality.
5f283d4 to
19dbdb8
Compare
99f2e5b to
fe8051c
Compare
Moved subscription logic for candles and mids to async onAppear/onDisappear methods in both PerpetualScene and PerpetualsScene. Updated ViewModels to subscribe/unsubscribe to all periods or mids on appearance/disappearance, and removed redundant or now-unnecessary code. This improves resource management and ensures subscriptions are properly handled with SwiftUI view lifecycle.
fe8051c to
ce03fa8
Compare
…ockets-for-perpetuals # Conflicts: # core
…Socket node support - Extract PerpetualObservable protocol with associated type for subscriptions - Extract ChartStreamable protocol and rename HyperliquidChartService to ChartObserverService - Replace specific subscribe/unsubscribe methods with generic subscribe(_:)/unsubscribe(_:) - Subscribe only to current chart period instead of all periods - Add PerpetualNodeService with Preferences-backed node selection - Add WebSocket base URLs to Constants and Chain extension for WS URLs - Remove hardcoded hyperliquidWebSocketURL constant
…ockets-for-perpetuals # Conflicts: # Features/Perpetuals/Sources/ViewModels/PerpetualsSceneViewModel.swift # Features/Perpetuals/TestKit/PerpetualsSceneViewModel+TestKit.swift # Gem/Services/ObserversService.swift # core
Replaces PerpetualObserverService with HyperliquidObserverService for perpetuals observation and updates related dependency injection, protocols, and usages throughout the codebase. Removes periodic polling in favor of WebSocket-based updates, adds Hyperliquid-specific protocol and types, and updates wallet/account accessors. Also updates WebSocketConnectable to support sending string messages and adds a PerpetualService mock for testing.
Introduces real-time candlestick chart updates for perpetuals by integrating HyperliquidChartService and chart subscription management in PerpetualSceneViewModel. Updates the observer service to handle candle messages, adds ChartCandleStick interval support, and wires dependencies through navigation and environment. This enables live chart data streaming and proper subscription lifecycle handling.
Close: #1082
Close: #1142