chore(runway): cherry-pick fix(perps): add spotMeta caching to reduce API calls on HIP-3 markets#25511
Merged
joaoloureirop merged 3 commits intorelease/7.63.0from Feb 2, 2026
Merged
Conversation
This commit manually ports the changes from commit b5c386c to reduce API calls during HIP-3 operations by caching spotMeta responses. Changes: - Added session-based `cachedSpotMeta` cache in HyperLiquidProvider - Added `getCachedSpotMeta()` method for centralized cache access - Updated `getUsdcTokenId()`, `isUsdhCollateralDex()`, `swapUsdcToUsdh()` to use cached spotMeta instead of making fresh API calls - Cache invalidated on `disconnect()` to ensure fresh state on reconnect - Extended `ensureError()` to handle undefined/null with optional context - Standardized error handling across perps providers to use ensureError - Added SpotMetaResponse type to hyperliquid-types.ts - Added TradingReadinessCache service for future signing state management Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
joaoloureirop
approved these changes
Feb 2, 2026
Contributor
🔍 Smart E2E Test Selection⏭️ Smart E2E selection skipped - base branch is not main (base: release/7.63.0) All E2E tests pre-selected. |
michalconsensys
approved these changes
Feb 2, 2026
|
Collaborator
|
No release label on PR. Adding release label release-7.63.0 on PR, as PR was cherry-picked in branch 7.63.0. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
fix(perps): add spotMeta caching to reduce API calls on HIP-3
markets
This PR adds session-based caching for HyperLiquid's global
spotMetaendpoint to avoid redundant API calls during HIP-3 operations.
Context
Following a rate limiting incident where excessive API calls triggered
HyperLiquid's rate limits (2000 msg/min), this is a defensive
improvement to reduce unnecessary network requests.
Problem
The
spotMetaAPI (which returns token metadata like USDC/USDH indices)was being called multiple times per trading session:
getUsdcTokenId()- called during transfersisUsdhCollateralDex()- called to check collateral typeswapUsdcToUsdh()- called during HIP-3 USDH swapsEach call was making a fresh API request, even though the data (token
indices) doesn't change during a session.
Solution
cachedSpotMetaproperty for session-based caching (no TTL -token indices are stable)
getCachedSpotMeta()method that returns cached data or fetchesonce
ensureReadyForTrading()when HIP-3 is enabled(non-blocking)
disconnect()to ensure fresh state onreconnect/account switch
Design Decisions
spotMetais a global endpointreturning all tokens
session
getCachedMeta(),getCachedPerpDexs()Changelog
CHANGELOG entry: Fixed excessive API calls on HIP-3 markets by caching
spot metadata
Related issues
Fixes: N/A (Defensive improvement following rate limiting incident)
Manual testing steps
Screenshots/Recordings
N/A - Internal optimization, no UI changes
Before
Multiple
spotMetaAPI calls per session (one per HIP-3 operation)After
Single
spotMetaAPI call per session, cached for subsequent operationsPre-merge author checklist
Docs and MetaMask Mobile
Coding
Standards.
if applicable
guidelines).
Not required for external contributors.
Pre-merge reviewer checklist
app, test code being changed).
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
Note
Medium Risk
Touches core Perps trading/connectivity paths (HIP-3 collateral checks, transfers, connection lifecycle), so caching or error-wrapping regressions could impact order placement or diagnostics despite being largely additive and well-tested.
Overview
Reduces redundant HyperLiquid API calls by adding a session-scoped
spotMetacache inHyperLiquidProviderand routing HIP-3 collateral checks/USDC↔USDH flows through it, with cache cleared on disconnect.Standardizes error handling by expanding
ensureError(better undefined/null handling + optional context) and updating Perps connection/provider/stream logging and Sentry capture to use it.Introduces a global singleton signing readiness cache (
TradingReadinessCache/PerpsSigningCache) with in-flight locks to prevent repeated signing prompts, plus comprehensive unit tests and updated HyperLiquid provider test mocks/types (SpotMetaResponse).Written by Cursor Bugbot for commit 90f96a1. This will update automatically on new commits. Configure here.
b5c386c