From 79b98e6918120716ed89bc9b60e614613555b5c0 Mon Sep 17 00:00:00 2001 From: Arthur Breton Date: Thu, 22 Oct 2026 14:23:35 +0800 Subject: [PATCH 1/3] fix(perps-controller): route Hyperliquid testnet deposits to the Arbitrum Sepolia bridge DepositService forced mainnet deposit routes, so a testnet session prepared an Arbitrum One USDC transfer to the mainnet bridge. Take routes for the provider's own network instead. Point the testnet USDC asset at USDC2 (0x1baAbB04529D43a73232B713C0FE471f7c7334d5), the token the Arbitrum Sepolia bridge credits and pays out, so testnet deposit and withdrawal routes name the right token. Refs: TAT-4204 --- packages/perps-controller/CHANGELOG.md | 6 ++++++ .../src/constants/hyperLiquidConfig.ts | 5 +++-- .../src/services/DepositService.ts | 4 ++-- .../src/constants/hyperLiquidConfig.test.ts | 19 ++++++++++++++++++- .../tests/src/services/DepositService.test.ts | 6 ++---- 5 files changed, 31 insertions(+), 9 deletions(-) diff --git a/packages/perps-controller/CHANGELOG.md b/packages/perps-controller/CHANGELOG.md index eeaebe940de..62bb5f73c4c 100644 --- a/packages/perps-controller/CHANGELOG.md +++ b/packages/perps-controller/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- On a testnet session, `depositWithConfirmation` now prepares an Arbitrum Sepolia transfer to the Hyperliquid testnet bridge instead of an Arbitrum One transfer to the mainnet bridge; `DepositService.prepareTransaction` takes deposit routes for the provider's own network instead of forcing mainnet +- Set `USDC_ARBITRUM_TESTNET_ADDRESS` and `HYPERLIQUID_ASSET_CONFIGS.usdc.testnet` to USDC2 (`0x1baAbB04529D43a73232B713C0FE471f7c7334d5`), the token the Arbitrum Sepolia bridge credits, so testnet deposit and withdrawal routes name the token that is deposited and paid out + - On testnet, `withdraw` rejects the previous asset ID (`0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d`). Clients that hardcode it should read the constant or `getWithdrawalRoutes()` instead. + ## [21.0.0] ### Added diff --git a/packages/perps-controller/src/constants/hyperLiquidConfig.ts b/packages/perps-controller/src/constants/hyperLiquidConfig.ts index 6e7102c95a6..217b1ff0a05 100644 --- a/packages/perps-controller/src/constants/hyperLiquidConfig.ts +++ b/packages/perps-controller/src/constants/hyperLiquidConfig.ts @@ -63,8 +63,9 @@ export const USDC_ETHEREUM_MAINNET_ADDRESS = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'; export const USDC_ARBITRUM_MAINNET_ADDRESS = '0xaf88d065e77c8cC2239327C5EDb3A432268e5831'; +// USDC2: the token the Arbitrum Sepolia bridge credits (its usdcToken()) export const USDC_ARBITRUM_TESTNET_ADDRESS = - '0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d'; + '0x1baAbB04529D43a73232B713C0FE471f7c7334d5'; // USDC token icon URL using MetaMask's official Token Icons API // Format: https://static.cx.metamask.io/api/v1/tokenIcons/{chainId}/{contractAddress}.png @@ -92,7 +93,7 @@ export const METAMASK_PERPS_ICONS_BASE_URL = export const HYPERLIQUID_ASSET_CONFIGS: HyperLiquidAssetConfigs = { usdc: { mainnet: `${ARBITRUM_MAINNET_CAIP_CHAIN_ID}/erc20:0xaf88d065e77c8cC2239327C5EDb3A432268e5831/default`, - testnet: `${ARBITRUM_TESTNET_CAIP_CHAIN_ID}/erc20:0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d/default`, + testnet: `${ARBITRUM_TESTNET_CAIP_CHAIN_ID}/erc20:0x1baAbB04529D43a73232B713C0FE471f7c7334d5/default`, }, }; diff --git a/packages/perps-controller/src/services/DepositService.ts b/packages/perps-controller/src/services/DepositService.ts index 8634b9877a4..1cbfc5a32cb 100644 --- a/packages/perps-controller/src/services/DepositService.ts +++ b/packages/perps-controller/src/services/DepositService.ts @@ -65,8 +65,8 @@ export class DepositService { // Generate deposit request ID for tracking const currentDepositId = generateDepositId(); - // Get deposit routes from provider - const depositRoutes = provider.getDepositRoutes({ isTestnet: false }); + // Get deposit routes for the provider's own network (testnet or mainnet) + const depositRoutes = provider.getDepositRoutes(); const route = depositRoutes[0]; if (!route) { // Fail CLOSED with a routable message instead of a TypeError: some diff --git a/packages/perps-controller/tests/src/constants/hyperLiquidConfig.test.ts b/packages/perps-controller/tests/src/constants/hyperLiquidConfig.test.ts index 098fbdff349..28f07c5bc86 100644 --- a/packages/perps-controller/tests/src/constants/hyperLiquidConfig.test.ts +++ b/packages/perps-controller/tests/src/constants/hyperLiquidConfig.test.ts @@ -1,7 +1,24 @@ -import { HIP3_ASSET_MARKET_TYPES } from '../../../src/constants/hyperLiquidConfig.js'; +import { + getSupportedAssets, + HIP3_ASSET_MARKET_TYPES, +} from '../../../src/constants/hyperLiquidConfig.js'; import { MarketCategory, MARKET_CATEGORIES } from '../../../src/types/index.js'; import type { MarketType, MarketTypeFilter } from '../../../src/types/index.js'; +describe('getSupportedAssets', () => { + it('returns the USDC2 token the Arbitrum Sepolia bridge credits on testnet', () => { + expect(getSupportedAssets(true)).toStrictEqual([ + 'eip155:421614/erc20:0x1baAbB04529D43a73232B713C0FE471f7c7334d5/default', + ]); + }); + + it('returns Arbitrum One USDC on mainnet', () => { + expect(getSupportedAssets(false)).toStrictEqual([ + 'eip155:42161/erc20:0xaf88d065e77c8cC2239327C5EDb3A432268e5831/default', + ]); + }); +}); + describe('HIP3_ASSET_MARKET_TYPES', () => { it('classifies known US stocks correctly', () => { expect(HIP3_ASSET_MARKET_TYPES['xyz:TSLA']).toBe('stock'); diff --git a/packages/perps-controller/tests/src/services/DepositService.test.ts b/packages/perps-controller/tests/src/services/DepositService.test.ts index 03d033dcd43..c11fb6e95ab 100644 --- a/packages/perps-controller/tests/src/services/DepositService.test.ts +++ b/packages/perps-controller/tests/src/services/DepositService.test.ts @@ -125,14 +125,12 @@ describe('DepositService', () => { expect(generateDepositId).toHaveBeenCalledTimes(1); }); - it('retrieves deposit routes from provider', async () => { + it('retrieves deposit routes for the provider network', async () => { await service.prepareTransaction({ provider: mockProvider, }); - expect(mockProvider.getDepositRoutes).toHaveBeenCalledWith({ - isTestnet: false, - }); + expect(mockProvider.getDepositRoutes).toHaveBeenCalledWith(); }); it('uses first deposit route from provider', async () => { From 75957fa97d99aeca14bcc90a29d5854e19bfc89f Mon Sep 17 00:00:00 2001 From: Arthur Breton Date: Thu, 22 Oct 2026 14:47:35 +0800 Subject: [PATCH 2/3] fix: address self-review feedback (TAT-4204) --- packages/perps-controller/CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/perps-controller/CHANGELOG.md b/packages/perps-controller/CHANGELOG.md index 62bb5f73c4c..7f09d297ae2 100644 --- a/packages/perps-controller/CHANGELOG.md +++ b/packages/perps-controller/CHANGELOG.md @@ -9,9 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- **BREAKING:** Set `USDC_ARBITRUM_TESTNET_ADDRESS` and `HYPERLIQUID_ASSET_CONFIGS.usdc.testnet` to USDC2 (`0x1baAbB04529D43a73232B713C0FE471f7c7334d5`), the token the Arbitrum Sepolia bridge credits, so testnet deposit and withdrawal routes name the token that is deposited and paid out + - The exported literal type of `USDC_ARBITRUM_TESTNET_ADDRESS` changes to the USDC2 address. Code typed against `typeof USDC_ARBITRUM_TESTNET_ADDRESS` with the previous value no longer compiles. + - On testnet, `withdraw` rejects the previous asset ID (`0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d`). Read `HYPERLIQUID_ASSET_CONFIGS.usdc.testnet` or `getWithdrawalRoutes()` instead of hardcoding it, and update test fixtures that pin the previous asset ID. - On a testnet session, `depositWithConfirmation` now prepares an Arbitrum Sepolia transfer to the Hyperliquid testnet bridge instead of an Arbitrum One transfer to the mainnet bridge; `DepositService.prepareTransaction` takes deposit routes for the provider's own network instead of forcing mainnet -- Set `USDC_ARBITRUM_TESTNET_ADDRESS` and `HYPERLIQUID_ASSET_CONFIGS.usdc.testnet` to USDC2 (`0x1baAbB04529D43a73232B713C0FE471f7c7334d5`), the token the Arbitrum Sepolia bridge credits, so testnet deposit and withdrawal routes name the token that is deposited and paid out - - On testnet, `withdraw` rejects the previous asset ID (`0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d`). Clients that hardcode it should read the constant or `getWithdrawalRoutes()` instead. ## [21.0.0] From e86e862bc3a8e5641abb7042e1bf7bf5d6bf50b6 Mon Sep 17 00:00:00 2001 From: Arthur Breton Date: Thu, 22 Oct 2026 16:08:19 +0800 Subject: [PATCH 3/3] fix: address CI feedback --- packages/perps-controller/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/perps-controller/CHANGELOG.md b/packages/perps-controller/CHANGELOG.md index 7f09d297ae2..699be019462 100644 --- a/packages/perps-controller/CHANGELOG.md +++ b/packages/perps-controller/CHANGELOG.md @@ -9,10 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- **BREAKING:** Set `USDC_ARBITRUM_TESTNET_ADDRESS` and `HYPERLIQUID_ASSET_CONFIGS.usdc.testnet` to USDC2 (`0x1baAbB04529D43a73232B713C0FE471f7c7334d5`), the token the Arbitrum Sepolia bridge credits, so testnet deposit and withdrawal routes name the token that is deposited and paid out +- **BREAKING:** Set `USDC_ARBITRUM_TESTNET_ADDRESS` and `HYPERLIQUID_ASSET_CONFIGS.usdc.testnet` to USDC2 (`0x1baAbB04529D43a73232B713C0FE471f7c7334d5`), the token the Arbitrum Sepolia bridge credits, so testnet deposit and withdrawal routes name the token that is deposited and paid out ([#10991](https://github.com/MetaMask/core/pull/10991)) - The exported literal type of `USDC_ARBITRUM_TESTNET_ADDRESS` changes to the USDC2 address. Code typed against `typeof USDC_ARBITRUM_TESTNET_ADDRESS` with the previous value no longer compiles. - On testnet, `withdraw` rejects the previous asset ID (`0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d`). Read `HYPERLIQUID_ASSET_CONFIGS.usdc.testnet` or `getWithdrawalRoutes()` instead of hardcoding it, and update test fixtures that pin the previous asset ID. -- On a testnet session, `depositWithConfirmation` now prepares an Arbitrum Sepolia transfer to the Hyperliquid testnet bridge instead of an Arbitrum One transfer to the mainnet bridge; `DepositService.prepareTransaction` takes deposit routes for the provider's own network instead of forcing mainnet +- On a testnet session, `depositWithConfirmation` now prepares an Arbitrum Sepolia transfer to the Hyperliquid testnet bridge instead of an Arbitrum One transfer to the mainnet bridge; `DepositService.prepareTransaction` takes deposit routes for the provider's own network instead of forcing mainnet ([#10991](https://github.com/MetaMask/core/pull/10991)) ## [21.0.0]