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

Add ETH-based Swap and Cross-Chain Functionality #39

Merged
merged 10 commits into from
Jan 23, 2024

Conversation

SibghatUllah1997
Copy link
Contributor

Description of Changes
This pull request introduces the swapAndCrossOneInchETH function to our smart contract suite. This addition enables users to perform ETH-based swaps and initiate cross-chain transactions seamlessly. The function is designed to accept Ethereum as input and interact with the 1inch protocol for efficient swapping and cross-chain operations.

Key Features

  • Accepts Ethereum (ETH) as the input token and handles conversion to WETH.
  • Facilitates local ETH swaps and prepares for cross-chain transactions.
  • Implements comprehensive input validation checks to ensure transaction integrity and security.
  • Emits detailed events for better tracking and transparency of operations.

Technical Details

  • The function is marked external and payable to handle incoming ETH transactions.
  • Utilizes IWETH interface for WETH interactions.
  • Detailed NatSpec comments added for better understanding and documentation purposes.
  • Includes prefixed require statements for clear and informative error handling.

This function enriches our contract's capabilities, making it more versatile in handling various types of token swaps and cross-chain interactions. The addition follows our commitment to enhancing user experience and expanding the functionality of our DeFi solutions.

Copy link

@naiemk naiemk left a comment

Choose a reason for hiding this comment

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

You need to pass the WETH address as constructor parameters. Better option will be to use the Deployer pattern where you deploy the contract using FerrumDeployer and pass the parameters through the initData (IFerrumDeployer(msg.sender).initData()).

To see how to use the Ferrum Deployer follow this pattern:

Check this contract for example

Line 10, import the deployer
Line 27, get the init params
Line 28, decode the init params. For example, you can pass pool, oneInchRouter and WETH as init params. Obviously these params must be abi encoded and passed to the deployer.

  1. Create a dummy file this and re-instatiate the FerrumDeployer. This is so that hardhat pulls the code for the contract.

  2. Update the deploy script:
    Follow this example in the deploy script.
    Line 11 encodes the init parameters and line 12 deploys the contract.

To import the deployUsingDeployer function you can reference the foundry-contracts package:

import { deployUsingDeployer, Salt, ZeroAddress } from "foundry-contracts/dist/test/common/Utils";

contracts/upgradeable-Bridge/FiberRouter.sol Outdated Show resolved Hide resolved
Copy link
Member

@taha-abbasi taha-abbasi left a comment

Choose a reason for hiding this comment

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

@taha-abbasi taha-abbasi removed the request for review from naiemk January 23, 2024 23:12
@taha-abbasi taha-abbasi merged commit 3c3708d into ferrumnet:feature/NonUpgradeable Jan 23, 2024
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