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

FE: add polygon native USDC and FRAX #1627

Merged
merged 4 commits into from
Dec 13, 2023
Merged

Conversation

ChiTimesChi
Copy link
Collaborator

@ChiTimesChi ChiTimesChi commented Dec 13, 2023

Description
Adds support for Polygon native USDC, more routes for USDC.e/DAI on Polygon. Also adds support for FRAX, although the on-chain liquidity is smaller than for the other coins.

Summary by CodeRabbit

  • New Features

    • Expanded the bridge map with additional entries and updated existing ones to enhance cross-chain swapping capabilities.
  • Enhancements

    • Updated token addresses for improved compatibility and support on the Polygon chain.
  • Bug Fixes

    • Corrected contract addresses and chain ID configurations to ensure accurate routing and functionality of cross-chain transactions.
  • Refactor

    • Streamlined contract instantiation for consistency across different blockchain networks.

620192cb945f9f46798bf4334b80810a010ee1f7: synapse-interface preview link

Copy link
Contributor

coderabbitai bot commented Dec 13, 2023

Walkthrough

The updates across various files in the Synapse Interface codebase reflect a significant enhancement of the bridge mapping logic, including the addition of new token addresses and chain IDs, as well as updates to contract addresses. These changes suggest an expansion of supported networks and tokens, and an update to the routing infrastructure within the platform.

Changes

File Path Change Summary
.../constants/bridgeMap.ts Updated BRIDGE_MAP object with new entries and modified properties for origin, destination, and swappability.
.../constants/tokens/bridgeable.ts Added new token address for the FRAX token on the Polygon chain.
.../scripts/generateMaps.js Updated contract addresses, added new chain ID, and modified contract instantiation logic.
.../utils/actions/fetchPortfolioBalances.tsx Updated the CCTP_ROUTER_ADDRESS constant to a new value.

🐇✨
In the code where bridges span,
New paths emerge, as change began.
Tokens travel, chains unite,
A rabbit's work, by code's delight. 🌉🚀

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on X ?


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • You can reply to a review comment made by CodeRabbit.
  • You can tag CodeRabbit on specific lines of code or files in the PR by tagging @coderabbitai in a comment.
  • You can tag @coderabbitai in a PR comment and ask one-off questions about the PR and the codebase. Use quoted replies to pass the context for follow-up questions.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

Copy link

codecov bot commented Dec 13, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4d7eb8e) 51.34971% compared to head (205d7ce) 51.34971%.
Report is 2 commits behind head on master.

Additional details and impacted files
@@              Coverage Diff              @@
##              master       #1627   +/-   ##
=============================================
  Coverage   51.34971%   51.34971%           
=============================================
  Files            362         362           
  Lines          24746       24746           
  Branches         284         284           
=============================================
  Hits           12707       12707           
  Misses         10802       10802           
  Partials        1237        1237           
Flag Coverage Δ
packages 90.77156% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 452bfca and 205d7ce.
Files selected for processing (4)
  • packages/synapse-interface/constants/bridgeMap.ts (3 hunks)
  • packages/synapse-interface/constants/tokens/bridgeable.ts (1 hunks)
  • packages/synapse-interface/scripts/generateMaps.js (2 hunks)
  • packages/synapse-interface/utils/actions/fetchPortfolioBalances.tsx (1 hunks)
Additional comments: 13
packages/synapse-interface/constants/bridgeMap.ts (6)
  • 521-531: The addition of USDC.e with the specified origin and destination arrays, as well as the swappable addresses, aligns with the PR's objective to support more routes for swapping USDC.e and DAI on the Polygon network.

  • 541-552: The addition of a new entry for USDC on the Polygon network with the origin, destination, and swappable addresses specified is consistent with the PR's goal to add support for Polygon native USDC.

  • 554-565: The addition of FRAX with the origin and destination arrays, as well as the swappable addresses, is in line with the PR's objective to add support for FRAX. However, it's important to note that the PR mentions the on-chain liquidity for FRAX is currently smaller compared to other coins, which may affect its usability and should be communicated to users.

  • 570-577: The changes to the DAI entry, including the updated origin and destination arrays and the addition of new swappable addresses, support the PR's objective to introduce more routes for swapping on the Polygon network.

  • 583-590: The addition of nUSD with the updated origin and destination arrays, as well as the new swappable addresses, aligns with the PR's objective to enhance the swapping functionality on the Polygon network.

  • 603-611: The changes to the USDT entry, including the updated origin and destination arrays and the addition of new swappable addresses, support the PR's objective to introduce more routes for swapping on the Polygon network.

packages/synapse-interface/constants/tokens/bridgeable.ts (1)
  • 634-640: The addition of the Polygon chain token address for the FRAX token is consistent with the PR objectives and follows the established pattern for token definitions in the file. The priority rank is set correctly according to the file's comments on priority ranks.
packages/synapse-interface/scripts/generateMaps.js (3)
  • 29-34: The contract addresses for SynapseCCTPRouterAddress and SynapseCCTPAddress have been updated, and a new chain ID 137 has been added to the allowedChainIdsForSynapseCCTPRouter array. Ensure that these changes are consistent with the new contract deployments and that the new chain ID is correctly integrated into the application's routing logic.

  • 60-66: The instantiation of SynapseCCTPs has been modified to use the new SynapseCCTPAddress for all chain IDs. Confirm that this change is intended and that it does not negatively impact any functionality that previously depended on different addresses for different chains.

  • 27-37: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [27-66]

Review the entire generateMaps.js file to ensure that the updated contract addresses and the addition of the new chain ID are correctly used in all relevant parts of the script, and that they align with the PR's objective of enhancing functionality for the Polygon network.

packages/synapse-interface/utils/actions/fetchPortfolioBalances.tsx (3)
  • 8-8: <!--Monologue:
    Thought 1: The search for ROUTER_ADDRESS returned multiple results, including some that reference a different address (0x7E7A0e201FD38d3ADAA9523Da6C109a07118C96a).
    Reflect 1: This suggests that there are multiple router addresses being used in the codebase, which could be for different purposes or networks. It's important to note that the CCTP_ROUTER_ADDRESS is distinct from the ROUTER_ADDRESS.

Thought 2: The CCTP_ROUTER_ADDRESS is consistently used in the files where it's expected to be used, based on the search results.
Reflect 2: This is a good sign that the update has been made correctly for the CCTP_ROUTER_ADDRESS.

Thought 3: The broader context search for the new CCTP_ROUTER_ADDRESS shows it's being used in the expected manner, with no unexpected occurrences.
Reflect 3: This indicates that the update to the new router address has been done correctly and is not used in any incorrect context.

Thought 4: The presence of both ROUTER_ADDRESS and CCTP_ROUTER_ADDRESS in the same files suggests that they are used for different purposes or contracts within the application.
Reflect 4: This is a common pattern in applications that interact with multiple smart contracts or services, where each service might have its own address.

Thought 5: The ROUTER_ADDRESS_MAP and CCTP_ROUTER_ADDRESS_MAP in the sdk-router package indicate that there are mappings for these addresses, which are likely used to handle different chains or contexts.
Reflect 5: This is a standard approach to handle different environments or networks in blockchain applications.

Thought 6: There are no indications that the old CCTP_ROUTER_ADDRESS is still being used, and the new one is correctly implemented in the places it's referenced.
Reflect 6: This suggests that the update has been done correctly and there are no issues with the router address update.

Conclusion: The verification process has not revealed any issues with the update of the CCTP_ROUTER_ADDRESS. The new address is used consistently across the codebase, and there are no remnants of the old address. The presence of different router addresses for different purposes is acknowledged and does not indicate an issue.
-->

The CCTP_ROUTER_ADDRESS has been successfully updated across the codebase, and the new address is being used consistently in the expected files. There are no instances of the old address remaining, and the presence of different router addresses for distinct purposes is correctly handled. The verification process has not revealed any issues with the update of the CCTP_ROUTER_ADDRESS.

Analysis chain

The CCTP_ROUTER_ADDRESS constant has been updated. Verify that this new address is correctly used wherever the ROUTER_ADDRESS is referenced, and ensure that any functionality relying on the router's address is tested to confirm that it interacts correctly with the updated address.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for the old router address to ensure it's no longer used.
rg '0xd359bc471554504f683fbd4f6e36848612349ddf'
# Search for the new router address to ensure it's being used consistently.
rg '0xd5a597d6e7ddf373a92C8f477DAAA673b0902F48'

Length of output: 492



Script:

#!/bin/bash
# Search for any other potential router address constants or variables that might not have been updated.
rg 'ROUTER_ADDRESS' --ignore-case

# Search for the new router address in a broader context to ensure it's not used incorrectly.
rg '0xd5a597d6e7ddf373a92C8f477DAAA673b0902F48' -C 3

Length of output: 7969

* 7-7:

The presence of both ROUTER_ADDRESS and CCTP_ROUTER_ADDRESS in the codebase is intentional, and their usage is distinct and correct. They are used in different contexts and serve different purposes, as evidenced by their usage in various parts of the codebase, including conditional logic that determines which address to use based on certain conditions. There is no indication that CCTP_ROUTER_ADDRESS is meant to replace ROUTER_ADDRESS.

Analysis chain

Confirm that the presence of both ROUTER_ADDRESS and CCTP_ROUTER_ADDRESS is intentional and that their usage is correct and distinct within the codebase. If CCTP_ROUTER_ADDRESS is meant to replace ROUTER_ADDRESS, then all instances of ROUTER_ADDRESS should be updated accordingly.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for usage of `ROUTER_ADDRESS` to ensure it's being used correctly.
rg 'ROUTER_ADDRESS'
# Search for usage of `CCTP_ROUTER_ADDRESS` to ensure it's being used correctly.
rg 'CCTP_ROUTER_ADDRESS'

Length of output: 8162

* 5-9: The changes to `CCTP_ROUTER_ADDRESS` are clear, but the PR objectives mention adding support for new cryptocurrencies and routes. Ensure that the necessary updates to token addresses and routing logic are also included in the PR and are consistent with the updated router address.

Copy link

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 205d7ce
Status: ✅  Deploy successful!
Preview URL: https://41f5b876.sanguine.pages.dev
Branch Preview URL: https://fe-polygon-native-usdc.sanguine.pages.dev

View logs

@ChiTimesChi ChiTimesChi merged commit 3f02e01 into master Dec 13, 2023
42 checks passed
@ChiTimesChi ChiTimesChi deleted the fe/polygon-native-usdc branch December 13, 2023 01:44
aureliusbtc added a commit that referenced this pull request Dec 13, 2023
* update for new tokens (#1623)

* feat: Add Polygon support to New CCTP Router Contracts (#1617)

* feat: Add Polygon support to SDK Router

- Clear CCTP_ROUTER_ADDRESS for future update
- Add Polygon to CCTP_SUPPORTED_CHAIN_IDS
- Define median time for Polygon in MEDIAN_TIME_CCTP

* Add new SynapseCCTpRouter address

* Adjust median time for Polygon: 8 minutes

* Chore: remove extra line

---------

Co-authored-by: ChiTimesChi <[email protected]>

* Publish

 - @synapsecns/[email protected]
 - @synapsecns/[email protected]
 - @synapsecns/[email protected]
 - @synapsecns/[email protected]

* Regenerate agents (#1575)

* adding cctp contracts to the explorer UI (#1626)

* adding cctp contracts

* Add Ethereum CCTP contract

---------

Co-authored-by: ChiTimesChi <[email protected]>

* Publish

 - @synapsecns/[email protected]

* FE: add polygon native USDC and FRAX (#1627)

* Update values in generation script

* Update CCTP Router Address

* Regenerate bridge map

* Add FRAX address on Polygon

---------

Co-authored-by: bigboydiamonds <[email protected]>

* Publish

 - @synapsecns/[email protected]

* adding frax support on polygon (#1631)

* Publish

 - @synapsecns/[email protected]

---------

Co-authored-by: Moses <[email protected]>
Co-authored-by: aureliusbtc <[email protected]>
Co-authored-by: ChiTimesChi <[email protected]>
Co-authored-by: bigboydiamonds <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants