Releases: ferrumnet/MultiSwap
v2.0.0
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 betweenFundManager
orCCTPFundManager
. ThecctpType
parameter has also been removed from withdrawal functions. These changes reduce the complexity in theFiberRouter
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 theFundManager
on the target network. - Following up with
withdrawSigned
andwithdrawSignedAndSwapRouter
functions once attestation is complete.
- Calling the
- The script now dynamically determines the CCTP type based on the balance of the
- 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 theFiberRouter
. - Integrated
swapStargate()
,swapUSDC
, andstargateComposer
functionalities with theFundManager
. - Developed decentralized on-chain withdrawal processes to enhance security and efficiency.
- Added support for
- 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
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 fromFiberRouter
. - 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
tosendToken
inremoveLiquidityByManager
improves consistency in token handling and leverages the functionality provided by theTokenReceivable
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:
-
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.
- Implemented a new function,
-
Enhancements in
removeLiquidityByManager
:- Modified the
removeLiquidityByManager
function to utilize theTokenReceivable.sendToken
method directly, replacing the previous use ofsafeTransfer
. - Ensured the function continues to validate a positive amount and a valid token address before proceeding with liquidity removal.
- Modified the
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:
-
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.
-
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.
-
_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
Full Changelog: v1.7.0...v1.7.1
v1.7.0
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 tomultiswap-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
andOneInchDecoder
) to optimizefillOrderTo
operations and fix the SafeERC20 allowance issue.
Changes
- New
handleFillOrderTo
function inFiberRouter
for improved token swap execution. - Updated
OneInchSwap
and introduceddecodeFillOrderTo
inOneInchDecoder
for extended functionality and compatibility withFiberRouter
. - 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 contractLiquidityManagerRole
.
MultiSwap Contract Changes
- Abstract
LiquidityManagerRole
contract for liquidity management functionalities. - Enhanced
FundManager
contract derived fromLiquidityManagerRole
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
andFundManager
for better documentation. - Added a configuration script for easier multiswap contract management.
Events
- Introduced
FailedWithdrawalCancelled
andLiquidityRemovedByManager
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
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 thefillOrderTo
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 theOneInchSwap
contract has been updated to align with the changes inFiberRouter
. - The updates ensure compatibility and extended functionality for 1inch swap operations.
- The
-
OneInchDecoder Contract:
- The
decodeFillOrderTo
function has been introduced to decode data related to thefillOrderTo
operation. - This function extracts relevant parameters, including the order, signature, interaction, and more.
- The
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 fromFiberRouter
contract to simulate withdrawals with gas estimation, featuringestimateGasForWithdrawSigned
andestimateGasForWithdrawSignedAndSwapOneInch
functions.ForgeFundManager
: A forgeFundManager gas estimation contract inherited from FundManager with a hardcoded signer for generating forge signatures.- Changed the visibility modifier of FiberRouter's
withdrawSigned
&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
What's Changed
- FeeManagement by @salmanferrum in #17
- Add fee management endpoints by @jpine3528 in #16
- CudosFiberEngineV1 X FiberContract Upgrades by @salmanferrum in #18
- Code Sorting & Formatting by @salmanferrum in #19
- Audit Fixes & Generalised Events by @salmanferrum in #20
- Second audit report fixes by @SibghatUllah1997 in #21
- Audit Fixes & Updates by @salmanferrum in #22
- Test Case Adjustment by @SibghatUllah1997 in #23
- Test Removed From .gitignore File To Push Test Cases by @SibghatUllah1997 in #24
- Test cases for fiberRouter Contract added by @SibghatUllah1997 in #25
- Test Cases for Fiber Router added also a new test case is added to fu… by @SibghatUllah1997 in #26
- settlementEngine file added for calculating slippage tolerance and us… by @SibghatUllah1997 in #27
- OneInch Implementation With nonUpgradeable Contract by @SibghatUllah1997 in #32
- Converted the code to Non Upgradeable contract for the testing of iss… by @SibghatUllah1997 in #28
- Expiry And Withdraw Message Management by @SibghatUllah1997 in #34
- checking the real time amound return from oneInch as well putted the … by @SibghatUllah1997 in #33
- validatedSignatureChainHash added to withdrawSigned by @SibghatUllah1997 in #35
- Title: Refactor
swapBridgeAmount
tosettledAmount
for Enhanced Security in Withdrawal Calculations by @SibghatUllah1997 in #36 - Add ETH-based Swap and Cross-Chain Functionality by @SibghatUllah1997 in #39
- compiler updated & deployment script improvement by @salmanferrum in #38
- Feature/non upgradeable by @taha-abbasi in #41
New Contributors
- @SibghatUllah1997 made their first contribution in #21
- @taha-abbasi made their first contribution in #41
Full Changelog: v0.5.1...v1.5.0
v1.4.0
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
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
Release Notes - v1.2.0
Features
- Added unit test cases for the fiberRouter functionality.
- Made changes to the fundmanager test cases.
What else Changed
- Test cases for fiberRouter Contract added by @SibghatUllah1997 in #25
Full Changelog: v1.1.1...v1.2.0
v1.1.1
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
- Test Removed From .gitignore File To Push Test Cases by @SibghatUllah1997 in #24
Full Changelog: v1.1.0...v1.1.1