Skip to content

Conversation

NikolasHaimerl
Copy link
Contributor

Fix WETH/ETH Symbol Resolution

Linear: ACX-4369

📝 Summary

This pull request addresses a bug where the swap/approval endpoint was incorrectly resolving the symbol for wrapped native tokens (like WETH) as the native token symbol (e.g., ETH). This was happening on chains like Base and Linea where the wrapped native token address is also present in the TOKEN_SYMBOLS_MAP under the ETH symbol.

🔧 Changes

  • Modified the getTokenByAddress function in api/_utils.ts to correctly resolve the token symbol in cases of ambiguity between ETH and WETH.
  • Added a comprehensive test suite for getTokenByAddress to ensure the correct symbol is returned for all supported chains.

💭 Rationale

The root cause of this issue lies in the @across-protocol/constants package, where some wrapped native token addresses are associated with both ETH and WETH symbols. The getTokenByAddress function was not deterministically picking the correct symbol, sometimes defaulting to ETH when it should have been WETH.

This pull request implements a solution that prioritizes WETH when a token address is associated with both symbols. This is a robust solution because it correctly handles the ambiguity in the constants file and ensures that the correct token symbol is used throughout the application.

The alternative of fixing the constants file is not feasible as it is an external dependency. This solution provides a local fix that is both effective and maintainable.

Copy link

vercel bot commented Oct 1, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
app-frontend-v3 Ready Ready Preview Comment Oct 1, 2025 8:44am
sepolia-frontend-v3 Building Building Preview Comment Oct 1, 2025 8:44am

@NikolasHaimerl
Copy link
Contributor Author

Closing in favour of #1867

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant