fix(dex): prefer subgraph-bound BASE/QUOTE symbol for market pair label

Request the indexer's bound `symbol` in the markets query and use it as the
authoritative pair label when it parses as BASE/QUOTE, falling back to live
token-metadata resolution then short addresses. One pair, one source of truth.

Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
2026-06-30 15:25:56 -07:00
co-authored by Hanzo Dev
parent 4aab561759
commit 6c8a170433
2 changed files with 10 additions and 2 deletions
+3
View File
@@ -5,6 +5,9 @@
export interface DexMarket {
readonly id: string;
// BASE/QUOTE pair the indexer bound from the two currencies' ERC-20 symbols
// (empty/poolId-hex when a token has no clean symbol). Authoritative when set.
readonly symbol?: string;
readonly baseToken: string;
readonly quoteToken: string;
readonly feeTier: number;
+7 -2
View File
@@ -8,7 +8,7 @@ import shortenString from 'lib/shortenString';
// One root field per request — the subgraph engine processes a single root
// field per query, so markets and fills are fetched separately.
const MARKETS_QUERY = '{ markets { id baseToken quoteToken feeTier volume24h tradeCount lastPrice lastUpdate } }';
const MARKETS_QUERY = '{ markets { id symbol baseToken quoteToken feeTier volume24h tradeCount lastPrice lastUpdate } }';
const FILLS_QUERY = '{ fills(first:25) { id market taker amountOut timestamp txHash } }';
const DEX_GRAPHQL_PATH = '/v1/graph/cchain/dex/graphql';
@@ -80,7 +80,12 @@ export function buildMarketViews(
): ReadonlyArray<DexMarketView> {
return markets.map((m) => ({
...m,
pair: `${ tokenLabel(m.baseToken, symbols) }/${ tokenLabel(m.quoteToken, symbols) }`,
// Prefer the subgraph's bound BASE/QUOTE symbol (the indexer derives it from
// both currencies' ERC-20 symbols — one pair, one source of truth). Fall back
// to live token-metadata resolution, then to short addresses.
pair: m.symbol && m.symbol.includes('/') ?
m.symbol :
`${ tokenLabel(m.baseToken, symbols) }/${ tokenLabel(m.quoteToken, symbols) }`,
}));
}