diff --git a/packages/bridge-controller/src/constants/tokens.ts b/packages/bridge-controller/src/constants/tokens.ts index ce522a8283..95f2d89bcf 100644 --- a/packages/bridge-controller/src/constants/tokens.ts +++ b/packages/bridge-controller/src/constants/tokens.ts @@ -192,8 +192,8 @@ const MEGAETH_SWAPS_TOKEN_OBJECT = { // Leaving for code consistency but we won't display it in the asset picker const ARC_SWAPS_TOKEN_OBJECT = { - symbol: 'USDC-native', - name: 'USDC-native', + symbol: 'USDC', + name: 'USDC', address: '0x0000000000000000000000000000000000000000', decimals: 18, iconUrl: '', @@ -248,5 +248,5 @@ export const SYMBOL_TO_SLIP44_MAP: Record< MON: 'slip44:268435779', HYPE: 'slip44:2457', // It won't be displayed - hidden on UI client side - 'USDC-native': 'erc20:0x0000000000000000000000000000000000000000', + USDC: 'erc20:0x0000000000000000000000000000000000000000', }; diff --git a/packages/bridge-controller/src/selectors.test.ts b/packages/bridge-controller/src/selectors.test.ts index 3c8c9f15ce..435566d4b3 100644 --- a/packages/bridge-controller/src/selectors.test.ts +++ b/packages/bridge-controller/src/selectors.test.ts @@ -596,12 +596,12 @@ describe('Bridge Selectors', () => { const expectedQuoteMetadata = { adjustedReturn: { - usd: '13.099927', - valueInCurrency: '2597.985546', + usd: '2.099927', + valueInCurrency: '419.985546', }, cost: { - usd: '-2.099927', - valueInCurrency: '-419.985546', + usd: '8.900073', + valueInCurrency: '1758.014454', }, gasFee: { effective: { @@ -638,14 +638,14 @@ describe('Bridge Selectors', () => { valueInCurrency: '420', }, totalMaxNetworkFee: { - amount: '-1.0999854', - usd: '-10.999854', - valueInCurrency: '-2177.971092', + amount: '0.0000146', + usd: '0.000146', + valueInCurrency: '0.028908', }, totalNetworkFee: { - amount: '-1.0999927', - usd: '-10.999927', - valueInCurrency: '-2177.985546', + amount: '0.0000073', + usd: '0.000073', + valueInCurrency: '0.014454', }, }; @@ -656,7 +656,7 @@ describe('Bridge Selectors', () => { validateQuoteResponseV1(quoteResponseV1); expect(result.sortedQuotes[0]).toStrictEqual(quoteResponseV1); - expect(result.sortedQuotes[0].cost?.valueInCurrency).toBe('-419.985546'); + expect(result.sortedQuotes[0].cost?.valueInCurrency).toBe('1758.014454'); }); it('should return metadata when quotes are empty', () => { @@ -753,14 +753,14 @@ describe('Bridge Selectors', () => { valueInCurrency: null, }, totalMaxNetworkFee: { - amount: '-1.0999854', - usd: '-1979.97372', - valueInCurrency: '-1979.97372', + amount: '0.0000146', + usd: '0.02628', + valueInCurrency: '0.02628', }, totalNetworkFee: { - amount: '-1.0999927', - usd: '-1979.98686', - valueInCurrency: '-1979.98686', + amount: '0.0000073', + usd: '0.01314', + valueInCurrency: '0.01314', }, }; @@ -848,14 +848,14 @@ describe('Bridge Selectors', () => { valueInCurrency: null, }, totalMaxNetworkFee: { - amount: '-1.0999854', - usd: '-1979.97372', - valueInCurrency: '-1979.97372', + amount: '0.0000146', + usd: '0.02628', + valueInCurrency: '0.02628', }, totalNetworkFee: { - amount: '-1.0999927', - usd: '-1979.98686', - valueInCurrency: '-1979.98686', + amount: '0.0000073', + usd: '0.01314', + valueInCurrency: '0.01314', }, }; diff --git a/packages/bridge-controller/src/utils/quote.ts b/packages/bridge-controller/src/utils/quote.ts index 00acc26507..a8a255e44e 100644 --- a/packages/bridge-controller/src/utils/quote.ts +++ b/packages/bridge-controller/src/utils/quote.ts @@ -200,8 +200,11 @@ export const calcRelayerFee = ( ); let relayerFeeInNative = calcTokenAmount(relayerFeeAmount, 18); - // Subtract srcAmount and other fees from trade value if srcAsset is native - if (isNativeAddress(quote.srcAsset.address)) { + // trade.value carries the native amount sent in the tx, so the relayer fee is + // back-calculated as trade.value - sentAmount. This only holds when the native + // asset actually flows through trade.value; when trade.value is 0 there is + // nothing to back out and the relayer fee is 0. + if (isNativeAddress(quote.srcAsset.address) && relayerFeeAmount.gt(0)) { const sentAmountInNative = calcSentAmount(quote, { exchangeRate, usdExchangeRate,