Skip to content

Releases: ferrumnet/MultiSwap

v2.0.0

29 Jul 07:44
Compare
Choose a tag to compare

Major Features

1. CCPT Circle USDC Swaps Integration

CCTP Feature Enhancements:

  • Code Simplification: The codebase has been streamlined by removing the CCTPFundManager related code and the logic for deciding between FundManager or CCTPFundManager. The cctpType parameter has also been removed from withdrawal functions. These changes reduce the complexity in the FiberRouter and simplify the overall integration script.
  • Integration Script Update:
    • The script now dynamically determines the CCTP type based on the balance of the FundManager on the target network.
    • Executes the appropriate flow (normal or CCTP) accordingly.
    • For CCTP flows, the script now includes:
      • Calling the circleAttestation function to handle withdrawals to the FundManager on the target network.
      • Following up with withdrawSigned and withdrawSignedAndSwapRouter functions once attestation is complete.
  • Gas Estimation Feature: Added a feature to estimate the gas required for the receivedMessage() function and handle gas fee transmission to the target network.
  • Removing Sync Pattern: The synchronous pattern in CCTP FundManager has been deprecated, enhancing asynchronous handling and improving efficiency.

2. Fee Distribution and Referral Fee Distribution Logic Implementation

Fee Distribution Logic Improvements:

  • New Fee Distribution Mechanism: Implemented a separate contract for fee distribution that integrates seamlessly with the swapSigned function. This mechanism securely deducts fees based on signature verification.
  • Referral System Integration: Added a robust referral system for fee and referral fee distribution. This includes features for managing referral discounts and a fixed fee distribution model.
  • Unit Tests: Developed comprehensive unit tests to ensure the correctness and reliability of the fee distribution logic.

3. OmniRouter / Omnichain Swaps Integration in MultiSwap

Omnichain Integration:

  • Omnichain and Axelar Contracts: Incorporated omnichain and Axelar contracts within the FiberRouter.
  • OmniRouter Integration: Enabled MultiSwap to perform omnichain swaps by integrating the OmniRouter.
  • LayerZero Integration: Enhanced the stargatecomposer to include the ability to set target networks for seamless cross-chain swaps.

4. Stargate v2 Integration with MultiSwap

Stargate v2 Enhancements:

  • Stargate v2 Integration:
    • Added support for swapSigned within the FiberRouter.
    • Integrated swapStargate(), swapUSDC, and stargateComposer functionalities with the FundManager.
    • Developed decentralized on-chain withdrawal processes to enhance security and efficiency.
  • Custom LzCompose Implementation: Implemented a custom Stargate LzCompose for secure and restricted withdrawals.
  • PrepareTakeTaxi Function: Implemented to provide backend gas fee estimation, covering total swap and withdrawal on-chain gas costs.

Other Notable Improvements and Fixes

  • Multiple Network Integrations: Added support for a variety of blockchain networks to expand the platform's reach and interoperability.
  • ZkSync Contracts Implementation: Integrated ZkSync contracts using the Hardhat framework for enhanced development and deployment processes.
  • Asset Transfer Fix: Addressed and resolved issues related to asset transfers in the swapSigned function.
  • Foundry Assets Swap Fix: Fixed issues related to asset swaps within Foundry, improving reliability and functionality.
  • Swap Types Decoder Restructuring: Restructured the swap types decoder and introduced new structs to support multiple swap types, including CCTP swaps.
  • Live Testing Scripts: Developed and implemented live testing scripts for swapSigned, swapSignedAndCrossRouter, and withdrawal functions (withdrawSigned / withdrawSignedAndCrossRouter).
  • Stargate v1 Integration: Successfully integrated Stargate v1 with the MultiSwap FiberRouter, enhancing overall swap capabilities.
  • Audit Documentation: Detailed documentation of the audit process for MultiSwap features has been added to ensure transparency and enhance security measures.

These updates significantly enhance the functionality, security, and user experience of the MultiSwap platform. Each feature and improvement has been meticulously developed and tested to ensure optimal performance.

v1.8.0

04 Apr 18:38
Compare
Choose a tag to compare

What's Changed

  • MultiSwap Gas Optimisation & Improvements by @salmanferrum in #45

Changes Proposed

This PR introduces a significant improvement to the gas efficiency of our system. The 1inchDecoder smart contract has been moved to the backend, and its functionality to decode the name of the function to be called on 1inch is now integrated into the swapHelperForOneInch function. The swapHelperForOneInch function now takes an enum parameter, representing the function to be called on 1inch.

1inch Decoder Context

The primary motivation behind this change is to enhance gas efficiency by eliminating the need for a separate smart contract (1inchDecoder) on the blockchain. By moving the decoding logic to the backend, we can reduce gas costs and improve overall system performance.

1inch Changes Overview

  • 1inchDecoder Removal: The 1inchDecoder smart contract has been removed from FiberRouter.
  • Function Name Decoding: The decoding logic for 1inch function names is now handled in the backend and a parameter funcSelector is passed to the swap or withdrawal functions.
  • Enum Parameter: The swapHelperForOneInch function now takes an enum parameter to identify the specific function to be called on 1inch.

Change Regarding LiquidityManagerRole / TokenReceivable

Background:

The changes were prompted by an issue identified in the TokenReceivable contract. Specifically, when attempting to remove liquidity using removeLiquidityByManager, the existing implementation with safeTransfer caused discrepancies in the token inventory and causing the transaction to fail.

Root Cause:

The discrepancy arose from a mismatch between how tokens were removed (using safeTransfer) in the LiquidityManagerRole contract and how the inventory was updated in the TokenReceivable contract. The absence of proper synchronization led to negative balances during subsequent calls to TokenReceivable.sync.

Resolution:

To address this, we introduced the addLiquidityByManager function, which utilizes the TokenReceivable.sendToken method for secure token transfers. This ensures consistency in token handling and updates the inventory using the TokenReceivable.sync method.

Similarly, in removeLiquidityByManager, the direct use of TokenReceivable.sendToken was introduced, providing a unified approach for managing token transfers and updating the inventory.

Additional Context:

  • The adjustment from safeTransfer to sendToken in removeLiquidityByManager improves consistency in token handling and leverages the functionality provided by the TokenReceivable library.
  • The addition of the addLiquidityByManager function enriches the contract's feature set, allowing liquidity managers to contribute assets in a controlled manner.

Changes Made:

  1. Introduction of addLiquidityByManager Function:

    • Implemented a new function, addLiquidityByManager, empowering designated liquidity managers to add a specified amount of liquidity for a given token.
    • This addition enhances the contract's flexibility by allowing controlled liquidity addition while ensuring secure token transfers to the FundManager contract. The inventory is also updated using the TokenReceivable.sync method.
  2. Enhancements in removeLiquidityByManager:

    • Modified the removeLiquidityByManager function to utilize the TokenReceivable.sendToken method directly, replacing the previous use of safeTransfer.
    • Ensured the function continues to validate a positive amount and a valid token address before proceeding with liquidity removal.

Same Network Swap Feature

This PR introduces new functionalities to the fiberRouter contract to enable same network token swaps on MultiSwap. The following key functions have been added:

  1. swapOnSameNetwork: This external function allows users to perform token swaps between two tokens on the same network using 1inch exchange. It takes parameters such as input amount, output amount, source token, target token, target address, and 1inch swap data.

  2. swapOnSameNetworkETH: Another external function introduced to enable swaps between native currency and a desired token on the same network. Users can swap native currency (ETH) to a target token using 1inch exchange. Parameters include output amount, target token, target address, and 1inch swap data.

  3. _swapOnSameNetwork: An internal function called within the above two functions to execute the token swaps using 1inch helper functions in fiberRouter.

These functions enhance the usability and flexibility of the fiberRouter contract by providing seamless token swapping capabilities within the same network using the powerful 1inch exchange.

Full Changelog: v1.7.1...v1.8.0

v1.7.1

12 Mar 17:53
Compare
Choose a tag to compare

Full Changelog: v1.7.0...v1.7.1

v1.7.0

28 Feb 17:36
Compare
Choose a tag to compare

Release Notes for v1.7.0

This release brings a host of improvements and new features across our contracts, enhancing gas estimation capabilities, swap functionality, and liquidity management. Here's what's new:

MultiSwapForge Contracts for GasEstimation (PR #42)

Overview

  • This update introduces a split in our contract architecture to enhance gas estimation functions while segregating production contracts from gas estimation contracts.

Features

  • Production Contracts: FiberRouter & FundManager for real-time transaction facilitation.
  • Gas Estimation Contracts: MultiSwapForgeContract & ForgeFundManager to simulate withdrawals and provide gas estimates without affecting production contracts.

Enhancements

  • New gas estimation workflow for withdrawals, improving system efficiency and accuracy.
  • Renamed Upgradeable-Contracts folder to multiswap-contracts.
  • Added deployment scripts for MultiSwapForge and ForgeFundManager contracts.

Additional Notes

  • Clear separation between production and gas estimation contracts to avoid unintended interactions and prepare the system for more efficient gas estimation handling.

FillOrderTo 1inch Swap and Allowance Fix in FiberRouter (PR #43)

Overview

  • Enhancements to FiberRouter and its dependencies (OneInchSwap and OneInchDecoder) to optimize fillOrderTo operations and fix the SafeERC20 allowance issue.

Changes

  • New handleFillOrderTo function in FiberRouter for improved token swap execution.
  • Updated OneInchSwap and introduced decodeFillOrderTo in OneInchDecoder for extended functionality and compatibility with FiberRouter.
  • Implemented a fix for the SafeERC20 allowance issue to ensure seamless swap execution.

Testing and Deployment

  • Added scripts for deploying contracts, fetching 1inch swap data, verifying signers, and testing withdrawal functions.

Additional Notes

  • These improvements enhance the FiberRouter contract's capabilities in handling 1inch aggregator swaps, offering a more reliable and efficient trading experience.

Liquidity Management and Cancellation of Failed Withdrawals (PR #44)

Overview

  • New features in the FundManager contract for liquidity management and cancellation of failed withdrawals, introducing a base contract LiquidityManagerRole.

MultiSwap Contract Changes

  • Abstract LiquidityManagerRole contract for liquidity management functionalities.
  • Enhanced FundManager contract derived from LiquidityManagerRole with specific liquidity management functions.
  • New modifiers and functions for setting liquidity and settlement managers, and for canceling failed withdrawals.

Additional Changes

  • Corrected NatSpec comments in FiberRouter and FundManager for better documentation.
  • Added a configuration script for easier multiswap contract management.

Events

  • Introduced FailedWithdrawalCancelled and LiquidityRemovedByManager events for better transparency and auditability of liquidity management actions.

This release marks significant strides in our platform's development, focusing on efficiency, reliability, and user experience improvements.

What's Changed

  • Liquidity Management and Cancellation of Failed Withdrawals by @salmanferrum in #44

Full Changelog: v1.6.0...v1.7.0

v1.6.0

20 Feb 04:50
Compare
Choose a tag to compare

What's Changed

  • MultiSwapForge Contracts for GasEstimation by @salmanferrum in #42
  • FillOrderTo 1inch Swap and Allowance Fix in FiberRouter by @salmanferrum in #43

Overview

This pull request introduces enhancements and new features to the FiberRouter smart contract, along with updates to its dependencies (OneInchSwap and OneInchDecoder contracts). The primary focus is on facilitating and optimizing the execution of the fillOrderTo operation involving the 1inch aggregator to accommodate new token swaps. Moreover, to resolve the allowance issue, the allowance check condition is added.

Changes Introduced

1. handleFillOrderTo Function (In FiberRouter)

  • The new function handleFillOrderTo has been introduced to streamline the execution of the fillOrderTo operation.
  • This function enables the swapping of new tokens, incorporates validations, and interacts seamlessly with the 1inch aggregator router.

2. Updates in Dependencies

  • OneInchSwap Contract:

    • The fillOrderTo function in the OneInchSwap contract has been updated to align with the changes in FiberRouter.
    • The updates ensure compatibility and extended functionality for 1inch swap operations.
  • OneInchDecoder Contract:

    • The decodeFillOrderTo function has been introduced to decode data related to the fillOrderTo operation.
    • This function extracts relevant parameters, including the order, signature, interaction, and more.

3. Resolved SafeERC20 Allowance Issue:**

To address the "execution reverted: SafeERC20: approve from non-zero to non-zero allowance" error encountered during swaps, the following condition has been added in both the withdrawSignedAndSwapOneInch and _swapAndCrossOneInch functions of FiberRouter.

// Check if allowance is non-zero
if (IERC20(foundryToken).allowance(address(this), oneInchAggregatorRouter) != 0) {
    // Reset it to zero
    IERC20(foundryToken).safeApprove(oneInchAggregatorRouter, 0);
}
// Set the allowance to the swap amount
IERC20(foundryToken).safeApprove(oneInchAggregatorRouter, amountIn);

This modification ensures that the allowance is appropriately managed, avoiding the mentioned error during token swaps on the 1inch aggregator. The contract now resets the allowance to zero before setting it to the intended swap amount, ensuring a seamless and error-free execution of swaps.

4. Testing Scripts Added

  • For deploying the contracts all at once, a new deploy script is created deployContracts.js
  • For getting the 1inch swap data response, oneInchAPI.js is added
  • For verifying the correct signer from a signature / msgHash combination, verifySigner.js is added
  • For generating withdrawal signature & testing the withdraw functions, withdrawSigned.js script is modified

Additional Notes

This pull request brings significant improvements to the FiberRouter contract, enhancing its capabilities in handling 1inch aggregator swaps and providing a more reliable and efficient trading experience for users. The combination of new features, dependency updates, and issue resolution contributes to the overall robustness and functionality of MultiSwap.

Summary of Additional Key Changes

This release refines the contract architecture to incorporate gas estimation functionality and segregate production contracts from gas estimation contracts. The notable changes include:

  • MultiSwapForge: Inherited from FiberRouter contract to simulate withdrawals with gas estimation, featuring estimateGasForWithdrawSigned and estimateGasForWithdrawSignedAndSwapOneInch functions.
  • ForgeFundManager: A forgeFundManager gas estimation contract inherited from FundManager with a hardcoded signer for generating forge signatures.
  • Changed the visibility modifier of FiberRouter'swithdrawSigned & withdrawSignedSwapAndCrossOneInch to public virtual
  • Changed the visibility modifier of FundManager's AddSigner function to public

These changes enhance gas estimation capabilities, ensuring more precise simulations and separating gas estimation logic from production transactions.

Full Changelog: v1.5.0...v1.6.0

v1.5.0

28 Jan 02:22
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v0.5.1...v1.5.0

v1.4.0

13 Jun 07:51
Compare
Choose a tag to compare

Release version: v1.4.0

We are excited to announce the release of version --- of our project! This release introduces a significant enhancement that improves the calculation of slippage tolerance and minimumAmountOut in the fiberEngine.

Key Changes

  • Added a new file, "settlementEngine", to the project.
  • The settlementEngine file incorporates advanced algorithms for calculating slippage tolerance.
  • Integration of the settlementEngine into the fiberEngine module.
  • The fiberEngine now utilizes the settlementEngine to accurately determine the minimumAmountOut, considering the specified slippage.
  • These changes provide a more precise and reliable trading experience, ensuring optimal execution while accounting for market - fluctuations. The settlementEngine plays a crucial role in maintaining trade integrity by offering a comprehensive solution for slippage tolerance calculation.

We encourage all users to upgrade to version 1.0.0 to take advantage of these enhancements. Please refer to the documentation provided in the repository for detailed instructions on integrating the settlementEngine and utilizing the improved functionality in the fiberEngine.

Thank you for your continued support and valuable feedback. We are committed to delivering further updates and improvements to enhance your trading experience.

What else Changed

  • settlementEngine file added for calculating slippage tolerance and us… by @SibghatUllah1997 in #27

Full Changelog: v1.3.0...v1.4.0

v1.3.0

08 May 13:49
Compare
Choose a tag to compare

Release Notes - v1.3.0

Features

  • Added test cases for Fiber Router
  • Added a new test case to fundManager

Improvements

  • Refactored code for some test cases in Fiber Router
  • Made some minor changes to dependent smart contracts

What else Changed

  • Test Cases for Fiber Router added also a new test case is added to fu… by @SibghatUllah1997 in #26

Full Changelog: v1.2.0...v1.3.0

v1.2.0

03 May 18:45
Compare
Choose a tag to compare

Release Notes - v1.2.0

Features

  • Added unit test cases for the fiberRouter functionality.
  • Made changes to the fundmanager test cases.

What else Changed

Full Changelog: v1.1.1...v1.2.0

v1.1.1

27 Apr 17:41
Compare
Choose a tag to compare

Release Notes - v1.1.1

Features

  • Introduced new functions to the smart contract to enhance its functionality
  • Replaced the original token in the common contract with a MockToken for improved testing
  • Modified the Hardhat configuration settings to resolve ChainID issues

Bug Fixes

  • Commented out all test cases related to fees and IGeneralTaxDistributor
  • Investigated and fixed 2 failed tests to ensure better stability
  • Testing
  • Successfully passed 65 tests, demonstrating a significant improvement in the testing environment

Known Issues

None

What else Changed

Full Changelog: v1.1.0...v1.1.1