-
Notifications
You must be signed in to change notification settings - Fork 0
feat(hl): backfill missed hyperliquid order updates on startup #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
terwey
commented
Oct 29, 2025
- add sqlc helper and storage API to enumerate stored HL metadata
- introduce Info-based status refresher + converter for REST order payloads
- refresh statuses before fill tracker rebuild and during periodic resync
- add sqlc helper and storage API to enumerate stored HL metadata - introduce Info-based status refresher + converter for REST order payloads - refresh statuses before fill tracker rebuild and during periodic resync
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๐ก Codex Review
Here are some automated review suggestions for this pull request.
โน๏ธ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with ๐.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| func (r *StatusRefresher) refreshOne(ctx context.Context, md metadata.Metadata) (bool, error) { | ||
| result, err := r.client.QueryOrderByCloid(ctx, md.Hex()) | ||
| if err != nil { | ||
| if r.logger != nil { | ||
| r.logger.Warn("failed to query order status", | ||
| slog.String("md", md.Hex()), | ||
| slog.String("error", err.Error())) | ||
| } | ||
| return false, fmt.Errorf("query order %s: %w", md.Hex(), err) | ||
| } | ||
| if result == nil { | ||
| return false, fmt.Errorf("query order %s returned nil result", md.Hex()) | ||
| } | ||
|
|
||
| wsOrder, err := orderResultToWsOrder(md, result) | ||
| if err != nil { | ||
| return false, fmt.Errorf("convert order %s: %w", md.Hex(), err) | ||
| } | ||
| if wsOrder == nil { | ||
| if r.logger != nil { | ||
| r.logger.Debug("order status unavailable", | ||
| slog.String("md", md.Hex()), | ||
| slog.String("query_status", string(result.Status))) | ||
| } | ||
| return false, nil | ||
| } | ||
|
|
||
| if err := r.store.RecordHyperliquidStatus(ctx, md, *wsOrder); err != nil { | ||
| return false, fmt.Errorf("record status %s: %w", md.Hex(), err) | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skip writing unchanged Hyperliquid statuses
The refresher writes a new row to hyperliquid_status_history every time it runs, regardless of whether Hyperliquid reports a different status. Because the resync loop in cmd/recomma/main.go now calls statusRefresher.Refresh every ResyncInterval (15โฏs by default), this code path will insert a fresh record and emit an SSE event for every tracked order on every tick even when nothing changed. The table will grow unbounded and clients will see duplicate status updates. Consider comparing the fetched WsOrder (e.g. by Status and StatusTimestamp) to the most recent stored status and only calling RecordHyperliquidStatus when something actually changed, or limiting the refresher to startup only.
Useful? React with ๐ย / ๐.
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? โน๏ธ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with ๐. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |