Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Handle L2 USDC symbol lookup #1509

Merged
merged 4 commits into from
May 10, 2024
Merged

fix: Handle L2 USDC symbol lookup #1509

merged 4 commits into from
May 10, 2024

Conversation

nicholaspai
Copy link
Member

Handle case where an L2 token for chain ID can map to more than one TOKEN_SYMBOLS_MAP entry. For example, L2 Bridged USDC maps to both the USDC and USDC.e/USDbC entries in TOKEN_SYMBOLS_MAP.

This PR is a temporary patch that handles the known USDC issue where both USDC.e/USDbC contain the same chain-address combinations as the USDC entry. This can be reverted once we remove the USDC entry in the TOKEN_SYMBOLS_MAP.

Handle case where an L2 token for chain ID can map to more than one TOKEN_SYMBOLS_MAP entry. For example, L2 Bridged USDC maps to both the USDC and USDC.e/USDbC entries in TOKEN_SYMBOLS_MAP.

This PR is a temporary patch that handles the known USDC issue where both USDC.e/USDbC contain the same chain-address combinations as the USDC entry. This can be reverted once we remove the USDC entry in the TOKEN_SYMBOLS_MAP.
Copy link
Contributor

@james-a-morris james-a-morris left a comment

Choose a reason for hiding this comment

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

Fair call +1

@nicholaspai nicholaspai marked this pull request as ready for review May 10, 2024 19:29
@nicholaspai nicholaspai requested review from mrice32 and pxrl as code owners May 10, 2024 19:29
@nicholaspai nicholaspai merged commit 58046e6 into master May 10, 2024
4 checks passed
*/
export function getUsdcSymbol(l2Token: string, chainId: number): string | undefined {
const compareToken = (token?: string) => isDefined(token) && compareAddressesSimple(l2Token, token);
return ["_USDC", "USDbC", "USDC.e"].find((token) => compareToken(TOKEN_SYMBOLS_MAP[token].addresses[chainId]));
Copy link
Contributor

Choose a reason for hiding this comment

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

In case one of those symbols stops being used/populated in the map in the future.

Suggested change
return ["_USDC", "USDbC", "USDC.e"].find((token) => compareToken(TOKEN_SYMBOLS_MAP[token].addresses[chainId]));
return ["_USDC", "USDbC", "USDC.e"].find((token) => compareToken(TOKEN_SYMBOLS_MAP[token]?.addresses?.[chainId]));

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.

3 participants