fix(frontend): explorer SPA bundle updates
Made-with: Cursor
This commit is contained in:
@@ -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 = '<div style="overflow-x:auto;"><table class="table"><thead><tr><th>Token</th><th>Direct Pools</th><th>Missing Quote Pools</th><th>Decision</th><th>Freshest Status</th></tr></thead><tbody>';
|
||||
var html = '<div style="overflow-x:auto;"><table class="table"><thead><tr><th>Probe</th><th>Direct Pools</th><th>Missing Quote Pools</th><th>Decision</th><th>Freshest Status</th></tr></thead><tbody>';
|
||||
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 += '<tr>';
|
||||
html += '<td>' + escapeHtml(entry.query.symbol + ' ' + shortenHash(entry.query.tokenIn)) + '</td>';
|
||||
html += '<td>' + escapeHtml((entry.query.pairLabel || entry.query.title || entry.query.symbol || 'probe') + ' ' + shortenHash(entry.query.tokenIn)) + '</td>';
|
||||
html += '<td>' + escapeHtml(String(pools.length)) + '</td>';
|
||||
html += '<td>' + escapeHtml(String(missing.length)) + '</td>';
|
||||
html += '<td>' + escapeHtml(response.decision || 'unresolved') + '</td>';
|
||||
@@ -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 += '</div>';
|
||||
html += '<div style="display:grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap:0.75rem; margin-bottom:1rem;">';
|
||||
html += '<div style="padding:0.9rem; border:1px solid var(--border); border-radius:10px; background:var(--light);"><div style="font-size:0.82rem; color:var(--text-light); text-transform:uppercase; letter-spacing:0.05em; margin-bottom:0.35rem;">Priority routes</div><div style="font-weight:700;">' + escapeHtml(String(priorityOkResults.length)) + ' ok' + (priorityErrors.length ? ' / ' + String(priorityErrors.length) + ' failed' : '') + '</div></div>';
|
||||
html += '<div style="padding:0.9rem; border:1px solid var(--border); border-radius:10px; background:var(--light);"><div style="font-size:0.82rem; color:var(--text-light); text-transform:uppercase; letter-spacing:0.05em; margin-bottom:0.35rem;">Sweep tokens</div><div style="font-weight:700;">' + escapeHtml(String(sweepOkResults.length)) + ' ok</div></div>';
|
||||
html += '<div style="padding:0.9rem; border:1px solid var(--border); border-radius:10px; background:var(--light);"><div style="font-size:0.82rem; color:var(--text-light); text-transform:uppercase; letter-spacing:0.05em; margin-bottom:0.35rem;">Sweep probes</div><div style="font-weight:700;">' + escapeHtml(String(sweepOkResults.length)) + ' ok</div></div>';
|
||||
html += '<div style="padding:0.9rem; border:1px solid var(--border); border-radius:10px; background:var(--light);"><div style="font-size:0.82rem; color:var(--text-light); text-transform:uppercase; letter-spacing:0.05em; margin-bottom:0.35rem;">Missing quote routes</div><div style="font-weight:700;">' + escapeHtml(String(allSweepMissing.length)) + '</div></div>';
|
||||
html += '</div>';
|
||||
html += '<div style="color:var(--text-light); margin-bottom:0.85rem; line-height:1.5;">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.</div>';
|
||||
html += '<div style="color:var(--text-light); margin-bottom:0.85rem; line-height:1.5;">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.</div>';
|
||||
html += renderRouteSweepSummary(sweepOkResults);
|
||||
if (priorityErrors.length) {
|
||||
html += '<div style="margin-top:0.75rem; color:var(--text-light); font-size:0.9rem;">Some priority route requests failed, but the pools table is still available.</div>';
|
||||
|
||||
Reference in New Issue
Block a user