Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/bridge-controller/src/constants/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: '',
Expand Down Expand Up @@ -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',
};
46 changes: 23 additions & 23 deletions packages/bridge-controller/src/selectors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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',
},
};

Expand All @@ -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', () => {
Expand Down Expand Up @@ -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',
},
};

Expand Down Expand Up @@ -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',
},
};

Expand Down
7 changes: 5 additions & 2 deletions packages/bridge-controller/src/utils/quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this is useful for Arc:

  • The logic " - " doesn't make sense for Arc since USDC native transactions will actually be ERC20 transactions. This change prevents the display of wrong fees in the quotes list.

const sentAmountInNative = calcSentAmount(quote, {
exchangeRate,
usdExchangeRate,
Expand Down
Loading