Repository navigation
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
handleFillOrderTohas been introduced to streamline the execution of thefillOrderTooperation. - 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
fillOrderTofunction in theOneInchSwapcontract has been updated to align with the changes inFiberRouter. - The updates ensure compatibility and extended functionality for 1inch swap operations.
- The
-
OneInchDecoder Contract:
- The
decodeFillOrderTofunction has been introduced to decode data related to thefillOrderTooperation. - 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 fromFiberRoutercontract to simulate withdrawals with gas estimation, featuringestimateGasForWithdrawSignedandestimateGasForWithdrawSignedAndSwapOneInchfunctions.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&withdrawSignedSwapAndCrossOneInchto public virtual - Changed the visibility modifier of FundManager's
AddSignerfunction 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