Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions app/controllers/perps/providers/HyperLiquidProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2119,16 +2119,13 @@ export class HyperLiquidProvider implements PerpsProvider {
'[buildAssetMapping] getValidatedDexs failed, falling back to main DEX',
{ error: String(dexError) },
);
this.#cachedAllPerpDexs = this.#cachedAllPerpDexs ?? [null];
dexsToMap = [null];
}

// Use cached perpDexs array (populated by getValidatedDexs)
// Defensive: ensure non-null even if getValidatedDexs had an unexpected issue
if (!this.#cachedAllPerpDexs) {
this.#cachedAllPerpDexs = [null];
}
const allPerpDexs = this.#cachedAllPerpDexs;
// Local fallback only — never write [null] into #cachedAllPerpDexs here.
// That cache is owned exclusively by #fetchValidatedDexsInternal; writing a
// fallback here would prevent subsequent callers from retrying perpDexs().
const allPerpDexs = this.#cachedAllPerpDexs ?? [null];

this.#deps.debugLogger.log(
'HyperLiquidProvider: Starting asset mapping rebuild',
Expand Down Expand Up @@ -4772,6 +4769,12 @@ export class HyperLiquidProvider implements PerpsProvider {
return [null];
}

// Populate #cachedAllPerpDexs so buildAssetMapping can compute perpDexIndex.
// Without this, getValidatedDexs returns from #cachedValidatedDexs (string names)
// but #cachedAllPerpDexs (raw objects for index computation) stays null,
// causing "Could not find perpDexIndex for DEX xyz" failures.
this.#cachedAllPerpDexs = allDexs;

// Extract HIP-3 DEX names (filter out null which represents main DEX)
const availableHip3Dexs: string[] = [];
allDexs.forEach((dex) => {
Expand Down
Loading