fix(perps): fix HIP-3 asset ID lookup failure from dual-cache desync cp-7.70.1#27854
Conversation
The standalone preload path (#getStandaloneValidatedDexs) populated #cachedValidatedDexs but not #cachedAllPerpDexs. When the full init later hit the cache, buildAssetMapping couldn't compute perpDexIndex for HIP-3 DEXs, causing "Asset ID not found for xyz:BRENTOIL". - Populate #cachedAllPerpDexs in standalone path - Remove cache poisoning writes from #buildAssetMapping - Use local fallback instead of persistent [null] write
|
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. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
This directly impacts the Perps Add Funds flow and DEX asset mapping. The fix is isolated to the HyperLiquidProvider and doesn't touch shared infrastructure. Tags selected:
Performance Test Selection: |
|
✅ E2E Fixture Validation — Schema is up to date |
|



Description
Fix HIP-3 asset ID lookup failure (
"Asset ID not found for xyz:BRENTOIL") that blocked trading on HIP-3 markets when navigating via the old Perps tab layout.Root cause: Dual-cache desync between
#cachedValidatedDexs(string DEX names) and#cachedAllPerpDexs(raw API objects forperpDexIndexcomputation). The standalone preload path (#getStandaloneValidatedDexs) populated one cache but not the other. When#buildAssetMappinglater ran, it found "xyz" indexsToMapbut couldn't compute itsperpDexIndexbecause#cachedAllPerpDexswas null.Why old Perps tab vs new Homepage Sections: Both layouts sit inside
Wallet/index.tsx, which callsstartMarketDataPreload()on mount. This fires standalone HTTP calls that populate#cachedValidatedDexsbut not#cachedAllPerpDexs.PerpsSectionWithProvidermounts immediately. Stream hooks fireensureReady()before or concurrently with the standalone preload. Since#cachedValidatedDexsis often still null,fetchValidatedDexsInternalruns fresh and sets both caches correctly.startMarketDataPreload()has already completed →#cachedValidatedDexsis populated by standalone. When the tab mounts →getValidatedDexs()→ cache hit →fetchValidatedDexsInternalis never called →#cachedAllPerpDexsstays null →buildAssetMappingcan't find "xyz".Changes (1 file, 3 sites):
#getStandaloneValidatedDexsnow setsthis.#cachedAllPerpDexs = allDexsafter a successfulperpDexs()call, keeping both caches in sync.this.#cachedAllPerpDexs = this.#cachedAllPerpDexs ?? [null]from the catch block in#buildAssetMapping.if (!cache) { cache = [null] }with localconst allPerpDexs = cache ?? [null]— consumers read the cache, only the owner writes it.Changelog
CHANGELOG entry: Fixed a bug where closing positions on HIP-3 markets (e.g., xyz:BRENTOIL) failed with "Asset ID not found" when navigating via the Perps tab
Related issues
Fixes: HIP-3 asset ID lookup failure on old Perps tab layout
Manual testing steps
Screenshots/Recordings
Before
Metro logs show the desync:
After
Metro logs show both caches in sync:
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Touches HIP-3 market routing/asset-ID mapping in
HyperLiquidProvider, so a mistake could break trading on some perps markets; scope is small and localized to cache population/fallback behavior.Overview
Fixes a HIP-3 asset mapping failure where
#cachedValidatedDexscould be populated via the standalone preload path while#cachedAllPerpDexsstayednull, leading to missingperpDexIndexduring#buildAssetMapping.#getStandaloneValidatedDexs()now also populates#cachedAllPerpDexsafter a successfulperpDexs()call, and#buildAssetMapping()no longer “poisons” the shared cache with a persistent[null]fallback (it uses a local fallback instead).Written by Cursor Bugbot for commit c925609. This will update automatically on new commits. Configure here.