From cd5c591a2c5b943ef69f336dc422e1b34208220e Mon Sep 17 00:00:00 2001 From: philipp Date: Wed, 13 May 2026 16:51:51 +0200 Subject: [PATCH] Normalize Ethereum bridge chain for USDC Proof: Ethereum 1Click assets now persist bridge chain eth:1, the current BTC/USDC seed uses eth:1, and regression tests cover Ethereum and Gnosis bridge-chain normalization. Assumptions: NEAR Intents bridge RPC expects eth:1 for Ethereum deposit and recent-deposit endpoints. Still fake: live ETH-USDC fills are not proven yet; runtime validation must confirm inventory refresh and quote lifecycle after deployment. --- src/core/trading-config.mjs | 5 ++++- test/trading-config.test.mjs | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/core/trading-config.mjs b/src/core/trading-config.mjs index 5083cd0..98f9fbf 100644 --- a/src/core/trading-config.mjs +++ b/src/core/trading-config.mjs @@ -133,7 +133,7 @@ export function buildSeedAssets() { label: 'USDC', decimals: 6, blockchain: 'eth', - chain: 'eth', + chain: 'eth:1', contractAddress: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', latestPrice: null, priceUpdatedAt: null, @@ -264,6 +264,9 @@ function normalizeBridgeChain({ assetId, blockchain }) { if (normalizedBlockchain === 'gnosis' || normalizedAssetId.startsWith('nep141:gnosis-')) { return 'eth:100'; } + if (normalizedBlockchain === 'eth' || normalizedAssetId.startsWith('nep141:eth-')) { + return 'eth:1'; + } return normalizedBlockchain; } diff --git a/test/trading-config.test.mjs b/test/trading-config.test.mjs index 8797f8c..d5ad95f 100644 --- a/test/trading-config.test.mjs +++ b/test/trading-config.test.mjs @@ -54,6 +54,21 @@ test('1Click token normalizer maps Gnosis assets to bridge chain id', () => { assert.equal(token.chain, 'eth:100'); }); +test('1Click token normalizer maps Ethereum assets to bridge chain id', () => { + const token = normalizeOneClickToken({ + assetId: CURRENT_USDC_ASSET_ID, + decimals: 6, + blockchain: 'eth', + symbol: 'USDC', + price: 1, + priceUpdatedAt: '2026-05-12T16:25:00.425Z', + contractAddress: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', + }); + + assert.equal(token.blockchain, 'eth'); + assert.equal(token.chain, 'eth:1'); +}); + test('supported token import is idempotent, does not enable inventory, and retires missing assets', async () => { const pool = createMemoryPool(); const first = await importSupportedAssets(pool, { @@ -122,7 +137,7 @@ test('seeded DB config preserves current nBTC/EURe pair, 49 bps edge, and legacy assert.equal(snapshot.pairs.length, 2); assert.equal(snapshot.pairByKey.get(snapshot.activePair).strategyConfig.edgeBps, 49); assert.equal(snapshot.trackedAssetIds.includes(LEGACY_OMFT_BTC_ASSET_ID), true); - assert.equal(snapshot.assetRegistry.get(CURRENT_USDC_ASSET_ID).chain, 'eth'); + assert.equal(snapshot.assetRegistry.get(CURRENT_USDC_ASSET_ID).chain, 'eth:1'); assert.equal(snapshot.trackedAssetIds.includes(CURRENT_USDC_ASSET_ID), false); assert.equal([...snapshot.makerPairKeys].some((pair) => pair.includes(LEGACY_OMFT_BTC_ASSET_ID)), false); }); @@ -329,7 +344,7 @@ test('pair mode activation wires known BTC/USDC route and inventory tracking', a assert.equal(pair.priceRoute.source, 'btc_usdc_reference'); assert.equal(pair.priceRoute.baseAssetId, CURRENT_NBTC_ASSET_ID); assert.equal(pair.priceRoute.quoteAssetId, CURRENT_USDC_ASSET_ID); - assert.equal(snapshot.assetRegistry.get(CURRENT_USDC_ASSET_ID).chain, 'eth'); + assert.equal(snapshot.assetRegistry.get(CURRENT_USDC_ASSET_ID).chain, 'eth:1'); assert.equal(snapshot.assetRegistry.get(CURRENT_USDC_ASSET_ID).enabledForInventory, true); assert.equal(snapshot.trackedAssetIds.includes(CURRENT_USDC_ASSET_ID), true); });