Skip to content

Fix blank underlying symbol ("/ USD") on default ETH2X buys - #1978

Open
ripples3 wants to merge 1 commit into
masterfrom
fix/underlying-asset-symbol
Open

Fix blank underlying symbol ("/ USD") on default ETH2X buys#1978
ripples3 wants to merge 1 commit into
masterfrom
fix/underlying-asset-symbol

Conversation

@ripples3

Copy link
Copy Markdown

Problem

Open Positions and the success dialog show "/ USD" for ETH2X buys made from a bare /trade URL (e.g. the marketing navbar link) while on Arbitrum/Base. 42 Trade rows affected (31 Base, 11 Arbitrum), all ETH2X buys.

Root cause

defaultParams.outputToken in trade/provider.tsx is the mainnet ETH2X object. useQueryParams uses it verbatim when the URL has no buy param and only re-resolves on URL changes. mapQuoteToTrade then looks the token up by (chainId, address), misses, and saves underlyingAssetSymbol: ''. The trade itself was fine (quotes resolve by symbol). The backend's mendOutputTokenAddress has masked the address half of this since 2025-04.

Change

  • trade/provider.tsx: re-match URL/default token objects by symbol against the connected chain's token lists (trade page only; useQueryParams untouched).
  • New getUnderlyingAssetSymbol util + 44 tests: address lookup with a same-chain symbol fallback; output identical to before for all 41 leverage tokens; '' + console.warn when the underlying is not in the known list.
  • database.ts uses the util.

Verified

tsc / eslint / prettier / knip clean; jest 97/97. On the Vercel preview: bare /trade on Arbitrum, ETH → ETH2X buy saved underlyingAssetSymbol = ETH, outputTokenAddress = 0x26d7… — the same flow saved '' 90 minutes earlier on production.

Follow-ups (not in this PR)

  • Backfill the 42 existing rows (SQL ready).
  • Backend: derive underlyingAssetSymbol server-side (unused helper in utils/coingecko.ts), then retire mendOutputTokenAddress.
  • useQueryParams memo deps + the same pattern in earn/provider.tsx; chain-exclusive token fallback while the wallet is disconnected.

🤖 Generated with Claude Code

https://claude.ai/code/session_0167pbkpr5kmXaxQw2EPmL8S

A bare /trade URL (e.g. the marketing navbar link) left the hard-coded
mainnet ETH2X default token object in use while the wallet was on
Arbitrum or Base. mapQuoteToTrade looked that object up by
(chainId, address), missed, and saved underlyingAssetSymbol as '' —
rendered as "/ USD" in Open Positions and the success dialog. The trade
itself was unaffected (quotes resolve the address by symbol).

- trade/provider.tsx: re-match URL/default token objects by symbol
  against the connected chain's token lists
- new getUnderlyingAssetSymbol util (+ tests): address lookup with a
  same-chain symbol fallback; unchanged output for all 41 leverage
  tokens; '' + console.warn when the underlying is not in the known list
- database.ts: use the util

Existing blank rows (42 ETH2X buys) are handled separately in the DB.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0167pbkpr5kmXaxQw2EPmL8S
@vercel

vercel Bot commented Aug 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
index-app Ready Ready Preview Aug 20, 2026 5:48pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant