From d4bd4a2f0fb5f64c6917e7d2a8dee35d97b80295 Mon Sep 17 00:00:00 2001 From: defiQUG Date: Fri, 27 Mar 2026 18:52:03 -0700 Subject: [PATCH] fix(frontend): explorer SPA bundle updates Made-with: Cursor --- frontend/public/explorer-spa.js | 52 ++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/frontend/public/explorer-spa.js b/frontend/public/explorer-spa.js index 8cbad5b..9625736 100644 --- a/frontend/public/explorer-spa.js +++ b/frontend/public/explorer-spa.js @@ -458,6 +458,39 @@ { symbol: 'cXAUC', address: '0x290E52a8819A4fbD0714E517225429aA2B70EC6b' }, { symbol: 'cXAUT', address: '0x94e408E26c6FD8F4ee00b54dF19082FDA07dC96E' } ]; + function buildRouteSweepQueries(ctx) { + var officialUsdt = (ctx && ctx.officialUSDT) || ''; + var officialUsdc = (ctx && ctx.officialUSDC) || ''; + var queries = []; + CHAIN_138_ROUTE_SWEEP_TOKENS.forEach(function(token) { + var anchors = []; + if (token.symbol === 'cUSDT') { + anchors.push({ symbol: 'cUSDC', address: CHAIN_138_CUSDC_ADDRESS }); + if (safeAddress(officialUsdt)) anchors.push({ symbol: 'USDT', address: officialUsdt }); + } else if (token.symbol === 'cUSDC') { + anchors.push({ symbol: 'cUSDT', address: CHAIN_138_CUSDT_ADDRESS }); + if (safeAddress(officialUsdc)) anchors.push({ symbol: 'USDC', address: officialUsdc }); + } else { + anchors.push({ symbol: 'cUSDT', address: CHAIN_138_CUSDT_ADDRESS }); + anchors.push({ symbol: 'cUSDC', address: CHAIN_138_CUSDC_ADDRESS }); + } + anchors.forEach(function(anchor) { + if (!safeAddress(anchor.address)) return; + if (String(anchor.address).toLowerCase() === String(token.address).toLowerCase()) return; + queries.push({ + key: token.symbol.toLowerCase() + '-' + anchor.symbol.toLowerCase(), + title: token.symbol + ' / ' + anchor.symbol + ' coverage probe', + symbol: token.symbol, + pairLabel: token.symbol + ' / ' + anchor.symbol, + tokenIn: token.address, + tokenOut: anchor.address, + destinationChainId: 138, + amountIn: '1000000' + }); + }); + }); + return queries; + } function stripHexPrefix(value) { return String(value || '').replace(/^0x/i, ''); } @@ -3268,14 +3301,14 @@ } function renderRouteSweepSummary(results) { - var html = '
'; + var html = '
TokenDirect PoolsMissing Quote PoolsDecisionFreshest Status
'; results.forEach(function(entry) { var response = entry.response || {}; var pools = Array.isArray(response.pools) ? response.pools : []; var missing = Array.isArray(response.missingQuoteTokenPools) ? response.missingQuoteTokenPools : []; var freshest = pools.length ? pools[0].depth && pools[0].depth.status ? pools[0].depth.status : 'unknown' : 'none'; html += ''; - html += ''; + html += ''; html += ''; html += ''; html += ''; @@ -3349,16 +3382,9 @@ try { var ctx = await fetchCurrentPmmContext(); var priorityQueries = buildRoutePriorityQueries(ctx); + var sweepQueries = buildRouteSweepQueries(ctx); var priorityResults = await Promise.allSettled(priorityQueries.map(fetchRouteTree)); - var sweepResults = await Promise.allSettled(CHAIN_138_ROUTE_SWEEP_TOKENS.map(function(token) { - return fetchRouteTree({ - key: token.symbol.toLowerCase(), - title: token.symbol + ' coverage sweep', - symbol: token.symbol, - tokenIn: token.address, - amountIn: '1000000' - }); - })); + var sweepResults = await Promise.allSettled(sweepQueries.map(fetchRouteTree)); var priorityOkResults = priorityResults.filter(function(result) { return result.status === 'fulfilled'; }).map(function(result) { return result.value; }); var priorityErrors = priorityResults.filter(function(result) { return result.status === 'rejected'; }); var sweepOkResults = sweepResults.filter(function(result) { return result.status === 'fulfilled'; }).map(function(result) { return result.value; }); @@ -3372,10 +3398,10 @@ html += ''; html += '
'; html += '
Priority routes
' + escapeHtml(String(priorityOkResults.length)) + ' ok' + (priorityErrors.length ? ' / ' + String(priorityErrors.length) + ' failed' : '') + '
'; - html += '
Sweep tokens
' + escapeHtml(String(sweepOkResults.length)) + ' ok
'; + html += '
Sweep probes
' + escapeHtml(String(sweepOkResults.length)) + ' ok
'; html += '
Missing quote routes
' + escapeHtml(String(allSweepMissing.length)) + '
'; html += '
'; - html += '
This sweep queries every known Chain 138 compliant token so we can catch direct pool depth, bridge-leg paths to Mainnet or other destinations, and any pools whose quote-token metadata is still missing in the index.
'; + html += '
This sweep probes explicit local token pairs against compliant and official anchor assets on Chain 138. The priority route cards above remain the bridge-path checks; this table focuses on direct-pair coverage and quote-token metadata gaps.
'; html += renderRouteSweepSummary(sweepOkResults); if (priorityErrors.length) { html += '
Some priority route requests failed, but the pools table is still available.
';
ProbeDirect PoolsMissing Quote PoolsDecisionFreshest Status
' + escapeHtml(entry.query.symbol + ' ' + shortenHash(entry.query.tokenIn)) + '' + escapeHtml((entry.query.pairLabel || entry.query.title || entry.query.symbol || 'probe') + ' ' + shortenHash(entry.query.tokenIn)) + '' + escapeHtml(String(pools.length)) + '' + escapeHtml(String(missing.length)) + '' + escapeHtml(response.decision || 'unresolved') + '