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

Deploy: metis token #331

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Deploy: metis token #331

wants to merge 7 commits into from

Conversation

ChiTimesChi
Copy link
Collaborator

@ChiTimesChi ChiTimesChi commented Jul 30, 2024

Description

Fixes # (issue)

Checklist

  • New Contracts have been tested
  • Lint has been run
  • I have checked my code and corrected any misspellings

Summary by CodeRabbit

  • New Features

    • Introduced a comprehensive ABI for a new token smart contract supporting standard ERC20 functionalities and role management.
    • Added new tokens ("dfk" and "klatyn") in the configuration, enhancing token management capabilities.
    • Implemented a script to verify ERC20 token deployments across multiple blockchain networks.
    • Launched a new contract for managing liquidity and calculating token swaps, improving DeFi application functionalities.
    • Added support for the new "Metis" token in multiple configuration files, expanding the range of tokens available for transactions.
  • Improvements

    • Updated network configurations to include a source verification step for enhanced reliability and security in operations.
    • Simplified logic for handling the WGAS address assignment in the router configuration.

These enhancements aim to improve user experience and security while interacting with token functionalities on the blockchain.

Copy link

coderabbitai bot commented Jul 30, 2024

Walkthrough

This update introduces a new token contract, Metis.json, defining its ABI with robust token management and role-based access controls. Additionally, token configurations for "dfk" and "klatyn" have been added to the SynapseERC20.symbols.json file, expanding asset support. The networks.json has been modified to enhance verification processes for the "dfk" and "klatyn" networks, ensuring improved security and reliability in blockchain interactions. Furthermore, new scripts and contracts for token verification and liquidity management have been introduced.

Changes

Files Change Summary
deployments/.../Metis.json New ABI for a token contract with ERC20 functionality, role management, and events.
deployments/.../DefaultPoolCalc.json New ABI for a liquidity calculation function.
deployments/.../SwapQuoterV2.json New ABI for a contract facilitating liquidity management and token swaps.
deployments/.../WGAS.json New JSON configuration for a specific blockchain address.
script/configs/.../SynapseERC20.symbols.json Added token definitions for "dfk" and "klatyn" with properties decimals, name, and symbol.
script/configs/.../SynapseRouter.dc.json Added "Metis" token configuration for "dfk", "klatyn", and "metis" routers.
script/networks.json Updated network arguments for "dfk" and "klatyn" to include verification options.
script/bridge/... Introduced VerifySynapseERC20 contract for role verification and new script check-synERC20.sh for token validation across networks.
script/router/SaveRouterConfig.s.sol Simplified logic for assigning the wgas address.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TokenContract
    participant Network

    User->>TokenContract: Transfer tokens
    TokenContract-->>Network: Verify transfer
    Network-->>TokenContract: Confirmation
    TokenContract-->>User: Transfer successful
Loading

🐰 In fields of green, where tokens twirl,
A new contract dances, watch it unfurl!
With roles and powers, oh what a sight,
In the land of Metis, all feels just right!
So hop with joy and take a chance,
For in this code, we all can prance! 🌼


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 your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 182e046 and adb8680.

Files selected for processing (4)
  • deployments/dfk/Metis.json (1 hunks)
  • deployments/klatyn/Metis.json (1 hunks)
  • script/configs/SynapseERC20.symbols.json (1 hunks)
  • script/networks.json (1 hunks)
Additional comments not posted (39)
script/configs/SynapseERC20.symbols.json (2)

2-7: LGTM!

The entry for the "dfk" token under "Metis" is correctly defined with properties: decimals, name, and symbol.


8-12: LGTM!

The entry for the "klatyn" token under "Metis" is correctly defined with properties: decimals, name, and symbol.

script/networks.json (2)

10-10: LGTM!

The argument for the "dfk" network has been correctly updated to include the --verifier sourcify option, enhancing verification processes.


13-13: LGTM!

The argument for the "klatyn" network has been correctly updated to include the --verifier sourcify option, enhancing verification processes.

deployments/dfk/Metis.json (3)

2-3: LGTM!

The address and constructor arguments for the Metis token deployment on the "dfk" network are correctly defined.


4-542: LGTM!

The ABI functions for the Metis token are correctly defined, covering all necessary functionalities.


543-667: LGTM!

The ABI events for the Metis token are correctly defined, covering all necessary events.

deployments/klatyn/Metis.json (32)

6-17: Ensure proper access control for DEFAULT_ADMIN_ROLE.

The DEFAULT_ADMIN_ROLE function returns the default admin role identifier. Ensure that proper access control mechanisms are in place to prevent unauthorized access.


19-30: Ensure proper access control for DOMAIN_SEPARATOR.

The DOMAIN_SEPARATOR function returns the domain separator for EIP-712 signatures. Ensure that proper access control mechanisms are in place to prevent unauthorized access.


32-43: Ensure proper access control for MINTER_ROLE.

The MINTER_ROLE function returns the minter role identifier. Ensure that proper access control mechanisms are in place to prevent unauthorized access.


45-67: Verify allowance function logic.

The allowance function returns the remaining number of tokens that spender will be allowed to spend on behalf of owner. Ensure that the logic correctly handles edge cases and potential integer overflow issues.


69-91: Verify approve function logic.

The approve function sets the amount of tokens that an spender is allowed to spend on behalf of the owner. Ensure that the logic correctly handles edge cases and potential integer overflow issues.


93-110: Verify balanceOf function logic.

The balanceOf function returns the token balance of a specific account. Ensure that the logic correctly handles edge cases and potential integer overflow issues.


112-123: Verify burn function logic.

The burn function destroys a specified amount of tokens from the caller's account. Ensure that the logic correctly handles edge cases and potential integer overflow issues.


125-141: Verify burnFrom function logic.

The burnFrom function destroys a specified amount of tokens from a specified account, deducting from the caller's allowance. Ensure that the logic correctly handles edge cases and potential integer overflow issues.


143-154: Verify decimals function logic.

The decimals function returns the number of decimals used to get its user representation. Ensure that the logic correctly handles edge cases and potential integer overflow issues.


156-178: Verify decreaseAllowance function logic.

The decreaseAllowance function decreases the amount of tokens that a spender is allowed to spend on behalf of the owner. Ensure that the logic correctly handles edge cases and potential integer overflow issues.


180-197: Ensure proper access control for getRoleAdmin.

The getRoleAdmin function returns the admin role that controls a specific role. Ensure that proper access control mechanisms are in place to prevent unauthorized access.


199-221: Ensure proper access control for getRoleMember.

The getRoleMember function returns a member of a specific role. Ensure that proper access control mechanisms are in place to prevent unauthorized access.


223-240: Ensure proper access control for getRoleMemberCount.

The getRoleMemberCount function returns the number of members in a specific role. Ensure that proper access control mechanisms are in place to prevent unauthorized access.


242-258: Ensure proper access control for grantRole.

The grantRole function grants a specific role to an account. Ensure that proper access control mechanisms are in place to prevent unauthorized access.


260-282: Ensure proper access control for hasRole.

The hasRole function checks if an account has a specific role. Ensure that proper access control mechanisms are in place to prevent unauthorized access.


284-306: Verify increaseAllowance function logic.

The increaseAllowance function increases the amount of tokens that a spender is allowed to spend on behalf of the owner. Ensure that the logic correctly handles edge cases and potential integer overflow issues.


308-334: Verify initialize function logic.

The initialize function initializes the contract with the specified parameters. Ensure that the logic correctly handles edge cases and potential integer overflow issues.


336-352: Verify mint function logic.

The mint function creates new tokens and assigns them to a specified account. Ensure that the logic correctly handles edge cases and potential integer overflow issues.


354-365: Verify name function logic.

The name function returns the name of the token. Ensure that the logic correctly handles edge cases and potential integer overflow issues.


367-384: Verify nonces function logic.

The nonces function returns the current nonce for a specific account. Ensure that the logic correctly handles edge cases and potential integer overflow issues.


386-427: Verify permit function logic.

The permit function allows a spender to spend a specific amount of tokens on behalf of the owner, using a signed message. Ensure that the logic correctly handles edge cases and potential integer overflow issues.


429-445: Ensure proper access control for renounceRole.

The renounceRole function allows an account to renounce a specific role. Ensure that proper access control mechanisms are in place to prevent unauthorized access.


447-463: Ensure proper access control for revokeRole.

The revokeRole function revokes a specific role from an account. Ensure that proper access control mechanisms are in place to prevent unauthorized access.


465-476: Verify symbol function logic.

The symbol function returns the symbol of the token. Ensure that the logic correctly handles edge cases and potential integer overflow issues.


478-489: Verify totalSupply function logic.

The totalSupply function returns the total supply of tokens. Ensure that the logic correctly handles edge cases and potential integer overflow issues.


491-513: Verify transfer function logic.

The transfer function transfers a specific amount of tokens to a specified recipient. Ensure that the logic correctly handles edge cases and potential integer overflow issues.


515-542: Verify transferFrom function logic.

The transferFrom function transfers a specific amount of tokens from a specified sender to a specified recipient. Ensure that the logic correctly handles edge cases and potential integer overflow issues.


544-567: Verify Approval event logic.

The Approval event is emitted when the allowance of a spender for an owner is set by a call to approve. Ensure that the logic correctly handles edge cases and potential integer overflow issues.


569-592: Verify RoleAdminChanged event logic.

The RoleAdminChanged event is emitted when the admin role of a specific role is changed. Ensure that the logic correctly handles edge cases and potential integer overflow issues.


594-617: Verify RoleGranted event logic.

The RoleGranted event is emitted when a specific role is granted to an account. Ensure that the logic correctly handles edge cases and potential integer overflow issues.


619-642: Verify RoleRevoked event logic.

The RoleRevoked event is emitted when a specific role is revoked from an account. Ensure that the logic correctly handles edge cases and potential integer overflow issues.


644-667: Verify Transfer event logic.

The Transfer event is emitted when tokens are transferred from one account to another. Ensure that the logic correctly handles edge cases and potential integer overflow issues.

@coveralls
Copy link

coveralls commented Jul 30, 2024

Pull Request Test Coverage Report for Build 10700602434

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 12.934%

Totals Coverage Status
Change from base Build 10076602134: 0.0%
Covered Lines: 664
Relevant Lines: 4684

💛 - Coveralls

Copy link

@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.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between adb8680 and fb99fb5.

Files selected for processing (2)
  • script/bridge/VerifySynapseERC20.s.sol (1 hunks)
  • script/bridge/check-synERC20.sh (1 hunks)
Additional comments not posted (15)
script/bridge/check-synERC20.sh (6)

1-3: LGTM!

The shebang and usage comment are correct.


4-9: LGTM!

The argument assignment and check are correctly implemented.


10-11: LGTM!

The find command is correctly used to locate the JSON files.


12-15: LGTM!

The sed command is correctly used to extract and format the chain names.


16-17: LGTM!

The echo command is correctly used to print the chain names.


18-20: LGTM!

The for loop is correctly used to iterate over the chain names and run the verification script.

script/bridge/VerifySynapseERC20.s.sol (9)

1-4: LGTM!

The SPDX license identifier and pragma directives are correctly specified.


5-6: LGTM!

The import statement for SynapseERC20 is correctly specified.


7-8: LGTM!

The import statements for BasicSynapseScript and StringUtils are correctly specified.


9-15: LGTM!

The contract definition, struct, and constant are correctly specified.


17-35: LGTM!

The state variables and the run function are correctly specified.


37-44: LGTM!

The printMetadata function is correctly specified.


46-51: LGTM!

The addAddress function is correctly specified.


53-74: LGTM!

The checkRole function is correctly specified.


76-88: LGTM!

The findMember and printCondition functions are correctly specified.

Copy link

@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.

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fb99fb5 and 2b9646a.

Files selected for processing (4)
  • deployments/metis/DefaultPoolCalc.json (1 hunks)
  • deployments/metis/SwapQuoterV2.json (1 hunks)
  • deployments/metis/WGAS.json (1 hunks)
  • script/configs/metis/SwapQuoterV2.dc.json (1 hunks)
Files skipped from review due to trivial changes (1)
  • deployments/metis/WGAS.json
Additional context used
Gitleaks
script/configs/metis/SwapQuoterV2.dc.json

7-7: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


13-13: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

Additional comments not posted (5)
deployments/metis/DefaultPoolCalc.json (3)

2-3: LGTM: Address and constructor arguments.

The address and constructor arguments are correctly formatted.


5-28: LGTM: ABI entry for calculateAddLiquidity.

The ABI entry for the calculateAddLiquidity function is correctly formatted and follows the standard ABI structure.


4-29: LGTM: ABI array.

The ABI array is correctly formatted and follows the standard ABI structure.

deployments/metis/SwapQuoterV2.json (2)

2-3: LGTM: Address and constructor arguments.

The address and constructor arguments are correctly formatted.


4-702: LGTM: ABI entries.

The ABI entries for multiple functions are correctly formatted and follow the standard ABI structure.

"description": "nUSD",
"isLinked": false,
"pool": "0x555982d2E211745b96736665e19D9308B615F78e",
"token": "0x961318Fc85475E125B99Cc9215f62679aE5200aB"
Copy link

Choose a reason for hiding this comment

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

Potential security issue: Generic API Key detected.

The token address 0x961318Fc85475E125B99Cc9215f62679aE5200aB is flagged as a potential generic API key. Ensure that this is not exposing any sensitive information.

Tools
Gitleaks

7-7: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

"description": "nETH",
"isLinked": false,
"pool": "0x09fEC30669d63A13c666d2129230dD5588E2e240",
"token": "0x931B8f17764362A3325D30681009f0eDd6211231"
Copy link

Choose a reason for hiding this comment

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

Potential security issue: Generic API Key detected.

The token address 0x931B8f17764362A3325D30681009f0eDd6211231 is flagged as a potential generic API key. Ensure that this is not exposing any sensitive information.

Tools
Gitleaks

13-13: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

Copy link

@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.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2b9646a and 4450dd8.

Files selected for processing (4)
  • script/configs/dfk/SynapseRouter.dc.json (2 hunks)
  • script/configs/klatyn/SynapseRouter.dc.json (2 hunks)
  • script/configs/metis/SynapseRouter.dc.json (3 hunks)
  • script/router/SaveRouterConfig.s.sol (1 hunks)
Additional context used
Gitleaks
script/configs/metis/SynapseRouter.dc.json

34-34: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


38-38: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

script/configs/klatyn/SynapseRouter.dc.json

73-73: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


77-77: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

script/configs/dfk/SynapseRouter.dc.json

73-73: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


77-77: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

Additional comments not posted (9)
script/router/SaveRouterConfig.s.sol (1)

32-32: Verify the impact of the change in wgas assignment logic.

The code change simplifies the assignment of the wgas variable by removing the conditional check for the METIS chain ID. Previously, if the chain ID matched METIS_CHAINID, wgas was set to the zero address; otherwise, it was assigned the deployment address of the "WGAS" contract.

With this change, wgas will always be assigned the deployment address of "WGAS", regardless of the chain ID. This may impact how the contract interacts with the WGAS token on the METIS chain.

Please verify if this change aligns with the intended behavior for the METIS chain. Consider the following:

  • Is it acceptable for wgas to be assigned the deployment address of "WGAS" on the METIS chain, instead of the zero address?
  • Are there any dependencies or interactions in other parts of the system that rely on the previous behavior of setting wgas to the zero address for the METIS chain?

Ensure that this change does not introduce any unintended consequences or break existing functionality related to the WGAS token on the METIS chain.

script/configs/metis/SynapseRouter.dc.json (3)

10-11: LGTM!

The code changes are approved.


32-40: LGTM!

The code changes are approved.

Note: The lines flagged by the static analysis tool (34 and 38) contain token addresses, not API keys. These are false positives and can be ignored.

Tools
Gitleaks

34-34: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


38-38: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


87-87: LGTM!

The code changes are approved.

script/configs/klatyn/SynapseRouter.dc.json (2)

13-14: LGTM!

The addition of "Metis" to the list of supported tokens is approved.


71-79: LGTM!

The configuration for the "Metis" token is approved. It follows the same structure as the other token configurations and does not introduce any issues.

Tools
Gitleaks

73-73: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


77-77: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

script/configs/dfk/SynapseRouter.dc.json (3)

13-14: LGTM!

The addition of "Metis" to the list of supported tokens in the SynapseRouter configuration is approved.


71-79: LGTM!

The configuration provided for the "Metis" token is approved. It follows the expected structure and the parameter values are consistent with the other token configurations.

Tools
Gitleaks

73-73: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


77-77: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


73-73: Dismiss Gitleaks warnings.

The lines flagged by Gitleaks contain token addresses, not API keys. Token addresses are public information and do not pose a security risk. These warnings can be dismissed as false positives.

Also applies to: 77-77

Tools
Gitleaks

73-73: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

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.

2 participants