From 34072f945307adf3b00df789ef4792c0aa2eb38c Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Mon, 18 Nov 2024 16:04:35 +0300 Subject: [PATCH 01/54] del DexType enum and add dexRouter --- contracts/DexSwap.sol | 454 ++++++++++---------- contracts/Interfaces/IDexSwap.sol | 17 +- test/foundry/Bridge/BridgeCompression.t.sol | 2 +- 3 files changed, 223 insertions(+), 250 deletions(-) diff --git a/contracts/DexSwap.sol b/contracts/DexSwap.sol index ebfc61c8..dd152906 100644 --- a/contracts/DexSwap.sol +++ b/contracts/DexSwap.sol @@ -109,239 +109,227 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { return tokenAmountReceived; } - function _performSwap(IDexSwap.SwapData memory _swapData, address destinationAddress) private { - DexType dexType = _swapData.dexType; - - if (dexType == DexType.UniswapV3Single) { - _swapUniV3Single(_swapData, destinationAddress); - } else if (dexType == DexType.UniswapV3Multi) { - _swapUniV3Multi(_swapData, destinationAddress); - } else if (dexType == DexType.WrapNative) { - _wrapNative(_swapData); - } else if (dexType == DexType.UnwrapWNative) { - _unwrapWNative(_swapData, destinationAddress); - } - } - - function _wrapNative(IDexSwap.SwapData memory _swapData) private { - address wrappedNative = _getWrappedNative(); - IWETH(wrappedNative).deposit{value: _swapData.fromAmount}(); - } - - function _unwrapWNative(IDexSwap.SwapData memory _swapData, address _recipient) private { - if (_swapData.fromToken != _getWrappedNative()) revert InvalidDexData(); - - IWETH(_swapData.fromToken).withdraw(_swapData.fromAmount); - - (bool sent, ) = _recipient.call{value: _swapData.fromAmount}(""); - if (!sent) { - revert UnwrapWNativeFailed(); - } - } - - /** - * @notice UniswapV3 function that executes single hop swaps - * @param _swapData the encoded swap data - * @dev This function can execute swap in any protocol compatible with UniV3 that implements the IV3SwapRouter - */ - function _swapUniV3Single(IDexSwap.SwapData memory _swapData, address _recipient) private { - if (_swapData.dexData.length == 0) revert EmptyDexData(); - (address routerAddress, uint24 fee, uint160 sqrtPriceLimitX96, uint256 deadline) = abi - .decode(_swapData.dexData, (address, uint24, uint160, uint256)); - - if (!s_routerAllowed[routerAddress]) revert DexRouterNotAllowed(); - - if (block.chainid == BASE_CHAIN_ID || block.chainid == AVAX_CHAIN_ID) { - IV3SwapRouter.ExactInputSingleParams memory dex = IV3SwapRouter.ExactInputSingleParams({ - tokenIn: _swapData.fromToken, - tokenOut: _swapData.toToken, - fee: fee, - recipient: _recipient, - amountIn: _swapData.fromAmount, - amountOutMinimum: _swapData.toAmountMin, - sqrtPriceLimitX96: sqrtPriceLimitX96 - }); - - IERC20(_swapData.fromToken).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); - ISwapRouter02(routerAddress).exactInputSingle(dex); - } else { - ISwapRouter.ExactInputSingleParams memory dex = ISwapRouter.ExactInputSingleParams({ - tokenIn: _swapData.fromToken, - tokenOut: _swapData.toToken, - fee: fee, - recipient: _recipient, - deadline: deadline, - amountIn: _swapData.fromAmount, - amountOutMinimum: _swapData.toAmountMin, - sqrtPriceLimitX96: sqrtPriceLimitX96 - }); - - IERC20(_swapData.fromToken).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); - ISwapRouter(routerAddress).exactInputSingle(dex); - } - } - - /** - * @notice UniswapV3 function that executes multi hop swaps - * @param _swapData the encoded swap data - * @dev This function can execute swap in any protocol compatible - */ - function _swapUniV3Multi(IDexSwap.SwapData memory _swapData, address _recipient) private { - if (_swapData.dexData.length == 0) revert EmptyDexData(); - - (address routerAddress, bytes memory path, uint256 deadline) = abi.decode( - _swapData.dexData, - (address, bytes, uint256) - ); - (address firstToken, address lastToken) = _extractTokens(path); - - if (!s_routerAllowed[routerAddress]) revert DexRouterNotAllowed(); - if (firstToken != _swapData.fromToken || lastToken != _swapData.toToken) - revert InvalidTokenPath(); - - if (block.chainid == BASE_CHAIN_ID || block.chainid == AVAX_CHAIN_ID) { - IV3SwapRouter.ExactInputParams memory params = IV3SwapRouter.ExactInputParams({ - path: path, - recipient: _recipient, - amountIn: _swapData.fromAmount, - amountOutMinimum: _swapData.toAmountMin - }); - - IERC20(_swapData.fromToken).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); - ISwapRouter02(routerAddress).exactInput(params); - } else { - ISwapRouter.ExactInputParams memory params = ISwapRouter.ExactInputParams({ - path: path, - recipient: _recipient, - deadline: deadline, - amountIn: _swapData.fromAmount, - amountOutMinimum: _swapData.toAmountMin - }); - - IERC20(_swapData.fromToken).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); - ISwapRouter(routerAddress).exactInput(params); - } - } - - /** - * @notice Function to execute swap accordingly to UniswapV2 - * @param _swapData the encoded swap data - * @dev This function can execute single or multi hop swaps - */ - function _swapUniV2Like(IDexSwap.SwapData memory _swapData, address _recipient) private { - if (_swapData.dexData.length == 0) revert EmptyDexData(); - - (address routerAddress, address[] memory path, uint256 deadline) = abi.decode( - _swapData.dexData, - (address, address[], uint256) - ); - uint256 numberOfHops = path.length; - - if (!s_routerAllowed[routerAddress]) revert DexRouterNotAllowed(); - if (path[0] != _swapData.fromToken || path[numberOfHops - 1] != _swapData.toToken) - revert InvalidTokenPath(); - - IERC20(path[0]).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); - - IUniswapV2Router02(routerAddress).swapExactTokensForTokens( - _swapData.fromAmount, - _swapData.toAmountMin, - path, - _recipient, - deadline - ); - } - - /** - * @notice Function to execute swap accordingly to UniswapV2 - * @param _swapData the encoded swap data - * @dev This function accept FoT tokens - * @dev This function can execute single or multi hop swaps - */ - function _swapUniV2LikeFoT(IDexSwap.SwapData memory _swapData, address _recipient) private { - if (_swapData.dexData.length == 0) revert EmptyDexData(); - - (address routerAddress, address[] memory path, uint256 deadline) = abi.decode( - _swapData.dexData, - (address, address[], uint256) - ); - uint256 numberOfHops = path.length; - - if (!s_routerAllowed[routerAddress]) revert DexRouterNotAllowed(); - if (path[0] != _swapData.fromToken || path[numberOfHops - 1] != _swapData.toToken) - revert InvalidTokenPath(); - - IERC20(path[0]).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); - - IUniswapV2Router02(routerAddress).swapExactTokensForTokensSupportingFeeOnTransferTokens( - _swapData.fromAmount, - _swapData.toAmountMin, - path, - _recipient, - deadline - ); - } - - /** - * @notice Function to execute swap - * @param _swapData the encoded swap data - * @dev This function can execute swap in any protocol compatible with UniV3 that implements the ISwapRouter - */ - function _swapSushiV3Single(IDexSwap.SwapData memory _swapData, address _recipient) private { - if (_swapData.dexData.length == 0) revert EmptyDexData(); - - (address routerAddress, uint24 fee, uint256 deadline, uint160 sqrtPriceLimitX96) = abi - .decode(_swapData.dexData, (address, uint24, uint256, uint160)); - - if (!s_routerAllowed[routerAddress]) revert DexRouterNotAllowed(); - - ISushiRouterV3.ExactInputSingleParams memory dex = ISushiRouterV3.ExactInputSingleParams({ - tokenIn: _swapData.fromToken, - tokenOut: _swapData.toToken, - fee: fee, - recipient: _recipient, - deadline: deadline, - amountIn: _swapData.fromAmount, - amountOutMinimum: _swapData.toAmountMin, - sqrtPriceLimitX96: sqrtPriceLimitX96 - }); - - IERC20(_swapData.fromToken).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); - - ISushiRouterV3(routerAddress).exactInputSingle(dex); - } - - /** - * @notice SushiSwapV3 function that executes multi hop swaps - * @param _swapData the encoded swap data - * @dev This function can execute swap in any protocol compatible with ISwapRouter - */ - function _swapSushiV3Multi(IDexSwap.SwapData memory _swapData, address _recipient) private { - if (_swapData.dexData.length == 0) revert EmptyDexData(); - - (address routerAddress, bytes memory path, uint256 deadline) = abi.decode( - _swapData.dexData, - (address, bytes, uint256) - ); - - (address firstToken, address lastToken) = _extractTokens(path); - - if (!s_routerAllowed[routerAddress]) revert DexRouterNotAllowed(); - if (firstToken != _swapData.fromToken || lastToken != _swapData.toToken) - revert InvalidTokenPath(); - - ISushiRouterV3.ExactInputParams memory params = ISushiRouterV3.ExactInputParams({ - path: path, - recipient: _recipient, - deadline: deadline, - amountIn: _swapData.fromAmount, - amountOutMinimum: _swapData.toAmountMin - }); - - IERC20(_swapData.fromToken).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); - - ISushiRouterV3(routerAddress).exactInput(params); - } + function _performSwap(IDexSwap.SwapData memory _swapData, address destinationAddress) private {} + + // function _wrapNative(IDexSwap.SwapData memory _swapData) private { + // address wrappedNative = _getWrappedNative(); + // IWETH(wrappedNative).deposit{value: _swapData.fromAmount}(); + // } + + // function _unwrapWNative(IDexSwap.SwapData memory _swapData, address _recipient) private { + // if (_swapData.fromToken != _getWrappedNative()) revert InvalidDexData(); + + // IWETH(_swapData.fromToken).withdraw(_swapData.fromAmount); + + // (bool sent, ) = _recipient.call{value: _swapData.fromAmount}(""); + // if (!sent) { + // revert UnwrapWNativeFailed(); + // } + // } + + // /** + // * @notice UniswapV3 function that executes single hop swaps + // * @param _swapData the encoded swap data + // * @dev This function can execute swap in any protocol compatible with UniV3 that implements the IV3SwapRouter + // */ + // function _swapUniV3Single(IDexSwap.SwapData memory _swapData, address _recipient) private { + // if (_swapData.dexData.length == 0) revert EmptyDexData(); + // (address routerAddress, uint24 fee, uint160 sqrtPriceLimitX96, uint256 deadline) = abi + // .decode(_swapData.dexData, (address, uint24, uint160, uint256)); + + // if (!s_routerAllowed[routerAddress]) revert DexRouterNotAllowed(); + + // if (block.chainid == BASE_CHAIN_ID || block.chainid == AVAX_CHAIN_ID) { + // IV3SwapRouter.ExactInputSingleParams memory dex = IV3SwapRouter.ExactInputSingleParams({ + // tokeDexTypenIn: _swapData.fromToken, + // tokenOut: _swapData.toToken, + // fee: fee, + // recipient: _recipient, + // amountIn: _swapData.fromAmount, + // amountOutMinimum: _swapData.toAmountMin, + // sqrtPriceLimitX96: sqrtPriceLimitX96 + // }); + + // IERC20(_swapData.fromToken).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); + // ISwapRouter02(routerAddress).exactInputSingle(dex); + // } else { + // ISwapRouter.ExactInputSingleParams memory dex = ISwapRouter.ExactInputSingleParams({ + // tokenIn: _swapData.fromToken, + // tokenOut: _swapData.toToken, + // fee: fee, + // recipient: _recipient, + // deadline: deadline, + // amountIn: _swapData.fromAmount, + // amountOutMinimum: _swapData.toAmountMin, + // sqrtPriceLimitX96: sqrtPriceLimitX96 + // }); + + // IERC20(_swapData.fromToken).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); + // ISwapRouter(routerAddress).exactInputSingle(dex); + // } + // } + + // /** + // * @notice UniswapV3 function that executes multi hop swaps + // * @param _swapData the encoded swap data + // * @dev This function can execute swap in any protocol compatible + // */ + // function _swapUniV3Multi(IDexSwap.SwapData memory _swapData, address _recipient) private { + // if (_swapData.dexData.length == 0) revert EmptyDexData(); + + // (address routerAddress, bytes memory path, uint256 deadline) = abi.decode( + // _swapData.dexData, + // (address, bytes, uint256) + // ); + // (address firstToken, address lastToken) = _extractTokens(path); + + // if (!s_routerAllowed[routerAddress]) revert DexRouterNotAllowed(); + // if (firstToken != _swapData.fromToken || lastToken != _swapData.toToken) + // revert InvalidTokenPath(); + + // if (block.chainid == BASE_CHAIN_ID || block.chainid == AVAX_CHAIN_ID) { + // IV3SwapRouter.ExactInputParams memory params = IV3SwapRouter.ExactInputParams({ + // path: path, + // recipient: _recipient, + // amountIn: _swapData.fromAmount, + // amountOutMinimum: _swapData.toAmountMin + // }); + + // IERC20(_swapData.fromToken).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); + // ISwapRouter02(routerAddress).exactInput(params); + // } else { + // ISwapRouter.ExactInputParams memory params = ISwapRouter.ExactInputParams({ + // path: path, + // recipient: _recipient, + // deadline: deadline, + // amountIn: _swapData.fromAmount, + // amountOutMinimum: _swapData.toAmountMin + // }); + + // IERC20(_swapData.fromToken).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); + // ISwapRouter(routerAddress).exactInput(params); + // } + // } + + // /** + // * @notice Function to execute swap accordingly to UniswapV2 + // * @param _swapData the encoded swap data + // * @dev This function can execute single or multi hop swaps + // */ + // function _swapUniV2Like(IDexSwap.SwapData memory _swapData, address _recipient) private { + // if (_swapData.dexData.length == 0) revert EmptyDexData(); + + // (address routerAddress, address[] memory path, uint256 deadline) = abi.decode( + // _swapData.dexData, + // (address, address[], uint256) + // ); + // uint256 numberOfHops = path.length; + + // if (!s_routerAllowed[routerAddress]) revert DexRouterNotAllowed(); + // if (path[0] != _swapData.fromToken || path[numberOfHops - 1] != _swapData.toToken) + // revert InvalidTokenPath(); + + // IERC20(path[0]).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); + + // IUniswapV2Router02(routerAddress).swapExactTokensForTokens( + // _swapData.fromAmount, + // _swapData.toAmountMin, + // path, + // _recipient, + // deadline + // ); + // } + + // /** + // * @notice Function to execute swap accordingly to UniswapV2 + // * @param _swapData the encoded swap data + // * @dev This function accept FoT tokens + // * @dev This function can execute single or multi hop swaps + // */ + // function _swapUniV2LikeFoT(IDexSwap.SwapData memory _swapData, address _recipient) private { + // if (_swapData.dexData.length == 0) revert EmptyDexData(); + + // (address routerAddress, address[] memory path, uint256 deadline) = abi.decode( + // _swapData.dexData, + // (address, address[], uint256) + // ); + // uint256 numberOfHops = path.length; + + // if (!s_routerAllowed[routerAddress]) revert DexRouterNotAllowed(); + // if (path[0] != _swapData.fromToken || path[numberOfHops - 1] != _swapData.toToken) + // revert InvalidTokenPath(); + + // IERC20(path[0]).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); + + // IUniswapV2Router02(routerAddress).swapExactTokensForTokensSupportingFeeOnTransferTokens( + // _swapData.fromAmount, + // _swapData.toAmountMin, + // path, + // _recipient, + // deadline + // ); + // } + + // /** + // * @notice Function to execute swap + // * @param _swapData the encoded swap data + // * @dev This function can execute swap in any protocol compatible with UniV3 that implements the ISwapRouter + // */ + // function _swapSushiV3Single(IDexSwap.SwapData memory _swapData, address _recipient) private { + // if (_swapData.dexData.length == 0) revert EmptyDexData(); + + // (address routerAddress, uint24 fee, uint256 deadline, uint160 sqrtPriceLimitX96) = abi + // .decode(_swapData.dexData, (address, uint24, uint256, uint160)); + + // if (!s_routerAllowed[routerAddress]) revert DexRouterNotAllowed(); + + // ISushiRouterV3.ExactInputSingleParams memory dex = ISushiRouterV3.ExactInputSingleParams({ + // tokenIn: _swapData.fromToken, + // tokenOut: _swapData.toToken, + // fee: fee, + // recipient: _recipient, + // deadline: deadline, + // amountIn: _swapData.fromAmount, + // amountOutMinimum: _swapData.toAmountMin, + // sqrtPriceLimitX96: sqrtPriceLimitX96 + // }); + + // IERC20(_swapData.fromToken).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); + + // ISushiRouterV3(routerAddress).exactInputSingle(dex); + // } + + // /** + // * @notice SushiSwapV3 function that executes multi hop swaps + // * @param _swapData the encoded swap data + // * @dev This function can execute swap in any protocol compatible with ISwapRouter + // */ + // function _swapSushiV3Multi(IDexSwap.SwapData memory _swapData, address _recipient) private { + // if (_swapData.dexData.length == 0) revert EmptyDexData(); + + // (address routerAddress, bytes memory path, uint256 deadline) = abi.decode( + // _swapData.dexData, + // (address, bytes, uint256) + // ); + + // (address firstToken, address lastToken) = _extractTokens(path); + + // if (!s_routerAllowed[routerAddress]) revert DexRouterNotAllowed(); + // if (firstToken != _swapData.fromToken || lastToken != _swapData.toToken) + // revert InvalidTokenPath(); + + // ISushiRouterV3.ExactInputParams memory params = ISushiRouterV3.ExactInputParams({ + // path: path, + // recipient: _recipient, + // deadline: deadline, + // amountIn: _swapData.fromAmount, + // amountOutMinimum: _swapData.toAmountMin + // }); + + // IERC20(_swapData.fromToken).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); + + // ISushiRouterV3(routerAddress).exactInput(params); + // } // // /** // * @notice Function to execute swaps on Aerodrome and Velodrome Protocols diff --git a/contracts/Interfaces/IDexSwap.sol b/contracts/Interfaces/IDexSwap.sol index dd0d7e29..c8b5c223 100644 --- a/contracts/Interfaces/IDexSwap.sol +++ b/contracts/Interfaces/IDexSwap.sol @@ -2,24 +2,9 @@ pragma solidity 0.8.20; interface IDexSwap { - ///@notice Concero Enum to track DEXes - enum DexType { - UniswapV2, - UniswapV2FoT, - SushiV3Single, - UniswapV3Single, - SushiV3Multi, - UniswapV3Multi, - Aerodrome, - AerodromeFoT, - UniswapV2Ether, - WrapNative, - UnwrapWNative - } - ///@notice Concero Struct to track DEX Data struct SwapData { - DexType dexType; + address dexRouter; address fromToken; uint256 fromAmount; address toToken; diff --git a/test/foundry/Bridge/BridgeCompression.t.sol b/test/foundry/Bridge/BridgeCompression.t.sol index 2b01d314..8150983d 100644 --- a/test/foundry/Bridge/BridgeCompression.t.sol +++ b/test/foundry/Bridge/BridgeCompression.t.sol @@ -198,7 +198,7 @@ contract BridgeCompressionTest is BridgeBaseTest { IDexSwap.SwapData[] memory _dstSwapData = new IDexSwap.SwapData[](1); IDexSwap.SwapData memory singleSwap = IDexSwap.SwapData({ - dexType: IDexSwap.DexType.UniswapV3Single, + dexRouter: routerAddress, fromToken: usdcAvalanche, fromAmount: USER_FUNDS / 2, toToken: DAI_AVALANCHE, From c5d248cbf228aecf66ec7437c481bb824a965555 Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Mon, 18 Nov 2024 16:06:56 +0300 Subject: [PATCH 02/54] natspec --- contracts/Interfaces/IDexSwap.sol | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/contracts/Interfaces/IDexSwap.sol b/contracts/Interfaces/IDexSwap.sol index c8b5c223..2e1ee0c8 100644 --- a/contracts/Interfaces/IDexSwap.sol +++ b/contracts/Interfaces/IDexSwap.sol @@ -2,7 +2,14 @@ pragma solidity 0.8.20; interface IDexSwap { - ///@notice Concero Struct to track DEX Data + /// @notice Concero Struct to track DEX Data + /// @param dexRouter address of the DEX Router + /// @param fromToken address of the token to be swapped + /// @param fromAmount amount of token to be swapped + /// @param toToken address of the token to be received + /// @param toAmount amount of token to be received + /// @param toAmountMin minimum amount of token to be received + /// @param dexData encoded data for the DEX struct SwapData { address dexRouter; address fromToken; From 9cbdc29c208c6388d451124c94caf5c9acaec776 Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Mon, 18 Nov 2024 16:07:47 +0300 Subject: [PATCH 03/54] add InsufficientAmount error --- contracts/DexSwap.sol | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contracts/DexSwap.sol b/contracts/DexSwap.sol index dd152906..363dd084 100644 --- a/contracts/DexSwap.sol +++ b/contracts/DexSwap.sol @@ -32,6 +32,8 @@ error InvalidTokenPath(); ///@notice error emitted when the DexData is not valid error InvalidDexData(); error UnwrapWNativeFailed(); +///@notice error emitted when the amount is not sufficient +error InsufficientAmount(uint256 amount); contract DexSwap is IDexSwap, InfraCommon, InfraStorage { using SafeERC20 for IERC20; From 9b3f94f6fc319d02069d8eb629a2e1a52e306bf6 Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Mon, 18 Nov 2024 16:09:05 +0300 Subject: [PATCH 04/54] add additional after swap check --- contracts/DexSwap.sol | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contracts/DexSwap.sol b/contracts/DexSwap.sol index 363dd084..c6d54630 100644 --- a/contracts/DexSwap.sol +++ b/contracts/DexSwap.sol @@ -88,6 +88,11 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { address(this) ); uint256 remainingBalance = postSwapBalance - preSwapBalance; + + if (remainingBalance < _swapData[i].toAmountMin) { + revert InsufficientAmount(remainingBalance); + } + _swapData[i + 1].fromAmount = remainingBalance; } From 6e9d021766e6a1b779e72285c4c0097de39b7949 Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Mon, 18 Nov 2024 16:11:01 +0300 Subject: [PATCH 05/54] implement _performSwap fn --- contracts/DexSwap.sol | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/contracts/DexSwap.sol b/contracts/DexSwap.sol index c6d54630..84d48183 100644 --- a/contracts/DexSwap.sol +++ b/contracts/DexSwap.sol @@ -116,7 +116,23 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { return tokenAmountReceived; } - function _performSwap(IDexSwap.SwapData memory _swapData, address destinationAddress) private {} + function _performSwap(IDexSwap.SwapData memory _swapData, address destinationAddress) private { + if (_swapData.dexData.length == 0) revert EmptyDexData(); + + address routerAddress = _swapData.dexRouter; + uint256 fromAmount = _swapData.fromAmount; + + if (!s_routerAllowed[routerAddress]) revert DexRouterNotAllowed(); + bool isFromNative = _swapData.fromToken == address(0); + + if (!isFromNative) { + IERC20(_swapData.fromToken).safeIncreaseAllowance(routerAddress, fromAmount); + fromAmount = 0; + } + + (bool success, ) = routerAddress.call{value: fromAmount}(_swapData.dexData); + if (!success) revert InvalidDexData(); + } // function _wrapNative(IDexSwap.SwapData memory _swapData) private { // address wrappedNative = _getWrappedNative(); From e924f8d254fa183ebf7b825d25d7d5254d251ede Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Mon, 18 Nov 2024 16:12:30 +0300 Subject: [PATCH 06/54] delete unused param --- contracts/DexSwap.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/DexSwap.sol b/contracts/DexSwap.sol index 84d48183..de9eef1c 100644 --- a/contracts/DexSwap.sol +++ b/contracts/DexSwap.sol @@ -77,7 +77,7 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { destinationAddress = _recipient; } - _performSwap(_swapData[i], destinationAddress); + _performSwap(_swapData[i]); if (i < swapDataLength - 1) { if (_swapData[i].toToken != _swapData[i + 1].fromToken) { @@ -116,7 +116,7 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { return tokenAmountReceived; } - function _performSwap(IDexSwap.SwapData memory _swapData, address destinationAddress) private { + function _performSwap(IDexSwap.SwapData memory _swapData) private { if (_swapData.dexData.length == 0) revert EmptyDexData(); address routerAddress = _swapData.dexRouter; From 1a3b71f596cfc62e77b6f6708cbb73cd4bc90030 Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Mon, 18 Nov 2024 16:15:09 +0300 Subject: [PATCH 07/54] add receiving tokens by the user --- contracts/DexSwap.sol | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/contracts/DexSwap.sol b/contracts/DexSwap.sol index de9eef1c..a5e2f8cc 100644 --- a/contracts/DexSwap.sol +++ b/contracts/DexSwap.sol @@ -34,6 +34,8 @@ error InvalidDexData(); error UnwrapWNativeFailed(); ///@notice error emitted when the amount is not sufficient error InsufficientAmount(uint256 amount); +///@notice error emitted when the transfer failed +error TransferFailed(); contract DexSwap is IDexSwap, InfraCommon, InfraStorage { using SafeERC20 for IERC20; @@ -105,6 +107,14 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { uint256 tokenAmountReceived = LibConcero.getBalance(dstToken, address(this)) - dstTokenBalanceBefore; + // if dstToken is native, send native + if (dstToken == address(0)) { + (bool sent, ) = _recipient.call{value: tokenAmountReceived}(""); + if (!sent) revert TransferFailed(); + } else { + IERC20(dstToken).safeTransfer(_recipient, tokenAmountReceived); + } + emit ConceroSwap( _swapData[0].fromToken, _swapData[swapDataLength - 1].toToken, From f85c295762d204150ec82c5035923fb3b0934eeb Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Mon, 18 Nov 2024 16:16:13 +0300 Subject: [PATCH 08/54] delete unused --- contracts/DexSwap.sol | 5 ----- 1 file changed, 5 deletions(-) diff --git a/contracts/DexSwap.sol b/contracts/DexSwap.sol index a5e2f8cc..8a941537 100644 --- a/contracts/DexSwap.sol +++ b/contracts/DexSwap.sol @@ -68,17 +68,12 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { if (address(this) != i_proxy) revert OnlyProxyContext(address(this)); uint256 swapDataLength = _swapData.length; - address destinationAddress = address(this); address dstToken = _swapData[swapDataLength - 1].toToken; uint256 dstTokenBalanceBefore = LibConcero.getBalance(dstToken, address(this)); for (uint256 i; i < swapDataLength; ) { uint256 preSwapBalance = LibConcero.getBalance(_swapData[i].toToken, address(this)); - if (i == swapDataLength - 1) { - destinationAddress = _recipient; - } - _performSwap(_swapData[i]); if (i < swapDataLength - 1) { From d38fd963cb10674df42043364f582a1ae18a6722 Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Fri, 22 Nov 2024 01:12:00 +0300 Subject: [PATCH 09/54] add new tokens --- .env.tokens | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.env.tokens b/.env.tokens index 8b2f0e53..5fe8a772 100644 --- a/.env.tokens +++ b/.env.tokens @@ -35,6 +35,22 @@ USDC_POLYGON=0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359 USDC_AVALANCHE=0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E USDC_BASE=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 +# USDT MAINNET +USDT_ARBITRUM=0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9 + +# WETH MAINNET +WETH_BASE=0x4200000000000000000000000000000000000006 +WETH_ARBITRUM=0x82aF49447D8a07e3bd95BD0d56f35241523fBab1 + +# DAI MAINNET +DAI_BASE=0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb + +# SUSHI MAINNET +SUSHI_BASE=0x7d49a065d17d6d4a55dc13649901fdbb98b2afba + +# 1INCH TOKEN MAINNET +1INCH_BASE=0xc5fecC3a29Fb57B5024eEc8a2239d4621e111CBE + # USDC TESTNET USDC_SEPOLIA=0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238 USDC_ARBITRUM_SEPOLIA=0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d From 3ecfbd74d5400b3763871ab3f8f9d73b1e87f4e8 Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Fri, 22 Nov 2024 01:12:16 +0300 Subject: [PATCH 10/54] add args in forks --- Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 06bc5984..09e05d55 100644 --- a/Makefile +++ b/Makefile @@ -30,10 +30,13 @@ install: grep -E '^\s*url' ./.gitmodules | awk '{print $$3}' | xargs -I {} sh -c 'forge install {}' run_fork: - anvil --fork-url ${BASE_RPC_URL} -p ${BASE_LOCAL_FORK_PORT} + anvil --fork-url ${BASE_RPC_URL} -p ${BASE_LOCAL_FORK_PORT} $(args) run_arb_fork: - anvil --fork-url ${ARB_RPC_URL} -p ${ARB_LOCAL_FORK_PORT} + anvil --fork-url ${ARB_RPC_URL} -p ${ARB_LOCAL_FORK_PORT} $(args) + +run_polygon_fork: + anvil --fork-url ${POLYGON_RPC_URL} -p ${POLYGON_LOCAL_FORK_PORT} $(args) test: forge test $(args) From b6f43f2d1dae09bc36579fadcde99698ddfcdc84 Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Fri, 22 Nov 2024 01:12:36 +0300 Subject: [PATCH 11/54] add tests for DexSwap --- test/foundry/Swap/DexSwap.t.sol | 717 ++++++++++++++++++++++++++++++++ 1 file changed, 717 insertions(+) create mode 100644 test/foundry/Swap/DexSwap.t.sol diff --git a/test/foundry/Swap/DexSwap.t.sol b/test/foundry/Swap/DexSwap.t.sol new file mode 100644 index 00000000..7848c639 --- /dev/null +++ b/test/foundry/Swap/DexSwap.t.sol @@ -0,0 +1,717 @@ +// SPDX-License-Identifier: SEE LICENSE IN LICENSE +pragma solidity ^0.8.20; + +import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import {console} from "forge-std/Test.sol"; +import {BaseTest} from "../utils/BaseTest.t.sol"; +import {IDexSwap} from "../../../contracts/Interfaces/IDexSwap.sol"; +import {IInfraOrchestrator} from "../../../contracts/Interfaces/IInfraOrchestrator.sol"; +import {InfraOrchestrator} from "../../../contracts/InfraOrchestrator.sol"; + +contract DexSwapTest is BaseTest { + uint256 internal constant WETH_DECIMALS = 18; + address internal constant ETH_TOKEN = address(0); + + // Base tokens + address internal usdcTokenBase = vm.envAddress("USDC_BASE"); + address internal wethTokenBase = vm.envAddress("WETH_BASE"); + address internal daiTokenBase = vm.envAddress("DAI_BASE"); + address internal sushiTokenBase = vm.envAddress("SUSHI_BASE"); + address internal oneInchTokenBase = vm.envAddress("1INCH_BASE"); + + //Arbitrum tokens + address internal usdcTokenArbitrum = vm.envAddress("USDC_ARBITRUM"); + address internal usdtTokenArbitrum = vm.envAddress("USDT_ARBITRUM"); + address internal wethTokenArbitrum = vm.envAddress("WETH_ARBITRUM"); + + //Arbitrum Routers + address internal sushiRouterArbitrum = vm.envAddress("SUSHISWAP_ROUTER_ARBITRUM_ADDRESS"); + address internal uniV3RouterArbitrum = vm.envAddress("UNI_V3_ROUTER_ARBITRUM_ADDRESS"); + address internal paraSwapV5RouterArbitrum = + vm.envAddress("PARASWAP_V5_ROUTER_ARBITRUM_ADDRESS"); + + //Base Routers + address internal uniV3RouterBase = vm.envAddress("UNI_V3_ROUTER02_BASE_ADDRESS"); + address internal paraSwapV6_2RouterBase = vm.envAddress("PARASWAP_V6_2_ROUTER_BASE_ADDRESS"); + address internal odosRouterV2Base = vm.envAddress("ODOS_ROUTER_V2_BASE_ADDRESS"); + address internal oneInchRouterV5Base = vm.envAddress("1INCH_ROUTER_V5_BASE_ADDRESS"); + address internal curveRouterBase = vm.envAddress("CURVE_ROUTER_BASE_ADDRESS"); + address internal alienbaseRouterBase = vm.envAddress("ALIENBASE_ROUTER_BASE_ADDRESS"); + + address payable internal sender = payable(makeAddr("sender")); + address internal recipient = makeAddr("recipient"); + address internal integrator = makeAddr("integrator"); + + uint256 internal constant USDC_INITIAL_BALANCE = 10 * USDC_DECIMALS; + uint256 internal constant ETH_INITIAL_BALANCE = 0.01 ether; + + modifier addRouterInWL(address router, address proxy) { + _allowRouter(router, address(proxy)); + _; + } + + function setUp() public override setFork(arbitrumAnvilForkId) { + super.setUp(); + } + + //////////////////// Base /////////////////////////////// + //////////////////// Block number 22713659 ////////////// + + ////////////////////////////////////////////////////////// + ////////////////// Alienbase //////////////////// + ////////////////////////////////////////////////////////// + + //passed + function test_dexSwapAlienbaseRouterETHToUSDCBase() public setFork(baseAnvilForkId) { + _allowRouter(alienbaseRouterBase, address(baseOrchestratorProxy)); + + uint256 fromAmount = 0.1 ether; + uint256 toAmount = 267.528449e6; + uint256 toAmountMin = 266.190806e6; + + bytes + memory dexData = hex"7ff36ab5000000000000000000000000000000000000000000000000000000000fddbfd70000000000000000000000000000000000000000000000000000000000000080000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673fb53400000000000000000000000000000000000000000000000000000000000000020000000000000000000000004200000000000000000000000000000000000006000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: alienbaseRouterBase, + fromToken: ETH_TOKEN, + fromAmount: fromAmount, + toToken: usdcTokenBase, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _callTestWithRouter(swapData, address(baseOrchestratorProxy)); + } + + //passed + function test_dexSwapAlienbaseRouterUSDCToWETHBase() public setFork(baseAnvilForkId) { + _allowRouter(alienbaseRouterBase, address(baseOrchestratorProxy)); + + uint256 fromAmount = 10e6; //1 usdc + uint256 toAmount = 0.002945698049459263e18; + uint256 toAmountMin = 0.002930969559211966e18; + + bytes + memory dexData = hex"38ed173900000000000000000000000000000000000000000000000000000000009834e7000000000000000000000000000000000000000000000000000a69b3876c9fbe00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673fb6140000000000000000000000000000000000000000000000000000000000000002000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000004200000000000000000000000000000000000006"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: alienbaseRouterBase, + fromToken: usdcTokenBase, + fromAmount: fromAmount, + toToken: wethTokenBase, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _callTestWithRouter(swapData, address(baseOrchestratorProxy)); + } + + //passed + function test_dexSwapAlienbaseRouterUSDCToETHBase() public setFork(baseAnvilForkId) { + _allowRouter(alienbaseRouterBase, address(baseOrchestratorProxy)); + + uint256 fromAmount = 10e6; + uint256 toAmount = 0.002945698049459263 ether; + uint256 toAmountMin = 0.002930969559211966 ether; + + bytes + memory dexData = hex"18cbafe500000000000000000000000000000000000000000000000000000000009834e7000000000000000000000000000000000000000000000000000a69b3876c9fbe00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673fb67c0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000004200000000000000000000000000000000000006"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: alienbaseRouterBase, + fromToken: usdcTokenBase, + fromAmount: fromAmount, + toToken: ETH_TOKEN, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _callTestWithRouter(swapData, address(baseOrchestratorProxy)); + } + + ////////////////////////////////////////////////////////// + ////////////////// Curve //////////////////////// + ////////////////////////////////////////////////////////// + + //passed + function test_dexSwapCurveRouterUSDCToWETHBase() public setFork(baseAnvilForkId) { + _allowRouter(curveRouterBase, address(baseOrchestratorProxy)); + + uint256 fromAmount = 10e6; //1 usdc + uint256 toAmount = 0.002950528095025959e18; + uint256 toAmountMin = 0.002935775454550829e18; + + bytes + memory dexData = hex"c872a3c5000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f000000000000000000000000417ac0e078398c154edfadd9ef675d30be60af930000000000000000000000006e53131f68a034873b6bfa15502af094ef0c58540000000000000000000000004200000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009834e7000000000000000000000000000000000000000000000000000a6e127d1bdb2d000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f0000000000000000000000006e53131f68a034873b6bfa15502af094ef0c5854000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: curveRouterBase, + fromToken: usdcTokenBase, + fromAmount: fromAmount, + toToken: wethTokenBase, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _callTestWithRouter(swapData, address(baseOrchestratorProxy)); + } + + //not working + function test_dexSwapCurveRouterETHToUSDCBase() public setFork(baseAnvilForkId) { + _allowRouter(curveRouterBase, address(baseOrchestratorProxy)); + + uint256 fromAmount = 0.0003 ether; + uint256 toAmount = 0.993336e6; + uint256 toAmountMin = 0.988369e6; + + bytes + memory dexData = hex"c872a3c5000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000420000000000000000000000000000000000000600000000000000000000000042000000000000000000000000000000000000060000000000000000000000006e53131f68a034873b6bfa15502af094ef0c5854000000000000000000000000417ac0e078398c154edfadd9ef675d30be60af93000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001102aacc5688000000000000000000000000000000000000000000000000000000000000f14d100000000000000000000000042000000000000000000000000000000000000060000000000000000000000006e53131f68a034873b6bfa15502af094ef0c5854000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: curveRouterBase, + fromToken: ETH_TOKEN, + fromAmount: fromAmount, + toToken: usdcTokenBase, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _callTestWithRouter(swapData, address(baseOrchestratorProxy)); + } + + //passed + function test_dexSwapCurveRouterUSDCToETHBase() public setFork(baseAnvilForkId) { + _allowRouter(curveRouterBase, address(baseOrchestratorProxy)); + address vyperEth = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; + + uint256 fromAmount = 1e6; + uint256 toAmount = 0.00029502055232845 ether; + uint256 toAmountMin = 0.000293545449566807 ether; + + bytes + memory dexData = hex"c872a3c5000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f000000000000000000000000417ac0e078398c154edfadd9ef675d30be60af930000000000000000000000006e53131f68a034873b6bfa15502af094ef0c585400000000000000000000000042000000000000000000000000000000000000060000000000000000000000004200000000000000000000000000000000000006000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010afa71c98c9d000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f0000000000000000000000006e53131f68a034873b6bfa15502af094ef0c5854000000000000000000000000420000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: curveRouterBase, + fromToken: usdcTokenBase, + fromAmount: fromAmount, + toToken: ETH_TOKEN, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _callTestWithRouter(swapData, address(baseOrchestratorProxy)); + } + + ////////////////////////////////////////////////////////// + ////////////////// Odos Router V2 //////////////////////// + ////////////////////////////////////////////////////////// + + //passed + function test_dexSwapOdosRouterV2USDCToWETHBase() public setFork(baseAnvilForkId) { + _allowRouter(odosRouterV2Base, address(baseOrchestratorProxy)); + + uint256 fromAmount = 1e6; //1 usdc + uint256 toAmount = 0.000295473686245412e18; + uint256 toAmountMin = 0.000293996317814184e18; + + bytes + memory dexData = hex"83bd37f900040002030f387e07010cbb65c26b5000c49b00017882570840a97a490a37bd8db9e1ae39165bfbd600000001cd1722f3947def4cf144679da39c4c32bdc356810000000003010203000a0101010200ff000000000000000000000000000000000000000000883e4ae0a817f2901500971b353b5dd89aa52184833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000000000000000000000000000"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: odosRouterV2Base, + fromToken: usdcTokenBase, + fromAmount: fromAmount, + toToken: wethTokenBase, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _callTestWithRouter(swapData, address(baseOrchestratorProxy)); + } + + //dont work with native + function test_dexSwapOdosRouterV2ETHToUSDCBase() public setFork(baseAnvilForkId) { + _allowRouter(odosRouterV2Base, address(baseOrchestratorProxy)); + + uint256 fromAmount = 0.001 ether; + uint256 toAmount = 3.355603e6; + uint256 toAmountMin = 3.338824e6; + + bytes + memory dexData = hex"83bd37f90000000407038b38ea920700033333d300c49b00017882570840a97a490a37bd8db9e1ae39165bfbd600000001cd1722f3947def4cf144679da39c4c32bdc35681000000000301020300040101022b000101010201ff000000000000000000000000000000005b52dfa81e7409df9390c9403aceb51ea3df4f204200000000000000000000000000000000000006000000000000000000000000000000000000000000000000"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: odosRouterV2Base, + fromToken: ETH_TOKEN, + fromAmount: fromAmount, + toToken: usdcTokenBase, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _callTestWithRouter(swapData, address(baseOrchestratorProxy)); + } + + ////////////////////////////////////////////////////////// + ////////////////// 1Inch //////////////////////// + ////////////////////////////////////////////////////////// + + function test_dexSwap1InchV5USDCTo1InchTokenBase() public setFork(baseAnvilForkId) { + _allowRouter(oneInchRouterV5Base, address(baseOrchestratorProxy)); + + uint256 fromAmount = 10e6; //10 usdc + uint256 toAmount = 29.186618652079786377e18; + uint256 toAmountMin = 29.040685558819387445e18; + + bytes + memory dexData = hex"12aa3caf000000000000000000000000e37e799d5077682fa0a244d46e5649f71457bd09000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000c5fecc3a29fb57b5024eec8a2239d4621e111cbe000000000000000000000000e37e799d5077682fa0a244d46e5649f71457bd09000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000009834e700000000000000000000000000000000000000000000000193053da6cf3ef835000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004af00000000000000000000000000000000000000000000000000000000049100a007e5c0d200000000000000000000000000000000000000000000046d00040a0003f0512003c01acae3d0173a93d819efdc832c7c4f153b06833589fcd6edb6e08f4c7c32d4f71b54bda02913016452bbbe2900000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000e37e799d5077682fa0a244d46e5649f71457bd090000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e37e799d5077682fa0a244d46e5649f71457bd090000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000673f9a44def66c6c178087fd931514e99b04479e4d3d956c0002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009834e700000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000062769914a469c00000000000000000000000000000000000000000000000000000000673f9a4400000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000005af3107a400000000000000000b671b09bd7eb7a242300000000000000008bd0c186893c2c000000000000000dd975ede04e7dbbc0000000000000000005aab64d6906dbaed800000000000000000000000000000000000000000004ee7259d6914ae6c461bc00000000000000004563918244f400000000000000000000006a94d74f430000000000000000000000000000673f99ea000000000000000000003b1dfde910000000000000000000000000000000000000000000000000000000000000000041b0087e9968881cc03a4f3270b3086fd3a18f6587c3179ad985c8c406056d7b98035f5800bbb63a992a30c39c7224be035751091573a74d263682a8536b8d51711c0000000000000000000000000000000000000000000000000000000000000040414200000000000000000000000000000000000006d0e30db002a000000000000000000000000000000000000000000000000190fec846c67c66e1ee63c1e5814af5a3adb853290bc9f909138fbf1a3c3feb086842000000000000000000000000000000000000061111111254eeb25477b68fb85ed929f73a96058200000000000000000000000000000000007787a5c8"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: oneInchRouterV5Base, + fromToken: usdcTokenBase, + fromAmount: fromAmount, + toToken: oneInchTokenBase, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _callTestWithRouter(swapData, address(baseOrchestratorProxy)); + } + + //////////////////// Arbitrum //////////////////////////// + //////////////////// Block number 276843772 ////////////// + + ////////////////////////////////////////////////////////// + ////////////////// Sushi Swap /////////////////////////// + ////////////////////////////////////////////////////////// + + //passed + function test_dexSwapSushiSwapRouterUSDCToUSDT() public setFork(arbitrumAnvilForkId) { + _allowRouter(sushiRouterArbitrum, address(arbitrumOrchestratorProxy)); + + uint256 fromAmount = 1e6; //1 usdc + uint256 toAmount = 0.993041e6; + uint256 toAmountMin = 0.988075e6; + + bytes + memory dexData = hex"38ed173900000000000000000000000000000000000000000000000000000000000f381a00000000000000000000000000000000000000000000000000000000000f13ac00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673f6a920000000000000000000000000000000000000000000000000000000000000003000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000fd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: sushiRouterArbitrum, + fromToken: usdcTokenArbitrum, + fromAmount: fromAmount, + toToken: usdtTokenArbitrum, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); + } + + //passed + function test_dexSwapSushiSwapRouterUSDCToWETH() public setFork(arbitrumAnvilForkId) { + _allowRouter(sushiRouterArbitrum, address(arbitrumOrchestratorProxy)); + + uint256 fromAmount = 1e6; //1 usdc + uint256 toAmount = 0.00029991786617675 ether; + uint256 toAmountMin = 0.000298418276845866 ether; + + bytes + memory dexData = hex"38ed173900000000000000000000000000000000000000000000000000000000000f381a00000000000000000000000000000000000000000000000000010f68f44ac36b00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673f697d0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: sushiRouterArbitrum, + fromToken: usdcTokenArbitrum, + fromAmount: fromAmount, + toToken: wethTokenArbitrum, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); + } + + //passed + function test_dexSwapSushiSwapRouterUSDCToETH() public setFork(arbitrumAnvilForkId) { + _allowRouter(sushiRouterArbitrum, address(arbitrumOrchestratorProxy)); + + //only for block number of 21234930 + uint256 fromAmount = 1e6; //usdc + uint256 toAmount = 0.00029991786617675 ether; + uint256 toAmountMin = 0.000298418276845866 ether; + + bytes + memory dexData = hex"18cbafe500000000000000000000000000000000000000000000000000000000000f381a00000000000000000000000000000000000000000000000000010f68f44ac36b00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673f69fe0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: sushiRouterArbitrum, + fromToken: usdcTokenArbitrum, + fromAmount: fromAmount, + toToken: address(0), + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); + } + + //passed + function test_dexSwapSushiSwapRouterETHToUSDC() public setFork(arbitrumAnvilForkId) { + _allowRouter(sushiRouterArbitrum, address(arbitrumOrchestratorProxy)); + + //only for block number of 21234930 + uint256 fromAmount = 0.0001 ether; //ETH + uint256 toAmount = 0.33059e6; //usdc + uint256 toAmountMin = 0.328937e6; //usdc + + bytes + memory dexData = hex"7ff36ab500000000000000000000000000000000000000000000000000000000000504e90000000000000000000000000000000000000000000000000000000000000080000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673f6b16000000000000000000000000000000000000000000000000000000000000000200000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: sushiRouterArbitrum, + fromToken: address(0), + fromAmount: fromAmount, + toToken: usdcTokenArbitrum, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); + } + + ////////////////////////////////////////////////////////// + ////////////////// Uniswap /////////////////////// + ////////////////////////////////////////////////////////// + + //passed + function test_dexSwapUniSwapRouterUSDCToUSDT() public setFork(arbitrumAnvilForkId) { + _allowRouter(uniV3RouterArbitrum, address(arbitrumOrchestratorProxy)); + + uint256 fromAmount = 1e6; //1 usdc + uint256 toAmount = 0.996903e6; + uint256 toAmountMin = 0.991918e6; + + bytes + memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681000000000000000000000000000000000000000000000000000001934fbb778500000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000000000000f22af000000000000000000000000000000000000000000000000000000000000002baf88d065e77c8cc2239327c5edb3a432268e5831000064fd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: uniV3RouterArbitrum, + fromToken: usdcTokenArbitrum, + fromAmount: fromAmount, + toToken: usdtTokenArbitrum, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); + } + + //passed + function test_dexSwapUniSwapRouterUSDCToWETH() public setFork(arbitrumAnvilForkId) { + _allowRouter(uniV3RouterArbitrum, address(arbitrumOrchestratorProxy)); + + uint256 fromAmount = 1e6; //1 usdc + uint256 toAmount = 0.000299377182115898 ether; + uint256 toAmountMin = 0.000297880296205318 ether; + + bytes + memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681000000000000000000000000000000000000000000000000000001934fbd59aa00000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010eebbb0ca1e0000000000000000000000000000000000000000000000000000000000000002baf88d065e77c8cc2239327c5edb3a432268e58310001f482af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: uniV3RouterArbitrum, + fromToken: usdcTokenArbitrum, + fromAmount: fromAmount, + toToken: wethTokenArbitrum, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); + } + + //passed + function test_dexSwapUniSwapRouterUSDCToETH() public setFork(arbitrumAnvilForkId) { + _allowRouter(uniV3RouterArbitrum, address(arbitrumOrchestratorProxy)); + + //only for block number of + uint256 fromAmount = 1e6; //usdc + uint256 toAmount = 0.000300419724797236 ether; + uint256 toAmountMin = 0.000298917626173249 ether; + + bytes + memory dexData = hex"ac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001934fb896d900000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010fdd40cbad5d000000000000000000000000000000000000000000000000000000000000002baf88d065e77c8cc2239327c5edb3a432268e58310001f482af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004449404b7c00000000000000000000000000000000000000000000000000010fdd2eecd741000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: uniV3RouterArbitrum, + fromToken: usdcTokenArbitrum, + fromAmount: fromAmount, + toToken: address(0), + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); + } + + //passed + function test_dexSwapUniSwapRouterETHToUSDC() public setFork(arbitrumAnvilForkId) { + _allowRouter(uniV3RouterArbitrum, address(arbitrumOrchestratorProxy)); + + //only for block number of 21234930 + uint256 fromAmount = 0.0001 ether; //ETH + uint256 toAmount = 0.331996e6; //usdc + uint256 toAmountMin = 0.330336e6; //usdc + + bytes + memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681000000000000000000000000000000000000000000000000000001934fad171000000000000000000000000000000000000000000000000000005ab8e441cd800000000000000000000000000000000000000000000000000000000000050a60000000000000000000000000000000000000000000000000000000000000002b82af49447d8a07e3bd95bd0d56f35241523fbab10001f4af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: uniV3RouterArbitrum, + fromToken: address(0), + fromAmount: fromAmount, + toToken: usdcTokenArbitrum, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); + } + + ////////////////////////////////////////////////////////// + ////////////////// ParaSwap //////////////////////// + ////////////////////////////////////////////////////////// + + //does not work + function test_dexSwapParaSwapRouterUSDCToUSDT() public setFork(arbitrumAnvilForkId) { + _allowRouter(paraSwapV5RouterArbitrum, address(arbitrumOrchestratorProxy)); + + uint256 fromAmount = 1e6; //1 usdc + uint256 toAmount = 0.996903e6; + uint256 toAmountMin = 0.991918e6; + + bytes + memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681000000000000000000000000000000000000000000000000000001934fbb778500000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000000000000f22af000000000000000000000000000000000000000000000000000000000000002baf88d065e77c8cc2239327c5edb3a432268e5831000064fd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: paraSwapV5RouterArbitrum, + fromToken: usdcTokenArbitrum, + fromAmount: fromAmount, + toToken: usdtTokenArbitrum, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); + } + + //does not work + function test_dexSwapParaSwapRouterUSDCToWETH() public setFork(arbitrumAnvilForkId) { + _allowRouter(paraSwapV5RouterArbitrum, address(arbitrumOrchestratorProxy)); + + uint256 fromAmount = 1e6; //1 usdc + uint256 toAmount = 0.00029758021792574 ether; + uint256 toAmountMin = 0.000296092316836111 ether; + + bytes + memory dexData = hex"54e3f31b0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010d4b6f1016c900000000000000000000000000000000000000000000000000010ea5dcf7ba4600000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000003800000000000000000000000000000000000000000000000000000000000000400000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000046000000000000000000000000000000000000000000000000000000000673f779551436a490fb745e4a0a79829c8000ce6000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831000000000000000000000000ed9e3f98bbed560e66b89aac922e29d4596a96420000000000000000000000000000000000000000000000000000000000000108a9059cbb000000000000000000000000ed9e3f98bbed560e66b89aac922e29d4596a964200000000000000000000000000000000000000000000000000000000000f387e7dc20382000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000f387e0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee57000000000000000000000000d5b927956057075377263aab7f8afc12f85100db00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000001080000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: paraSwapV5RouterArbitrum, + fromToken: usdcTokenArbitrum, + fromAmount: fromAmount, + toToken: wethTokenArbitrum, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); + } + + //does not work + function test_dexSwapParaSwapRouterUSDCToETH() public setFork(arbitrumAnvilForkId) { + _allowRouter(paraSwapV5RouterArbitrum, address(arbitrumOrchestratorProxy)); + + //only for block number of + uint256 fromAmount = 1e6; //usdc + uint256 toAmount = 0.000300419724797236 ether; + uint256 toAmountMin = 0.000298917626173249 ether; + + bytes + memory dexData = hex"ac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001934fb896d900000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010fdd40cbad5d000000000000000000000000000000000000000000000000000000000000002baf88d065e77c8cc2239327c5edb3a432268e58310001f482af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004449404b7c00000000000000000000000000000000000000000000000000010fdd2eecd741000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: paraSwapV5RouterArbitrum, + fromToken: usdcTokenArbitrum, + fromAmount: fromAmount, + toToken: address(0), + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); + } + + //does not work + function test_dexSwapParaSwapRouterETHToUSDC() public setFork(arbitrumAnvilForkId) { + _allowRouter(paraSwapV5RouterArbitrum, address(arbitrumOrchestratorProxy)); + + //only for block number of 21234930 + uint256 fromAmount = 0.001 ether; //ETH + uint256 toAmount = 3.334998e6; //usdc + uint256 toAmountMin = 3.318323e6; //usdc + + bytes + memory dexData = hex"54e3f31b0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000038b38ea920700000000000000000000000000000000000000000000000000000000000032a1e5000000000000000000000000000000000000000000000000000000000032e30700000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000003a00000000000000000000000000000000000000000000000000000000000000440000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc356810000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000004c000000000000000000000000000000000000000000000000000000000673f7930962cd732e34c45a093489154807ea37000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000ed9e3f98bbed560e66b89aac922e29d4596a9642000000000000000000000000000000000000000000000000000000000000010cd0e30db0a9059cbb000000000000000000000000ed9e3f98bbed560e66b89aac922e29d4596a964200000000000000000000000000000000000000000000000000038b38ea9207007dc2038200000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000038b38ea9207000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee57000000000000000000000000d5b927956057075377263aab7f8afc12f85100db00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000048000000000000000000000000000000000000000000000000000000000000010c000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000038b38ea920700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: paraSwapV5RouterArbitrum, + fromToken: address(0), + fromAmount: fromAmount, + toToken: usdcTokenArbitrum, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); + } + + ////////////////////////////////////////////////////////// + ////////////////// Utils ///////////////////////// + ////////////////////////////////////////////////////////// + + function formatUnits(uint256 amount, uint256 decimals) public pure returns (uint256) { + return amount * 10 ** decimals; + } + + function _callTestWithRouter(IDexSwap.SwapData[] memory swapData, address proxy) internal { + console.log("block.number", block.number); + console.log("fromAmount: ", swapData[0].fromAmount); + console.log("toAmount: ", swapData[0].toAmount); + console.log("toAmountMin: ", swapData[0].toAmountMin); + + InfraOrchestrator orchestrator = InfraOrchestrator(payable(proxy)); + + IInfraOrchestrator.Integration memory integration = IInfraOrchestrator.Integration({ + integrator: integrator, + feeBps: 0 + }); + bool isFromNative = swapData[0].fromToken == address(0); + bool isToNative = swapData[0].toToken == address(0); + + uint256 userBalanceFromTokenBefore; + uint256 userBalanceFromTokenAfter; + uint256 userBalanceToTokenBefore; + uint256 userBalanceToTokenAfter; + + if (isFromNative && !isToNative) { + deal(sender, swapData[0].fromAmount); + + userBalanceFromTokenBefore = sender.balance; + userBalanceToTokenBefore = IERC20(swapData[0].toToken).balanceOf(sender); + + vm.prank(sender); + orchestrator.swap{value: swapData[0].fromAmount}(swapData, sender, integration); + + userBalanceFromTokenAfter = sender.balance; + userBalanceToTokenAfter = IERC20(swapData[0].toToken).balanceOf(sender); + } else if (isToNative && !isFromNative) { + _dealERC20AndApprove(swapData[0].fromToken, sender, swapData[0].fromAmount, proxy); + + userBalanceFromTokenBefore = IERC20(swapData[0].fromToken).balanceOf(sender); + userBalanceToTokenBefore = sender.balance; + + vm.prank(sender); + orchestrator.swap(swapData, sender, integration); + + userBalanceFromTokenAfter = IERC20(swapData[0].fromToken).balanceOf(sender); + userBalanceToTokenAfter = sender.balance; + } else if (!isFromNative && !isToNative) { + _dealERC20AndApprove(swapData[0].fromToken, sender, swapData[0].fromAmount, proxy); + + userBalanceFromTokenBefore = IERC20(swapData[0].fromToken).balanceOf(sender); + userBalanceToTokenBefore = IERC20(swapData[0].toToken).balanceOf(sender); + + vm.prank(sender); + orchestrator.swap(swapData, sender, integration); + + userBalanceFromTokenAfter = IERC20(swapData[0].fromToken).balanceOf(sender); + userBalanceToTokenAfter = IERC20(swapData[0].toToken).balanceOf(sender); + } + + console.log("userBalanceFromTokenBefore: ", userBalanceFromTokenBefore); + console.log("userBalanceFromTokenAfter: ", userBalanceFromTokenAfter); + console.log("userBalanceToTokenBefore: ", userBalanceToTokenBefore); + console.log("userBalanceToTokenAfter: ", userBalanceToTokenAfter); + + assertGt(userBalanceToTokenAfter, userBalanceToTokenBefore); + assertLt(userBalanceFromTokenAfter, userBalanceFromTokenBefore); + } + + function _allowRouter(address router, address orchestratorProxy) internal { + vm.prank(deployer); + (bool success, ) = address(orchestratorProxy).call( + abi.encodeWithSignature("setDexRouterAddress(address,bool)", router, true) + ); + /// @dev assert it is set correctly + (, bytes memory returnData) = address(orchestratorProxy).call( + abi.encodeWithSignature("s_routerAllowed(address)", router) + ); + bool returnedValue = abi.decode(returnData, (bool)); + assertEq(returnedValue, true); + } + + function _dealERC20AndApprove( + address token, + address _caller, + uint256 _amount, + address proxy + ) internal { + deal(token, _caller, _amount); + vm.prank(_caller); + IERC20(token).approve(proxy, _amount); + } +} From f654b9af25d05ba702a429ed907beb1d5b9c8eb7 Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Fri, 22 Nov 2024 01:14:27 +0300 Subject: [PATCH 12/54] delete useless checks and calls --- contracts/DexSwap.sol | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/contracts/DexSwap.sol b/contracts/DexSwap.sol index 8a941537..eab264c0 100644 --- a/contracts/DexSwap.sol +++ b/contracts/DexSwap.sol @@ -69,9 +69,10 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { uint256 swapDataLength = _swapData.length; address dstToken = _swapData[swapDataLength - 1].toToken; - uint256 dstTokenBalanceBefore = LibConcero.getBalance(dstToken, address(this)); + uint256 recipientBalanceBefore = LibConcero.getBalance(dstToken, _recipient); for (uint256 i; i < swapDataLength; ) { + //seems to be useless uint256 preSwapBalance = LibConcero.getBalance(_swapData[i].toToken, address(this)); _performSwap(_swapData[i]); @@ -80,6 +81,7 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { if (_swapData[i].toToken != _swapData[i + 1].fromToken) { revert InvalidTokenPath(); } + //seems to be useless uint256 postSwapBalance = LibConcero.getBalance( _swapData[i].toToken, address(this) @@ -98,44 +100,37 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { } } - //TODO: optimise this line in the future - uint256 tokenAmountReceived = LibConcero.getBalance(dstToken, address(this)) - - dstTokenBalanceBefore; - - // if dstToken is native, send native - if (dstToken == address(0)) { - (bool sent, ) = _recipient.call{value: tokenAmountReceived}(""); - if (!sent) revert TransferFailed(); - } else { - IERC20(dstToken).safeTransfer(_recipient, tokenAmountReceived); - } + uint256 recipientBalanceAfter = LibConcero.getBalance(dstToken, _recipient); + uint256 dstTokenRecieved = recipientBalanceAfter - recipientBalanceBefore; emit ConceroSwap( _swapData[0].fromToken, - _swapData[swapDataLength - 1].toToken, + dstToken, _swapData[0].fromAmount, - tokenAmountReceived, + dstTokenRecieved, _recipient ); - return tokenAmountReceived; + return dstTokenRecieved; } function _performSwap(IDexSwap.SwapData memory _swapData) private { if (_swapData.dexData.length == 0) revert EmptyDexData(); address routerAddress = _swapData.dexRouter; - uint256 fromAmount = _swapData.fromAmount; - if (!s_routerAllowed[routerAddress]) revert DexRouterNotAllowed(); + + uint256 fromAmount = _swapData.fromAmount; bool isFromNative = _swapData.fromToken == address(0); - if (!isFromNative) { + bool success; + if (isFromNative) { + (success, ) = routerAddress.call{value: fromAmount}(_swapData.dexData); + } else { IERC20(_swapData.fromToken).safeIncreaseAllowance(routerAddress, fromAmount); - fromAmount = 0; + (success, ) = routerAddress.call(_swapData.dexData); } - (bool success, ) = routerAddress.call{value: fromAmount}(_swapData.dexData); if (!success) revert InvalidDexData(); } From aa5cbe600a6046b4413b5e0793c83a2efa946412 Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Fri, 22 Nov 2024 15:05:45 +0300 Subject: [PATCH 13/54] add new tokens --- .env.tokens | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.env.tokens b/.env.tokens index 5fe8a772..361a5295 100644 --- a/.env.tokens +++ b/.env.tokens @@ -41,6 +41,10 @@ USDT_ARBITRUM=0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9 # WETH MAINNET WETH_BASE=0x4200000000000000000000000000000000000006 WETH_ARBITRUM=0x82aF49447D8a07e3bd95BD0d56f35241523fBab1 +WETH_POLYGON=0x7ceb23fd6bc0add59e62ac25578270cff1b9f619 + +# WAVAX MAINNET +WAVAX_AVALANCHE=0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7 # DAI MAINNET DAI_BASE=0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb From 5d420398413c1e1f89b8818ea09f06e5a690edf0 Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Fri, 22 Nov 2024 15:06:06 +0300 Subject: [PATCH 14/54] add avalanche fork --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 09e05d55..625bfa75 100644 --- a/Makefile +++ b/Makefile @@ -38,6 +38,9 @@ run_arb_fork: run_polygon_fork: anvil --fork-url ${POLYGON_RPC_URL} -p ${POLYGON_LOCAL_FORK_PORT} $(args) +run_avalanche_fork: + anvil --fork-url ${AVALANCHE_RPC_URL} -p ${AVALANCHE_LOCAL_FORK_PORT} $(args) + test: forge test $(args) From f25392e8149c0fcb3a61fdcf7d4dcee890c1826b Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Fri, 22 Nov 2024 15:27:06 +0300 Subject: [PATCH 15/54] add polygon & avalanche tests --- test/foundry/Swap/DexSwap.t.sol | 327 ++++++++++++++++++++++++-------- 1 file changed, 244 insertions(+), 83 deletions(-) diff --git a/test/foundry/Swap/DexSwap.t.sol b/test/foundry/Swap/DexSwap.t.sol index 7848c639..e8f7da89 100644 --- a/test/foundry/Swap/DexSwap.t.sol +++ b/test/foundry/Swap/DexSwap.t.sol @@ -9,8 +9,8 @@ import {IInfraOrchestrator} from "../../../contracts/Interfaces/IInfraOrchestrat import {InfraOrchestrator} from "../../../contracts/InfraOrchestrator.sol"; contract DexSwapTest is BaseTest { - uint256 internal constant WETH_DECIMALS = 18; address internal constant ETH_TOKEN = address(0); + address internal constant POL_TOKEN = address(0); // Base tokens address internal usdcTokenBase = vm.envAddress("USDC_BASE"); @@ -24,6 +24,14 @@ contract DexSwapTest is BaseTest { address internal usdtTokenArbitrum = vm.envAddress("USDT_ARBITRUM"); address internal wethTokenArbitrum = vm.envAddress("WETH_ARBITRUM"); + //Polygon tokens + address internal usdcTokenPolygon = vm.envAddress("USDC_POLYGON"); + address internal wethTokenPolygon = vm.envAddress("WETH_POLYGON"); + + //Avalanche tokens + address internal usdcTokenAvalanche = vm.envAddress("USDC_AVALANCHE"); + address internal wavaxTokenAvalanche = vm.envAddress("WAVAX_AVALANCHE"); + //Arbitrum Routers address internal sushiRouterArbitrum = vm.envAddress("SUSHISWAP_ROUTER_ARBITRUM_ADDRESS"); address internal uniV3RouterArbitrum = vm.envAddress("UNI_V3_ROUTER_ARBITRUM_ADDRESS"); @@ -38,19 +46,21 @@ contract DexSwapTest is BaseTest { address internal curveRouterBase = vm.envAddress("CURVE_ROUTER_BASE_ADDRESS"); address internal alienbaseRouterBase = vm.envAddress("ALIENBASE_ROUTER_BASE_ADDRESS"); + //Polygon Routers + address internal quickSwapRouterPolygon = vm.envAddress("QUICKSWAP_ROUTER_POLYGON_ADDRESS"); + + //Avalanche Routers + address internal pangolinRouterAvalanche = vm.envAddress("PANGOLIN_ROUTER_AVALANCHE_ADDRESS"); + address payable internal sender = payable(makeAddr("sender")); - address internal recipient = makeAddr("recipient"); address internal integrator = makeAddr("integrator"); - uint256 internal constant USDC_INITIAL_BALANCE = 10 * USDC_DECIMALS; - uint256 internal constant ETH_INITIAL_BALANCE = 0.01 ether; - - modifier addRouterInWL(address router, address proxy) { + modifier addRouterInWhiteList(address router, address proxy) { _allowRouter(router, address(proxy)); _; } - function setUp() public override setFork(arbitrumAnvilForkId) { + function setUp() public override setFork(polygonAnvilForkId) { super.setUp(); } @@ -62,9 +72,11 @@ contract DexSwapTest is BaseTest { ////////////////////////////////////////////////////////// //passed - function test_dexSwapAlienbaseRouterETHToUSDCBase() public setFork(baseAnvilForkId) { - _allowRouter(alienbaseRouterBase, address(baseOrchestratorProxy)); - + function test_dexSwapAlienbaseRouterETHToUSDCBase() + public + setFork(baseAnvilForkId) + addRouterInWhiteList(alienbaseRouterBase, address(baseOrchestratorProxy)) + { uint256 fromAmount = 0.1 ether; uint256 toAmount = 267.528449e6; uint256 toAmountMin = 266.190806e6; @@ -87,10 +99,12 @@ contract DexSwapTest is BaseTest { } //passed - function test_dexSwapAlienbaseRouterUSDCToWETHBase() public setFork(baseAnvilForkId) { - _allowRouter(alienbaseRouterBase, address(baseOrchestratorProxy)); - - uint256 fromAmount = 10e6; //1 usdc + function test_dexSwapAlienbaseRouterUSDCToWETHBase() + public + setFork(baseAnvilForkId) + addRouterInWhiteList(alienbaseRouterBase, address(baseOrchestratorProxy)) + { + uint256 fromAmount = 10e6; //10 usdc uint256 toAmount = 0.002945698049459263e18; uint256 toAmountMin = 0.002930969559211966e18; @@ -112,9 +126,11 @@ contract DexSwapTest is BaseTest { } //passed - function test_dexSwapAlienbaseRouterUSDCToETHBase() public setFork(baseAnvilForkId) { - _allowRouter(alienbaseRouterBase, address(baseOrchestratorProxy)); - + function test_dexSwapAlienbaseRouterUSDCToETHBase() + public + setFork(baseAnvilForkId) + addRouterInWhiteList(alienbaseRouterBase, address(baseOrchestratorProxy)) + { uint256 fromAmount = 10e6; uint256 toAmount = 0.002945698049459263 ether; uint256 toAmountMin = 0.002930969559211966 ether; @@ -141,9 +157,11 @@ contract DexSwapTest is BaseTest { ////////////////////////////////////////////////////////// //passed - function test_dexSwapCurveRouterUSDCToWETHBase() public setFork(baseAnvilForkId) { - _allowRouter(curveRouterBase, address(baseOrchestratorProxy)); - + function test_dexSwapCurveRouterUSDCToWETHBase() + public + setFork(baseAnvilForkId) + addRouterInWhiteList(curveRouterBase, address(baseOrchestratorProxy)) + { uint256 fromAmount = 10e6; //1 usdc uint256 toAmount = 0.002950528095025959e18; uint256 toAmountMin = 0.002935775454550829e18; @@ -166,9 +184,11 @@ contract DexSwapTest is BaseTest { } //not working - function test_dexSwapCurveRouterETHToUSDCBase() public setFork(baseAnvilForkId) { - _allowRouter(curveRouterBase, address(baseOrchestratorProxy)); - + function test_dexSwapCurveRouterETHToUSDCBase() + public + setFork(baseAnvilForkId) + addRouterInWhiteList(curveRouterBase, address(baseOrchestratorProxy)) + { uint256 fromAmount = 0.0003 ether; uint256 toAmount = 0.993336e6; uint256 toAmountMin = 0.988369e6; @@ -191,10 +211,11 @@ contract DexSwapTest is BaseTest { } //passed - function test_dexSwapCurveRouterUSDCToETHBase() public setFork(baseAnvilForkId) { - _allowRouter(curveRouterBase, address(baseOrchestratorProxy)); - address vyperEth = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; - + function test_dexSwapCurveRouterUSDCToETHBase() + public + setFork(baseAnvilForkId) + addRouterInWhiteList(curveRouterBase, address(baseOrchestratorProxy)) + { uint256 fromAmount = 1e6; uint256 toAmount = 0.00029502055232845 ether; uint256 toAmountMin = 0.000293545449566807 ether; @@ -221,9 +242,11 @@ contract DexSwapTest is BaseTest { ////////////////////////////////////////////////////////// //passed - function test_dexSwapOdosRouterV2USDCToWETHBase() public setFork(baseAnvilForkId) { - _allowRouter(odosRouterV2Base, address(baseOrchestratorProxy)); - + function test_dexSwapOdosRouterV2USDCToWETHBase() + public + setFork(baseAnvilForkId) + addRouterInWhiteList(odosRouterV2Base, address(baseOrchestratorProxy)) + { uint256 fromAmount = 1e6; //1 usdc uint256 toAmount = 0.000295473686245412e18; uint256 toAmountMin = 0.000293996317814184e18; @@ -245,10 +268,12 @@ contract DexSwapTest is BaseTest { _callTestWithRouter(swapData, address(baseOrchestratorProxy)); } - //dont work with native - function test_dexSwapOdosRouterV2ETHToUSDCBase() public setFork(baseAnvilForkId) { - _allowRouter(odosRouterV2Base, address(baseOrchestratorProxy)); - + //doesnt work with native + function test_dexSwapOdosRouterV2ETHToUSDCBase() + public + setFork(baseAnvilForkId) + addRouterInWhiteList(odosRouterV2Base, address(baseOrchestratorProxy)) + { uint256 fromAmount = 0.001 ether; uint256 toAmount = 3.355603e6; uint256 toAmountMin = 3.338824e6; @@ -274,9 +299,11 @@ contract DexSwapTest is BaseTest { ////////////////// 1Inch //////////////////////// ////////////////////////////////////////////////////////// - function test_dexSwap1InchV5USDCTo1InchTokenBase() public setFork(baseAnvilForkId) { - _allowRouter(oneInchRouterV5Base, address(baseOrchestratorProxy)); - + function test_dexSwap1InchV5USDCTo1InchTokenBase() + public + setFork(baseAnvilForkId) + addRouterInWhiteList(oneInchRouterV5Base, address(baseOrchestratorProxy)) + { uint256 fromAmount = 10e6; //10 usdc uint256 toAmount = 29.186618652079786377e18; uint256 toAmountMin = 29.040685558819387445e18; @@ -306,9 +333,11 @@ contract DexSwapTest is BaseTest { ////////////////////////////////////////////////////////// //passed - function test_dexSwapSushiSwapRouterUSDCToUSDT() public setFork(arbitrumAnvilForkId) { - _allowRouter(sushiRouterArbitrum, address(arbitrumOrchestratorProxy)); - + function test_dexSwapSushiSwapRouterUSDCToUSDT() + public + setFork(arbitrumAnvilForkId) + addRouterInWhiteList(sushiRouterArbitrum, address(arbitrumOrchestratorProxy)) + { uint256 fromAmount = 1e6; //1 usdc uint256 toAmount = 0.993041e6; uint256 toAmountMin = 0.988075e6; @@ -331,12 +360,14 @@ contract DexSwapTest is BaseTest { } //passed - function test_dexSwapSushiSwapRouterUSDCToWETH() public setFork(arbitrumAnvilForkId) { - _allowRouter(sushiRouterArbitrum, address(arbitrumOrchestratorProxy)); - + function test_dexSwapSushiSwapRouterUSDCToWETH() + public + setFork(arbitrumAnvilForkId) + addRouterInWhiteList(sushiRouterArbitrum, address(arbitrumOrchestratorProxy)) + { uint256 fromAmount = 1e6; //1 usdc - uint256 toAmount = 0.00029991786617675 ether; - uint256 toAmountMin = 0.000298418276845866 ether; + uint256 toAmount = 0.00029991786617675e18; + uint256 toAmountMin = 0.000298418276845866e18; bytes memory dexData = hex"38ed173900000000000000000000000000000000000000000000000000000000000f381a00000000000000000000000000000000000000000000000000010f68f44ac36b00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673f697d0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1"; @@ -356,10 +387,11 @@ contract DexSwapTest is BaseTest { } //passed - function test_dexSwapSushiSwapRouterUSDCToETH() public setFork(arbitrumAnvilForkId) { - _allowRouter(sushiRouterArbitrum, address(arbitrumOrchestratorProxy)); - - //only for block number of 21234930 + function test_dexSwapSushiSwapRouterUSDCToETH() + public + setFork(arbitrumAnvilForkId) + addRouterInWhiteList(sushiRouterArbitrum, address(arbitrumOrchestratorProxy)) + { uint256 fromAmount = 1e6; //usdc uint256 toAmount = 0.00029991786617675 ether; uint256 toAmountMin = 0.000298418276845866 ether; @@ -382,10 +414,11 @@ contract DexSwapTest is BaseTest { } //passed - function test_dexSwapSushiSwapRouterETHToUSDC() public setFork(arbitrumAnvilForkId) { - _allowRouter(sushiRouterArbitrum, address(arbitrumOrchestratorProxy)); - - //only for block number of 21234930 + function test_dexSwapSushiSwapRouterETHToUSDC() + public + setFork(arbitrumAnvilForkId) + addRouterInWhiteList(sushiRouterArbitrum, address(arbitrumOrchestratorProxy)) + { uint256 fromAmount = 0.0001 ether; //ETH uint256 toAmount = 0.33059e6; //usdc uint256 toAmountMin = 0.328937e6; //usdc @@ -412,9 +445,11 @@ contract DexSwapTest is BaseTest { ////////////////////////////////////////////////////////// //passed - function test_dexSwapUniSwapRouterUSDCToUSDT() public setFork(arbitrumAnvilForkId) { - _allowRouter(uniV3RouterArbitrum, address(arbitrumOrchestratorProxy)); - + function test_dexSwapUniSwapRouterUSDCToUSDT() + public + setFork(arbitrumAnvilForkId) + addRouterInWhiteList(uniV3RouterArbitrum, address(arbitrumOrchestratorProxy)) + { uint256 fromAmount = 1e6; //1 usdc uint256 toAmount = 0.996903e6; uint256 toAmountMin = 0.991918e6; @@ -437,12 +472,14 @@ contract DexSwapTest is BaseTest { } //passed - function test_dexSwapUniSwapRouterUSDCToWETH() public setFork(arbitrumAnvilForkId) { - _allowRouter(uniV3RouterArbitrum, address(arbitrumOrchestratorProxy)); - + function test_dexSwapUniSwapRouterUSDCToWETH() + public + setFork(arbitrumAnvilForkId) + addRouterInWhiteList(uniV3RouterArbitrum, address(arbitrumOrchestratorProxy)) + { uint256 fromAmount = 1e6; //1 usdc - uint256 toAmount = 0.000299377182115898 ether; - uint256 toAmountMin = 0.000297880296205318 ether; + uint256 toAmount = 0.000299377182115898e18; + uint256 toAmountMin = 0.000297880296205318e18; bytes memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681000000000000000000000000000000000000000000000000000001934fbd59aa00000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010eebbb0ca1e0000000000000000000000000000000000000000000000000000000000000002baf88d065e77c8cc2239327c5edb3a432268e58310001f482af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; @@ -462,10 +499,11 @@ contract DexSwapTest is BaseTest { } //passed - function test_dexSwapUniSwapRouterUSDCToETH() public setFork(arbitrumAnvilForkId) { - _allowRouter(uniV3RouterArbitrum, address(arbitrumOrchestratorProxy)); - - //only for block number of + function test_dexSwapUniSwapRouterUSDCToETH() + public + setFork(arbitrumAnvilForkId) + addRouterInWhiteList(uniV3RouterArbitrum, address(arbitrumOrchestratorProxy)) + { uint256 fromAmount = 1e6; //usdc uint256 toAmount = 0.000300419724797236 ether; uint256 toAmountMin = 0.000298917626173249 ether; @@ -488,10 +526,11 @@ contract DexSwapTest is BaseTest { } //passed - function test_dexSwapUniSwapRouterETHToUSDC() public setFork(arbitrumAnvilForkId) { - _allowRouter(uniV3RouterArbitrum, address(arbitrumOrchestratorProxy)); - - //only for block number of 21234930 + function test_dexSwapUniSwapRouterETHToUSDC() + public + setFork(arbitrumAnvilForkId) + addRouterInWhiteList(uniV3RouterArbitrum, address(arbitrumOrchestratorProxy)) + { uint256 fromAmount = 0.0001 ether; //ETH uint256 toAmount = 0.331996e6; //usdc uint256 toAmountMin = 0.330336e6; //usdc @@ -518,9 +557,11 @@ contract DexSwapTest is BaseTest { ////////////////////////////////////////////////////////// //does not work - function test_dexSwapParaSwapRouterUSDCToUSDT() public setFork(arbitrumAnvilForkId) { - _allowRouter(paraSwapV5RouterArbitrum, address(arbitrumOrchestratorProxy)); - + function test_dexSwapParaSwapRouterUSDCToUSDT() + public + setFork(arbitrumAnvilForkId) + addRouterInWhiteList(paraSwapV5RouterArbitrum, address(arbitrumOrchestratorProxy)) + { uint256 fromAmount = 1e6; //1 usdc uint256 toAmount = 0.996903e6; uint256 toAmountMin = 0.991918e6; @@ -568,10 +609,11 @@ contract DexSwapTest is BaseTest { } //does not work - function test_dexSwapParaSwapRouterUSDCToETH() public setFork(arbitrumAnvilForkId) { - _allowRouter(paraSwapV5RouterArbitrum, address(arbitrumOrchestratorProxy)); - - //only for block number of + function test_dexSwapParaSwapRouterUSDCToETH() + public + setFork(arbitrumAnvilForkId) + addRouterInWhiteList(paraSwapV5RouterArbitrum, address(arbitrumOrchestratorProxy)) + { uint256 fromAmount = 1e6; //usdc uint256 toAmount = 0.000300419724797236 ether; uint256 toAmountMin = 0.000298917626173249 ether; @@ -594,10 +636,11 @@ contract DexSwapTest is BaseTest { } //does not work - function test_dexSwapParaSwapRouterETHToUSDC() public setFork(arbitrumAnvilForkId) { - _allowRouter(paraSwapV5RouterArbitrum, address(arbitrumOrchestratorProxy)); - - //only for block number of 21234930 + function test_dexSwapParaSwapRouterETHToUSDC() + public + setFork(arbitrumAnvilForkId) + addRouterInWhiteList(paraSwapV5RouterArbitrum, address(arbitrumOrchestratorProxy)) + { uint256 fromAmount = 0.001 ether; //ETH uint256 toAmount = 3.334998e6; //usdc uint256 toAmountMin = 3.318323e6; //usdc @@ -619,14 +662,132 @@ contract DexSwapTest is BaseTest { _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); } + //////////////////// Polygon //////////////////////////// + //////////////////// Block number 64588691 ////////////// + ////////////////////////////////////////////////////////// - ////////////////// Utils ///////////////////////// + ////////////////// Quick Swap //////////////////// + ////////////////////////////////////////////////////////// + + //passed + function test_dexSwapQuickSwapRouterUSDCToWETH() + public + setFork(polygonAnvilForkId) + addRouterInWhiteList(quickSwapRouterPolygon, address(polygonOrchestratorProxy)) + { + uint256 fromAmount = 1e6; //1 usdc + uint256 toAmount = 0.000294773721275645e18; + uint256 toAmountMin = 0.000293299852669266e18; + + bytes + memory dexData = hex"38ed173900000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010ac13a4b12cf00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681000000000000000000000000000000000000000000000000000000006740511a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c33590000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f619"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: quickSwapRouterPolygon, + fromToken: usdcTokenPolygon, + fromAmount: fromAmount, + toToken: wethTokenPolygon, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _callTestWithRouter(swapData, address(polygonOrchestratorProxy)); + } + + //passed + function test_dexSwapQuickSwapRouterPOLToUSDC() + public + setFork(polygonAnvilForkId) + addRouterInWhiteList(quickSwapRouterPolygon, address(polygonOrchestratorProxy)) + { + uint256 fromAmount = 0.001e18; //POL + uint256 toAmount = 0.000457e6; //usdc + uint256 toAmountMin = 0.000454e6; //usdc + + bytes + memory dexData = hex"7ff36ab500000000000000000000000000000000000000000000000000000000000001c70000000000000000000000000000000000000000000000000000000000000080000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000674056ac00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf12700000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c3359"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: quickSwapRouterPolygon, + fromToken: POL_TOKEN, + fromAmount: fromAmount, + toToken: usdcTokenPolygon, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _callTestWithRouter(swapData, address(polygonOrchestratorProxy)); + } + + //passed + function test_dexSwapQuickSwapRouterUSDCToPOL() + public + setFork(polygonAnvilForkId) + addRouterInWhiteList(quickSwapRouterPolygon, address(polygonOrchestratorProxy)) + { + uint256 fromAmount = 1e6; //usdc + uint256 toAmount = 2.16620982591814043e18; //pol + uint256 toAmountMin = 2.155378776788549727e18; //pol + + bytes + memory dexData = hex"18cbafe500000000000000000000000000000000000000000000000000000000000f387e0000000000000000000000000000000000000000000000001de9728f133bb56100000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000674057b000000000000000000000000000000000000000000000000000000000000000020000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c33590000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf1270"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: quickSwapRouterPolygon, + fromToken: usdcTokenPolygon, + fromAmount: fromAmount, + toToken: POL_TOKEN, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _callTestWithRouter(swapData, address(polygonOrchestratorProxy)); + } + + //////////////////// Avalanche //////////////////////////// + //////////////////// Block number 53397798 ////////////// + + ////////////////////////////////////////////////////////// + ////////////////// Pangolin Swap ///////////////// ////////////////////////////////////////////////////////// - function formatUnits(uint256 amount, uint256 decimals) public pure returns (uint256) { - return amount * 10 ** decimals; + //doesnt work + function test_dexSwapPangolinSwapRouterUSDCToWAVAX() + public + setFork(avalancheAnvilForkId) + addRouterInWhiteList(pangolinRouterAvalanche, address(avalancheOrchestratorProxy)) + { + uint256 fromAmount = 1e6; //1 usdc + uint256 toAmount = 0.027249956050478939e18; + uint256 toAmountMin = 0.027113706270226544e18; + + bytes + memory dexData = hex"38ed173900000000000000000000000000000000000000000000000000000000000f387e000000000000000000000000000000000000000000000000006053c8d8cb68b600000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000674060d40000000000000000000000000000000000000000000000000000000000000003000000000000000000000000b97ef9ef8734c71904d8002f8b6bc66dd9c48a6e00000000000000000000000060781c2586d68229fde47564546784ab3faca982000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c7"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: pangolinRouterAvalanche, + fromToken: usdcTokenAvalanche, + fromAmount: fromAmount, + toToken: wavaxTokenAvalanche, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _callTestWithRouter(swapData, address(avalancheOrchestratorProxy)); } + ////////////////////////////////////////////////////////// + ////////////////// Utils ///////////////////////// + ////////////////////////////////////////////////////////// + function _callTestWithRouter(IDexSwap.SwapData[] memory swapData, address proxy) internal { console.log("block.number", block.number); console.log("fromAmount: ", swapData[0].fromAmount); From eb1b1543de64be2e657969d167df8a860ccb636d Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Fri, 22 Nov 2024 15:42:50 +0300 Subject: [PATCH 16/54] add forks and funcs for them --- test/foundry/utils/BaseTest.t.sol | 254 +++++++++++++++++++++++++++--- 1 file changed, 234 insertions(+), 20 deletions(-) diff --git a/test/foundry/utils/BaseTest.t.sol b/test/foundry/utils/BaseTest.t.sol index e472f63d..417c8af6 100644 --- a/test/foundry/utils/BaseTest.t.sol +++ b/test/foundry/utils/BaseTest.t.sol @@ -19,6 +19,7 @@ import {InfraOrchestrator} from "contracts/InfraOrchestrator.sol"; import {IInfraStorage} from "contracts/Interfaces/IInfraStorage.sol"; //import {IOwner} from "@chainlink/contracts-ccip/src/v0.8/ccip/interfaces/IOwner.sol"; import {DexSwap} from "contracts/DexSwap.sol"; +import {PauseDummy} from "contracts/PauseDummy.sol"; contract BaseTest is Test { /*////////////////////////////////////////////////////////////// @@ -27,12 +28,18 @@ contract BaseTest is Test { uint256 internal constant LINK_INIT_BALANCE = 100 * 1e18; uint256 internal constant USDC_DECIMALS = 1e6; uint256 internal constant PARENT_POOL_CAP = 100_000_000 * USDC_DECIMALS; + uint256 internal constant ARBITRUM_ANVIL_FORK_BLOCK_NUMBER = 21234930; ParentPoolCLFCLA public parentPoolCLFCLA; ParentPool public parentPoolImplementation; TransparentUpgradeableProxy public parentPoolProxy; LPToken public lpToken; - DexSwap public dexSwap; + + DexSwap public baseDexSwap; + DexSwap public arbitrumDexSwap; + DexSwap public polygonDexSwap; + DexSwap public avalancheDexSwap; + FunctionsSubscriptions public functionsSubscriptions; // CCIPLocalSimulator public ccipLocalSimulator; // CCIPLocalSimulatorFork public ccipLocalSimulatorFork; @@ -44,6 +51,12 @@ contract BaseTest is Test { address internal deployer = vm.envAddress("FORGE_DEPLOYER_ADDRESS"); address internal proxyDeployer = vm.envAddress("FORGE_PROXY_DEPLOYER_ADDRESS"); uint256 internal baseAnvilForkId = vm.createFork(vm.envString("LOCAL_BASE_FORK_RPC_URL")); + uint256 internal arbitrumAnvilForkId = + vm.createFork(vm.envString("LOCAL_ARBITRUM_FORK_RPC_URL"), 276843772); + uint256 internal polygonAnvilForkId = + vm.createFork(vm.envString("LOCAL_POLYGON_FORK_RPC_URL"), 64588691); + uint256 internal avalancheAnvilForkId = + vm.createFork(vm.envString("LOCAL_AVALANCHE_FORK_RPC_URL"), 53397798); uint64 internal baseChainSelector = uint64(vm.envUint("CL_CCIP_CHAIN_SELECTOR_BASE")); uint64 internal optimismChainSelector = uint64(vm.envUint("CL_CCIP_CHAIN_SELECTOR_OPTIMISM")); @@ -58,11 +71,26 @@ contract BaseTest is Test { ConceroBridge internal baseBridgeImplementation; ConceroBridge internal arbitrumBridgeImplementation; ConceroBridge internal avalancheBridgeImplementation; + ConceroBridge internal polygonBridgeImplementation; TransparentUpgradeableProxy internal baseOrchestratorProxy; + TransparentUpgradeableProxy internal arbitrumOrchestratorProxy; + TransparentUpgradeableProxy internal polygonOrchestratorProxy; + TransparentUpgradeableProxy internal avalancheOrchestratorProxy; + InfraOrchestrator internal baseOrchestratorImplementation; - address internal arbitrumOrchestratorProxy = address(1); - address internal avalancheOrchestratorProxy = address(2); + InfraOrchestrator internal arbitrumOrchestratorImplementation; + InfraOrchestrator internal polygonOrchestratorImplementation; + InfraOrchestrator internal avalancheOrchestratorImplementation; + + /*////////////////////////////////////////////////////////////// + MODIFIERS + //////////////////////////////////////////////////////////////*/ + modifier setFork(uint256 forkId) { + vm.selectFork(forkId); + _; + //vm.selectFork(baseAnvilForkId); + } /*////////////////////////////////////////////////////////////// SETUP @@ -71,20 +99,24 @@ contract BaseTest is Test { vm.selectFork(baseAnvilForkId); _deployOrchestratorProxy(); - deployInfra(); - deployPoolsInfra(); - _deployOrchestratorImplementation(); - - _setProxyImplementation( - address(baseOrchestratorProxy), - address(baseOrchestratorImplementation) - ); - - _setDstInfraContractsForInfra( - address(baseOrchestratorProxy), - arbitrumChainSelector, - arbitrumOrchestratorProxy - ); + deployArbitrumInfra(); + deployBaseInfra(); + deployPolygonInfra(); + deployAvalancheInfra(); + + //deployPoolsInfra(); + //_deployOrchestratorImplementation(); + + // _setProxyImplementation( + // address(baseOrchestratorProxy), + // address(baseOrchestratorImplementation) + // ); + + // _setDstInfraContractsForInfra( + // address(baseOrchestratorProxy), + // arbitrumChainSelector, + // arbitrumOrchestratorProxy + // ); } function deployPoolsInfra() public { @@ -105,6 +137,50 @@ contract BaseTest is Test { addFunctionsConsumer(address(baseOrchestratorProxy)); } + function deployArbitrumInfra() public setFork(arbitrumAnvilForkId) { + _deployOrchestratorProxyArbitrum(); + _deployDexSwapArbitrum(); + _deployOrchestratorImplementationArbitrum(); + + _setProxyImplementation( + address(arbitrumOrchestratorProxy), + address(arbitrumOrchestratorImplementation) + ); + } + + function deployBaseInfra() public setFork(baseAnvilForkId) { + _deployOrchestratorProxyBase(); + _deployDexSwapBase(); + _deployOrchestratorImplementationBase(); + + _setProxyImplementation( + address(baseOrchestratorProxy), + address(baseOrchestratorImplementation) + ); + } + + function deployPolygonInfra() public setFork(polygonAnvilForkId) { + _deployOrchestratorProxyPolygon(); + _deployDexSwapPolygon(); + _deployOrchestratorImplementationPolygon(); + + _setProxyImplementation( + address(polygonOrchestratorProxy), + address(polygonOrchestratorImplementation) + ); + } + + function deployAvalancheInfra() public setFork(avalancheAnvilForkId) { + _deployOrchestratorProxyAvalanche(); + _deployDexSwapAvalanche(); + _deployOrchestratorImplementationAvalanche(); + + _setProxyImplementation( + address(avalancheOrchestratorProxy), + address(avalancheOrchestratorImplementation) + ); + } + /*////////////////////////////////////////////////////////////// DEPLOYMENTS //////////////////////////////////////////////////////////////*/ @@ -422,7 +498,7 @@ contract BaseTest is Test { address ccipRouter = vm.envAddress("CL_CCIP_ROUTER_ARBITRUM"); address dexswap = vm.envAddress("CONCERO_DEX_SWAP_ARBITRUM"); address pool = address(parentPoolProxy); - address proxy = address(0); // arbitrumOrchestratorProxy + address proxy = address(arbitrumOrchestratorProxy); //address(0); // arbitrumOrchestratorProxy address[3] memory messengers = [ vm.envAddress("POOL_MESSENGER_0_ADDRESS"), address(0), @@ -488,6 +564,66 @@ contract BaseTest is Test { vm.stopPrank(); } + function _deployOrchestratorProxyArbitrum() internal { + vm.prank(proxyDeployer); + address pauseContract = vm.envAddress("CONCERO_PAUSE_ARBITRUM"); + if (pauseContract.code.length == 0) { + pauseContract = address(new PauseDummy()); + } + + arbitrumOrchestratorProxy = new TransparentUpgradeableProxy( + pauseContract, + proxyDeployer, + bytes("") + ); + vm.stopPrank(); + } + + function _deployOrchestratorProxyBase() internal { + vm.prank(proxyDeployer); + address pauseContract = vm.envAddress("CONCERO_PAUSE_BASE"); + if (pauseContract.code.length == 0) { + pauseContract = address(new PauseDummy()); + } + + baseOrchestratorProxy = new TransparentUpgradeableProxy( + pauseContract, + proxyDeployer, + bytes("") + ); + vm.stopPrank(); + } + + function _deployOrchestratorProxyPolygon() internal { + vm.prank(proxyDeployer); + address pauseContract = vm.envAddress("CONCERO_PAUSE_POLYGON"); + if (pauseContract.code.length == 0) { + pauseContract = address(new PauseDummy()); + } + + polygonOrchestratorProxy = new TransparentUpgradeableProxy( + pauseContract, + proxyDeployer, + bytes("") + ); + vm.stopPrank(); + } + + function _deployOrchestratorProxyAvalanche() internal { + vm.prank(proxyDeployer); + address pauseContract = vm.envAddress("CONCERO_PAUSE_AVALANCHE"); + if (pauseContract.code.length == 0) { + pauseContract = address(new PauseDummy()); + } + + avalancheOrchestratorProxy = new TransparentUpgradeableProxy( + pauseContract, + proxyDeployer, + bytes("") + ); + vm.stopPrank(); + } + function _deployOrchestratorImplementation() internal { vm.prank(deployer); baseOrchestratorImplementation = new InfraOrchestrator( @@ -501,6 +637,58 @@ contract BaseTest is Test { ); } + function _deployOrchestratorImplementationArbitrum() internal { + vm.prank(deployer); + arbitrumOrchestratorImplementation = new InfraOrchestrator( + vm.envAddress("CLF_ROUTER_ARBITRUM"), + address(arbitrumDexSwap), + address(arbitrumBridgeImplementation), + address(parentPoolProxy), + address(arbitrumOrchestratorProxy), + 0, // IInfraStorage.Chain.base + [vm.envAddress("POOL_MESSENGER_0_ADDRESS"), address(0), address(0)] + ); + } + + function _deployOrchestratorImplementationBase() internal { + vm.prank(deployer); + baseOrchestratorImplementation = new InfraOrchestrator( + vm.envAddress("CLF_ROUTER_BASE"), + address(baseDexSwap), + address(baseBridgeImplementation), + address(parentPoolProxy), + address(baseOrchestratorProxy), + 1, // IInfraStorage.Chain.base + [vm.envAddress("POOL_MESSENGER_0_ADDRESS"), address(0), address(0)] + ); + } + + function _deployOrchestratorImplementationPolygon() internal { + vm.prank(deployer); + polygonOrchestratorImplementation = new InfraOrchestrator( + vm.envAddress("CLF_ROUTER_POLYGON"), + address(polygonDexSwap), + address(polygonBridgeImplementation), + address(parentPoolProxy), + address(polygonOrchestratorProxy), + 3, // IInfraStorage.Chain.pol + [vm.envAddress("POOL_MESSENGER_0_ADDRESS"), address(0), address(0)] + ); + } + + function _deployOrchestratorImplementationAvalanche() internal { + vm.prank(deployer); + avalancheOrchestratorImplementation = new InfraOrchestrator( + vm.envAddress("CLF_ROUTER_AVALANCHE"), + address(avalancheDexSwap), + address(avalancheBridgeImplementation), + address(parentPoolProxy), + address(avalancheOrchestratorProxy), + 4, // IInfraStorage.Chain.avax + [vm.envAddress("POOL_MESSENGER_0_ADDRESS"), address(0), address(0)] + ); + } + /*////////////////////////////////////////////////////////////// UTILS //////////////////////////////////////////////////////////////*/ @@ -556,16 +744,42 @@ contract BaseTest is Test { ); require(success, string(data)); } + /*////////////////////////////////////////////////////////////// DEXSWAP //////////////////////////////////////////////////////////////*/ - function _deployDexSwap() internal { + function _deployDexSwapArbitrum() internal { vm.prank(deployer); - dexSwap = new DexSwap( + arbitrumDexSwap = new DexSwap( + address(arbitrumOrchestratorProxy), + [vm.envAddress("POOL_MESSENGER_0_ADDRESS"), address(0), address(0)] + ); + } + + function _deployDexSwapBase() internal { + vm.prank(deployer); + baseDexSwap = new DexSwap( address(baseOrchestratorProxy), [vm.envAddress("POOL_MESSENGER_0_ADDRESS"), address(0), address(0)] ); } + + function _deployDexSwapPolygon() internal { + vm.prank(deployer); + polygonDexSwap = new DexSwap( + address(polygonOrchestratorProxy), + [vm.envAddress("POOL_MESSENGER_0_ADDRESS"), address(0), address(0)] + ); + } + + function _deployDexSwapAvalanche() internal { + vm.prank(deployer); + avalancheDexSwap = new DexSwap( + address(avalancheOrchestratorProxy), + [vm.envAddress("POOL_MESSENGER_0_ADDRESS"), address(0), address(0)] + ); + } + function _getBaseInfraImplementationConstructorArgs() internal returns (address, address, address, address, address, uint8, address[3] memory) From 47ab35052faeb6cfe0a8c3ae490a4518ef2e50db Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Fri, 29 Nov 2024 22:07:50 +0300 Subject: [PATCH 17/54] optimize comparison --- contracts/ParentPoolCLFCLA.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/ParentPoolCLFCLA.sol b/contracts/ParentPoolCLFCLA.sol index c027fbbd..d0c1c11a 100644 --- a/contracts/ParentPoolCLFCLA.sol +++ b/contracts/ParentPoolCLFCLA.sol @@ -176,7 +176,7 @@ contract ParentPoolCLFCLA is (address, uint256, bytes32) ); - if (s_withdrawTriggered[withdrawalId] == true) { + if (s_withdrawTriggered[withdrawalId]) { revert WithdrawAlreadyTriggered(withdrawalId); } else { s_withdrawTriggered[withdrawalId] = true; From 980bc7e29223a6c33859722117551fab63511e1e Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Fri, 29 Nov 2024 22:09:05 +0300 Subject: [PATCH 18/54] optimize conditions --- contracts/ChildPool.sol | 2 +- contracts/ParentPoolCLFCLA.sol | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/ChildPool.sol b/contracts/ChildPool.sol index 4560d5f4..c48bb1ca 100644 --- a/contracts/ChildPool.sol +++ b/contracts/ChildPool.sol @@ -85,7 +85,7 @@ contract ChildPool is CCIPReceiver, ChildPoolStorage { * @notice modifier to check if the caller is the an approved messenger */ modifier onlyMessenger() { - if (_isMessenger(msg.sender) == false) revert NotMessenger(msg.sender); + if (!_isMessenger(msg.sender)) revert NotMessenger(msg.sender); _; } diff --git a/contracts/ParentPoolCLFCLA.sol b/contracts/ParentPoolCLFCLA.sol index d0c1c11a..392a6505 100644 --- a/contracts/ParentPoolCLFCLA.sol +++ b/contracts/ParentPoolCLFCLA.sol @@ -150,7 +150,7 @@ contract ParentPoolCLFCLA is } // s_withdrawTriggered is used to prevent multiple CLA triggers of the same withdrawal request if ( - s_withdrawTriggered[withdrawalId] == false && + !s_withdrawTriggered[withdrawalId] && block.timestamp > withdrawalRequest.triggeredAtTimestamp ) { bytes memory _performData = abi.encode( From 0f855549015661ebf43a42c3eda55c77b971a0ef Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Fri, 29 Nov 2024 22:15:08 +0300 Subject: [PATCH 19/54] delete comments and unused imports --- contracts/DexSwap.sol | 267 ------------------------------------------ 1 file changed, 267 deletions(-) diff --git a/contracts/DexSwap.sol b/contracts/DexSwap.sol index eab264c0..0a4acc41 100644 --- a/contracts/DexSwap.sol +++ b/contracts/DexSwap.sol @@ -9,10 +9,6 @@ pragma abicoder v2; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; -import {IUniswapV2Router02} from "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol"; -import {ISwapRouter} from "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol"; -import {ISwapRouter as ISushiRouterV3} from "sushiswap-v3-periphery/contracts/interfaces/ISwapRouter.sol"; -import {ISwapRouter02, IV3SwapRouter} from "./Interfaces/ISwapRouter02.sol"; import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol"; import {InfraStorage} from "./Libraries/InfraStorage.sol"; import {IDexSwap} from "./Interfaces/IDexSwap.sol"; @@ -150,269 +146,6 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { // } // } - // /** - // * @notice UniswapV3 function that executes single hop swaps - // * @param _swapData the encoded swap data - // * @dev This function can execute swap in any protocol compatible with UniV3 that implements the IV3SwapRouter - // */ - // function _swapUniV3Single(IDexSwap.SwapData memory _swapData, address _recipient) private { - // if (_swapData.dexData.length == 0) revert EmptyDexData(); - // (address routerAddress, uint24 fee, uint160 sqrtPriceLimitX96, uint256 deadline) = abi - // .decode(_swapData.dexData, (address, uint24, uint160, uint256)); - - // if (!s_routerAllowed[routerAddress]) revert DexRouterNotAllowed(); - - // if (block.chainid == BASE_CHAIN_ID || block.chainid == AVAX_CHAIN_ID) { - // IV3SwapRouter.ExactInputSingleParams memory dex = IV3SwapRouter.ExactInputSingleParams({ - // tokeDexTypenIn: _swapData.fromToken, - // tokenOut: _swapData.toToken, - // fee: fee, - // recipient: _recipient, - // amountIn: _swapData.fromAmount, - // amountOutMinimum: _swapData.toAmountMin, - // sqrtPriceLimitX96: sqrtPriceLimitX96 - // }); - - // IERC20(_swapData.fromToken).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); - // ISwapRouter02(routerAddress).exactInputSingle(dex); - // } else { - // ISwapRouter.ExactInputSingleParams memory dex = ISwapRouter.ExactInputSingleParams({ - // tokenIn: _swapData.fromToken, - // tokenOut: _swapData.toToken, - // fee: fee, - // recipient: _recipient, - // deadline: deadline, - // amountIn: _swapData.fromAmount, - // amountOutMinimum: _swapData.toAmountMin, - // sqrtPriceLimitX96: sqrtPriceLimitX96 - // }); - - // IERC20(_swapData.fromToken).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); - // ISwapRouter(routerAddress).exactInputSingle(dex); - // } - // } - - // /** - // * @notice UniswapV3 function that executes multi hop swaps - // * @param _swapData the encoded swap data - // * @dev This function can execute swap in any protocol compatible - // */ - // function _swapUniV3Multi(IDexSwap.SwapData memory _swapData, address _recipient) private { - // if (_swapData.dexData.length == 0) revert EmptyDexData(); - - // (address routerAddress, bytes memory path, uint256 deadline) = abi.decode( - // _swapData.dexData, - // (address, bytes, uint256) - // ); - // (address firstToken, address lastToken) = _extractTokens(path); - - // if (!s_routerAllowed[routerAddress]) revert DexRouterNotAllowed(); - // if (firstToken != _swapData.fromToken || lastToken != _swapData.toToken) - // revert InvalidTokenPath(); - - // if (block.chainid == BASE_CHAIN_ID || block.chainid == AVAX_CHAIN_ID) { - // IV3SwapRouter.ExactInputParams memory params = IV3SwapRouter.ExactInputParams({ - // path: path, - // recipient: _recipient, - // amountIn: _swapData.fromAmount, - // amountOutMinimum: _swapData.toAmountMin - // }); - - // IERC20(_swapData.fromToken).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); - // ISwapRouter02(routerAddress).exactInput(params); - // } else { - // ISwapRouter.ExactInputParams memory params = ISwapRouter.ExactInputParams({ - // path: path, - // recipient: _recipient, - // deadline: deadline, - // amountIn: _swapData.fromAmount, - // amountOutMinimum: _swapData.toAmountMin - // }); - - // IERC20(_swapData.fromToken).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); - // ISwapRouter(routerAddress).exactInput(params); - // } - // } - - // /** - // * @notice Function to execute swap accordingly to UniswapV2 - // * @param _swapData the encoded swap data - // * @dev This function can execute single or multi hop swaps - // */ - // function _swapUniV2Like(IDexSwap.SwapData memory _swapData, address _recipient) private { - // if (_swapData.dexData.length == 0) revert EmptyDexData(); - - // (address routerAddress, address[] memory path, uint256 deadline) = abi.decode( - // _swapData.dexData, - // (address, address[], uint256) - // ); - // uint256 numberOfHops = path.length; - - // if (!s_routerAllowed[routerAddress]) revert DexRouterNotAllowed(); - // if (path[0] != _swapData.fromToken || path[numberOfHops - 1] != _swapData.toToken) - // revert InvalidTokenPath(); - - // IERC20(path[0]).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); - - // IUniswapV2Router02(routerAddress).swapExactTokensForTokens( - // _swapData.fromAmount, - // _swapData.toAmountMin, - // path, - // _recipient, - // deadline - // ); - // } - - // /** - // * @notice Function to execute swap accordingly to UniswapV2 - // * @param _swapData the encoded swap data - // * @dev This function accept FoT tokens - // * @dev This function can execute single or multi hop swaps - // */ - // function _swapUniV2LikeFoT(IDexSwap.SwapData memory _swapData, address _recipient) private { - // if (_swapData.dexData.length == 0) revert EmptyDexData(); - - // (address routerAddress, address[] memory path, uint256 deadline) = abi.decode( - // _swapData.dexData, - // (address, address[], uint256) - // ); - // uint256 numberOfHops = path.length; - - // if (!s_routerAllowed[routerAddress]) revert DexRouterNotAllowed(); - // if (path[0] != _swapData.fromToken || path[numberOfHops - 1] != _swapData.toToken) - // revert InvalidTokenPath(); - - // IERC20(path[0]).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); - - // IUniswapV2Router02(routerAddress).swapExactTokensForTokensSupportingFeeOnTransferTokens( - // _swapData.fromAmount, - // _swapData.toAmountMin, - // path, - // _recipient, - // deadline - // ); - // } - - // /** - // * @notice Function to execute swap - // * @param _swapData the encoded swap data - // * @dev This function can execute swap in any protocol compatible with UniV3 that implements the ISwapRouter - // */ - // function _swapSushiV3Single(IDexSwap.SwapData memory _swapData, address _recipient) private { - // if (_swapData.dexData.length == 0) revert EmptyDexData(); - - // (address routerAddress, uint24 fee, uint256 deadline, uint160 sqrtPriceLimitX96) = abi - // .decode(_swapData.dexData, (address, uint24, uint256, uint160)); - - // if (!s_routerAllowed[routerAddress]) revert DexRouterNotAllowed(); - - // ISushiRouterV3.ExactInputSingleParams memory dex = ISushiRouterV3.ExactInputSingleParams({ - // tokenIn: _swapData.fromToken, - // tokenOut: _swapData.toToken, - // fee: fee, - // recipient: _recipient, - // deadline: deadline, - // amountIn: _swapData.fromAmount, - // amountOutMinimum: _swapData.toAmountMin, - // sqrtPriceLimitX96: sqrtPriceLimitX96 - // }); - - // IERC20(_swapData.fromToken).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); - - // ISushiRouterV3(routerAddress).exactInputSingle(dex); - // } - - // /** - // * @notice SushiSwapV3 function that executes multi hop swaps - // * @param _swapData the encoded swap data - // * @dev This function can execute swap in any protocol compatible with ISwapRouter - // */ - // function _swapSushiV3Multi(IDexSwap.SwapData memory _swapData, address _recipient) private { - // if (_swapData.dexData.length == 0) revert EmptyDexData(); - - // (address routerAddress, bytes memory path, uint256 deadline) = abi.decode( - // _swapData.dexData, - // (address, bytes, uint256) - // ); - - // (address firstToken, address lastToken) = _extractTokens(path); - - // if (!s_routerAllowed[routerAddress]) revert DexRouterNotAllowed(); - // if (firstToken != _swapData.fromToken || lastToken != _swapData.toToken) - // revert InvalidTokenPath(); - - // ISushiRouterV3.ExactInputParams memory params = ISushiRouterV3.ExactInputParams({ - // path: path, - // recipient: _recipient, - // deadline: deadline, - // amountIn: _swapData.fromAmount, - // amountOutMinimum: _swapData.toAmountMin - // }); - - // IERC20(_swapData.fromToken).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); - - // ISushiRouterV3(routerAddress).exactInput(params); - // } - // - // /** - // * @notice Function to execute swaps on Aerodrome and Velodrome Protocols - // * @param _swapData the encoded swap data - // * @dev This function accepts regular and Fee on Transfer tokens - // */ - // function _swapDrome(IDexSwap.SwapData memory _swapData, address _recipient) private { - // if (_swapData.dexData.length == 0) revert EmptyDexData(); - // - // (address routerAddress, IRouter.Route[] memory routes, uint256 deadline) = abi.decode( - // _swapData.dexData, - // (address, IRouter.Route[], uint256) - // ); - // - // if (!s_routerAllowed[routerAddress]) revert DexRouterNotAllowed(); - // if ( - // routes[0].from != _swapData.fromToken || - // routes[routes.length - 1].to != _swapData.toToken - // ) revert InvalidTokenPath(); - // - // IERC20(routes[0].from).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); - // - // IRouter(routerAddress).swapExactTokensForTokens( - // _swapData.fromAmount, - // _swapData.toAmountMin, - // routes, - // _recipient, - // deadline - // ); - // } - // - // /** - // * @notice Function to execute swaps on Aerodrome and Velodrome Protocols - // * @param _swapData the encoded swap data - // * @dev This function accepts Fee on Transfer tokens - // */ - // function _swapDromeFoT(IDexSwap.SwapData memory _swapData, address _recipient) private { - // if (_swapData.dexData.length == 0) revert EmptyDexData(); - // (address routerAddress, IRouter.Route[] memory routes, uint256 deadline) = abi.decode( - // _swapData.dexData, - // (address, IRouter.Route[], uint256) - // ); - // - // if (!s_routerAllowed[routerAddress]) revert DexRouterNotAllowed(); - // if ( - // routes[0].from != _swapData.fromToken || - // routes[routes.length - 1].to != _swapData.toToken - // ) revert InvalidTokenPath(); - // - // IERC20(routes[0].from).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); - // - // IRouter(routerAddress).swapExactTokensForTokensSupportingFeeOnTransferTokens( - // _swapData.fromAmount, - // _swapData.toAmountMin, - // routes, - // _recipient, - // deadline - // ); - // } - /* HELPER FUNCTIONS */ function _extractTokens( bytes memory _path From dd5b30916fc80a2928c652854849cdbf0c5b210f Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Fri, 29 Nov 2024 22:18:10 +0300 Subject: [PATCH 20/54] delete abicoder v2 because it already presents since 0.8.0 --- contracts/DexSwap.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/contracts/DexSwap.sol b/contracts/DexSwap.sol index 0a4acc41..ec6d649d 100644 --- a/contracts/DexSwap.sol +++ b/contracts/DexSwap.sol @@ -5,7 +5,6 @@ * @contact email: security@concero.io */ pragma solidity 0.8.20; -pragma abicoder v2; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; From 2757f1ab5b268317512ece9c356ab0fd2c8d4bbb Mon Sep 17 00:00:00 2001 From: lufaque <95128636+lufaque@users.noreply.github.com> Date: Sun, 15 Dec 2024 21:56:22 +0300 Subject: [PATCH 21/54] fix naming issues --- contracts/DexSwap.sol | 40 ++++++++++++++++++++-------------------- yarn.lock | 1 - 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/contracts/DexSwap.sol b/contracts/DexSwap.sol index ec6d649d..31038e9e 100644 --- a/contracts/DexSwap.sol +++ b/contracts/DexSwap.sol @@ -96,17 +96,17 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { } uint256 recipientBalanceAfter = LibConcero.getBalance(dstToken, _recipient); - uint256 dstTokenRecieved = recipientBalanceAfter - recipientBalanceBefore; + uint256 dstTokenReceived = recipientBalanceAfter - recipientBalanceBefore; emit ConceroSwap( _swapData[0].fromToken, dstToken, _swapData[0].fromAmount, - dstTokenRecieved, + dstTokenReceived, _recipient ); - return dstTokenRecieved; + return dstTokenReceived; } function _performSwap(IDexSwap.SwapData memory _swapData) private { @@ -146,21 +146,21 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { // } /* HELPER FUNCTIONS */ - function _extractTokens( - bytes memory _path - ) private pure returns (address _firstToken, address _lastToken) { - uint256 pathSize = _path.length; - - bytes memory tokenBytes = _path.slice(0, 20); - - assembly { - _firstToken := mload(add(tokenBytes, 20)) - } - - bytes memory secondTokenBytes = _path.slice(pathSize - 20, 20); - - assembly { - _lastToken := mload(add(secondTokenBytes, 20)) - } - } + // function _extractTokens( + // bytes memory _path + // ) private pure returns (address _firstToken, address _lastToken) { + // uint256 pathSize = _path.length; + // + // bytes memory tokenBytes = _path.slice(0, 20); + // + // assembly { + // _firstToken := mload(add(tokenBytes, 20)) + // } + // + // bytes memory secondTokenBytes = _path.slice(pathSize - 20, 20); + // + // assembly { + // _lastToken := mload(add(secondTokenBytes, 20)) + // } + // } } diff --git a/yarn.lock b/yarn.lock index 5c6558eb..166bf3ba 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10724,7 +10724,6 @@ workerpool@^6.5.1: integrity sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA== "wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: - name wrap-ansi-cjs version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== From 543ec886cf235a6f6c1253faaffae554b05d7cca Mon Sep 17 00:00:00 2001 From: lufaque <95128636+lufaque@users.noreply.github.com> Date: Mon, 16 Dec 2024 21:31:49 +0300 Subject: [PATCH 22/54] new test suit base --- .env.clccip | 20 + Makefile | 4 +- foundry.toml | 2 +- test/foundry/Bridge/BridgeCompression.t.sol | 2 +- .../InfraOrchestrator.swap.t.sol | 925 ++++++++++++++++++ test/foundry/ParentPool/Deposit.t.sol | 2 +- test/foundry/ParentPool/Withdraw.t.sol | 4 +- .../unitTests/CalculateLpTokensToMint.t.sol | 4 +- .../ParentPool/unitTests/IsMessenger.t.sol | 4 +- test/foundry/Swap/DexSwap.t.sol | 878 ----------------- test/foundry/scripts/DeployInfra.s.sol | 104 ++ test/foundry/utils/BaseTest.t.sol | 66 +- .../foundry/utils/CreateAndSwitchToFork.t.sol | 25 - test/foundry/utils/DeployHelper.sol | 148 +++ test/foundry/utils/InfraBaseTest.t.sol | 57 ++ 15 files changed, 1275 insertions(+), 970 deletions(-) create mode 100644 test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol delete mode 100644 test/foundry/Swap/DexSwap.t.sol create mode 100644 test/foundry/scripts/DeployInfra.s.sol delete mode 100644 test/foundry/utils/CreateAndSwitchToFork.t.sol create mode 100644 test/foundry/utils/DeployHelper.sol create mode 100644 test/foundry/utils/InfraBaseTest.t.sol diff --git a/.env.clccip b/.env.clccip index 3cb22770..16143658 100644 --- a/.env.clccip +++ b/.env.clccip @@ -45,3 +45,23 @@ UNISWAP_ROUTER_OPTIMISM=0xE592427A0AEce92De3Edee1F18E0157C05861564 UNISWAP_ROUTER_POLYGON=0xE592427A0AEce92De3Edee1F18E0157C05861564 UNISWAP_ROUTER_ARBITRUM=0xE592427A0AEce92De3Edee1F18E0157C05861564 UNISWAP_ROUTER_AVALANCHE=0xbb00FF08d01D300023C629E8fFfFcb65A5a578cE +UNI_V3_ROUTER02_BASE=0x2626664c2603336E57B271c5C0b26F421741e481 +UNI_V3_ROUTER_ARBITRUM=0xE592427A0AEce92De3Edee1F18E0157C05861564 + +# SUSHISWAP ROUTERS +SUSHISWAP_ROUTER_ARBITRUM=0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506 + +# QUICKSWAP ROUTERS +QUICKSWAP_ROUTER_POLYGON_ADDRESS=0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff + +# ODOS +ODOS_ROUTER_V2_BASE=0x19cEeAd7105607Cd444F5ad10dd51356436095a1 + +# ALIENBASE +ALIENBASE_ROUTER_BASE=0x8c1A3cF8f83074169FE5D7aD50B978e1cD6b37c7 + +# CURVE +CURVE_ROUTER_BASE=0xd6681e74eEA20d196c15038C580f721EF2aB6320 + +# PANGOLIN +PANGOLIN_ROUTER_AVALANCHE_ADDRESS=0xE54Ca86531e17Ef3616d22Ca28b0D458b6C89106 diff --git a/Makefile b/Makefile index 625bfa75..8600574a 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,6 @@ # - `make test` : Run all tests using forge with any optional arguments specified in --args. # For example: `make test args="--match-test Deposit"` -include .env.foundry include ./.env include ./.env.tokens include ./.env.clccip @@ -19,8 +18,9 @@ include ./.env.clf include ./.env.deployments.mainnet include ./.env.deployments.testnet include ./.env.wallets +include .env.foundry -ENV_FILES := .env.foundry ./.env ./.env.tokens ./.env.clccip ./.env.clf ./.env.deployments.mainnet ./.env.deployments.testnet ./.env.wallets +ENV_FILES := ./.env ./.env.tokens ./.env.clccip ./.env.clf ./.env.deployments.mainnet ./.env.deployments.testnet ./.env.wallets .env.foundry export $(shell cat $(ENV_FILES) | sed 's/=.*//' | sort | uniq) args = diff --git a/foundry.toml b/foundry.toml index 828362f3..e08bf2fb 100644 --- a/foundry.toml +++ b/foundry.toml @@ -12,5 +12,5 @@ remappings = [ "@chainlink/=node_modules/@chainlink/", "@uniswap/=node_modules/@uniswap/", "sushiswap-v3-periphery/contracts/=node_modules/sushiswap-v3-periphery/contracts/", - "forge-std/=node_modules/forge-std/src/", + "forge-std/=node_modules/forge-std/", ] diff --git a/test/foundry/Bridge/BridgeCompression.t.sol b/test/foundry/Bridge/BridgeCompression.t.sol index 76641c3c..c0a664f3 100644 --- a/test/foundry/Bridge/BridgeCompression.t.sol +++ b/test/foundry/Bridge/BridgeCompression.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.20; -import {console, Vm} from "forge-std/Test.sol"; +import {console, Vm} from "forge-std/src/Test.sol"; import {BridgeBaseTest} from "./BridgeBaseTest.t.sol"; import {IDexSwap} from "contracts/Interfaces/IDexSwap.sol"; import {LibZip} from "solady/src/utils/LibZip.sol"; diff --git a/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol new file mode 100644 index 00000000..e4cbfe8a --- /dev/null +++ b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol @@ -0,0 +1,925 @@ +// SPDX-License-Identifier: SEE LICENSE IN LICENSE +pragma solidity ^0.8.20; + +import {Test} from "forge-std/src/Test.sol"; +import {IDexSwap} from "contracts/Interfaces/IDexSwap.sol"; +import {IInfraOrchestrator} from "contracts/Interfaces/IInfraOrchestrator.sol"; +import {InfraOrchestrator} from "contracts/InfraOrchestrator.sol"; +import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import {console} from "forge-std/src/console.sol"; +import {DeployInfraScript} from "../scripts/DeployInfra.s.sol"; + +contract DexSwapTest is Test { + // @notice helper vars + address internal constant NATIVE_TOKEN = address(0); + IInfraOrchestrator.Integration internal emptyIntegration = + IInfraOrchestrator.Integration({integrator: address(0), feeBps: 0}); + + address internal infraProxy; + + modifier selectFork(uint256 forkId) { + DeployInfraScript deployInfraScript = new DeployInfraScript(); + infraProxy = deployInfraScript.run(forkId); + _; + } + + function testFork_Univ3OnBaseViaRangoRouting() + public + selectFork(vm.createFork(vm.envString("BASE_RPC_URL"))) + { + uint256 fromAmount = 0.1 ether; + uint256 toAmount = 267.528449e6; + uint256 toAmountMin = 266.190806e6; + address user = makeAddr("user"); + + deal(user, fromAmount); + + bytes + memory dexData = hex"7ff36ab5000000000000000000000000000000000000000000000000000000000fddbfd70000000000000000000000000000000000000000000000000000000000000080000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673fb53400000000000000000000000000000000000000000000000000000000000000020000000000000000000000004200000000000000000000000000000000000006000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: vm.envAddress("ALIENBASE_ROUTER_BASE"), + fromToken: NATIVE_TOKEN, + fromAmount: fromAmount, + toToken: vm.envAddress("USDC_BASE"), + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + vm.prank(user); + InfraOrchestrator(payable(infraProxy)).swap{value: fromAmount}( + swapData, + user, + emptyIntegration + ); + } + + // address internal constant ETH_TOKEN = address(0); + // address internal constant POL_TOKEN = address(0); + // + // // Base tokens + // address internal usdcTokenBase = vm.envAddress("USDC_BASE"); + // address internal wethTokenBase = vm.envAddress("WETH_BASE"); + // address internal daiTokenBase = vm.envAddress("DAI_BASE"); + // address internal sushiTokenBase = vm.envAddress("SUSHI_BASE"); + // address internal oneInchTokenBase = vm.envAddress("1INCH_BASE"); + // + // //Arbitrum tokens + // address internal usdcTokenArbitrum = vm.envAddress("USDC_ARBITRUM"); + // address internal usdtTokenArbitrum = vm.envAddress("USDT_ARBITRUM"); + // address internal wethTokenArbitrum = vm.envAddress("WETH_ARBITRUM"); + // + // //Polygon tokens + // address internal usdcTokenPolygon = vm.envAddress("USDC_POLYGON"); + // address internal wethTokenPolygon = vm.envAddress("WETH_POLYGON"); + // + // //Avalanche tokens + // address internal usdcTokenAvalanche = vm.envAddress("USDC_AVALANCHE"); + // address internal wavaxTokenAvalanche = vm.envAddress("WAVAX_AVALANCHE"); + // + // //Arbitrum Routers + // address internal sushiRouterArbitrum = vm.envAddress("SUSHISWAP_ROUTER_ARBITRUM_ADDRESS"); + // address internal uniV3RouterArbitrum = vm.envAddress("UNI_V3_ROUTER_ARBITRUM_ADDRESS"); + // address internal paraSwapV5RouterArbitrum = + // vm.envAddress("PARASWAP_V5_ROUTER_ARBITRUM_ADDRESS"); + // + // //Base Routers + // address internal uniV3RouterBase = vm.envAddress("UNI_V3_ROUTER02_BASE_ADDRESS"); + // address internal paraSwapV6_2RouterBase = vm.envAddress("PARASWAP_V6_2_ROUTER_BASE_ADDRESS"); + // address internal odosRouterV2Base = vm.envAddress("ODOS_ROUTER_V2_BASE_ADDRESS"); + // address internal oneInchRouterV5Base = vm.envAddress("1INCH_ROUTER_V5_BASE_ADDRESS"); + // address internal curveRouterBase = vm.envAddress("CURVE_ROUTER_BASE_ADDRESS"); + // address internal alienbaseRouterBase = vm.envAddress("ALIENBASE_ROUTER_BASE_ADDRESS"); + // + // //Polygon Routers + // address internal quickSwapRouterPolygon = vm.envAddress("QUICKSWAP_ROUTER_POLYGON_ADDRESS"); + // + // //Avalanche Routers + // address internal pangolinRouterAvalanche = vm.envAddress("PANGOLIN_ROUTER_AVALANCHE_ADDRESS"); + // + // address payable internal sender = payable(makeAddr("sender")); + // address internal integrator = makeAddr("integrator"); + // + // modifier addRouterInWhiteList(address router, address proxy) { + // _allowRouter(router, address(proxy)); + // _; + // } + // + // function setUp() public override setFork(polygonAnvilForkId) { + // super.setUp(); + // } + // + // //////////////////// Base /////////////////////////////// + // //////////////////// Block number 22713659 ////////////// + // + // ////////////////////////////////////////////////////////// + // ////////////////// Alienbase //////////////////// + // ////////////////////////////////////////////////////////// + // + // //passed + // function test_dexSwapAlienbaseRouterETHToUSDCBase() + // public + // setFork(baseAnvilForkId) + // addRouterInWhiteList(alienbaseRouterBase, address(baseOrchestratorProxy)) + // { + // uint256 fromAmount = 0.1 ether; + // uint256 toAmount = 267.528449e6; + // uint256 toAmountMin = 266.190806e6; + // + // bytes + // memory dexData = hex"7ff36ab5000000000000000000000000000000000000000000000000000000000fddbfd70000000000000000000000000000000000000000000000000000000000000080000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673fb53400000000000000000000000000000000000000000000000000000000000000020000000000000000000000004200000000000000000000000000000000000006000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913"; + // + // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + // swapData[0] = IDexSwap.SwapData({ + // dexRouter: alienbaseRouterBase, + // fromToken: ETH_TOKEN, + // fromAmount: fromAmount, + // toToken: usdcTokenBase, + // toAmount: toAmount, + // toAmountMin: toAmountMin, + // dexData: dexData + // }); + // + // _callTestWithRouter(swapData, address(baseOrchestratorProxy)); + // } + // + // //passed + // function test_dexSwapAlienbaseRouterUSDCToWETHBase() + // public + // setFork(baseAnvilForkId) + // addRouterInWhiteList(alienbaseRouterBase, address(baseOrchestratorProxy)) + // { + // uint256 fromAmount = 10e6; //10 usdc + // uint256 toAmount = 0.002945698049459263e18; + // uint256 toAmountMin = 0.002930969559211966e18; + // + // bytes + // memory dexData = hex"38ed173900000000000000000000000000000000000000000000000000000000009834e7000000000000000000000000000000000000000000000000000a69b3876c9fbe00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673fb6140000000000000000000000000000000000000000000000000000000000000002000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000004200000000000000000000000000000000000006"; + // + // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + // swapData[0] = IDexSwap.SwapData({ + // dexRouter: alienbaseRouterBase, + // fromToken: usdcTokenBase, + // fromAmount: fromAmount, + // toToken: wethTokenBase, + // toAmount: toAmount, + // toAmountMin: toAmountMin, + // dexData: dexData + // }); + // + // _callTestWithRouter(swapData, address(baseOrchestratorProxy)); + // } + // + // //passed + // function test_dexSwapAlienbaseRouterUSDCToETHBase() + // public + // setFork(baseAnvilForkId) + // addRouterInWhiteList(alienbaseRouterBase, address(baseOrchestratorProxy)) + // { + // uint256 fromAmount = 10e6; + // uint256 toAmount = 0.002945698049459263 ether; + // uint256 toAmountMin = 0.002930969559211966 ether; + // + // bytes + // memory dexData = hex"18cbafe500000000000000000000000000000000000000000000000000000000009834e7000000000000000000000000000000000000000000000000000a69b3876c9fbe00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673fb67c0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000004200000000000000000000000000000000000006"; + // + // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + // swapData[0] = IDexSwap.SwapData({ + // dexRouter: alienbaseRouterBase, + // fromToken: usdcTokenBase, + // fromAmount: fromAmount, + // toToken: ETH_TOKEN, + // toAmount: toAmount, + // toAmountMin: toAmountMin, + // dexData: dexData + // }); + // + // _callTestWithRouter(swapData, address(baseOrchestratorProxy)); + // } + // + // ////////////////////////////////////////////////////////// + // ////////////////// Curve //////////////////////// + // ////////////////////////////////////////////////////////// + // + // //passed + // function test_dexSwapCurveRouterUSDCToWETHBase() + // public + // setFork(baseAnvilForkId) + // addRouterInWhiteList(curveRouterBase, address(baseOrchestratorProxy)) + // { + // uint256 fromAmount = 10e6; //1 usdc + // uint256 toAmount = 0.002950528095025959e18; + // uint256 toAmountMin = 0.002935775454550829e18; + // + // bytes + // memory dexData = hex"c872a3c5000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f000000000000000000000000417ac0e078398c154edfadd9ef675d30be60af930000000000000000000000006e53131f68a034873b6bfa15502af094ef0c58540000000000000000000000004200000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009834e7000000000000000000000000000000000000000000000000000a6e127d1bdb2d000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f0000000000000000000000006e53131f68a034873b6bfa15502af094ef0c5854000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681"; + // + // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + // swapData[0] = IDexSwap.SwapData({ + // dexRouter: curveRouterBase, + // fromToken: usdcTokenBase, + // fromAmount: fromAmount, + // toToken: wethTokenBase, + // toAmount: toAmount, + // toAmountMin: toAmountMin, + // dexData: dexData + // }); + // + // _callTestWithRouter(swapData, address(baseOrchestratorProxy)); + // } + // + // //not working + // function test_dexSwapCurveRouterETHToUSDCBase() + // public + // setFork(baseAnvilForkId) + // addRouterInWhiteList(curveRouterBase, address(baseOrchestratorProxy)) + // { + // uint256 fromAmount = 0.0003 ether; + // uint256 toAmount = 0.993336e6; + // uint256 toAmountMin = 0.988369e6; + // + // bytes + // memory dexData = hex"c872a3c5000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000420000000000000000000000000000000000000600000000000000000000000042000000000000000000000000000000000000060000000000000000000000006e53131f68a034873b6bfa15502af094ef0c5854000000000000000000000000417ac0e078398c154edfadd9ef675d30be60af93000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001102aacc5688000000000000000000000000000000000000000000000000000000000000f14d100000000000000000000000042000000000000000000000000000000000000060000000000000000000000006e53131f68a034873b6bfa15502af094ef0c5854000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681"; + // + // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + // swapData[0] = IDexSwap.SwapData({ + // dexRouter: curveRouterBase, + // fromToken: ETH_TOKEN, + // fromAmount: fromAmount, + // toToken: usdcTokenBase, + // toAmount: toAmount, + // toAmountMin: toAmountMin, + // dexData: dexData + // }); + // + // _callTestWithRouter(swapData, address(baseOrchestratorProxy)); + // } + // + // //passed + // function test_dexSwapCurveRouterUSDCToETHBase() + // public + // setFork(baseAnvilForkId) + // addRouterInWhiteList(curveRouterBase, address(baseOrchestratorProxy)) + // { + // uint256 fromAmount = 1e6; + // uint256 toAmount = 0.00029502055232845 ether; + // uint256 toAmountMin = 0.000293545449566807 ether; + // + // bytes + // memory dexData = hex"c872a3c5000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f000000000000000000000000417ac0e078398c154edfadd9ef675d30be60af930000000000000000000000006e53131f68a034873b6bfa15502af094ef0c585400000000000000000000000042000000000000000000000000000000000000060000000000000000000000004200000000000000000000000000000000000006000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010afa71c98c9d000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f0000000000000000000000006e53131f68a034873b6bfa15502af094ef0c5854000000000000000000000000420000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681"; + // + // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + // swapData[0] = IDexSwap.SwapData({ + // dexRouter: curveRouterBase, + // fromToken: usdcTokenBase, + // fromAmount: fromAmount, + // toToken: ETH_TOKEN, + // toAmount: toAmount, + // toAmountMin: toAmountMin, + // dexData: dexData + // }); + // + // _callTestWithRouter(swapData, address(baseOrchestratorProxy)); + // } + // + // ////////////////////////////////////////////////////////// + // ////////////////// Odos Router V2 //////////////////////// + // ////////////////////////////////////////////////////////// + // + // //passed + // function test_dexSwapOdosRouterV2USDCToWETHBase() + // public + // setFork(baseAnvilForkId) + // addRouterInWhiteList(odosRouterV2Base, address(baseOrchestratorProxy)) + // { + // uint256 fromAmount = 1e6; //1 usdc + // uint256 toAmount = 0.000295473686245412e18; + // uint256 toAmountMin = 0.000293996317814184e18; + // + // bytes + // memory dexData = hex"83bd37f900040002030f387e07010cbb65c26b5000c49b00017882570840a97a490a37bd8db9e1ae39165bfbd600000001cd1722f3947def4cf144679da39c4c32bdc356810000000003010203000a0101010200ff000000000000000000000000000000000000000000883e4ae0a817f2901500971b353b5dd89aa52184833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000000000000000000000000000"; + // + // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + // swapData[0] = IDexSwap.SwapData({ + // dexRouter: odosRouterV2Base, + // fromToken: usdcTokenBase, + // fromAmount: fromAmount, + // toToken: wethTokenBase, + // toAmount: toAmount, + // toAmountMin: toAmountMin, + // dexData: dexData + // }); + // + // _callTestWithRouter(swapData, address(baseOrchestratorProxy)); + // } + // + // //doesnt work with native + // function test_dexSwapOdosRouterV2ETHToUSDCBase() + // public + // setFork(baseAnvilForkId) + // addRouterInWhiteList(odosRouterV2Base, address(baseOrchestratorProxy)) + // { + // uint256 fromAmount = 0.001 ether; + // uint256 toAmount = 3.355603e6; + // uint256 toAmountMin = 3.338824e6; + // + // bytes + // memory dexData = hex"83bd37f90000000407038b38ea920700033333d300c49b00017882570840a97a490a37bd8db9e1ae39165bfbd600000001cd1722f3947def4cf144679da39c4c32bdc35681000000000301020300040101022b000101010201ff000000000000000000000000000000005b52dfa81e7409df9390c9403aceb51ea3df4f204200000000000000000000000000000000000006000000000000000000000000000000000000000000000000"; + // + // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + // swapData[0] = IDexSwap.SwapData({ + // dexRouter: odosRouterV2Base, + // fromToken: ETH_TOKEN, + // fromAmount: fromAmount, + // toToken: usdcTokenBase, + // toAmount: toAmount, + // toAmountMin: toAmountMin, + // dexData: dexData + // }); + // + // _callTestWithRouter(swapData, address(baseOrchestratorProxy)); + // } + // + // ////////////////////////////////////////////////////////// + // ////////////////// 1Inch //////////////////////// + // ////////////////////////////////////////////////////////// + // + // function test_dexSwap1InchV5USDCTo1InchTokenBase() + // public + // setFork(baseAnvilForkId) + // addRouterInWhiteList(oneInchRouterV5Base, address(baseOrchestratorProxy)) + // { + // uint256 fromAmount = 10e6; //10 usdc + // uint256 toAmount = 29.186618652079786377e18; + // uint256 toAmountMin = 29.040685558819387445e18; + // + // bytes + // memory dexData = hex"12aa3caf000000000000000000000000e37e799d5077682fa0a244d46e5649f71457bd09000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000c5fecc3a29fb57b5024eec8a2239d4621e111cbe000000000000000000000000e37e799d5077682fa0a244d46e5649f71457bd09000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000009834e700000000000000000000000000000000000000000000000193053da6cf3ef835000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004af00000000000000000000000000000000000000000000000000000000049100a007e5c0d200000000000000000000000000000000000000000000046d00040a0003f0512003c01acae3d0173a93d819efdc832c7c4f153b06833589fcd6edb6e08f4c7c32d4f71b54bda02913016452bbbe2900000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000e37e799d5077682fa0a244d46e5649f71457bd090000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e37e799d5077682fa0a244d46e5649f71457bd090000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000673f9a44def66c6c178087fd931514e99b04479e4d3d956c0002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009834e700000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000062769914a469c00000000000000000000000000000000000000000000000000000000673f9a4400000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000005af3107a400000000000000000b671b09bd7eb7a242300000000000000008bd0c186893c2c000000000000000dd975ede04e7dbbc0000000000000000005aab64d6906dbaed800000000000000000000000000000000000000000004ee7259d6914ae6c461bc00000000000000004563918244f400000000000000000000006a94d74f430000000000000000000000000000673f99ea000000000000000000003b1dfde910000000000000000000000000000000000000000000000000000000000000000041b0087e9968881cc03a4f3270b3086fd3a18f6587c3179ad985c8c406056d7b98035f5800bbb63a992a30c39c7224be035751091573a74d263682a8536b8d51711c0000000000000000000000000000000000000000000000000000000000000040414200000000000000000000000000000000000006d0e30db002a000000000000000000000000000000000000000000000000190fec846c67c66e1ee63c1e5814af5a3adb853290bc9f909138fbf1a3c3feb086842000000000000000000000000000000000000061111111254eeb25477b68fb85ed929f73a96058200000000000000000000000000000000007787a5c8"; + // + // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + // swapData[0] = IDexSwap.SwapData({ + // dexRouter: oneInchRouterV5Base, + // fromToken: usdcTokenBase, + // fromAmount: fromAmount, + // toToken: oneInchTokenBase, + // toAmount: toAmount, + // toAmountMin: toAmountMin, + // dexData: dexData + // }); + // + // _callTestWithRouter(swapData, address(baseOrchestratorProxy)); + // } + // + // //////////////////// Arbitrum //////////////////////////// + // //////////////////// Block number 276843772 ////////////// + // + // ////////////////////////////////////////////////////////// + // ////////////////// Sushi Swap /////////////////////////// + // ////////////////////////////////////////////////////////// + // + // //passed + // function test_dexSwapSushiSwapRouterUSDCToUSDT() + // public + // setFork(arbitrumAnvilForkId) + // addRouterInWhiteList(sushiRouterArbitrum, address(arbitrumOrchestratorProxy)) + // { + // uint256 fromAmount = 1e6; //1 usdc + // uint256 toAmount = 0.993041e6; + // uint256 toAmountMin = 0.988075e6; + // + // bytes + // memory dexData = hex"38ed173900000000000000000000000000000000000000000000000000000000000f381a00000000000000000000000000000000000000000000000000000000000f13ac00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673f6a920000000000000000000000000000000000000000000000000000000000000003000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000fd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"; + // + // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + // swapData[0] = IDexSwap.SwapData({ + // dexRouter: sushiRouterArbitrum, + // fromToken: usdcTokenArbitrum, + // fromAmount: fromAmount, + // toToken: usdtTokenArbitrum, + // toAmount: toAmount, + // toAmountMin: toAmountMin, + // dexData: dexData + // }); + // + // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); + // } + // + // //passed + // function test_dexSwapSushiSwapRouterUSDCToWETH() + // public + // setFork(arbitrumAnvilForkId) + // addRouterInWhiteList(sushiRouterArbitrum, address(arbitrumOrchestratorProxy)) + // { + // uint256 fromAmount = 1e6; //1 usdc + // uint256 toAmount = 0.00029991786617675e18; + // uint256 toAmountMin = 0.000298418276845866e18; + // + // bytes + // memory dexData = hex"38ed173900000000000000000000000000000000000000000000000000000000000f381a00000000000000000000000000000000000000000000000000010f68f44ac36b00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673f697d0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1"; + // + // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + // swapData[0] = IDexSwap.SwapData({ + // dexRouter: sushiRouterArbitrum, + // fromToken: usdcTokenArbitrum, + // fromAmount: fromAmount, + // toToken: wethTokenArbitrum, + // toAmount: toAmount, + // toAmountMin: toAmountMin, + // dexData: dexData + // }); + // + // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); + // } + // + // //passed + // function test_dexSwapSushiSwapRouterUSDCToETH() + // public + // setFork(arbitrumAnvilForkId) + // addRouterInWhiteList(sushiRouterArbitrum, address(arbitrumOrchestratorProxy)) + // { + // uint256 fromAmount = 1e6; //usdc + // uint256 toAmount = 0.00029991786617675 ether; + // uint256 toAmountMin = 0.000298418276845866 ether; + // + // bytes + // memory dexData = hex"18cbafe500000000000000000000000000000000000000000000000000000000000f381a00000000000000000000000000000000000000000000000000010f68f44ac36b00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673f69fe0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1"; + // + // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + // swapData[0] = IDexSwap.SwapData({ + // dexRouter: sushiRouterArbitrum, + // fromToken: usdcTokenArbitrum, + // fromAmount: fromAmount, + // toToken: address(0), + // toAmount: toAmount, + // toAmountMin: toAmountMin, + // dexData: dexData + // }); + // + // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); + // } + // + // //passed + // function test_dexSwapSushiSwapRouterETHToUSDC() + // public + // setFork(arbitrumAnvilForkId) + // addRouterInWhiteList(sushiRouterArbitrum, address(arbitrumOrchestratorProxy)) + // { + // uint256 fromAmount = 0.0001 ether; //ETH + // uint256 toAmount = 0.33059e6; //usdc + // uint256 toAmountMin = 0.328937e6; //usdc + // + // bytes + // memory dexData = hex"7ff36ab500000000000000000000000000000000000000000000000000000000000504e90000000000000000000000000000000000000000000000000000000000000080000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673f6b16000000000000000000000000000000000000000000000000000000000000000200000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831"; + // + // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + // swapData[0] = IDexSwap.SwapData({ + // dexRouter: sushiRouterArbitrum, + // fromToken: address(0), + // fromAmount: fromAmount, + // toToken: usdcTokenArbitrum, + // toAmount: toAmount, + // toAmountMin: toAmountMin, + // dexData: dexData + // }); + // + // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); + // } + // + // ////////////////////////////////////////////////////////// + // ////////////////// Uniswap /////////////////////// + // ////////////////////////////////////////////////////////// + // + // //passed + // function test_dexSwapUniSwapRouterUSDCToUSDT() + // public + // setFork(arbitrumAnvilForkId) + // addRouterInWhiteList(uniV3RouterArbitrum, address(arbitrumOrchestratorProxy)) + // { + // uint256 fromAmount = 1e6; //1 usdc + // uint256 toAmount = 0.996903e6; + // uint256 toAmountMin = 0.991918e6; + // + // bytes + // memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681000000000000000000000000000000000000000000000000000001934fbb778500000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000000000000f22af000000000000000000000000000000000000000000000000000000000000002baf88d065e77c8cc2239327c5edb3a432268e5831000064fd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + // + // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + // swapData[0] = IDexSwap.SwapData({ + // dexRouter: uniV3RouterArbitrum, + // fromToken: usdcTokenArbitrum, + // fromAmount: fromAmount, + // toToken: usdtTokenArbitrum, + // toAmount: toAmount, + // toAmountMin: toAmountMin, + // dexData: dexData + // }); + // + // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); + // } + // + // //passed + // function test_dexSwapUniSwapRouterUSDCToWETH() + // public + // setFork(arbitrumAnvilForkId) + // addRouterInWhiteList(uniV3RouterArbitrum, address(arbitrumOrchestratorProxy)) + // { + // uint256 fromAmount = 1e6; //1 usdc + // uint256 toAmount = 0.000299377182115898e18; + // uint256 toAmountMin = 0.000297880296205318e18; + // + // bytes + // memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681000000000000000000000000000000000000000000000000000001934fbd59aa00000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010eebbb0ca1e0000000000000000000000000000000000000000000000000000000000000002baf88d065e77c8cc2239327c5edb3a432268e58310001f482af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + // + // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + // swapData[0] = IDexSwap.SwapData({ + // dexRouter: uniV3RouterArbitrum, + // fromToken: usdcTokenArbitrum, + // fromAmount: fromAmount, + // toToken: wethTokenArbitrum, + // toAmount: toAmount, + // toAmountMin: toAmountMin, + // dexData: dexData + // }); + // + // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); + // } + // + // //passed + // function test_dexSwapUniSwapRouterUSDCToETH() + // public + // setFork(arbitrumAnvilForkId) + // addRouterInWhiteList(uniV3RouterArbitrum, address(arbitrumOrchestratorProxy)) + // { + // uint256 fromAmount = 1e6; //usdc + // uint256 toAmount = 0.000300419724797236 ether; + // uint256 toAmountMin = 0.000298917626173249 ether; + // + // bytes + // memory dexData = hex"ac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001934fb896d900000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010fdd40cbad5d000000000000000000000000000000000000000000000000000000000000002baf88d065e77c8cc2239327c5edb3a432268e58310001f482af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004449404b7c00000000000000000000000000000000000000000000000000010fdd2eecd741000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000"; + // + // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + // swapData[0] = IDexSwap.SwapData({ + // dexRouter: uniV3RouterArbitrum, + // fromToken: usdcTokenArbitrum, + // fromAmount: fromAmount, + // toToken: address(0), + // toAmount: toAmount, + // toAmountMin: toAmountMin, + // dexData: dexData + // }); + // + // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); + // } + // + // //passed + // function test_dexSwapUniSwapRouterETHToUSDC() + // public + // setFork(arbitrumAnvilForkId) + // addRouterInWhiteList(uniV3RouterArbitrum, address(arbitrumOrchestratorProxy)) + // { + // uint256 fromAmount = 0.0001 ether; //ETH + // uint256 toAmount = 0.331996e6; //usdc + // uint256 toAmountMin = 0.330336e6; //usdc + // + // bytes + // memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681000000000000000000000000000000000000000000000000000001934fad171000000000000000000000000000000000000000000000000000005ab8e441cd800000000000000000000000000000000000000000000000000000000000050a60000000000000000000000000000000000000000000000000000000000000002b82af49447d8a07e3bd95bd0d56f35241523fbab10001f4af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + // + // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + // swapData[0] = IDexSwap.SwapData({ + // dexRouter: uniV3RouterArbitrum, + // fromToken: address(0), + // fromAmount: fromAmount, + // toToken: usdcTokenArbitrum, + // toAmount: toAmount, + // toAmountMin: toAmountMin, + // dexData: dexData + // }); + // + // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); + // } + // + // ////////////////////////////////////////////////////////// + // ////////////////// ParaSwap //////////////////////// + // ////////////////////////////////////////////////////////// + // + // //does not work + // function test_dexSwapParaSwapRouterUSDCToUSDT() + // public + // setFork(arbitrumAnvilForkId) + // addRouterInWhiteList(paraSwapV5RouterArbitrum, address(arbitrumOrchestratorProxy)) + // { + // uint256 fromAmount = 1e6; //1 usdc + // uint256 toAmount = 0.996903e6; + // uint256 toAmountMin = 0.991918e6; + // + // bytes + // memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681000000000000000000000000000000000000000000000000000001934fbb778500000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000000000000f22af000000000000000000000000000000000000000000000000000000000000002baf88d065e77c8cc2239327c5edb3a432268e5831000064fd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + // + // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + // swapData[0] = IDexSwap.SwapData({ + // dexRouter: paraSwapV5RouterArbitrum, + // fromToken: usdcTokenArbitrum, + // fromAmount: fromAmount, + // toToken: usdtTokenArbitrum, + // toAmount: toAmount, + // toAmountMin: toAmountMin, + // dexData: dexData + // }); + // + // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); + // } + // + // //does not work + // function test_dexSwapParaSwapRouterUSDCToWETH() public setFork(arbitrumAnvilForkId) { + // _allowRouter(paraSwapV5RouterArbitrum, address(arbitrumOrchestratorProxy)); + // + // uint256 fromAmount = 1e6; //1 usdc + // uint256 toAmount = 0.00029758021792574 ether; + // uint256 toAmountMin = 0.000296092316836111 ether; + // + // bytes + // memory dexData = hex"54e3f31b0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010d4b6f1016c900000000000000000000000000000000000000000000000000010ea5dcf7ba4600000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000003800000000000000000000000000000000000000000000000000000000000000400000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000046000000000000000000000000000000000000000000000000000000000673f779551436a490fb745e4a0a79829c8000ce6000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831000000000000000000000000ed9e3f98bbed560e66b89aac922e29d4596a96420000000000000000000000000000000000000000000000000000000000000108a9059cbb000000000000000000000000ed9e3f98bbed560e66b89aac922e29d4596a964200000000000000000000000000000000000000000000000000000000000f387e7dc20382000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000f387e0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee57000000000000000000000000d5b927956057075377263aab7f8afc12f85100db00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000001080000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + // + // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + // swapData[0] = IDexSwap.SwapData({ + // dexRouter: paraSwapV5RouterArbitrum, + // fromToken: usdcTokenArbitrum, + // fromAmount: fromAmount, + // toToken: wethTokenArbitrum, + // toAmount: toAmount, + // toAmountMin: toAmountMin, + // dexData: dexData + // }); + // + // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); + // } + // + // //does not work + // function test_dexSwapParaSwapRouterUSDCToETH() + // public + // setFork(arbitrumAnvilForkId) + // addRouterInWhiteList(paraSwapV5RouterArbitrum, address(arbitrumOrchestratorProxy)) + // { + // uint256 fromAmount = 1e6; //usdc + // uint256 toAmount = 0.000300419724797236 ether; + // uint256 toAmountMin = 0.000298917626173249 ether; + // + // bytes + // memory dexData = hex"ac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001934fb896d900000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010fdd40cbad5d000000000000000000000000000000000000000000000000000000000000002baf88d065e77c8cc2239327c5edb3a432268e58310001f482af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004449404b7c00000000000000000000000000000000000000000000000000010fdd2eecd741000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000"; + // + // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + // swapData[0] = IDexSwap.SwapData({ + // dexRouter: paraSwapV5RouterArbitrum, + // fromToken: usdcTokenArbitrum, + // fromAmount: fromAmount, + // toToken: address(0), + // toAmount: toAmount, + // toAmountMin: toAmountMin, + // dexData: dexData + // }); + // + // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); + // } + // + // //does not work + // function test_dexSwapParaSwapRouterETHToUSDC() + // public + // setFork(arbitrumAnvilForkId) + // addRouterInWhiteList(paraSwapV5RouterArbitrum, address(arbitrumOrchestratorProxy)) + // { + // uint256 fromAmount = 0.001 ether; //ETH + // uint256 toAmount = 3.334998e6; //usdc + // uint256 toAmountMin = 3.318323e6; //usdc + // + // bytes + // memory dexData = hex"54e3f31b0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000038b38ea920700000000000000000000000000000000000000000000000000000000000032a1e5000000000000000000000000000000000000000000000000000000000032e30700000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000003a00000000000000000000000000000000000000000000000000000000000000440000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc356810000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000004c000000000000000000000000000000000000000000000000000000000673f7930962cd732e34c45a093489154807ea37000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000ed9e3f98bbed560e66b89aac922e29d4596a9642000000000000000000000000000000000000000000000000000000000000010cd0e30db0a9059cbb000000000000000000000000ed9e3f98bbed560e66b89aac922e29d4596a964200000000000000000000000000000000000000000000000000038b38ea9207007dc2038200000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000038b38ea9207000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee57000000000000000000000000d5b927956057075377263aab7f8afc12f85100db00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000048000000000000000000000000000000000000000000000000000000000000010c000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000038b38ea920700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + // + // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + // swapData[0] = IDexSwap.SwapData({ + // dexRouter: paraSwapV5RouterArbitrum, + // fromToken: address(0), + // fromAmount: fromAmount, + // toToken: usdcTokenArbitrum, + // toAmount: toAmount, + // toAmountMin: toAmountMin, + // dexData: dexData + // }); + // + // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); + // } + // + // //////////////////// Polygon //////////////////////////// + // //////////////////// Block number 64588691 ////////////// + // + // ////////////////////////////////////////////////////////// + // ////////////////// Quick Swap //////////////////// + // ////////////////////////////////////////////////////////// + // + // //passed + // function test_dexSwapQuickSwapRouterUSDCToWETH() + // public + // setFork(polygonAnvilForkId) + // addRouterInWhiteList(quickSwapRouterPolygon, address(polygonOrchestratorProxy)) + // { + // uint256 fromAmount = 1e6; //1 usdc + // uint256 toAmount = 0.000294773721275645e18; + // uint256 toAmountMin = 0.000293299852669266e18; + // + // bytes + // memory dexData = hex"38ed173900000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010ac13a4b12cf00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681000000000000000000000000000000000000000000000000000000006740511a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c33590000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f619"; + // + // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + // swapData[0] = IDexSwap.SwapData({ + // dexRouter: quickSwapRouterPolygon, + // fromToken: usdcTokenPolygon, + // fromAmount: fromAmount, + // toToken: wethTokenPolygon, + // toAmount: toAmount, + // toAmountMin: toAmountMin, + // dexData: dexData + // }); + // + // _callTestWithRouter(swapData, address(polygonOrchestratorProxy)); + // } + // + // //passed + // function test_dexSwapQuickSwapRouterPOLToUSDC() + // public + // setFork(polygonAnvilForkId) + // addRouterInWhiteList(quickSwapRouterPolygon, address(polygonOrchestratorProxy)) + // { + // uint256 fromAmount = 0.001e18; //POL + // uint256 toAmount = 0.000457e6; //usdc + // uint256 toAmountMin = 0.000454e6; //usdc + // + // bytes + // memory dexData = hex"7ff36ab500000000000000000000000000000000000000000000000000000000000001c70000000000000000000000000000000000000000000000000000000000000080000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000674056ac00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf12700000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c3359"; + // + // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + // swapData[0] = IDexSwap.SwapData({ + // dexRouter: quickSwapRouterPolygon, + // fromToken: POL_TOKEN, + // fromAmount: fromAmount, + // toToken: usdcTokenPolygon, + // toAmount: toAmount, + // toAmountMin: toAmountMin, + // dexData: dexData + // }); + // + // _callTestWithRouter(swapData, address(polygonOrchestratorProxy)); + // } + // + // //passed + // function test_dexSwapQuickSwapRouterUSDCToPOL() + // public + // setFork(polygonAnvilForkId) + // addRouterInWhiteList(quickSwapRouterPolygon, address(polygonOrchestratorProxy)) + // { + // uint256 fromAmount = 1e6; //usdc + // uint256 toAmount = 2.16620982591814043e18; //pol + // uint256 toAmountMin = 2.155378776788549727e18; //pol + // + // bytes + // memory dexData = hex"18cbafe500000000000000000000000000000000000000000000000000000000000f387e0000000000000000000000000000000000000000000000001de9728f133bb56100000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000674057b000000000000000000000000000000000000000000000000000000000000000020000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c33590000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf1270"; + // + // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + // swapData[0] = IDexSwap.SwapData({ + // dexRouter: quickSwapRouterPolygon, + // fromToken: usdcTokenPolygon, + // fromAmount: fromAmount, + // toToken: POL_TOKEN, + // toAmount: toAmount, + // toAmountMin: toAmountMin, + // dexData: dexData + // }); + // + // _callTestWithRouter(swapData, address(polygonOrchestratorProxy)); + // } + // + // //////////////////// Avalanche //////////////////////////// + // //////////////////// Block number 53397798 ////////////// + // + // ////////////////////////////////////////////////////////// + // ////////////////// Pangolin Swap ///////////////// + // ////////////////////////////////////////////////////////// + // + // //doesnt work + // function test_dexSwapPangolinSwapRouterUSDCToWAVAX() + // public + // setFork(avalancheAnvilForkId) + // addRouterInWhiteList(pangolinRouterAvalanche, address(avalancheOrchestratorProxy)) + // { + // uint256 fromAmount = 1e6; //1 usdc + // uint256 toAmount = 0.027249956050478939e18; + // uint256 toAmountMin = 0.027113706270226544e18; + // + // bytes + // memory dexData = hex"38ed173900000000000000000000000000000000000000000000000000000000000f387e000000000000000000000000000000000000000000000000006053c8d8cb68b600000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000674060d40000000000000000000000000000000000000000000000000000000000000003000000000000000000000000b97ef9ef8734c71904d8002f8b6bc66dd9c48a6e00000000000000000000000060781c2586d68229fde47564546784ab3faca982000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c7"; + // + // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + // swapData[0] = IDexSwap.SwapData({ + // dexRouter: pangolinRouterAvalanche, + // fromToken: usdcTokenAvalanche, + // fromAmount: fromAmount, + // toToken: wavaxTokenAvalanche, + // toAmount: toAmount, + // toAmountMin: toAmountMin, + // dexData: dexData + // }); + // + // _callTestWithRouter(swapData, address(avalancheOrchestratorProxy)); + // } + // + // ////////////////////////////////////////////////////////// + // ////////////////// Utils ///////////////////////// + // ////////////////////////////////////////////////////////// + // + // function _callTestWithRouter(IDexSwap.SwapData[] memory swapData, address proxy) internal { + // console.log("block.number", block.number); + // console.log("fromAmount: ", swapData[0].fromAmount); + // console.log("toAmount: ", swapData[0].toAmount); + // console.log("toAmountMin: ", swapData[0].toAmountMin); + // + // InfraOrchestrator orchestrator = InfraOrchestrator(payable(proxy)); + // + // IInfraOrchestrator.Integration memory integration = IInfraOrchestrator.Integration({ + // integrator: integrator, + // feeBps: 0 + // }); + // bool isFromNative = swapData[0].fromToken == address(0); + // bool isToNative = swapData[0].toToken == address(0); + // + // uint256 userBalanceFromTokenBefore; + // uint256 userBalanceFromTokenAfter; + // uint256 userBalanceToTokenBefore; + // uint256 userBalanceToTokenAfter; + // + // if (isFromNative && !isToNative) { + // deal(sender, swapData[0].fromAmount); + // + // userBalanceFromTokenBefore = sender.balance; + // userBalanceToTokenBefore = IERC20(swapData[0].toToken).balanceOf(sender); + // + // vm.prank(sender); + // orchestrator.swap{value: swapData[0].fromAmount}(swapData, sender, integration); + // + // userBalanceFromTokenAfter = sender.balance; + // userBalanceToTokenAfter = IERC20(swapData[0].toToken).balanceOf(sender); + // } else if (isToNative && !isFromNative) { + // _dealERC20AndApprove(swapData[0].fromToken, sender, swapData[0].fromAmount, proxy); + // + // userBalanceFromTokenBefore = IERC20(swapData[0].fromToken).balanceOf(sender); + // userBalanceToTokenBefore = sender.balance; + // + // vm.prank(sender); + // orchestrator.swap(swapData, sender, integration); + // + // userBalanceFromTokenAfter = IERC20(swapData[0].fromToken).balanceOf(sender); + // userBalanceToTokenAfter = sender.balance; + // } else if (!isFromNative && !isToNative) { + // _dealERC20AndApprove(swapData[0].fromToken, sender, swapData[0].fromAmount, proxy); + // + // userBalanceFromTokenBefore = IERC20(swapData[0].fromToken).balanceOf(sender); + // userBalanceToTokenBefore = IERC20(swapData[0].toToken).balanceOf(sender); + // + // vm.prank(sender); + // orchestrator.swap(swapData, sender, integration); + // + // userBalanceFromTokenAfter = IERC20(swapData[0].fromToken).balanceOf(sender); + // userBalanceToTokenAfter = IERC20(swapData[0].toToken).balanceOf(sender); + // } + // + // console.log("userBalanceFromTokenBefore: ", userBalanceFromTokenBefore); + // console.log("userBalanceFromTokenAfter: ", userBalanceFromTokenAfter); + // console.log("userBalanceToTokenBefore: ", userBalanceToTokenBefore); + // console.log("userBalanceToTokenAfter: ", userBalanceToTokenAfter); + // + // assertGt(userBalanceToTokenAfter, userBalanceToTokenBefore); + // assertLt(userBalanceFromTokenAfter, userBalanceFromTokenBefore); + // } + // + // function _allowRouter(address router, address orchestratorProxy) internal { + // vm.prank(deployer); + // (bool success, ) = address(orchestratorProxy).call( + // abi.encodeWithSignature("setDexRouterAddress(address,bool)", router, true) + // ); + // /// @dev assert it is set correctly + // (, bytes memory returnData) = address(orchestratorProxy).call( + // abi.encodeWithSignature("s_routerAllowed(address)", router) + // ); + // bool returnedValue = abi.decode(returnData, (bool)); + // assertEq(returnedValue, true); + // } + // + // function _dealERC20AndApprove( + // address token, + // address _caller, + // uint256 _amount, + // address proxy + // ) internal { + // deal(token, _caller, _amount); + // vm.prank(_caller); + // IERC20(token).approve(proxy, _amount); + // } +} diff --git a/test/foundry/ParentPool/Deposit.t.sol b/test/foundry/ParentPool/Deposit.t.sol index eb5a4d66..df37e4ab 100644 --- a/test/foundry/ParentPool/Deposit.t.sol +++ b/test/foundry/ParentPool/Deposit.t.sol @@ -34,7 +34,7 @@ contract Deposit is BaseTest { SETUP //////////////////////////////////////////////////////////////*/ function setUp() public virtual override { - vm.selectFork(baseAnvilForkId); + vm.selectFork(baseForkId); deployParentPoolProxy(); deployLpToken(); diff --git a/test/foundry/ParentPool/Withdraw.t.sol b/test/foundry/ParentPool/Withdraw.t.sol index 5106a071..b40fef43 100644 --- a/test/foundry/ParentPool/Withdraw.t.sol +++ b/test/foundry/ParentPool/Withdraw.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.20; -import {VmSafe} from "forge-std/Vm.sol"; +import {VmSafe} from "forge-std/src/Vm.sol"; import {BaseTest, console} from "../utils/BaseTest.t.sol"; import {Client} from "@chainlink/contracts-ccip/src/v0.8/ccip/libraries/Client.sol"; import {FunctionsClient} from "@chainlink/contracts/src/v0.8/functions/v1_0_0/FunctionsClient.sol"; @@ -35,7 +35,7 @@ contract WithdrawTest is BaseTest { SETUP //////////////////////////////////////////////////////////////*/ function setUp() public virtual override { - vm.selectFork(baseAnvilForkId); + vm.selectFork(baseForkId); deployParentPoolProxy(); deployLpToken(); diff --git a/test/foundry/ParentPool/unitTests/CalculateLpTokensToMint.t.sol b/test/foundry/ParentPool/unitTests/CalculateLpTokensToMint.t.sol index 20f0273b..7aa4cdc4 100644 --- a/test/foundry/ParentPool/unitTests/CalculateLpTokensToMint.t.sol +++ b/test/foundry/ParentPool/unitTests/CalculateLpTokensToMint.t.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.20; import {BaseTest} from "../../utils/BaseTest.t.sol"; -import {Test, console, Vm} from "forge-std/Test.sol"; +import {Test, console, Vm} from "forge-std/src/Test.sol"; import {ParentPoolWrapper} from "../wrappers/ParentPoolWrapper.sol"; import {ParentPool} from "contracts/ParentPool.sol"; @@ -17,7 +17,7 @@ contract CalculateLpTokensToMintTest is BaseTest { SETUP //////////////////////////////////////////////////////////////*/ function setUp() public virtual override { - vm.selectFork(baseAnvilForkId); + vm.selectFork(baseForkId); deployParentPoolProxy(); deployLpToken(); diff --git a/test/foundry/ParentPool/unitTests/IsMessenger.t.sol b/test/foundry/ParentPool/unitTests/IsMessenger.t.sol index abae5a56..9cc5f41b 100644 --- a/test/foundry/ParentPool/unitTests/IsMessenger.t.sol +++ b/test/foundry/ParentPool/unitTests/IsMessenger.t.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.0; import {BaseTest} from "../../utils/BaseTest.t.sol"; import {ParentPoolDepositWrapper, IDepositParentPool} from "../wrappers/ParentPoolDepositWrapper.sol"; -import {Test, console, Vm} from "forge-std/Test.sol"; +import {Test, console, Vm} from "forge-std/src/Test.sol"; contract IsMessengerTest is BaseTest { address messenger1 = vm.envAddress("POOL_MESSENGER_0_ADDRESS"); @@ -13,7 +13,7 @@ contract IsMessengerTest is BaseTest { uint8 slotId = 0; function setUp() public override { - vm.selectFork(baseAnvilForkId); + vm.selectFork(baseForkId); deployParentPoolProxy(); parentPoolImplementation = new ParentPoolDepositWrapper( address(parentPoolProxy), diff --git a/test/foundry/Swap/DexSwap.t.sol b/test/foundry/Swap/DexSwap.t.sol deleted file mode 100644 index e8f7da89..00000000 --- a/test/foundry/Swap/DexSwap.t.sol +++ /dev/null @@ -1,878 +0,0 @@ -// SPDX-License-Identifier: SEE LICENSE IN LICENSE -pragma solidity ^0.8.20; - -import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import {console} from "forge-std/Test.sol"; -import {BaseTest} from "../utils/BaseTest.t.sol"; -import {IDexSwap} from "../../../contracts/Interfaces/IDexSwap.sol"; -import {IInfraOrchestrator} from "../../../contracts/Interfaces/IInfraOrchestrator.sol"; -import {InfraOrchestrator} from "../../../contracts/InfraOrchestrator.sol"; - -contract DexSwapTest is BaseTest { - address internal constant ETH_TOKEN = address(0); - address internal constant POL_TOKEN = address(0); - - // Base tokens - address internal usdcTokenBase = vm.envAddress("USDC_BASE"); - address internal wethTokenBase = vm.envAddress("WETH_BASE"); - address internal daiTokenBase = vm.envAddress("DAI_BASE"); - address internal sushiTokenBase = vm.envAddress("SUSHI_BASE"); - address internal oneInchTokenBase = vm.envAddress("1INCH_BASE"); - - //Arbitrum tokens - address internal usdcTokenArbitrum = vm.envAddress("USDC_ARBITRUM"); - address internal usdtTokenArbitrum = vm.envAddress("USDT_ARBITRUM"); - address internal wethTokenArbitrum = vm.envAddress("WETH_ARBITRUM"); - - //Polygon tokens - address internal usdcTokenPolygon = vm.envAddress("USDC_POLYGON"); - address internal wethTokenPolygon = vm.envAddress("WETH_POLYGON"); - - //Avalanche tokens - address internal usdcTokenAvalanche = vm.envAddress("USDC_AVALANCHE"); - address internal wavaxTokenAvalanche = vm.envAddress("WAVAX_AVALANCHE"); - - //Arbitrum Routers - address internal sushiRouterArbitrum = vm.envAddress("SUSHISWAP_ROUTER_ARBITRUM_ADDRESS"); - address internal uniV3RouterArbitrum = vm.envAddress("UNI_V3_ROUTER_ARBITRUM_ADDRESS"); - address internal paraSwapV5RouterArbitrum = - vm.envAddress("PARASWAP_V5_ROUTER_ARBITRUM_ADDRESS"); - - //Base Routers - address internal uniV3RouterBase = vm.envAddress("UNI_V3_ROUTER02_BASE_ADDRESS"); - address internal paraSwapV6_2RouterBase = vm.envAddress("PARASWAP_V6_2_ROUTER_BASE_ADDRESS"); - address internal odosRouterV2Base = vm.envAddress("ODOS_ROUTER_V2_BASE_ADDRESS"); - address internal oneInchRouterV5Base = vm.envAddress("1INCH_ROUTER_V5_BASE_ADDRESS"); - address internal curveRouterBase = vm.envAddress("CURVE_ROUTER_BASE_ADDRESS"); - address internal alienbaseRouterBase = vm.envAddress("ALIENBASE_ROUTER_BASE_ADDRESS"); - - //Polygon Routers - address internal quickSwapRouterPolygon = vm.envAddress("QUICKSWAP_ROUTER_POLYGON_ADDRESS"); - - //Avalanche Routers - address internal pangolinRouterAvalanche = vm.envAddress("PANGOLIN_ROUTER_AVALANCHE_ADDRESS"); - - address payable internal sender = payable(makeAddr("sender")); - address internal integrator = makeAddr("integrator"); - - modifier addRouterInWhiteList(address router, address proxy) { - _allowRouter(router, address(proxy)); - _; - } - - function setUp() public override setFork(polygonAnvilForkId) { - super.setUp(); - } - - //////////////////// Base /////////////////////////////// - //////////////////// Block number 22713659 ////////////// - - ////////////////////////////////////////////////////////// - ////////////////// Alienbase //////////////////// - ////////////////////////////////////////////////////////// - - //passed - function test_dexSwapAlienbaseRouterETHToUSDCBase() - public - setFork(baseAnvilForkId) - addRouterInWhiteList(alienbaseRouterBase, address(baseOrchestratorProxy)) - { - uint256 fromAmount = 0.1 ether; - uint256 toAmount = 267.528449e6; - uint256 toAmountMin = 266.190806e6; - - bytes - memory dexData = hex"7ff36ab5000000000000000000000000000000000000000000000000000000000fddbfd70000000000000000000000000000000000000000000000000000000000000080000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673fb53400000000000000000000000000000000000000000000000000000000000000020000000000000000000000004200000000000000000000000000000000000006000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913"; - - IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - swapData[0] = IDexSwap.SwapData({ - dexRouter: alienbaseRouterBase, - fromToken: ETH_TOKEN, - fromAmount: fromAmount, - toToken: usdcTokenBase, - toAmount: toAmount, - toAmountMin: toAmountMin, - dexData: dexData - }); - - _callTestWithRouter(swapData, address(baseOrchestratorProxy)); - } - - //passed - function test_dexSwapAlienbaseRouterUSDCToWETHBase() - public - setFork(baseAnvilForkId) - addRouterInWhiteList(alienbaseRouterBase, address(baseOrchestratorProxy)) - { - uint256 fromAmount = 10e6; //10 usdc - uint256 toAmount = 0.002945698049459263e18; - uint256 toAmountMin = 0.002930969559211966e18; - - bytes - memory dexData = hex"38ed173900000000000000000000000000000000000000000000000000000000009834e7000000000000000000000000000000000000000000000000000a69b3876c9fbe00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673fb6140000000000000000000000000000000000000000000000000000000000000002000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000004200000000000000000000000000000000000006"; - - IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - swapData[0] = IDexSwap.SwapData({ - dexRouter: alienbaseRouterBase, - fromToken: usdcTokenBase, - fromAmount: fromAmount, - toToken: wethTokenBase, - toAmount: toAmount, - toAmountMin: toAmountMin, - dexData: dexData - }); - - _callTestWithRouter(swapData, address(baseOrchestratorProxy)); - } - - //passed - function test_dexSwapAlienbaseRouterUSDCToETHBase() - public - setFork(baseAnvilForkId) - addRouterInWhiteList(alienbaseRouterBase, address(baseOrchestratorProxy)) - { - uint256 fromAmount = 10e6; - uint256 toAmount = 0.002945698049459263 ether; - uint256 toAmountMin = 0.002930969559211966 ether; - - bytes - memory dexData = hex"18cbafe500000000000000000000000000000000000000000000000000000000009834e7000000000000000000000000000000000000000000000000000a69b3876c9fbe00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673fb67c0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000004200000000000000000000000000000000000006"; - - IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - swapData[0] = IDexSwap.SwapData({ - dexRouter: alienbaseRouterBase, - fromToken: usdcTokenBase, - fromAmount: fromAmount, - toToken: ETH_TOKEN, - toAmount: toAmount, - toAmountMin: toAmountMin, - dexData: dexData - }); - - _callTestWithRouter(swapData, address(baseOrchestratorProxy)); - } - - ////////////////////////////////////////////////////////// - ////////////////// Curve //////////////////////// - ////////////////////////////////////////////////////////// - - //passed - function test_dexSwapCurveRouterUSDCToWETHBase() - public - setFork(baseAnvilForkId) - addRouterInWhiteList(curveRouterBase, address(baseOrchestratorProxy)) - { - uint256 fromAmount = 10e6; //1 usdc - uint256 toAmount = 0.002950528095025959e18; - uint256 toAmountMin = 0.002935775454550829e18; - - bytes - memory dexData = hex"c872a3c5000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f000000000000000000000000417ac0e078398c154edfadd9ef675d30be60af930000000000000000000000006e53131f68a034873b6bfa15502af094ef0c58540000000000000000000000004200000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009834e7000000000000000000000000000000000000000000000000000a6e127d1bdb2d000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f0000000000000000000000006e53131f68a034873b6bfa15502af094ef0c5854000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681"; - - IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - swapData[0] = IDexSwap.SwapData({ - dexRouter: curveRouterBase, - fromToken: usdcTokenBase, - fromAmount: fromAmount, - toToken: wethTokenBase, - toAmount: toAmount, - toAmountMin: toAmountMin, - dexData: dexData - }); - - _callTestWithRouter(swapData, address(baseOrchestratorProxy)); - } - - //not working - function test_dexSwapCurveRouterETHToUSDCBase() - public - setFork(baseAnvilForkId) - addRouterInWhiteList(curveRouterBase, address(baseOrchestratorProxy)) - { - uint256 fromAmount = 0.0003 ether; - uint256 toAmount = 0.993336e6; - uint256 toAmountMin = 0.988369e6; - - bytes - memory dexData = hex"c872a3c5000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000420000000000000000000000000000000000000600000000000000000000000042000000000000000000000000000000000000060000000000000000000000006e53131f68a034873b6bfa15502af094ef0c5854000000000000000000000000417ac0e078398c154edfadd9ef675d30be60af93000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001102aacc5688000000000000000000000000000000000000000000000000000000000000f14d100000000000000000000000042000000000000000000000000000000000000060000000000000000000000006e53131f68a034873b6bfa15502af094ef0c5854000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681"; - - IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - swapData[0] = IDexSwap.SwapData({ - dexRouter: curveRouterBase, - fromToken: ETH_TOKEN, - fromAmount: fromAmount, - toToken: usdcTokenBase, - toAmount: toAmount, - toAmountMin: toAmountMin, - dexData: dexData - }); - - _callTestWithRouter(swapData, address(baseOrchestratorProxy)); - } - - //passed - function test_dexSwapCurveRouterUSDCToETHBase() - public - setFork(baseAnvilForkId) - addRouterInWhiteList(curveRouterBase, address(baseOrchestratorProxy)) - { - uint256 fromAmount = 1e6; - uint256 toAmount = 0.00029502055232845 ether; - uint256 toAmountMin = 0.000293545449566807 ether; - - bytes - memory dexData = hex"c872a3c5000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f000000000000000000000000417ac0e078398c154edfadd9ef675d30be60af930000000000000000000000006e53131f68a034873b6bfa15502af094ef0c585400000000000000000000000042000000000000000000000000000000000000060000000000000000000000004200000000000000000000000000000000000006000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010afa71c98c9d000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f0000000000000000000000006e53131f68a034873b6bfa15502af094ef0c5854000000000000000000000000420000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681"; - - IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - swapData[0] = IDexSwap.SwapData({ - dexRouter: curveRouterBase, - fromToken: usdcTokenBase, - fromAmount: fromAmount, - toToken: ETH_TOKEN, - toAmount: toAmount, - toAmountMin: toAmountMin, - dexData: dexData - }); - - _callTestWithRouter(swapData, address(baseOrchestratorProxy)); - } - - ////////////////////////////////////////////////////////// - ////////////////// Odos Router V2 //////////////////////// - ////////////////////////////////////////////////////////// - - //passed - function test_dexSwapOdosRouterV2USDCToWETHBase() - public - setFork(baseAnvilForkId) - addRouterInWhiteList(odosRouterV2Base, address(baseOrchestratorProxy)) - { - uint256 fromAmount = 1e6; //1 usdc - uint256 toAmount = 0.000295473686245412e18; - uint256 toAmountMin = 0.000293996317814184e18; - - bytes - memory dexData = hex"83bd37f900040002030f387e07010cbb65c26b5000c49b00017882570840a97a490a37bd8db9e1ae39165bfbd600000001cd1722f3947def4cf144679da39c4c32bdc356810000000003010203000a0101010200ff000000000000000000000000000000000000000000883e4ae0a817f2901500971b353b5dd89aa52184833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000000000000000000000000000"; - - IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - swapData[0] = IDexSwap.SwapData({ - dexRouter: odosRouterV2Base, - fromToken: usdcTokenBase, - fromAmount: fromAmount, - toToken: wethTokenBase, - toAmount: toAmount, - toAmountMin: toAmountMin, - dexData: dexData - }); - - _callTestWithRouter(swapData, address(baseOrchestratorProxy)); - } - - //doesnt work with native - function test_dexSwapOdosRouterV2ETHToUSDCBase() - public - setFork(baseAnvilForkId) - addRouterInWhiteList(odosRouterV2Base, address(baseOrchestratorProxy)) - { - uint256 fromAmount = 0.001 ether; - uint256 toAmount = 3.355603e6; - uint256 toAmountMin = 3.338824e6; - - bytes - memory dexData = hex"83bd37f90000000407038b38ea920700033333d300c49b00017882570840a97a490a37bd8db9e1ae39165bfbd600000001cd1722f3947def4cf144679da39c4c32bdc35681000000000301020300040101022b000101010201ff000000000000000000000000000000005b52dfa81e7409df9390c9403aceb51ea3df4f204200000000000000000000000000000000000006000000000000000000000000000000000000000000000000"; - - IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - swapData[0] = IDexSwap.SwapData({ - dexRouter: odosRouterV2Base, - fromToken: ETH_TOKEN, - fromAmount: fromAmount, - toToken: usdcTokenBase, - toAmount: toAmount, - toAmountMin: toAmountMin, - dexData: dexData - }); - - _callTestWithRouter(swapData, address(baseOrchestratorProxy)); - } - - ////////////////////////////////////////////////////////// - ////////////////// 1Inch //////////////////////// - ////////////////////////////////////////////////////////// - - function test_dexSwap1InchV5USDCTo1InchTokenBase() - public - setFork(baseAnvilForkId) - addRouterInWhiteList(oneInchRouterV5Base, address(baseOrchestratorProxy)) - { - uint256 fromAmount = 10e6; //10 usdc - uint256 toAmount = 29.186618652079786377e18; - uint256 toAmountMin = 29.040685558819387445e18; - - bytes - memory dexData = hex"12aa3caf000000000000000000000000e37e799d5077682fa0a244d46e5649f71457bd09000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000c5fecc3a29fb57b5024eec8a2239d4621e111cbe000000000000000000000000e37e799d5077682fa0a244d46e5649f71457bd09000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000009834e700000000000000000000000000000000000000000000000193053da6cf3ef835000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004af00000000000000000000000000000000000000000000000000000000049100a007e5c0d200000000000000000000000000000000000000000000046d00040a0003f0512003c01acae3d0173a93d819efdc832c7c4f153b06833589fcd6edb6e08f4c7c32d4f71b54bda02913016452bbbe2900000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000e37e799d5077682fa0a244d46e5649f71457bd090000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e37e799d5077682fa0a244d46e5649f71457bd090000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000673f9a44def66c6c178087fd931514e99b04479e4d3d956c0002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009834e700000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000062769914a469c00000000000000000000000000000000000000000000000000000000673f9a4400000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000005af3107a400000000000000000b671b09bd7eb7a242300000000000000008bd0c186893c2c000000000000000dd975ede04e7dbbc0000000000000000005aab64d6906dbaed800000000000000000000000000000000000000000004ee7259d6914ae6c461bc00000000000000004563918244f400000000000000000000006a94d74f430000000000000000000000000000673f99ea000000000000000000003b1dfde910000000000000000000000000000000000000000000000000000000000000000041b0087e9968881cc03a4f3270b3086fd3a18f6587c3179ad985c8c406056d7b98035f5800bbb63a992a30c39c7224be035751091573a74d263682a8536b8d51711c0000000000000000000000000000000000000000000000000000000000000040414200000000000000000000000000000000000006d0e30db002a000000000000000000000000000000000000000000000000190fec846c67c66e1ee63c1e5814af5a3adb853290bc9f909138fbf1a3c3feb086842000000000000000000000000000000000000061111111254eeb25477b68fb85ed929f73a96058200000000000000000000000000000000007787a5c8"; - - IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - swapData[0] = IDexSwap.SwapData({ - dexRouter: oneInchRouterV5Base, - fromToken: usdcTokenBase, - fromAmount: fromAmount, - toToken: oneInchTokenBase, - toAmount: toAmount, - toAmountMin: toAmountMin, - dexData: dexData - }); - - _callTestWithRouter(swapData, address(baseOrchestratorProxy)); - } - - //////////////////// Arbitrum //////////////////////////// - //////////////////// Block number 276843772 ////////////// - - ////////////////////////////////////////////////////////// - ////////////////// Sushi Swap /////////////////////////// - ////////////////////////////////////////////////////////// - - //passed - function test_dexSwapSushiSwapRouterUSDCToUSDT() - public - setFork(arbitrumAnvilForkId) - addRouterInWhiteList(sushiRouterArbitrum, address(arbitrumOrchestratorProxy)) - { - uint256 fromAmount = 1e6; //1 usdc - uint256 toAmount = 0.993041e6; - uint256 toAmountMin = 0.988075e6; - - bytes - memory dexData = hex"38ed173900000000000000000000000000000000000000000000000000000000000f381a00000000000000000000000000000000000000000000000000000000000f13ac00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673f6a920000000000000000000000000000000000000000000000000000000000000003000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000fd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"; - - IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - swapData[0] = IDexSwap.SwapData({ - dexRouter: sushiRouterArbitrum, - fromToken: usdcTokenArbitrum, - fromAmount: fromAmount, - toToken: usdtTokenArbitrum, - toAmount: toAmount, - toAmountMin: toAmountMin, - dexData: dexData - }); - - _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - } - - //passed - function test_dexSwapSushiSwapRouterUSDCToWETH() - public - setFork(arbitrumAnvilForkId) - addRouterInWhiteList(sushiRouterArbitrum, address(arbitrumOrchestratorProxy)) - { - uint256 fromAmount = 1e6; //1 usdc - uint256 toAmount = 0.00029991786617675e18; - uint256 toAmountMin = 0.000298418276845866e18; - - bytes - memory dexData = hex"38ed173900000000000000000000000000000000000000000000000000000000000f381a00000000000000000000000000000000000000000000000000010f68f44ac36b00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673f697d0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1"; - - IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - swapData[0] = IDexSwap.SwapData({ - dexRouter: sushiRouterArbitrum, - fromToken: usdcTokenArbitrum, - fromAmount: fromAmount, - toToken: wethTokenArbitrum, - toAmount: toAmount, - toAmountMin: toAmountMin, - dexData: dexData - }); - - _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - } - - //passed - function test_dexSwapSushiSwapRouterUSDCToETH() - public - setFork(arbitrumAnvilForkId) - addRouterInWhiteList(sushiRouterArbitrum, address(arbitrumOrchestratorProxy)) - { - uint256 fromAmount = 1e6; //usdc - uint256 toAmount = 0.00029991786617675 ether; - uint256 toAmountMin = 0.000298418276845866 ether; - - bytes - memory dexData = hex"18cbafe500000000000000000000000000000000000000000000000000000000000f381a00000000000000000000000000000000000000000000000000010f68f44ac36b00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673f69fe0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1"; - - IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - swapData[0] = IDexSwap.SwapData({ - dexRouter: sushiRouterArbitrum, - fromToken: usdcTokenArbitrum, - fromAmount: fromAmount, - toToken: address(0), - toAmount: toAmount, - toAmountMin: toAmountMin, - dexData: dexData - }); - - _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - } - - //passed - function test_dexSwapSushiSwapRouterETHToUSDC() - public - setFork(arbitrumAnvilForkId) - addRouterInWhiteList(sushiRouterArbitrum, address(arbitrumOrchestratorProxy)) - { - uint256 fromAmount = 0.0001 ether; //ETH - uint256 toAmount = 0.33059e6; //usdc - uint256 toAmountMin = 0.328937e6; //usdc - - bytes - memory dexData = hex"7ff36ab500000000000000000000000000000000000000000000000000000000000504e90000000000000000000000000000000000000000000000000000000000000080000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673f6b16000000000000000000000000000000000000000000000000000000000000000200000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831"; - - IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - swapData[0] = IDexSwap.SwapData({ - dexRouter: sushiRouterArbitrum, - fromToken: address(0), - fromAmount: fromAmount, - toToken: usdcTokenArbitrum, - toAmount: toAmount, - toAmountMin: toAmountMin, - dexData: dexData - }); - - _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - } - - ////////////////////////////////////////////////////////// - ////////////////// Uniswap /////////////////////// - ////////////////////////////////////////////////////////// - - //passed - function test_dexSwapUniSwapRouterUSDCToUSDT() - public - setFork(arbitrumAnvilForkId) - addRouterInWhiteList(uniV3RouterArbitrum, address(arbitrumOrchestratorProxy)) - { - uint256 fromAmount = 1e6; //1 usdc - uint256 toAmount = 0.996903e6; - uint256 toAmountMin = 0.991918e6; - - bytes - memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681000000000000000000000000000000000000000000000000000001934fbb778500000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000000000000f22af000000000000000000000000000000000000000000000000000000000000002baf88d065e77c8cc2239327c5edb3a432268e5831000064fd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; - - IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - swapData[0] = IDexSwap.SwapData({ - dexRouter: uniV3RouterArbitrum, - fromToken: usdcTokenArbitrum, - fromAmount: fromAmount, - toToken: usdtTokenArbitrum, - toAmount: toAmount, - toAmountMin: toAmountMin, - dexData: dexData - }); - - _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - } - - //passed - function test_dexSwapUniSwapRouterUSDCToWETH() - public - setFork(arbitrumAnvilForkId) - addRouterInWhiteList(uniV3RouterArbitrum, address(arbitrumOrchestratorProxy)) - { - uint256 fromAmount = 1e6; //1 usdc - uint256 toAmount = 0.000299377182115898e18; - uint256 toAmountMin = 0.000297880296205318e18; - - bytes - memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681000000000000000000000000000000000000000000000000000001934fbd59aa00000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010eebbb0ca1e0000000000000000000000000000000000000000000000000000000000000002baf88d065e77c8cc2239327c5edb3a432268e58310001f482af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; - - IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - swapData[0] = IDexSwap.SwapData({ - dexRouter: uniV3RouterArbitrum, - fromToken: usdcTokenArbitrum, - fromAmount: fromAmount, - toToken: wethTokenArbitrum, - toAmount: toAmount, - toAmountMin: toAmountMin, - dexData: dexData - }); - - _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - } - - //passed - function test_dexSwapUniSwapRouterUSDCToETH() - public - setFork(arbitrumAnvilForkId) - addRouterInWhiteList(uniV3RouterArbitrum, address(arbitrumOrchestratorProxy)) - { - uint256 fromAmount = 1e6; //usdc - uint256 toAmount = 0.000300419724797236 ether; - uint256 toAmountMin = 0.000298917626173249 ether; - - bytes - memory dexData = hex"ac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001934fb896d900000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010fdd40cbad5d000000000000000000000000000000000000000000000000000000000000002baf88d065e77c8cc2239327c5edb3a432268e58310001f482af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004449404b7c00000000000000000000000000000000000000000000000000010fdd2eecd741000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000"; - - IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - swapData[0] = IDexSwap.SwapData({ - dexRouter: uniV3RouterArbitrum, - fromToken: usdcTokenArbitrum, - fromAmount: fromAmount, - toToken: address(0), - toAmount: toAmount, - toAmountMin: toAmountMin, - dexData: dexData - }); - - _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - } - - //passed - function test_dexSwapUniSwapRouterETHToUSDC() - public - setFork(arbitrumAnvilForkId) - addRouterInWhiteList(uniV3RouterArbitrum, address(arbitrumOrchestratorProxy)) - { - uint256 fromAmount = 0.0001 ether; //ETH - uint256 toAmount = 0.331996e6; //usdc - uint256 toAmountMin = 0.330336e6; //usdc - - bytes - memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681000000000000000000000000000000000000000000000000000001934fad171000000000000000000000000000000000000000000000000000005ab8e441cd800000000000000000000000000000000000000000000000000000000000050a60000000000000000000000000000000000000000000000000000000000000002b82af49447d8a07e3bd95bd0d56f35241523fbab10001f4af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; - - IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - swapData[0] = IDexSwap.SwapData({ - dexRouter: uniV3RouterArbitrum, - fromToken: address(0), - fromAmount: fromAmount, - toToken: usdcTokenArbitrum, - toAmount: toAmount, - toAmountMin: toAmountMin, - dexData: dexData - }); - - _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - } - - ////////////////////////////////////////////////////////// - ////////////////// ParaSwap //////////////////////// - ////////////////////////////////////////////////////////// - - //does not work - function test_dexSwapParaSwapRouterUSDCToUSDT() - public - setFork(arbitrumAnvilForkId) - addRouterInWhiteList(paraSwapV5RouterArbitrum, address(arbitrumOrchestratorProxy)) - { - uint256 fromAmount = 1e6; //1 usdc - uint256 toAmount = 0.996903e6; - uint256 toAmountMin = 0.991918e6; - - bytes - memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681000000000000000000000000000000000000000000000000000001934fbb778500000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000000000000f22af000000000000000000000000000000000000000000000000000000000000002baf88d065e77c8cc2239327c5edb3a432268e5831000064fd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; - - IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - swapData[0] = IDexSwap.SwapData({ - dexRouter: paraSwapV5RouterArbitrum, - fromToken: usdcTokenArbitrum, - fromAmount: fromAmount, - toToken: usdtTokenArbitrum, - toAmount: toAmount, - toAmountMin: toAmountMin, - dexData: dexData - }); - - _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - } - - //does not work - function test_dexSwapParaSwapRouterUSDCToWETH() public setFork(arbitrumAnvilForkId) { - _allowRouter(paraSwapV5RouterArbitrum, address(arbitrumOrchestratorProxy)); - - uint256 fromAmount = 1e6; //1 usdc - uint256 toAmount = 0.00029758021792574 ether; - uint256 toAmountMin = 0.000296092316836111 ether; - - bytes - memory dexData = hex"54e3f31b0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010d4b6f1016c900000000000000000000000000000000000000000000000000010ea5dcf7ba4600000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000003800000000000000000000000000000000000000000000000000000000000000400000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000046000000000000000000000000000000000000000000000000000000000673f779551436a490fb745e4a0a79829c8000ce6000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831000000000000000000000000ed9e3f98bbed560e66b89aac922e29d4596a96420000000000000000000000000000000000000000000000000000000000000108a9059cbb000000000000000000000000ed9e3f98bbed560e66b89aac922e29d4596a964200000000000000000000000000000000000000000000000000000000000f387e7dc20382000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000f387e0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee57000000000000000000000000d5b927956057075377263aab7f8afc12f85100db00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000001080000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; - - IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - swapData[0] = IDexSwap.SwapData({ - dexRouter: paraSwapV5RouterArbitrum, - fromToken: usdcTokenArbitrum, - fromAmount: fromAmount, - toToken: wethTokenArbitrum, - toAmount: toAmount, - toAmountMin: toAmountMin, - dexData: dexData - }); - - _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - } - - //does not work - function test_dexSwapParaSwapRouterUSDCToETH() - public - setFork(arbitrumAnvilForkId) - addRouterInWhiteList(paraSwapV5RouterArbitrum, address(arbitrumOrchestratorProxy)) - { - uint256 fromAmount = 1e6; //usdc - uint256 toAmount = 0.000300419724797236 ether; - uint256 toAmountMin = 0.000298917626173249 ether; - - bytes - memory dexData = hex"ac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001934fb896d900000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010fdd40cbad5d000000000000000000000000000000000000000000000000000000000000002baf88d065e77c8cc2239327c5edb3a432268e58310001f482af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004449404b7c00000000000000000000000000000000000000000000000000010fdd2eecd741000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000"; - - IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - swapData[0] = IDexSwap.SwapData({ - dexRouter: paraSwapV5RouterArbitrum, - fromToken: usdcTokenArbitrum, - fromAmount: fromAmount, - toToken: address(0), - toAmount: toAmount, - toAmountMin: toAmountMin, - dexData: dexData - }); - - _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - } - - //does not work - function test_dexSwapParaSwapRouterETHToUSDC() - public - setFork(arbitrumAnvilForkId) - addRouterInWhiteList(paraSwapV5RouterArbitrum, address(arbitrumOrchestratorProxy)) - { - uint256 fromAmount = 0.001 ether; //ETH - uint256 toAmount = 3.334998e6; //usdc - uint256 toAmountMin = 3.318323e6; //usdc - - bytes - memory dexData = hex"54e3f31b0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000038b38ea920700000000000000000000000000000000000000000000000000000000000032a1e5000000000000000000000000000000000000000000000000000000000032e30700000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000003a00000000000000000000000000000000000000000000000000000000000000440000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc356810000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000004c000000000000000000000000000000000000000000000000000000000673f7930962cd732e34c45a093489154807ea37000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000ed9e3f98bbed560e66b89aac922e29d4596a9642000000000000000000000000000000000000000000000000000000000000010cd0e30db0a9059cbb000000000000000000000000ed9e3f98bbed560e66b89aac922e29d4596a964200000000000000000000000000000000000000000000000000038b38ea9207007dc2038200000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000038b38ea9207000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee57000000000000000000000000d5b927956057075377263aab7f8afc12f85100db00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000048000000000000000000000000000000000000000000000000000000000000010c000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000038b38ea920700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; - - IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - swapData[0] = IDexSwap.SwapData({ - dexRouter: paraSwapV5RouterArbitrum, - fromToken: address(0), - fromAmount: fromAmount, - toToken: usdcTokenArbitrum, - toAmount: toAmount, - toAmountMin: toAmountMin, - dexData: dexData - }); - - _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - } - - //////////////////// Polygon //////////////////////////// - //////////////////// Block number 64588691 ////////////// - - ////////////////////////////////////////////////////////// - ////////////////// Quick Swap //////////////////// - ////////////////////////////////////////////////////////// - - //passed - function test_dexSwapQuickSwapRouterUSDCToWETH() - public - setFork(polygonAnvilForkId) - addRouterInWhiteList(quickSwapRouterPolygon, address(polygonOrchestratorProxy)) - { - uint256 fromAmount = 1e6; //1 usdc - uint256 toAmount = 0.000294773721275645e18; - uint256 toAmountMin = 0.000293299852669266e18; - - bytes - memory dexData = hex"38ed173900000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010ac13a4b12cf00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681000000000000000000000000000000000000000000000000000000006740511a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c33590000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f619"; - - IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - swapData[0] = IDexSwap.SwapData({ - dexRouter: quickSwapRouterPolygon, - fromToken: usdcTokenPolygon, - fromAmount: fromAmount, - toToken: wethTokenPolygon, - toAmount: toAmount, - toAmountMin: toAmountMin, - dexData: dexData - }); - - _callTestWithRouter(swapData, address(polygonOrchestratorProxy)); - } - - //passed - function test_dexSwapQuickSwapRouterPOLToUSDC() - public - setFork(polygonAnvilForkId) - addRouterInWhiteList(quickSwapRouterPolygon, address(polygonOrchestratorProxy)) - { - uint256 fromAmount = 0.001e18; //POL - uint256 toAmount = 0.000457e6; //usdc - uint256 toAmountMin = 0.000454e6; //usdc - - bytes - memory dexData = hex"7ff36ab500000000000000000000000000000000000000000000000000000000000001c70000000000000000000000000000000000000000000000000000000000000080000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000674056ac00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf12700000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c3359"; - - IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - swapData[0] = IDexSwap.SwapData({ - dexRouter: quickSwapRouterPolygon, - fromToken: POL_TOKEN, - fromAmount: fromAmount, - toToken: usdcTokenPolygon, - toAmount: toAmount, - toAmountMin: toAmountMin, - dexData: dexData - }); - - _callTestWithRouter(swapData, address(polygonOrchestratorProxy)); - } - - //passed - function test_dexSwapQuickSwapRouterUSDCToPOL() - public - setFork(polygonAnvilForkId) - addRouterInWhiteList(quickSwapRouterPolygon, address(polygonOrchestratorProxy)) - { - uint256 fromAmount = 1e6; //usdc - uint256 toAmount = 2.16620982591814043e18; //pol - uint256 toAmountMin = 2.155378776788549727e18; //pol - - bytes - memory dexData = hex"18cbafe500000000000000000000000000000000000000000000000000000000000f387e0000000000000000000000000000000000000000000000001de9728f133bb56100000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000674057b000000000000000000000000000000000000000000000000000000000000000020000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c33590000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf1270"; - - IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - swapData[0] = IDexSwap.SwapData({ - dexRouter: quickSwapRouterPolygon, - fromToken: usdcTokenPolygon, - fromAmount: fromAmount, - toToken: POL_TOKEN, - toAmount: toAmount, - toAmountMin: toAmountMin, - dexData: dexData - }); - - _callTestWithRouter(swapData, address(polygonOrchestratorProxy)); - } - - //////////////////// Avalanche //////////////////////////// - //////////////////// Block number 53397798 ////////////// - - ////////////////////////////////////////////////////////// - ////////////////// Pangolin Swap ///////////////// - ////////////////////////////////////////////////////////// - - //doesnt work - function test_dexSwapPangolinSwapRouterUSDCToWAVAX() - public - setFork(avalancheAnvilForkId) - addRouterInWhiteList(pangolinRouterAvalanche, address(avalancheOrchestratorProxy)) - { - uint256 fromAmount = 1e6; //1 usdc - uint256 toAmount = 0.027249956050478939e18; - uint256 toAmountMin = 0.027113706270226544e18; - - bytes - memory dexData = hex"38ed173900000000000000000000000000000000000000000000000000000000000f387e000000000000000000000000000000000000000000000000006053c8d8cb68b600000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000674060d40000000000000000000000000000000000000000000000000000000000000003000000000000000000000000b97ef9ef8734c71904d8002f8b6bc66dd9c48a6e00000000000000000000000060781c2586d68229fde47564546784ab3faca982000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c7"; - - IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - swapData[0] = IDexSwap.SwapData({ - dexRouter: pangolinRouterAvalanche, - fromToken: usdcTokenAvalanche, - fromAmount: fromAmount, - toToken: wavaxTokenAvalanche, - toAmount: toAmount, - toAmountMin: toAmountMin, - dexData: dexData - }); - - _callTestWithRouter(swapData, address(avalancheOrchestratorProxy)); - } - - ////////////////////////////////////////////////////////// - ////////////////// Utils ///////////////////////// - ////////////////////////////////////////////////////////// - - function _callTestWithRouter(IDexSwap.SwapData[] memory swapData, address proxy) internal { - console.log("block.number", block.number); - console.log("fromAmount: ", swapData[0].fromAmount); - console.log("toAmount: ", swapData[0].toAmount); - console.log("toAmountMin: ", swapData[0].toAmountMin); - - InfraOrchestrator orchestrator = InfraOrchestrator(payable(proxy)); - - IInfraOrchestrator.Integration memory integration = IInfraOrchestrator.Integration({ - integrator: integrator, - feeBps: 0 - }); - bool isFromNative = swapData[0].fromToken == address(0); - bool isToNative = swapData[0].toToken == address(0); - - uint256 userBalanceFromTokenBefore; - uint256 userBalanceFromTokenAfter; - uint256 userBalanceToTokenBefore; - uint256 userBalanceToTokenAfter; - - if (isFromNative && !isToNative) { - deal(sender, swapData[0].fromAmount); - - userBalanceFromTokenBefore = sender.balance; - userBalanceToTokenBefore = IERC20(swapData[0].toToken).balanceOf(sender); - - vm.prank(sender); - orchestrator.swap{value: swapData[0].fromAmount}(swapData, sender, integration); - - userBalanceFromTokenAfter = sender.balance; - userBalanceToTokenAfter = IERC20(swapData[0].toToken).balanceOf(sender); - } else if (isToNative && !isFromNative) { - _dealERC20AndApprove(swapData[0].fromToken, sender, swapData[0].fromAmount, proxy); - - userBalanceFromTokenBefore = IERC20(swapData[0].fromToken).balanceOf(sender); - userBalanceToTokenBefore = sender.balance; - - vm.prank(sender); - orchestrator.swap(swapData, sender, integration); - - userBalanceFromTokenAfter = IERC20(swapData[0].fromToken).balanceOf(sender); - userBalanceToTokenAfter = sender.balance; - } else if (!isFromNative && !isToNative) { - _dealERC20AndApprove(swapData[0].fromToken, sender, swapData[0].fromAmount, proxy); - - userBalanceFromTokenBefore = IERC20(swapData[0].fromToken).balanceOf(sender); - userBalanceToTokenBefore = IERC20(swapData[0].toToken).balanceOf(sender); - - vm.prank(sender); - orchestrator.swap(swapData, sender, integration); - - userBalanceFromTokenAfter = IERC20(swapData[0].fromToken).balanceOf(sender); - userBalanceToTokenAfter = IERC20(swapData[0].toToken).balanceOf(sender); - } - - console.log("userBalanceFromTokenBefore: ", userBalanceFromTokenBefore); - console.log("userBalanceFromTokenAfter: ", userBalanceFromTokenAfter); - console.log("userBalanceToTokenBefore: ", userBalanceToTokenBefore); - console.log("userBalanceToTokenAfter: ", userBalanceToTokenAfter); - - assertGt(userBalanceToTokenAfter, userBalanceToTokenBefore); - assertLt(userBalanceFromTokenAfter, userBalanceFromTokenBefore); - } - - function _allowRouter(address router, address orchestratorProxy) internal { - vm.prank(deployer); - (bool success, ) = address(orchestratorProxy).call( - abi.encodeWithSignature("setDexRouterAddress(address,bool)", router, true) - ); - /// @dev assert it is set correctly - (, bytes memory returnData) = address(orchestratorProxy).call( - abi.encodeWithSignature("s_routerAllowed(address)", router) - ); - bool returnedValue = abi.decode(returnData, (bool)); - assertEq(returnedValue, true); - } - - function _dealERC20AndApprove( - address token, - address _caller, - uint256 _amount, - address proxy - ) internal { - deal(token, _caller, _amount); - vm.prank(_caller); - IERC20(token).approve(proxy, _amount); - } -} diff --git a/test/foundry/scripts/DeployInfra.s.sol b/test/foundry/scripts/DeployInfra.s.sol new file mode 100644 index 00000000..656e354b --- /dev/null +++ b/test/foundry/scripts/DeployInfra.s.sol @@ -0,0 +1,104 @@ +pragma solidity 0.8.20; + +import {DeployHelper} from "../utils/DeployHelper.sol"; +import {ConceroBridge} from "contracts/ConceroBridge.sol"; +import {DexSwap} from "contracts/DexSwap.sol"; +import {InfraOrchestrator} from "contracts/InfraOrchestrator.sol"; +import {PauseDummy} from "contracts/PauseDummy.sol"; +import {Script} from "forge-std/src/Script.sol"; +import {TransparentUpgradeableProxy, ITransparentUpgradeableProxy} from "contracts/Proxy/TransparentUpgradeableProxy.sol"; +import {console} from "forge-std/src/Console.sol"; +import {IInfraStorage} from "contracts/Interfaces/IInfraStorage.sol"; + +contract DeployInfraScript is DeployHelper { + // @notice contract addresses + TransparentUpgradeableProxy internal infraProxy; + InfraOrchestrator internal infraOrchestrator; + ConceroBridge internal conceroBridge; + DexSwap internal dexSwap; + + // @notice helper variables + address public proxyDeployer = vm.envAddress("PROXY_DEPLOYER"); + address public deployer = vm.envAddress("DEPLOYER_ADDRESS"); + address[3] public messengers = [vm.envAddress("MESSENGER_0_ADDRESS"), address(0), address(0)]; + + function run() public returns (address) { + _deployFullInfra(); + return address(infraProxy); + } + + function run(uint256 forkId) public returns (address) { + vm.selectFork(forkId); + return run(); + } + + function setProxyImplementation(address implementation) public { + vm.prank(proxyDeployer); + ITransparentUpgradeableProxy(address(infraProxy)).upgradeToAndCall( + implementation, + bytes("") + ); + } + + function getProxy() public view returns (address) { + return address(infraProxy); + } + + function _deployFullInfra() internal { + _deployInfraProxy(); + _deployAndSetImplementation(); + } + + function _deployInfraProxy() internal { + vm.prank(proxyDeployer); + infraProxy = new TransparentUpgradeableProxy(address(new PauseDummy()), proxyDeployer, ""); + } + + function _deployAndSetImplementation() internal { + _deployDexSwap(); + _deployConceroBridge(); + _deployOrchestrator(); + + setProxyImplementation(address(infraOrchestrator)); + } + + function _deployDexSwap() internal { + vm.prank(deployer); + dexSwap = new DexSwap(address(infraProxy), messengers); + } + + function _deployConceroBridge() internal { + vm.prank(deployer); + + IInfraStorage.FunctionsVariables memory clfVars = IInfraStorage.FunctionsVariables({ + subscriptionId: getCLfSubId(), + donId: getDonId(), + functionsRouter: getClfRouter() + }); + + conceroBridge = new ConceroBridge( + clfVars, + getChainSelector(), + getChainIndex(), + getLinkAddress(), + getCcipRouter(), + address(dexSwap), + address(0), + address(infraProxy), + messengers + ); + } + + function _deployOrchestrator() internal { + vm.prank(deployer); + infraOrchestrator = new InfraOrchestrator( + getClfRouter(), + address(dexSwap), + address(conceroBridge), + address(0), + address(infraProxy), + getChainIndex(), + messengers + ); + } +} diff --git a/test/foundry/utils/BaseTest.t.sol b/test/foundry/utils/BaseTest.t.sol index 56385cd1..2c06e230 100644 --- a/test/foundry/utils/BaseTest.t.sol +++ b/test/foundry/utils/BaseTest.t.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.20; -import {console, Vm, Test} from "forge-std/Test.sol"; +import {console, Vm, Test} from "forge-std/src/Test.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {ParentPool} from "contracts/ParentPool.sol"; import {ParentPoolCLFCLA} from "contracts/ParentPoolCLFCLA.sol"; @@ -29,7 +29,6 @@ contract BaseTest is Test { uint256 internal constant LINK_INIT_BALANCE = 100 * 1e18; uint256 internal constant USDC_DECIMALS = 1e6; uint256 internal constant PARENT_POOL_CAP = 100_000_000 * USDC_DECIMALS; - uint256 internal constant ARBITRUM_ANVIL_FORK_BLOCK_NUMBER = 21234930; ParentPoolCLFCLA public parentPoolCLFCLA; ParentPool public parentPoolImplementation; @@ -42,8 +41,6 @@ contract BaseTest is Test { DexSwap public avalancheDexSwap; FunctionsSubscriptions public functionsSubscriptions; - // CCIPLocalSimulator public ccipLocalSimulator; - // CCIPLocalSimulatorFork public ccipLocalSimulatorFork; address internal user1 = makeAddr("user1"); address internal user2 = makeAddr("user2"); @@ -51,12 +48,12 @@ contract BaseTest is Test { address internal deployer = vm.envAddress("FORGE_DEPLOYER_ADDRESS"); address internal proxyDeployer = vm.envAddress("FORGE_PROXY_DEPLOYER_ADDRESS"); - uint256 internal baseAnvilForkId = vm.createFork(vm.envString("LOCAL_BASE_FORK_RPC_URL")); - uint256 internal arbitrumAnvilForkId = + uint256 internal baseForkId = vm.createFork(vm.envString("LOCAL_BASE_FORK_RPC_URL")); + uint256 internal arbitrumForkId = vm.createFork(vm.envString("LOCAL_ARBITRUM_FORK_RPC_URL"), 276843772); - uint256 internal polygonAnvilForkId = + uint256 internal polygonForkId = vm.createFork(vm.envString("LOCAL_POLYGON_FORK_RPC_URL"), 64588691); - uint256 internal avalancheAnvilForkId = + uint256 internal avalancheForkId = vm.createFork(vm.envString("LOCAL_AVALANCHE_FORK_RPC_URL"), 53397798); uint64 internal baseChainSelector = uint64(vm.envUint("CL_CCIP_CHAIN_SELECTOR_BASE")); @@ -97,27 +94,13 @@ contract BaseTest is Test { SETUP //////////////////////////////////////////////////////////////*/ function setUp() public virtual { - vm.selectFork(baseAnvilForkId); + vm.selectFork(baseForkId); _deployOrchestratorProxy(); deployArbitrumInfra(); deployBaseInfra(); deployPolygonInfra(); deployAvalancheInfra(); - - //deployPoolsInfra(); - //_deployOrchestratorImplementation(); - - // _setProxyImplementation( - // address(baseOrchestratorProxy), - // address(baseOrchestratorImplementation) - // ); - - // _setDstInfraContractsForInfra( - // address(baseOrchestratorProxy), - // arbitrumChainSelector, - // arbitrumOrchestratorProxy - // ); } function deployPoolsInfra() public { @@ -138,7 +121,7 @@ contract BaseTest is Test { addFunctionsConsumer(address(baseOrchestratorProxy)); } - function deployArbitrumInfra() public setFork(arbitrumAnvilForkId) { + function deployArbitrumInfra() public setFork(arbitrumForkId) { _deployOrchestratorProxyArbitrum(); _deployDexSwapArbitrum(); _deployOrchestratorImplementationArbitrum(); @@ -149,7 +132,7 @@ contract BaseTest is Test { ); } - function deployBaseInfra() public setFork(baseAnvilForkId) { + function deployBaseInfra() public setFork(baseForkId) { _deployOrchestratorProxyBase(); _deployDexSwapBase(); _deployOrchestratorImplementationBase(); @@ -160,7 +143,7 @@ contract BaseTest is Test { ); } - function deployPolygonInfra() public setFork(polygonAnvilForkId) { + function deployPolygonInfra() public setFork(polygonForkId) { _deployOrchestratorProxyPolygon(); _deployDexSwapPolygon(); _deployOrchestratorImplementationPolygon(); @@ -171,7 +154,7 @@ contract BaseTest is Test { ); } - function deployAvalancheInfra() public setFork(avalancheAnvilForkId) { + function deployAvalancheInfra() public setFork(avalancheForkId) { _deployOrchestratorProxyAvalanche(); _deployDexSwapAvalanche(); _deployOrchestratorImplementationAvalanche(); @@ -254,34 +237,6 @@ contract BaseTest is Test { vm.stopPrank(); } - // function _deployCCIPLocalSimulatorFork() internal { - // uint256 BASE_CHAIN_ID = 8453; - // - // ccipLocalSimulatorFork = new CCIPLocalSimulatorFork(); - // vm.makePersistent(address(ccipLocalSimulatorFork)); - // - // Register.NetworkDetails memory baseDetails = Register.NetworkDetails({ - // chainSelector: uint64(vm.envUint("CL_CCIP_CHAIN_SELECTOR_BASE")), - // routerAddress: vm.envAddress("CL_CCIP_ROUTER_BASE"), - // linkAddress: vm.envAddress("LINK_BASE"), - // wrappedNativeAddress: 0x4200000000000000000000000000000000000006, - // ccipBnMAddress: address(0), - // ccipLnMAddress: address(0), - // rmnProxyAddress: address(0), - // registryModuleOwnerCustomAddress: address(0), - // tokenAdminRegistryAddress: address(0) - // }); - // - // ccipLocalSimulatorFork.setNetworkDetails(BASE_CHAIN_ID, baseDetails); - // } - // - // function _deployCcipLocalSimulation() private { - // ccipLocalSimulator = new CCIPLocalSimulator(); - // ccipLocalSimulator.configuration(); - // // vm.prank(IOwner(vm.envAddress("USDC_BASE")).owner()); - // ccipLocalSimulator.supportNewTokenViaOwner(vm.envAddress("USDC_BASE")); - // } - /*////////////////////////////////////////////////////////////// SETTERS //////////////////////////////////////////////////////////////*/ @@ -753,7 +708,6 @@ contract BaseTest is Test { InfraStorageSetters(target).setClfPremiumFees(chainSelector, feeAmount); } - /*////////////////////////////////////////////////////////////// DEXSWAP //////////////////////////////////////////////////////////////*/ diff --git a/test/foundry/utils/CreateAndSwitchToFork.t.sol b/test/foundry/utils/CreateAndSwitchToFork.t.sol deleted file mode 100644 index 62d3f6c1..00000000 --- a/test/foundry/utils/CreateAndSwitchToFork.t.sol +++ /dev/null @@ -1,25 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.20; - -import {Test, console} from "forge-std/Test.sol"; - -enum ForkType { - BASE, - ARBITRUM, - POLYGON, - LocalBase -} - -contract CreateAndSwitchToForkTest is Test { - uint256 private forkId; - - function switchToFork(ForkType forkType) internal { - if (forkType == ForkType.BASE) { - forkId = vm.createFork(vm.envString("BASE_RPC_URL"), 17655883); - vm.selectFork(forkId); - } else if (forkType == ForkType.LocalBase) { - forkId = vm.createFork(vm.envString("LOCAL_BASE_FORK_RPC_URL")); - vm.selectFork(forkId); - } - } -} diff --git a/test/foundry/utils/DeployHelper.sol b/test/foundry/utils/DeployHelper.sol new file mode 100644 index 00000000..78950959 --- /dev/null +++ b/test/foundry/utils/DeployHelper.sol @@ -0,0 +1,148 @@ +pragma solidity 0.8.20; + +import {Script} from "forge-std/src/Script.sol"; + +contract DeployHelper is Script { + function getClfRouter() public returns (address) { + uint256 chainId = block.chainid; + + if (chainId == vm.envUint("BASE_CHAIN_ID")) { + return vm.envAddress("CLF_ROUTER_BASE"); + } else if (chainId == vm.envUint("ARBITRUM_CHAIN_ID")) { + return vm.envAddress("CLF_ROUTER_ARBITRUM"); + } else if (chainId == vm.envUint("POLYGON_CHAIN_ID")) { + return vm.envAddress("CLF_ROUTER_POLYGON"); + } else if (chainId == vm.envUint("AVALANCHE_CHAIN_ID")) { + return vm.envAddress("CLF_ROUTER_AVALANCHE"); + } else if (chainId == vm.envUint("OPTIMISM_CHAIN_ID")) { + return vm.envAddress("CLF_ROUTER_OPTIMISM"); + } else if (chainId == vm.envUint("ETHEREUM_CHAIN_ID")) { + return vm.envAddress("CLF_ROUTER_ETHEREUM"); + } + + return vm.envAddress("CLF_ROUTER_BASE"); + } + + function getCLfSubId() public returns (uint64) { + uint256 chainId = block.chainid; + uint256 res = vm.envUint("CLF_SUBID_BASE"); + + if (chainId == vm.envUint("BASE_CHAIN_ID")) { + res = vm.envUint("CLF_SUBID_BASE"); + } else if (chainId == vm.envUint("ARBITRUM_CHAIN_ID")) { + res = vm.envUint("CLF_SUBID_ARBITRUM"); + } else if (chainId == vm.envUint("POLYGON_CHAIN_ID")) { + res = vm.envUint("CLF_SUBID_POLYGON"); + } else if (chainId == vm.envUint("AVALANCHE_CHAIN_ID")) { + res = vm.envUint("CLF_SUBID_AVALANCHE"); + } else if (chainId == vm.envUint("OPTIMISM_CHAIN_ID")) { + res = vm.envUint("CLF_SUBID_OPTIMISM"); + } else if (chainId == vm.envUint("ETHEREUM_CHAIN_ID")) { + res = vm.envUint("CLF_SUBID_ETHEREUM"); + } + + return uint64(res); + } + + function getDonId() public returns (bytes32) { + uint256 chainId = block.chainid; + + if (chainId == vm.envUint("BASE_CHAIN_ID")) { + return vm.envBytes32("CLF_DONID_BASE"); + } else if (chainId == vm.envUint("ARBITRUM_CHAIN_ID")) { + return vm.envBytes32("CLF_DONID_ARBITRUM"); + } else if (chainId == vm.envUint("POLYGON_CHAIN_ID")) { + return vm.envBytes32("CLF_DONID_POLYGON"); + } else if (chainId == vm.envUint("AVALANCHE_CHAIN_ID")) { + return vm.envBytes32("CLF_DONID_AVALANCHE"); + } else if (chainId == vm.envUint("OPTIMISM_CHAIN_ID")) { + return vm.envBytes32("CLF_DONID_OPTIMISM"); + } else if (chainId == vm.envUint("ETHEREUM_CHAIN_ID")) { + return vm.envBytes32("CLF_DONID_ETHEREUM"); + } + + return vm.envBytes32("CLF_DONID_BASE"); + } + + function getChainSelector() public returns (uint64) { + uint256 chainId = block.chainid; + uint256 res = vm.envUint("CL_CCIP_CHAIN_SELECTOR_BASE"); + + if (chainId == vm.envUint("BASE_CHAIN_ID")) { + res = vm.envUint("CL_CCIP_CHAIN_SELECTOR_BASE"); + } else if (chainId == vm.envUint("ARBITRUM_CHAIN_ID")) { + res = vm.envUint("CL_CCIP_CHAIN_SELECTOR_ARBITRUM"); + } else if (chainId == vm.envUint("POLYGON_CHAIN_ID")) { + res = vm.envUint("CL_CCIP_CHAIN_SELECTOR_POLYGON"); + } else if (chainId == vm.envUint("AVALANCHE_CHAIN_ID")) { + res = vm.envUint("CL_CCIP_CHAIN_SELECTOR_AVALANCHE"); + } else if (chainId == vm.envUint("OPTIMISM_CHAIN_ID")) { + res = vm.envUint("CL_CCIP_CHAIN_SELECTOR_OPTIMISM"); + } else if (chainId == vm.envUint("ETHEREUM_CHAIN_ID")) { + res = vm.envUint("CL_CCIP_CHAIN_SELECTOR_ETHEREUM"); + } + + return uint64(res); + } + + function getChainIndex() public returns (uint8) { + uint256 chainId = block.chainid; + uint256 res = 1; + + if (chainId == vm.envUint("BASE_CHAIN_ID")) { + res = 1; + } else if (chainId == vm.envUint("ARBITRUM_CHAIN_ID")) { + res = 0; + } else if (chainId == vm.envUint("POLYGON_CHAIN_ID")) { + res = 3; + } else if (chainId == vm.envUint("AVALANCHE_CHAIN_ID")) { + res = 4; + } else if (chainId == vm.envUint("OPTIMISM_CHAIN_ID")) { + res = 2; + } else if (chainId == vm.envUint("ETHEREUM_CHAIN_ID")) { + res = 5; + } + + return uint8(res); + } + + function getLinkAddress() public returns (address) { + uint256 chainId = block.chainid; + + if (chainId == vm.envUint("BASE_CHAIN_ID")) { + return vm.envAddress("LINK_BASE"); + } else if (chainId == vm.envUint("ARBITRUM_CHAIN_ID")) { + return vm.envAddress("LINK_ARBITRUM"); + } else if (chainId == vm.envUint("POLYGON_CHAIN_ID")) { + return vm.envAddress("LINK_POLYGON"); + } else if (chainId == vm.envUint("AVALANCHE_CHAIN_ID")) { + return vm.envAddress("LINK_AVALANCHE"); + } else if (chainId == vm.envUint("OPTIMISM_CHAIN_ID")) { + return vm.envAddress("LINK_OPTIMISM"); + } else if (chainId == vm.envUint("ETHEREUM_CHAIN_ID")) { + return vm.envAddress("LINK_ETHEREUM"); + } + + return vm.envAddress("LINK_BASE"); + } + + function getCcipRouter() public returns (address) { + uint256 chainId = block.chainid; + + if (chainId == vm.envUint("BASE_CHAIN_ID")) { + return vm.envAddress("CL_CCIP_ROUTER_BASE"); + } else if (chainId == vm.envUint("ARBITRUM_CHAIN_ID")) { + return vm.envAddress("CL_CCIP_ROUTER_ARBITRUM"); + } else if (chainId == vm.envUint("POLYGON_CHAIN_ID")) { + return vm.envAddress("CL_CCIP_ROUTER_POLYGON"); + } else if (chainId == vm.envUint("AVALANCHE_CHAIN_ID")) { + return vm.envAddress("CL_CCIP_ROUTER_AVALANCHE"); + } else if (chainId == vm.envUint("OPTIMISM_CHAIN_ID")) { + return vm.envAddress("CL_CCIP_ROUTER_OPTIMISM"); + } else if (chainId == vm.envUint("ETHEREUM_CHAIN_ID")) { + return vm.envAddress("CL_CCIP_ROUTER_ETHEREUM"); + } + + return vm.envAddress("CL_CCIP_ROUTER_BASE"); + } +} diff --git a/test/foundry/utils/InfraBaseTest.t.sol b/test/foundry/utils/InfraBaseTest.t.sol new file mode 100644 index 00000000..0bcc3e18 --- /dev/null +++ b/test/foundry/utils/InfraBaseTest.t.sol @@ -0,0 +1,57 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity 0.8.20; + +import "forge-std/src/Test.sol"; +import {DexSwap} from "contracts/DexSwap.sol"; +import {TransparentUpgradeableProxy, ITransparentUpgradeableProxy} from "contracts/Proxy/TransparentUpgradeableProxy.sol"; +import {InfraOrchestrator} from "contracts/InfraOrchestrator.sol"; +import {ConceroBridge} from "contracts/ConceroBridge.sol"; +import {PauseDummy} from "contracts/PauseDummy.sol"; + +contract InfraBaseTest is Test { + // @notice contract addresses + TransparentUpgradeableProxy public infraProxy; + InfraOrchestrator public infraOrchestrator; + ConceroBridge public conceroBridge; + DexSwap public dexSwap; + + // @notice helper variables + address public proxyDeployer = vm.envAddress("PROXY_DEPLOYER"); + address public deployer = vm.envAddress("DEPLOYER_ADDRESS"); + + function deployFullInfra() public { + deployInfraProxy(); + deployAndSetImplementation(); + } + + function deployAndSetImplementation() public { + deployDexSwap(); + deployOrchestrator(); + } + + function deployInfraProxy() public { + vm.prank(proxyDeployer); + infraProxy = new TransparentUpgradeableProxy(address(new PauseDummy()), proxyDeployer, ""); + } + + function deployDexSwap() public { + vm.prank(deployer); + dexSwap = new DexSwap( + address(infraProxy), + [vm.envAddress("MESSENGER_0_ADDRESS"), address(0), address(0)] + ); + } + + function deployOrchestrator() public { + vm.prank(deployer); + infraOrchestrator = new InfraOrchestrator( + vm.envAddress("CLF_ROUTER_BASE"), + vm.envAddress("CONCERO_DEX_SWAP_BASE"), + address(conceroBridge), + address(0), + address(infraProxy), + 1, + [vm.envAddress("MESSENGER_0_ADDRESS"), address(0), address(0)] + ); + } +} From 11d1b13f0ff968b577057712b6da356d08820fae Mon Sep 17 00:00:00 2001 From: lufaque <95128636+lufaque@users.noreply.github.com> Date: Mon, 16 Dec 2024 22:15:23 +0300 Subject: [PATCH 23/54] uni v3 test --- .../InfraOrchestrator.swap.t.sol | 18 +++++++++++++----- test/foundry/scripts/DeployInfra.s.sol | 17 +++++++++++++++++ test/foundry/utils/DeployHelper.sol | 13 +++++++++++++ 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol index e4cbfe8a..7bd0aa6e 100644 --- a/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol +++ b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol @@ -25,21 +25,24 @@ contract DexSwapTest is Test { function testFork_Univ3OnBaseViaRangoRouting() public - selectFork(vm.createFork(vm.envString("BASE_RPC_URL"))) + selectFork(vm.createFork(vm.envString("BASE_RPC_URL"), 23793491)) { uint256 fromAmount = 0.1 ether; - uint256 toAmount = 267.528449e6; - uint256 toAmountMin = 266.190806e6; + uint256 toAmount = 406.037259e6; + uint256 toAmountMin = 404.007072e6; address user = makeAddr("user"); + console.log(user); deal(user, fromAmount); + uint256 userToTokenBalanceBefore = IERC20(vm.envAddress("USDC_BASE")).balanceOf(user); + // @notice swap data generated by rango bytes - memory dexData = hex"7ff36ab5000000000000000000000000000000000000000000000000000000000fddbfd70000000000000000000000000000000000000000000000000000000000000080000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673fb53400000000000000000000000000000000000000000000000000000000000000020000000000000000000000004200000000000000000000000000000000000006000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913"; + memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124b858183f0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000162623ba10abc00000000000000000000000000000000000000000000000000000000001814a8a0000000000000000000000000000000000000000000000000000000000000004242000000000000000000000000000000000000060001f4cbb7c0000ab88b473b1f5afd9ef808440eed33bf0001f4833589fcd6edb6e08f4c7c32d4f71b54bda0291300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); swapData[0] = IDexSwap.SwapData({ - dexRouter: vm.envAddress("ALIENBASE_ROUTER_BASE"), + dexRouter: vm.envAddress("UNISWAP_ROUTER_BASE"), fromToken: NATIVE_TOKEN, fromAmount: fromAmount, toToken: vm.envAddress("USDC_BASE"), @@ -54,6 +57,11 @@ contract DexSwapTest is Test { user, emptyIntegration ); + + uint256 userToTokenBalanceAfter = IERC20(vm.envAddress("USDC_BASE")).balanceOf(user); + uint256 toTokenReceived = userToTokenBalanceAfter - userToTokenBalanceBefore; + + assert(toTokenReceived >= toAmountMin); } // address internal constant ETH_TOKEN = address(0); diff --git a/test/foundry/scripts/DeployInfra.s.sol b/test/foundry/scripts/DeployInfra.s.sol index 656e354b..1b728934 100644 --- a/test/foundry/scripts/DeployInfra.s.sol +++ b/test/foundry/scripts/DeployInfra.s.sol @@ -9,6 +9,7 @@ import {Script} from "forge-std/src/Script.sol"; import {TransparentUpgradeableProxy, ITransparentUpgradeableProxy} from "contracts/Proxy/TransparentUpgradeableProxy.sol"; import {console} from "forge-std/src/Console.sol"; import {IInfraStorage} from "contracts/Interfaces/IInfraStorage.sol"; +import {InfraStorageSetters} from "contracts/Libraries/InfraStorageSetters.sol"; contract DeployInfraScript is DeployHelper { // @notice contract addresses @@ -47,6 +48,7 @@ contract DeployInfraScript is DeployHelper { function _deployFullInfra() internal { _deployInfraProxy(); _deployAndSetImplementation(); + _setInfraVars(); } function _deployInfraProxy() internal { @@ -101,4 +103,19 @@ contract DeployInfraScript is DeployHelper { messengers ); } + + function _setInfraVars() internal { + _setAllowedDexRouters(); + } + + function _setAllowedDexRouters() internal { + address[] memory dexRouters = getDexRouters(); + vm.startPrank(deployer); + + for (uint i; i < dexRouters.length; i++) { + InfraStorageSetters(address(infraProxy)).setDexRouterAddress(dexRouters[i], true); + } + + vm.stopPrank(); + } } diff --git a/test/foundry/utils/DeployHelper.sol b/test/foundry/utils/DeployHelper.sol index 78950959..9825b311 100644 --- a/test/foundry/utils/DeployHelper.sol +++ b/test/foundry/utils/DeployHelper.sol @@ -145,4 +145,17 @@ contract DeployHelper is Script { return vm.envAddress("CL_CCIP_ROUTER_BASE"); } + + function getDexRouters() public returns (address[] memory) { + uint256 chainId = block.chainid; + + if (chainId == vm.envUint("BASE_CHAIN_ID")) { + address[] memory routers = new address[](1); + routers[0] = vm.envAddress("UNISWAP_ROUTER_BASE"); + return routers; + } + + address[] memory res = new address[](0); + return res; + } } From 36249f5f7b5b60800b58cbfcd4d4d668e4536275 Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Tue, 17 Dec 2024 00:20:36 +0300 Subject: [PATCH 24/54] add view --- test/foundry/utils/DeployHelper.sol | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/test/foundry/utils/DeployHelper.sol b/test/foundry/utils/DeployHelper.sol index 9825b311..b4e377d3 100644 --- a/test/foundry/utils/DeployHelper.sol +++ b/test/foundry/utils/DeployHelper.sol @@ -1,9 +1,10 @@ +// SPDX-License-Identifier: SEE LICENSE IN LICENSE pragma solidity 0.8.20; import {Script} from "forge-std/src/Script.sol"; contract DeployHelper is Script { - function getClfRouter() public returns (address) { + function getClfRouter() public view returns (address) { uint256 chainId = block.chainid; if (chainId == vm.envUint("BASE_CHAIN_ID")) { @@ -23,7 +24,7 @@ contract DeployHelper is Script { return vm.envAddress("CLF_ROUTER_BASE"); } - function getCLfSubId() public returns (uint64) { + function getCLfSubId() public view returns (uint64) { uint256 chainId = block.chainid; uint256 res = vm.envUint("CLF_SUBID_BASE"); @@ -44,7 +45,7 @@ contract DeployHelper is Script { return uint64(res); } - function getDonId() public returns (bytes32) { + function getDonId() public view returns (bytes32) { uint256 chainId = block.chainid; if (chainId == vm.envUint("BASE_CHAIN_ID")) { @@ -64,7 +65,7 @@ contract DeployHelper is Script { return vm.envBytes32("CLF_DONID_BASE"); } - function getChainSelector() public returns (uint64) { + function getChainSelector() public view returns (uint64) { uint256 chainId = block.chainid; uint256 res = vm.envUint("CL_CCIP_CHAIN_SELECTOR_BASE"); @@ -85,7 +86,7 @@ contract DeployHelper is Script { return uint64(res); } - function getChainIndex() public returns (uint8) { + function getChainIndex() public view returns (uint8) { uint256 chainId = block.chainid; uint256 res = 1; @@ -106,7 +107,7 @@ contract DeployHelper is Script { return uint8(res); } - function getLinkAddress() public returns (address) { + function getLinkAddress() public view returns (address) { uint256 chainId = block.chainid; if (chainId == vm.envUint("BASE_CHAIN_ID")) { @@ -126,7 +127,7 @@ contract DeployHelper is Script { return vm.envAddress("LINK_BASE"); } - function getCcipRouter() public returns (address) { + function getCcipRouter() public view returns (address) { uint256 chainId = block.chainid; if (chainId == vm.envUint("BASE_CHAIN_ID")) { @@ -146,7 +147,7 @@ contract DeployHelper is Script { return vm.envAddress("CL_CCIP_ROUTER_BASE"); } - function getDexRouters() public returns (address[] memory) { + function getDexRouters() public view returns (address[] memory) { uint256 chainId = block.chainid; if (chainId == vm.envUint("BASE_CHAIN_ID")) { From 3c2077efe751f2c00b652f0c3add99fc01e804a1 Mon Sep 17 00:00:00 2001 From: lufaque <95128636+lufaque@users.noreply.github.com> Date: Tue, 17 Dec 2024 10:22:51 +0300 Subject: [PATCH 25/54] update naming --- .../InfraOrchestrator/InfraOrchestrator.swap.t.sol | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol index 7bd0aa6e..5bfcf83b 100644 --- a/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol +++ b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol @@ -17,7 +17,7 @@ contract DexSwapTest is Test { address internal infraProxy; - modifier selectFork(uint256 forkId) { + modifier selectForkAndUpdateInfraProxy(uint256 forkId) { DeployInfraScript deployInfraScript = new DeployInfraScript(); infraProxy = deployInfraScript.run(forkId); _; @@ -25,11 +25,11 @@ contract DexSwapTest is Test { function testFork_Univ3OnBaseViaRangoRouting() public - selectFork(vm.createFork(vm.envString("BASE_RPC_URL"), 23793491)) + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("BASE_RPC_URL"), 23814899)) { uint256 fromAmount = 0.1 ether; - uint256 toAmount = 406.037259e6; - uint256 toAmountMin = 404.007072e6; + uint256 toAmount = 400.734039e6; + uint256 toAmountMin = 398.730368e6; address user = makeAddr("user"); console.log(user); @@ -38,7 +38,7 @@ contract DexSwapTest is Test { uint256 userToTokenBalanceBefore = IERC20(vm.envAddress("USDC_BASE")).balanceOf(user); // @notice swap data generated by rango bytes - memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124b858183f0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000162623ba10abc00000000000000000000000000000000000000000000000000000000001814a8a0000000000000000000000000000000000000000000000000000000000000004242000000000000000000000000000000000000060001f4cbb7c0000ab88b473b1f5afd9ef808440eed33bf0001f4833589fcd6edb6e08f4c7c32d4f71b54bda0291300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000104b858183f0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000162623ba10abc000000000000000000000000000000000000000000000000000000000017bcd6d8000000000000000000000000000000000000000000000000000000000000002b42000000000000000000000000000000000000060001f4833589fcd6edb6e08f4c7c32d4f71b54bda0291300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); swapData[0] = IDexSwap.SwapData({ From 4538e9ff1058f201aab2f5e41c5a47f8f6096641 Mon Sep 17 00:00:00 2001 From: lufaque <95128636+lufaque@users.noreply.github.com> Date: Tue, 17 Dec 2024 12:46:49 +0300 Subject: [PATCH 26/54] update dex swap, add univ3 and sushi swap tests --- .env.clccip | 1 + contracts/DexSwap.sol | 108 +++++++----------- .../InfraOrchestrator.swap.t.sol | 108 +++++++++++++++--- test/foundry/utils/DeployHelper.sol | 3 +- 4 files changed, 139 insertions(+), 81 deletions(-) diff --git a/.env.clccip b/.env.clccip index 16143658..66d72245 100644 --- a/.env.clccip +++ b/.env.clccip @@ -50,6 +50,7 @@ UNI_V3_ROUTER_ARBITRUM=0xE592427A0AEce92De3Edee1F18E0157C05861564 # SUSHISWAP ROUTERS SUSHISWAP_ROUTER_ARBITRUM=0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506 +SUSHISWAP_ROUTER_BASE=0x6BDED42c6DA8FBf0d2bA55B2fa120C5e0c8D7891 # QUICKSWAP ROUTERS QUICKSWAP_ROUTER_POLYGON_ADDRESS=0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff diff --git a/contracts/DexSwap.sol b/contracts/DexSwap.sol index 31038e9e..2afd962b 100644 --- a/contracts/DexSwap.sol +++ b/contracts/DexSwap.sol @@ -13,7 +13,6 @@ import {InfraStorage} from "./Libraries/InfraStorage.sol"; import {IDexSwap} from "./Interfaces/IDexSwap.sol"; import {LibConcero} from "./Libraries/LibConcero.sol"; import {InfraCommon} from "./InfraCommon.sol"; -import {IWETH} from "./Interfaces/IWETH.sol"; /* ERRORS */ ///@notice error emitted when the caller is not allowed @@ -26,7 +25,6 @@ error DexRouterNotAllowed(); error InvalidTokenPath(); ///@notice error emitted when the DexData is not valid error InvalidDexData(); -error UnwrapWNativeFailed(); ///@notice error emitted when the amount is not sufficient error InsufficientAmount(uint256 amount); ///@notice error emitted when the transfer failed @@ -57,58 +55,69 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { } function entrypoint( - IDexSwap.SwapData[] memory _swapData, - address _recipient + IDexSwap.SwapData[] memory swapData, + address recipient ) external payable returns (uint256) { if (address(this) != i_proxy) revert OnlyProxyContext(address(this)); - uint256 swapDataLength = _swapData.length; - address dstToken = _swapData[swapDataLength - 1].toToken; - uint256 recipientBalanceBefore = LibConcero.getBalance(dstToken, _recipient); + uint256 swapDataLength = swapData.length; + address dstToken = swapData[swapDataLength - 1].toToken; + uint256 addressThisBalanceBefore = LibConcero.getBalance(dstToken, address(this)); + uint256 balanceAfter; - for (uint256 i; i < swapDataLength; ) { - //seems to be useless - uint256 preSwapBalance = LibConcero.getBalance(_swapData[i].toToken, address(this)); + for (uint256 i; i < swapDataLength; i++) { + uint256 balanceBefore = LibConcero.getBalance(swapData[i].toToken, address(this)); - _performSwap(_swapData[i]); + _performSwap(swapData[i]); + + balanceAfter = LibConcero.getBalance(swapData[i].toToken, address(this)); + uint256 remainingBalance = balanceAfter - balanceBefore; + + if (remainingBalance < swapData[i].toAmountMin) { + revert InsufficientAmount(remainingBalance); + } if (i < swapDataLength - 1) { - if (_swapData[i].toToken != _swapData[i + 1].fromToken) { + if (swapData[i].toToken != swapData[i + 1].fromToken) { revert InvalidTokenPath(); } - //seems to be useless - uint256 postSwapBalance = LibConcero.getBalance( - _swapData[i].toToken, - address(this) - ); - uint256 remainingBalance = postSwapBalance - preSwapBalance; - - if (remainingBalance < _swapData[i].toAmountMin) { - revert InsufficientAmount(remainingBalance); - } - _swapData[i + 1].fromAmount = remainingBalance; - } - - unchecked { - ++i; + swapData[i + 1].fromAmount = remainingBalance; } } - uint256 recipientBalanceAfter = LibConcero.getBalance(dstToken, _recipient); - uint256 dstTokenReceived = recipientBalanceAfter - recipientBalanceBefore; + uint256 dstTokenReceived = balanceAfter - addressThisBalanceBefore; + + if (recipient != address(this)) { + _transferTokenToUser(recipient, dstToken, dstTokenReceived); + } emit ConceroSwap( - _swapData[0].fromToken, + swapData[0].fromToken, dstToken, - _swapData[0].fromAmount, + swapData[0].fromAmount, dstTokenReceived, - _recipient + recipient ); return dstTokenReceived; } + function _transferTokenToUser(address recipient, address token, uint256 amount) internal { + if (amount == 0 || recipient == address(0)) { + revert InvalidDexData(); + } + + if (token == address(0)) { + (bool success, ) = recipient.call{value: amount}(""); + if (!success) { + revert TransferFailed(); + } + } else { + IERC20(token).safeTransfer(recipient, amount); + } + } + function _performSwap(IDexSwap.SwapData memory _swapData) private { if (_swapData.dexData.length == 0) revert EmptyDexData(); @@ -128,39 +137,4 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { if (!success) revert InvalidDexData(); } - - // function _wrapNative(IDexSwap.SwapData memory _swapData) private { - // address wrappedNative = _getWrappedNative(); - // IWETH(wrappedNative).deposit{value: _swapData.fromAmount}(); - // } - - // function _unwrapWNative(IDexSwap.SwapData memory _swapData, address _recipient) private { - // if (_swapData.fromToken != _getWrappedNative()) revert InvalidDexData(); - - // IWETH(_swapData.fromToken).withdraw(_swapData.fromAmount); - - // (bool sent, ) = _recipient.call{value: _swapData.fromAmount}(""); - // if (!sent) { - // revert UnwrapWNativeFailed(); - // } - // } - - /* HELPER FUNCTIONS */ - // function _extractTokens( - // bytes memory _path - // ) private pure returns (address _firstToken, address _lastToken) { - // uint256 pathSize = _path.length; - // - // bytes memory tokenBytes = _path.slice(0, 20); - // - // assembly { - // _firstToken := mload(add(tokenBytes, 20)) - // } - // - // bytes memory secondTokenBytes = _path.slice(pathSize - 20, 20); - // - // assembly { - // _lastToken := mload(add(secondTokenBytes, 20)) - // } - // } } diff --git a/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol index 5bfcf83b..1e755446 100644 --- a/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol +++ b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol @@ -8,6 +8,7 @@ import {InfraOrchestrator} from "contracts/InfraOrchestrator.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {console} from "forge-std/src/console.sol"; import {DeployInfraScript} from "../scripts/DeployInfra.s.sol"; +import {LibConcero} from "contracts/Libraries/LibConcero.sol"; contract DexSwapTest is Test { // @notice helper vars @@ -23,7 +24,7 @@ contract DexSwapTest is Test { _; } - function testFork_Univ3OnBaseViaRangoRouting() + function testFork_Univ3BaseNativeToErc20ViaRangoRouting() public selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("BASE_RPC_URL"), 23814899)) { @@ -31,14 +32,10 @@ contract DexSwapTest is Test { uint256 toAmount = 400.734039e6; uint256 toAmountMin = 398.730368e6; address user = makeAddr("user"); - console.log(user); - deal(user, fromAmount); - - uint256 userToTokenBalanceBefore = IERC20(vm.envAddress("USDC_BASE")).balanceOf(user); // @notice swap data generated by rango bytes - memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000104b858183f0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000162623ba10abc000000000000000000000000000000000000000000000000000000000017bcd6d8000000000000000000000000000000000000000000000000000000000000002b42000000000000000000000000000000000000060001f4833589fcd6edb6e08f4c7c32d4f71b54bda0291300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + memory dexData = hex"ac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000124b858183f00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000b1311dd0855e00000000000000000000000000000000000000000000000000000000000be200d1000000000000000000000000000000000000000000000000000000000000004242000000000000000000000000000000000000060001f4d9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca000064833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000104b858183f00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000b1311dd0855e00000000000000000000000000000000000000000000000000000000000be1dfbc000000000000000000000000000000000000000000000000000000000000002b42000000000000000000000000000000000000060001f4833589fcd6edb6e08f4c7c32d4f71b54bda0291300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); swapData[0] = IDexSwap.SwapData({ @@ -51,14 +48,99 @@ contract DexSwapTest is Test { dexData: dexData }); - vm.prank(user); - InfraOrchestrator(payable(infraProxy)).swap{value: fromAmount}( - swapData, - user, - emptyIntegration - ); + _performSwapAndCheck(swapData, user); + } + + function testFork_UniV3Erc20ToErc20BaseViaRangoRouting() + public + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("BASE_RPC_URL"), 23817245)) + { + uint256 fromAmount = 100e6; + uint256 toAmount = 468828.018268057070520348e18; + uint256 toAmountMin = 468359.190249789013449827e18; + address fromToken = vm.envAddress("USDC_BASE"); + address toToken = address(0xAC1Bd2486aAf3B5C0fc3Fd868558b082a531B2B4); // @notice Toshi token + address user = makeAddr("user"); + + // @notice swap data generated by rango + bytes + memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124b858183f0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000005f2110600000000000000000000000000000000000000000000632dcd75cad78e795c630000000000000000000000000000000000000000000000000000000000000042833589fcd6edb6e08f4c7c32d4f71b54bda029130001f44200000000000000000000000000000000000006002710ac1bd2486aaf3b5c0fc3fd868558b082a531b2b400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: vm.envAddress("UNISWAP_ROUTER_BASE"), + fromToken: fromToken, + fromAmount: fromAmount, + toToken: toToken, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _performSwapAndCheck(swapData, user); + } + + function testFork_SushiSwapErc20ToErc20BaseViaRangoRouting() + public + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("BASE_RPC_URL"), 23818245)) + { + uint256 fromAmount = 100e6; + uint256 toAmount = 0.023621031555323924e18; + uint256 toAmountMin = 0.021258928399791531e18; + address fromToken = vm.envAddress("USDC_BASE"); + address toToken = address(0x4200000000000000000000000000000000000006); // @notice weth token + address user = makeAddr("user"); + + // @notice swap data generated by rango + bytes + memory dexData = hex"38ed17390000000000000000000000000000000000000000000000000000000005f21106000000000000000000000000000000000000000000000000004b86e1fb9335ac00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000000676146d70000000000000000000000000000000000000000000000000000000000000002000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000004200000000000000000000000000000000000006"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: vm.envAddress("SUSHISWAP_ROUTER_BASE"), + fromToken: fromToken, + fromAmount: fromAmount, + toToken: toToken, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + uint256 userToTokenBalanceBefore = IERC20(toToken).balanceOf(user); + + _performSwapAndCheck(swapData, user); + } + + function _performSwapAndCheck(IDexSwap.SwapData[] memory swapData, address recipient) internal { + address fromToken = swapData[0].fromToken; + address toToken = swapData[swapData.length - 1].toToken; + uint256 fromAmount = swapData[0].fromAmount; + uint256 toAmount = swapData[swapData.length - 1].toAmount; + uint256 toAmountMin = swapData[swapData.length - 1].toAmountMin; + bool isFormTokenNative = fromToken == address(0); + uint256 userToTokenBalanceBefore = LibConcero.getBalance(toToken, recipient); + + if (isFormTokenNative) { + deal(recipient, fromAmount); + } else { + deal(fromToken, recipient, fromAmount); + } + + vm.startPrank(recipient); + + if (isFormTokenNative) { + InfraOrchestrator(payable(infraProxy)).swap{value: fromAmount}( + swapData, + recipient, + emptyIntegration + ); + } else { + IERC20(fromToken).approve(address(infraProxy), fromAmount); + InfraOrchestrator(payable(infraProxy)).swap(swapData, recipient, emptyIntegration); + } + vm.stopPrank(); - uint256 userToTokenBalanceAfter = IERC20(vm.envAddress("USDC_BASE")).balanceOf(user); + uint256 userToTokenBalanceAfter = LibConcero.getBalance(toToken, recipient); uint256 toTokenReceived = userToTokenBalanceAfter - userToTokenBalanceBefore; assert(toTokenReceived >= toAmountMin); diff --git a/test/foundry/utils/DeployHelper.sol b/test/foundry/utils/DeployHelper.sol index b4e377d3..65e8e56a 100644 --- a/test/foundry/utils/DeployHelper.sol +++ b/test/foundry/utils/DeployHelper.sol @@ -151,8 +151,9 @@ contract DeployHelper is Script { uint256 chainId = block.chainid; if (chainId == vm.envUint("BASE_CHAIN_ID")) { - address[] memory routers = new address[](1); + address[] memory routers = new address[](2); routers[0] = vm.envAddress("UNISWAP_ROUTER_BASE"); + routers[1] = vm.envAddress("SUSHISWAP_ROUTER_BASE"); return routers; } From 07eeb5929172c463f6027cda052b382846d2d922 Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Tue, 17 Dec 2024 13:57:48 +0300 Subject: [PATCH 27/54] fix typo --- test/foundry/scripts/DeployInfra.s.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/foundry/scripts/DeployInfra.s.sol b/test/foundry/scripts/DeployInfra.s.sol index 1b728934..02a80060 100644 --- a/test/foundry/scripts/DeployInfra.s.sol +++ b/test/foundry/scripts/DeployInfra.s.sol @@ -7,7 +7,7 @@ import {InfraOrchestrator} from "contracts/InfraOrchestrator.sol"; import {PauseDummy} from "contracts/PauseDummy.sol"; import {Script} from "forge-std/src/Script.sol"; import {TransparentUpgradeableProxy, ITransparentUpgradeableProxy} from "contracts/Proxy/TransparentUpgradeableProxy.sol"; -import {console} from "forge-std/src/Console.sol"; +import {console} from "forge-std/src/console.sol"; import {IInfraStorage} from "contracts/Interfaces/IInfraStorage.sol"; import {InfraStorageSetters} from "contracts/Libraries/InfraStorageSetters.sol"; From 69e58ccdcd3bf2aaf30dce55a23c7ef234f4d915 Mon Sep 17 00:00:00 2001 From: lufaque <95128636+lufaque@users.noreply.github.com> Date: Tue, 17 Dec 2024 13:58:18 +0300 Subject: [PATCH 28/54] update dex swap, add univ3 and sushi swap tests --- contracts/DexSwap.sol | 15 +++-- .../InfraOrchestrator.swap.t.sol | 59 ++++++++++++++++++- 2 files changed, 66 insertions(+), 8 deletions(-) diff --git a/contracts/DexSwap.sol b/contracts/DexSwap.sol index 2afd962b..4348aced 100644 --- a/contracts/DexSwap.sol +++ b/contracts/DexSwap.sol @@ -29,6 +29,7 @@ error InvalidDexData(); error InsufficientAmount(uint256 amount); ///@notice error emitted when the transfer failed error TransferFailed(); +error SwapFailed(); contract DexSwap is IDexSwap, InfraCommon, InfraStorage { using SafeERC20 for IERC20; @@ -65,16 +66,16 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { uint256 addressThisBalanceBefore = LibConcero.getBalance(dstToken, address(this)); uint256 balanceAfter; - for (uint256 i; i < swapDataLength; i++) { + for (uint256 i; i < swapDataLength; ++i) { uint256 balanceBefore = LibConcero.getBalance(swapData[i].toToken, address(this)); _performSwap(swapData[i]); balanceAfter = LibConcero.getBalance(swapData[i].toToken, address(this)); - uint256 remainingBalance = balanceAfter - balanceBefore; + uint256 tokenReceived = balanceAfter - balanceBefore; - if (remainingBalance < swapData[i].toAmountMin) { - revert InsufficientAmount(remainingBalance); + if (tokenReceived < swapData[i].toAmountMin) { + revert InsufficientAmount(tokenReceived); } if (i < swapDataLength - 1) { @@ -82,7 +83,7 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { revert InvalidTokenPath(); } - swapData[i + 1].fromAmount = remainingBalance; + swapData[i + 1].fromAmount = tokenReceived; } } @@ -135,6 +136,8 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { (success, ) = routerAddress.call(_swapData.dexData); } - if (!success) revert InvalidDexData(); + if (!success) { + revert SwapFailed(); + } } } diff --git a/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol index 1e755446..10c31806 100644 --- a/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol +++ b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol @@ -106,7 +106,63 @@ contract DexSwapTest is Test { dexData: dexData }); - uint256 userToTokenBalanceBefore = IERC20(toToken).balanceOf(user); + _performSwapAndCheck(swapData, user); + } + + function testFork_UniV3Erc20ToNativeBaseViaRangoRouting() + public + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("BASE_RPC_URL"), 23819957)) + { + uint256 fromAmount = 100e6; + uint256 toAmount = 0.024773855091872125e18; + uint256 toAmountMin = 0.024649985816412764e18; + address fromToken = address(0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA); // @notice USDCb + address toToken = NATIVE_TOKEN; + address user = makeAddr("user"); + + // @notice swap data generated by rango + bytes + memory dexData = hex"ac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000124b858183f0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000005f2110600000000000000000000000000000000000000000000000000579308104e425c0000000000000000000000000000000000000000000000000000000000000042d9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca000064833589fcd6edb6e08f4c7c32d4f71b54bda029130001f4420000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004449404b7c00000000000000000000000000000000000000000000000000579308104e425c000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000000"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: vm.envAddress("UNISWAP_ROUTER_BASE"), + fromToken: fromToken, + fromAmount: fromAmount, + toToken: toToken, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _performSwapAndCheck(swapData, user); + } + + function testFork_SushiSwapErc20ToNativeBaseViaRangoRouting() + public + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("BASE_RPC_URL"), 23820938)) + { + uint256 fromAmount = 100e6; + uint256 toAmount = 0.021804830498532758e18; + uint256 toAmountMin = 0.021695806346040094e18; + address fromToken = address(0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA); // @notice USDCb + address toToken = NATIVE_TOKEN; + address user = makeAddr("user"); + + // @notice swap data generated by rango + bytes + memory dexData = hex"18cbafe50000000000000000000000000000000000000000000000000000000005f21106000000000000000000000000000000000000000000000000004d14388e5f131e00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000000676159260000000000000000000000000000000000000000000000000000000000000002000000000000000000000000d9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca0000000000000000000000004200000000000000000000000000000000000006"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: vm.envAddress("SUSHISWAP_ROUTER_BASE"), + fromToken: fromToken, + fromAmount: fromAmount, + toToken: toToken, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); _performSwapAndCheck(swapData, user); } @@ -115,7 +171,6 @@ contract DexSwapTest is Test { address fromToken = swapData[0].fromToken; address toToken = swapData[swapData.length - 1].toToken; uint256 fromAmount = swapData[0].fromAmount; - uint256 toAmount = swapData[swapData.length - 1].toAmount; uint256 toAmountMin = swapData[swapData.length - 1].toAmountMin; bool isFormTokenNative = fromToken == address(0); uint256 userToTokenBalanceBefore = LibConcero.getBalance(toToken, recipient); From 23870e570173b163c5317cc9620acd32bee1575a Mon Sep 17 00:00:00 2001 From: lufaque <95128636+lufaque@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:18:38 +0300 Subject: [PATCH 29/54] sushi swap, uniswap tests --- contracts/DexSwap.sol | 16 +- .../InfraOrchestrator.swap.t.sol | 906 +----------------- 2 files changed, 30 insertions(+), 892 deletions(-) diff --git a/contracts/DexSwap.sol b/contracts/DexSwap.sol index 4348aced..5366a69a 100644 --- a/contracts/DexSwap.sol +++ b/contracts/DexSwap.sol @@ -119,21 +119,21 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { } } - function _performSwap(IDexSwap.SwapData memory _swapData) private { - if (_swapData.dexData.length == 0) revert EmptyDexData(); + function _performSwap(IDexSwap.SwapData memory swapData) private { + if (swapData.dexData.length == 0) revert EmptyDexData(); - address routerAddress = _swapData.dexRouter; + address routerAddress = swapData.dexRouter; if (!s_routerAllowed[routerAddress]) revert DexRouterNotAllowed(); - uint256 fromAmount = _swapData.fromAmount; - bool isFromNative = _swapData.fromToken == address(0); + uint256 fromAmount = swapData.fromAmount; + bool isFromNative = swapData.fromToken == address(0); bool success; if (isFromNative) { - (success, ) = routerAddress.call{value: fromAmount}(_swapData.dexData); + (success, ) = routerAddress.call{value: fromAmount}(swapData.dexData); } else { - IERC20(_swapData.fromToken).safeIncreaseAllowance(routerAddress, fromAmount); - (success, ) = routerAddress.call(_swapData.dexData); + IERC20(swapData.fromToken).safeIncreaseAllowance(routerAddress, fromAmount); + (success, ) = routerAddress.call(swapData.dexData); } if (!success) { diff --git a/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol index 10c31806..c2158887 100644 --- a/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol +++ b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol @@ -24,6 +24,8 @@ contract DexSwapTest is Test { _; } + // @dev UNISWAP + function testFork_Univ3BaseNativeToErc20ViaRangoRouting() public selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("BASE_RPC_URL"), 23814899)) @@ -80,24 +82,24 @@ contract DexSwapTest is Test { _performSwapAndCheck(swapData, user); } - function testFork_SushiSwapErc20ToErc20BaseViaRangoRouting() + function testFork_UniV3Erc20ToNativeBaseViaRangoRouting() public - selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("BASE_RPC_URL"), 23818245)) + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("BASE_RPC_URL"), 23819957)) { uint256 fromAmount = 100e6; - uint256 toAmount = 0.023621031555323924e18; - uint256 toAmountMin = 0.021258928399791531e18; - address fromToken = vm.envAddress("USDC_BASE"); - address toToken = address(0x4200000000000000000000000000000000000006); // @notice weth token + uint256 toAmount = 0.024773855091872125e18; + uint256 toAmountMin = 0.024649985816412764e18; + address fromToken = address(0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA); // @notice USDCb + address toToken = NATIVE_TOKEN; address user = makeAddr("user"); // @notice swap data generated by rango bytes - memory dexData = hex"38ed17390000000000000000000000000000000000000000000000000000000005f21106000000000000000000000000000000000000000000000000004b86e1fb9335ac00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000000676146d70000000000000000000000000000000000000000000000000000000000000002000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000004200000000000000000000000000000000000006"; + memory dexData = hex"ac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000124b858183f0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000005f2110600000000000000000000000000000000000000000000000000579308104e425c0000000000000000000000000000000000000000000000000000000000000042d9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca000064833589fcd6edb6e08f4c7c32d4f71b54bda029130001f4420000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004449404b7c00000000000000000000000000000000000000000000000000579308104e425c000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000000"; IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); swapData[0] = IDexSwap.SwapData({ - dexRouter: vm.envAddress("SUSHISWAP_ROUTER_BASE"), + dexRouter: vm.envAddress("UNISWAP_ROUTER_BASE"), fromToken: fromToken, fromAmount: fromAmount, toToken: toToken, @@ -109,24 +111,26 @@ contract DexSwapTest is Test { _performSwapAndCheck(swapData, user); } - function testFork_UniV3Erc20ToNativeBaseViaRangoRouting() + // @dev SUSHI SWAP + + function testFork_SushiSwapErc20ToErc20BaseViaRangoRouting() public - selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("BASE_RPC_URL"), 23819957)) + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("BASE_RPC_URL"), 23818245)) { uint256 fromAmount = 100e6; - uint256 toAmount = 0.024773855091872125e18; - uint256 toAmountMin = 0.024649985816412764e18; - address fromToken = address(0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA); // @notice USDCb - address toToken = NATIVE_TOKEN; + uint256 toAmount = 0.023621031555323924e18; + uint256 toAmountMin = 0.021258928399791531e18; + address fromToken = vm.envAddress("USDC_BASE"); + address toToken = address(0x4200000000000000000000000000000000000006); // @notice weth token address user = makeAddr("user"); // @notice swap data generated by rango bytes - memory dexData = hex"ac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000124b858183f0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000005f2110600000000000000000000000000000000000000000000000000579308104e425c0000000000000000000000000000000000000000000000000000000000000042d9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca000064833589fcd6edb6e08f4c7c32d4f71b54bda029130001f4420000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004449404b7c00000000000000000000000000000000000000000000000000579308104e425c000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000000"; + memory dexData = hex"38ed17390000000000000000000000000000000000000000000000000000000005f21106000000000000000000000000000000000000000000000000004b86e1fb9335ac00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000000676146d70000000000000000000000000000000000000000000000000000000000000002000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000004200000000000000000000000000000000000006"; IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); swapData[0] = IDexSwap.SwapData({ - dexRouter: vm.envAddress("UNISWAP_ROUTER_BASE"), + dexRouter: vm.envAddress("SUSHISWAP_ROUTER_BASE"), fromToken: fromToken, fromAmount: fromAmount, toToken: toToken, @@ -167,6 +171,8 @@ contract DexSwapTest is Test { _performSwapAndCheck(swapData, user); } + // @dev helper functions + function _performSwapAndCheck(IDexSwap.SwapData[] memory swapData, address recipient) internal { address fromToken = swapData[0].fromToken; address toToken = swapData[swapData.length - 1].toToken; @@ -182,7 +188,6 @@ contract DexSwapTest is Test { } vm.startPrank(recipient); - if (isFormTokenNative) { InfraOrchestrator(payable(infraProxy)).swap{value: fromAmount}( swapData, @@ -200,871 +205,4 @@ contract DexSwapTest is Test { assert(toTokenReceived >= toAmountMin); } - - // address internal constant ETH_TOKEN = address(0); - // address internal constant POL_TOKEN = address(0); - // - // // Base tokens - // address internal usdcTokenBase = vm.envAddress("USDC_BASE"); - // address internal wethTokenBase = vm.envAddress("WETH_BASE"); - // address internal daiTokenBase = vm.envAddress("DAI_BASE"); - // address internal sushiTokenBase = vm.envAddress("SUSHI_BASE"); - // address internal oneInchTokenBase = vm.envAddress("1INCH_BASE"); - // - // //Arbitrum tokens - // address internal usdcTokenArbitrum = vm.envAddress("USDC_ARBITRUM"); - // address internal usdtTokenArbitrum = vm.envAddress("USDT_ARBITRUM"); - // address internal wethTokenArbitrum = vm.envAddress("WETH_ARBITRUM"); - // - // //Polygon tokens - // address internal usdcTokenPolygon = vm.envAddress("USDC_POLYGON"); - // address internal wethTokenPolygon = vm.envAddress("WETH_POLYGON"); - // - // //Avalanche tokens - // address internal usdcTokenAvalanche = vm.envAddress("USDC_AVALANCHE"); - // address internal wavaxTokenAvalanche = vm.envAddress("WAVAX_AVALANCHE"); - // - // //Arbitrum Routers - // address internal sushiRouterArbitrum = vm.envAddress("SUSHISWAP_ROUTER_ARBITRUM_ADDRESS"); - // address internal uniV3RouterArbitrum = vm.envAddress("UNI_V3_ROUTER_ARBITRUM_ADDRESS"); - // address internal paraSwapV5RouterArbitrum = - // vm.envAddress("PARASWAP_V5_ROUTER_ARBITRUM_ADDRESS"); - // - // //Base Routers - // address internal uniV3RouterBase = vm.envAddress("UNI_V3_ROUTER02_BASE_ADDRESS"); - // address internal paraSwapV6_2RouterBase = vm.envAddress("PARASWAP_V6_2_ROUTER_BASE_ADDRESS"); - // address internal odosRouterV2Base = vm.envAddress("ODOS_ROUTER_V2_BASE_ADDRESS"); - // address internal oneInchRouterV5Base = vm.envAddress("1INCH_ROUTER_V5_BASE_ADDRESS"); - // address internal curveRouterBase = vm.envAddress("CURVE_ROUTER_BASE_ADDRESS"); - // address internal alienbaseRouterBase = vm.envAddress("ALIENBASE_ROUTER_BASE_ADDRESS"); - // - // //Polygon Routers - // address internal quickSwapRouterPolygon = vm.envAddress("QUICKSWAP_ROUTER_POLYGON_ADDRESS"); - // - // //Avalanche Routers - // address internal pangolinRouterAvalanche = vm.envAddress("PANGOLIN_ROUTER_AVALANCHE_ADDRESS"); - // - // address payable internal sender = payable(makeAddr("sender")); - // address internal integrator = makeAddr("integrator"); - // - // modifier addRouterInWhiteList(address router, address proxy) { - // _allowRouter(router, address(proxy)); - // _; - // } - // - // function setUp() public override setFork(polygonAnvilForkId) { - // super.setUp(); - // } - // - // //////////////////// Base /////////////////////////////// - // //////////////////// Block number 22713659 ////////////// - // - // ////////////////////////////////////////////////////////// - // ////////////////// Alienbase //////////////////// - // ////////////////////////////////////////////////////////// - // - // //passed - // function test_dexSwapAlienbaseRouterETHToUSDCBase() - // public - // setFork(baseAnvilForkId) - // addRouterInWhiteList(alienbaseRouterBase, address(baseOrchestratorProxy)) - // { - // uint256 fromAmount = 0.1 ether; - // uint256 toAmount = 267.528449e6; - // uint256 toAmountMin = 266.190806e6; - // - // bytes - // memory dexData = hex"7ff36ab5000000000000000000000000000000000000000000000000000000000fddbfd70000000000000000000000000000000000000000000000000000000000000080000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673fb53400000000000000000000000000000000000000000000000000000000000000020000000000000000000000004200000000000000000000000000000000000006000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: alienbaseRouterBase, - // fromToken: ETH_TOKEN, - // fromAmount: fromAmount, - // toToken: usdcTokenBase, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(baseOrchestratorProxy)); - // } - // - // //passed - // function test_dexSwapAlienbaseRouterUSDCToWETHBase() - // public - // setFork(baseAnvilForkId) - // addRouterInWhiteList(alienbaseRouterBase, address(baseOrchestratorProxy)) - // { - // uint256 fromAmount = 10e6; //10 usdc - // uint256 toAmount = 0.002945698049459263e18; - // uint256 toAmountMin = 0.002930969559211966e18; - // - // bytes - // memory dexData = hex"38ed173900000000000000000000000000000000000000000000000000000000009834e7000000000000000000000000000000000000000000000000000a69b3876c9fbe00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673fb6140000000000000000000000000000000000000000000000000000000000000002000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000004200000000000000000000000000000000000006"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: alienbaseRouterBase, - // fromToken: usdcTokenBase, - // fromAmount: fromAmount, - // toToken: wethTokenBase, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(baseOrchestratorProxy)); - // } - // - // //passed - // function test_dexSwapAlienbaseRouterUSDCToETHBase() - // public - // setFork(baseAnvilForkId) - // addRouterInWhiteList(alienbaseRouterBase, address(baseOrchestratorProxy)) - // { - // uint256 fromAmount = 10e6; - // uint256 toAmount = 0.002945698049459263 ether; - // uint256 toAmountMin = 0.002930969559211966 ether; - // - // bytes - // memory dexData = hex"18cbafe500000000000000000000000000000000000000000000000000000000009834e7000000000000000000000000000000000000000000000000000a69b3876c9fbe00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673fb67c0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000004200000000000000000000000000000000000006"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: alienbaseRouterBase, - // fromToken: usdcTokenBase, - // fromAmount: fromAmount, - // toToken: ETH_TOKEN, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(baseOrchestratorProxy)); - // } - // - // ////////////////////////////////////////////////////////// - // ////////////////// Curve //////////////////////// - // ////////////////////////////////////////////////////////// - // - // //passed - // function test_dexSwapCurveRouterUSDCToWETHBase() - // public - // setFork(baseAnvilForkId) - // addRouterInWhiteList(curveRouterBase, address(baseOrchestratorProxy)) - // { - // uint256 fromAmount = 10e6; //1 usdc - // uint256 toAmount = 0.002950528095025959e18; - // uint256 toAmountMin = 0.002935775454550829e18; - // - // bytes - // memory dexData = hex"c872a3c5000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f000000000000000000000000417ac0e078398c154edfadd9ef675d30be60af930000000000000000000000006e53131f68a034873b6bfa15502af094ef0c58540000000000000000000000004200000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009834e7000000000000000000000000000000000000000000000000000a6e127d1bdb2d000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f0000000000000000000000006e53131f68a034873b6bfa15502af094ef0c5854000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: curveRouterBase, - // fromToken: usdcTokenBase, - // fromAmount: fromAmount, - // toToken: wethTokenBase, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(baseOrchestratorProxy)); - // } - // - // //not working - // function test_dexSwapCurveRouterETHToUSDCBase() - // public - // setFork(baseAnvilForkId) - // addRouterInWhiteList(curveRouterBase, address(baseOrchestratorProxy)) - // { - // uint256 fromAmount = 0.0003 ether; - // uint256 toAmount = 0.993336e6; - // uint256 toAmountMin = 0.988369e6; - // - // bytes - // memory dexData = hex"c872a3c5000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000420000000000000000000000000000000000000600000000000000000000000042000000000000000000000000000000000000060000000000000000000000006e53131f68a034873b6bfa15502af094ef0c5854000000000000000000000000417ac0e078398c154edfadd9ef675d30be60af93000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001102aacc5688000000000000000000000000000000000000000000000000000000000000f14d100000000000000000000000042000000000000000000000000000000000000060000000000000000000000006e53131f68a034873b6bfa15502af094ef0c5854000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: curveRouterBase, - // fromToken: ETH_TOKEN, - // fromAmount: fromAmount, - // toToken: usdcTokenBase, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(baseOrchestratorProxy)); - // } - // - // //passed - // function test_dexSwapCurveRouterUSDCToETHBase() - // public - // setFork(baseAnvilForkId) - // addRouterInWhiteList(curveRouterBase, address(baseOrchestratorProxy)) - // { - // uint256 fromAmount = 1e6; - // uint256 toAmount = 0.00029502055232845 ether; - // uint256 toAmountMin = 0.000293545449566807 ether; - // - // bytes - // memory dexData = hex"c872a3c5000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f000000000000000000000000417ac0e078398c154edfadd9ef675d30be60af930000000000000000000000006e53131f68a034873b6bfa15502af094ef0c585400000000000000000000000042000000000000000000000000000000000000060000000000000000000000004200000000000000000000000000000000000006000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010afa71c98c9d000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f0000000000000000000000006e53131f68a034873b6bfa15502af094ef0c5854000000000000000000000000420000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: curveRouterBase, - // fromToken: usdcTokenBase, - // fromAmount: fromAmount, - // toToken: ETH_TOKEN, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(baseOrchestratorProxy)); - // } - // - // ////////////////////////////////////////////////////////// - // ////////////////// Odos Router V2 //////////////////////// - // ////////////////////////////////////////////////////////// - // - // //passed - // function test_dexSwapOdosRouterV2USDCToWETHBase() - // public - // setFork(baseAnvilForkId) - // addRouterInWhiteList(odosRouterV2Base, address(baseOrchestratorProxy)) - // { - // uint256 fromAmount = 1e6; //1 usdc - // uint256 toAmount = 0.000295473686245412e18; - // uint256 toAmountMin = 0.000293996317814184e18; - // - // bytes - // memory dexData = hex"83bd37f900040002030f387e07010cbb65c26b5000c49b00017882570840a97a490a37bd8db9e1ae39165bfbd600000001cd1722f3947def4cf144679da39c4c32bdc356810000000003010203000a0101010200ff000000000000000000000000000000000000000000883e4ae0a817f2901500971b353b5dd89aa52184833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000000000000000000000000000"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: odosRouterV2Base, - // fromToken: usdcTokenBase, - // fromAmount: fromAmount, - // toToken: wethTokenBase, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(baseOrchestratorProxy)); - // } - // - // //doesnt work with native - // function test_dexSwapOdosRouterV2ETHToUSDCBase() - // public - // setFork(baseAnvilForkId) - // addRouterInWhiteList(odosRouterV2Base, address(baseOrchestratorProxy)) - // { - // uint256 fromAmount = 0.001 ether; - // uint256 toAmount = 3.355603e6; - // uint256 toAmountMin = 3.338824e6; - // - // bytes - // memory dexData = hex"83bd37f90000000407038b38ea920700033333d300c49b00017882570840a97a490a37bd8db9e1ae39165bfbd600000001cd1722f3947def4cf144679da39c4c32bdc35681000000000301020300040101022b000101010201ff000000000000000000000000000000005b52dfa81e7409df9390c9403aceb51ea3df4f204200000000000000000000000000000000000006000000000000000000000000000000000000000000000000"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: odosRouterV2Base, - // fromToken: ETH_TOKEN, - // fromAmount: fromAmount, - // toToken: usdcTokenBase, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(baseOrchestratorProxy)); - // } - // - // ////////////////////////////////////////////////////////// - // ////////////////// 1Inch //////////////////////// - // ////////////////////////////////////////////////////////// - // - // function test_dexSwap1InchV5USDCTo1InchTokenBase() - // public - // setFork(baseAnvilForkId) - // addRouterInWhiteList(oneInchRouterV5Base, address(baseOrchestratorProxy)) - // { - // uint256 fromAmount = 10e6; //10 usdc - // uint256 toAmount = 29.186618652079786377e18; - // uint256 toAmountMin = 29.040685558819387445e18; - // - // bytes - // memory dexData = hex"12aa3caf000000000000000000000000e37e799d5077682fa0a244d46e5649f71457bd09000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000c5fecc3a29fb57b5024eec8a2239d4621e111cbe000000000000000000000000e37e799d5077682fa0a244d46e5649f71457bd09000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000009834e700000000000000000000000000000000000000000000000193053da6cf3ef835000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004af00000000000000000000000000000000000000000000000000000000049100a007e5c0d200000000000000000000000000000000000000000000046d00040a0003f0512003c01acae3d0173a93d819efdc832c7c4f153b06833589fcd6edb6e08f4c7c32d4f71b54bda02913016452bbbe2900000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000e37e799d5077682fa0a244d46e5649f71457bd090000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e37e799d5077682fa0a244d46e5649f71457bd090000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000673f9a44def66c6c178087fd931514e99b04479e4d3d956c0002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009834e700000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000062769914a469c00000000000000000000000000000000000000000000000000000000673f9a4400000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000005af3107a400000000000000000b671b09bd7eb7a242300000000000000008bd0c186893c2c000000000000000dd975ede04e7dbbc0000000000000000005aab64d6906dbaed800000000000000000000000000000000000000000004ee7259d6914ae6c461bc00000000000000004563918244f400000000000000000000006a94d74f430000000000000000000000000000673f99ea000000000000000000003b1dfde910000000000000000000000000000000000000000000000000000000000000000041b0087e9968881cc03a4f3270b3086fd3a18f6587c3179ad985c8c406056d7b98035f5800bbb63a992a30c39c7224be035751091573a74d263682a8536b8d51711c0000000000000000000000000000000000000000000000000000000000000040414200000000000000000000000000000000000006d0e30db002a000000000000000000000000000000000000000000000000190fec846c67c66e1ee63c1e5814af5a3adb853290bc9f909138fbf1a3c3feb086842000000000000000000000000000000000000061111111254eeb25477b68fb85ed929f73a96058200000000000000000000000000000000007787a5c8"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: oneInchRouterV5Base, - // fromToken: usdcTokenBase, - // fromAmount: fromAmount, - // toToken: oneInchTokenBase, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(baseOrchestratorProxy)); - // } - // - // //////////////////// Arbitrum //////////////////////////// - // //////////////////// Block number 276843772 ////////////// - // - // ////////////////////////////////////////////////////////// - // ////////////////// Sushi Swap /////////////////////////// - // ////////////////////////////////////////////////////////// - // - // //passed - // function test_dexSwapSushiSwapRouterUSDCToUSDT() - // public - // setFork(arbitrumAnvilForkId) - // addRouterInWhiteList(sushiRouterArbitrum, address(arbitrumOrchestratorProxy)) - // { - // uint256 fromAmount = 1e6; //1 usdc - // uint256 toAmount = 0.993041e6; - // uint256 toAmountMin = 0.988075e6; - // - // bytes - // memory dexData = hex"38ed173900000000000000000000000000000000000000000000000000000000000f381a00000000000000000000000000000000000000000000000000000000000f13ac00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673f6a920000000000000000000000000000000000000000000000000000000000000003000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000fd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: sushiRouterArbitrum, - // fromToken: usdcTokenArbitrum, - // fromAmount: fromAmount, - // toToken: usdtTokenArbitrum, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - // } - // - // //passed - // function test_dexSwapSushiSwapRouterUSDCToWETH() - // public - // setFork(arbitrumAnvilForkId) - // addRouterInWhiteList(sushiRouterArbitrum, address(arbitrumOrchestratorProxy)) - // { - // uint256 fromAmount = 1e6; //1 usdc - // uint256 toAmount = 0.00029991786617675e18; - // uint256 toAmountMin = 0.000298418276845866e18; - // - // bytes - // memory dexData = hex"38ed173900000000000000000000000000000000000000000000000000000000000f381a00000000000000000000000000000000000000000000000000010f68f44ac36b00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673f697d0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: sushiRouterArbitrum, - // fromToken: usdcTokenArbitrum, - // fromAmount: fromAmount, - // toToken: wethTokenArbitrum, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - // } - // - // //passed - // function test_dexSwapSushiSwapRouterUSDCToETH() - // public - // setFork(arbitrumAnvilForkId) - // addRouterInWhiteList(sushiRouterArbitrum, address(arbitrumOrchestratorProxy)) - // { - // uint256 fromAmount = 1e6; //usdc - // uint256 toAmount = 0.00029991786617675 ether; - // uint256 toAmountMin = 0.000298418276845866 ether; - // - // bytes - // memory dexData = hex"18cbafe500000000000000000000000000000000000000000000000000000000000f381a00000000000000000000000000000000000000000000000000010f68f44ac36b00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673f69fe0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: sushiRouterArbitrum, - // fromToken: usdcTokenArbitrum, - // fromAmount: fromAmount, - // toToken: address(0), - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - // } - // - // //passed - // function test_dexSwapSushiSwapRouterETHToUSDC() - // public - // setFork(arbitrumAnvilForkId) - // addRouterInWhiteList(sushiRouterArbitrum, address(arbitrumOrchestratorProxy)) - // { - // uint256 fromAmount = 0.0001 ether; //ETH - // uint256 toAmount = 0.33059e6; //usdc - // uint256 toAmountMin = 0.328937e6; //usdc - // - // bytes - // memory dexData = hex"7ff36ab500000000000000000000000000000000000000000000000000000000000504e90000000000000000000000000000000000000000000000000000000000000080000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673f6b16000000000000000000000000000000000000000000000000000000000000000200000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: sushiRouterArbitrum, - // fromToken: address(0), - // fromAmount: fromAmount, - // toToken: usdcTokenArbitrum, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - // } - // - // ////////////////////////////////////////////////////////// - // ////////////////// Uniswap /////////////////////// - // ////////////////////////////////////////////////////////// - // - // //passed - // function test_dexSwapUniSwapRouterUSDCToUSDT() - // public - // setFork(arbitrumAnvilForkId) - // addRouterInWhiteList(uniV3RouterArbitrum, address(arbitrumOrchestratorProxy)) - // { - // uint256 fromAmount = 1e6; //1 usdc - // uint256 toAmount = 0.996903e6; - // uint256 toAmountMin = 0.991918e6; - // - // bytes - // memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681000000000000000000000000000000000000000000000000000001934fbb778500000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000000000000f22af000000000000000000000000000000000000000000000000000000000000002baf88d065e77c8cc2239327c5edb3a432268e5831000064fd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: uniV3RouterArbitrum, - // fromToken: usdcTokenArbitrum, - // fromAmount: fromAmount, - // toToken: usdtTokenArbitrum, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - // } - // - // //passed - // function test_dexSwapUniSwapRouterUSDCToWETH() - // public - // setFork(arbitrumAnvilForkId) - // addRouterInWhiteList(uniV3RouterArbitrum, address(arbitrumOrchestratorProxy)) - // { - // uint256 fromAmount = 1e6; //1 usdc - // uint256 toAmount = 0.000299377182115898e18; - // uint256 toAmountMin = 0.000297880296205318e18; - // - // bytes - // memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681000000000000000000000000000000000000000000000000000001934fbd59aa00000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010eebbb0ca1e0000000000000000000000000000000000000000000000000000000000000002baf88d065e77c8cc2239327c5edb3a432268e58310001f482af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: uniV3RouterArbitrum, - // fromToken: usdcTokenArbitrum, - // fromAmount: fromAmount, - // toToken: wethTokenArbitrum, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - // } - // - // //passed - // function test_dexSwapUniSwapRouterUSDCToETH() - // public - // setFork(arbitrumAnvilForkId) - // addRouterInWhiteList(uniV3RouterArbitrum, address(arbitrumOrchestratorProxy)) - // { - // uint256 fromAmount = 1e6; //usdc - // uint256 toAmount = 0.000300419724797236 ether; - // uint256 toAmountMin = 0.000298917626173249 ether; - // - // bytes - // memory dexData = hex"ac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001934fb896d900000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010fdd40cbad5d000000000000000000000000000000000000000000000000000000000000002baf88d065e77c8cc2239327c5edb3a432268e58310001f482af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004449404b7c00000000000000000000000000000000000000000000000000010fdd2eecd741000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: uniV3RouterArbitrum, - // fromToken: usdcTokenArbitrum, - // fromAmount: fromAmount, - // toToken: address(0), - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - // } - // - // //passed - // function test_dexSwapUniSwapRouterETHToUSDC() - // public - // setFork(arbitrumAnvilForkId) - // addRouterInWhiteList(uniV3RouterArbitrum, address(arbitrumOrchestratorProxy)) - // { - // uint256 fromAmount = 0.0001 ether; //ETH - // uint256 toAmount = 0.331996e6; //usdc - // uint256 toAmountMin = 0.330336e6; //usdc - // - // bytes - // memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681000000000000000000000000000000000000000000000000000001934fad171000000000000000000000000000000000000000000000000000005ab8e441cd800000000000000000000000000000000000000000000000000000000000050a60000000000000000000000000000000000000000000000000000000000000002b82af49447d8a07e3bd95bd0d56f35241523fbab10001f4af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: uniV3RouterArbitrum, - // fromToken: address(0), - // fromAmount: fromAmount, - // toToken: usdcTokenArbitrum, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - // } - // - // ////////////////////////////////////////////////////////// - // ////////////////// ParaSwap //////////////////////// - // ////////////////////////////////////////////////////////// - // - // //does not work - // function test_dexSwapParaSwapRouterUSDCToUSDT() - // public - // setFork(arbitrumAnvilForkId) - // addRouterInWhiteList(paraSwapV5RouterArbitrum, address(arbitrumOrchestratorProxy)) - // { - // uint256 fromAmount = 1e6; //1 usdc - // uint256 toAmount = 0.996903e6; - // uint256 toAmountMin = 0.991918e6; - // - // bytes - // memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681000000000000000000000000000000000000000000000000000001934fbb778500000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000000000000f22af000000000000000000000000000000000000000000000000000000000000002baf88d065e77c8cc2239327c5edb3a432268e5831000064fd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: paraSwapV5RouterArbitrum, - // fromToken: usdcTokenArbitrum, - // fromAmount: fromAmount, - // toToken: usdtTokenArbitrum, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - // } - // - // //does not work - // function test_dexSwapParaSwapRouterUSDCToWETH() public setFork(arbitrumAnvilForkId) { - // _allowRouter(paraSwapV5RouterArbitrum, address(arbitrumOrchestratorProxy)); - // - // uint256 fromAmount = 1e6; //1 usdc - // uint256 toAmount = 0.00029758021792574 ether; - // uint256 toAmountMin = 0.000296092316836111 ether; - // - // bytes - // memory dexData = hex"54e3f31b0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010d4b6f1016c900000000000000000000000000000000000000000000000000010ea5dcf7ba4600000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000003800000000000000000000000000000000000000000000000000000000000000400000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000046000000000000000000000000000000000000000000000000000000000673f779551436a490fb745e4a0a79829c8000ce6000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831000000000000000000000000ed9e3f98bbed560e66b89aac922e29d4596a96420000000000000000000000000000000000000000000000000000000000000108a9059cbb000000000000000000000000ed9e3f98bbed560e66b89aac922e29d4596a964200000000000000000000000000000000000000000000000000000000000f387e7dc20382000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000f387e0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee57000000000000000000000000d5b927956057075377263aab7f8afc12f85100db00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000001080000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: paraSwapV5RouterArbitrum, - // fromToken: usdcTokenArbitrum, - // fromAmount: fromAmount, - // toToken: wethTokenArbitrum, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - // } - // - // //does not work - // function test_dexSwapParaSwapRouterUSDCToETH() - // public - // setFork(arbitrumAnvilForkId) - // addRouterInWhiteList(paraSwapV5RouterArbitrum, address(arbitrumOrchestratorProxy)) - // { - // uint256 fromAmount = 1e6; //usdc - // uint256 toAmount = 0.000300419724797236 ether; - // uint256 toAmountMin = 0.000298917626173249 ether; - // - // bytes - // memory dexData = hex"ac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001934fb896d900000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010fdd40cbad5d000000000000000000000000000000000000000000000000000000000000002baf88d065e77c8cc2239327c5edb3a432268e58310001f482af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004449404b7c00000000000000000000000000000000000000000000000000010fdd2eecd741000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: paraSwapV5RouterArbitrum, - // fromToken: usdcTokenArbitrum, - // fromAmount: fromAmount, - // toToken: address(0), - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - // } - // - // //does not work - // function test_dexSwapParaSwapRouterETHToUSDC() - // public - // setFork(arbitrumAnvilForkId) - // addRouterInWhiteList(paraSwapV5RouterArbitrum, address(arbitrumOrchestratorProxy)) - // { - // uint256 fromAmount = 0.001 ether; //ETH - // uint256 toAmount = 3.334998e6; //usdc - // uint256 toAmountMin = 3.318323e6; //usdc - // - // bytes - // memory dexData = hex"54e3f31b0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000038b38ea920700000000000000000000000000000000000000000000000000000000000032a1e5000000000000000000000000000000000000000000000000000000000032e30700000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000003a00000000000000000000000000000000000000000000000000000000000000440000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc356810000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000004c000000000000000000000000000000000000000000000000000000000673f7930962cd732e34c45a093489154807ea37000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000ed9e3f98bbed560e66b89aac922e29d4596a9642000000000000000000000000000000000000000000000000000000000000010cd0e30db0a9059cbb000000000000000000000000ed9e3f98bbed560e66b89aac922e29d4596a964200000000000000000000000000000000000000000000000000038b38ea9207007dc2038200000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000038b38ea9207000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee57000000000000000000000000d5b927956057075377263aab7f8afc12f85100db00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000048000000000000000000000000000000000000000000000000000000000000010c000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000038b38ea920700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: paraSwapV5RouterArbitrum, - // fromToken: address(0), - // fromAmount: fromAmount, - // toToken: usdcTokenArbitrum, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - // } - // - // //////////////////// Polygon //////////////////////////// - // //////////////////// Block number 64588691 ////////////// - // - // ////////////////////////////////////////////////////////// - // ////////////////// Quick Swap //////////////////// - // ////////////////////////////////////////////////////////// - // - // //passed - // function test_dexSwapQuickSwapRouterUSDCToWETH() - // public - // setFork(polygonAnvilForkId) - // addRouterInWhiteList(quickSwapRouterPolygon, address(polygonOrchestratorProxy)) - // { - // uint256 fromAmount = 1e6; //1 usdc - // uint256 toAmount = 0.000294773721275645e18; - // uint256 toAmountMin = 0.000293299852669266e18; - // - // bytes - // memory dexData = hex"38ed173900000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010ac13a4b12cf00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681000000000000000000000000000000000000000000000000000000006740511a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c33590000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f619"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: quickSwapRouterPolygon, - // fromToken: usdcTokenPolygon, - // fromAmount: fromAmount, - // toToken: wethTokenPolygon, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(polygonOrchestratorProxy)); - // } - // - // //passed - // function test_dexSwapQuickSwapRouterPOLToUSDC() - // public - // setFork(polygonAnvilForkId) - // addRouterInWhiteList(quickSwapRouterPolygon, address(polygonOrchestratorProxy)) - // { - // uint256 fromAmount = 0.001e18; //POL - // uint256 toAmount = 0.000457e6; //usdc - // uint256 toAmountMin = 0.000454e6; //usdc - // - // bytes - // memory dexData = hex"7ff36ab500000000000000000000000000000000000000000000000000000000000001c70000000000000000000000000000000000000000000000000000000000000080000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000674056ac00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf12700000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c3359"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: quickSwapRouterPolygon, - // fromToken: POL_TOKEN, - // fromAmount: fromAmount, - // toToken: usdcTokenPolygon, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(polygonOrchestratorProxy)); - // } - // - // //passed - // function test_dexSwapQuickSwapRouterUSDCToPOL() - // public - // setFork(polygonAnvilForkId) - // addRouterInWhiteList(quickSwapRouterPolygon, address(polygonOrchestratorProxy)) - // { - // uint256 fromAmount = 1e6; //usdc - // uint256 toAmount = 2.16620982591814043e18; //pol - // uint256 toAmountMin = 2.155378776788549727e18; //pol - // - // bytes - // memory dexData = hex"18cbafe500000000000000000000000000000000000000000000000000000000000f387e0000000000000000000000000000000000000000000000001de9728f133bb56100000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000674057b000000000000000000000000000000000000000000000000000000000000000020000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c33590000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf1270"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: quickSwapRouterPolygon, - // fromToken: usdcTokenPolygon, - // fromAmount: fromAmount, - // toToken: POL_TOKEN, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(polygonOrchestratorProxy)); - // } - // - // //////////////////// Avalanche //////////////////////////// - // //////////////////// Block number 53397798 ////////////// - // - // ////////////////////////////////////////////////////////// - // ////////////////// Pangolin Swap ///////////////// - // ////////////////////////////////////////////////////////// - // - // //doesnt work - // function test_dexSwapPangolinSwapRouterUSDCToWAVAX() - // public - // setFork(avalancheAnvilForkId) - // addRouterInWhiteList(pangolinRouterAvalanche, address(avalancheOrchestratorProxy)) - // { - // uint256 fromAmount = 1e6; //1 usdc - // uint256 toAmount = 0.027249956050478939e18; - // uint256 toAmountMin = 0.027113706270226544e18; - // - // bytes - // memory dexData = hex"38ed173900000000000000000000000000000000000000000000000000000000000f387e000000000000000000000000000000000000000000000000006053c8d8cb68b600000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000674060d40000000000000000000000000000000000000000000000000000000000000003000000000000000000000000b97ef9ef8734c71904d8002f8b6bc66dd9c48a6e00000000000000000000000060781c2586d68229fde47564546784ab3faca982000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c7"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: pangolinRouterAvalanche, - // fromToken: usdcTokenAvalanche, - // fromAmount: fromAmount, - // toToken: wavaxTokenAvalanche, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(avalancheOrchestratorProxy)); - // } - // - // ////////////////////////////////////////////////////////// - // ////////////////// Utils ///////////////////////// - // ////////////////////////////////////////////////////////// - // - // function _callTestWithRouter(IDexSwap.SwapData[] memory swapData, address proxy) internal { - // console.log("block.number", block.number); - // console.log("fromAmount: ", swapData[0].fromAmount); - // console.log("toAmount: ", swapData[0].toAmount); - // console.log("toAmountMin: ", swapData[0].toAmountMin); - // - // InfraOrchestrator orchestrator = InfraOrchestrator(payable(proxy)); - // - // IInfraOrchestrator.Integration memory integration = IInfraOrchestrator.Integration({ - // integrator: integrator, - // feeBps: 0 - // }); - // bool isFromNative = swapData[0].fromToken == address(0); - // bool isToNative = swapData[0].toToken == address(0); - // - // uint256 userBalanceFromTokenBefore; - // uint256 userBalanceFromTokenAfter; - // uint256 userBalanceToTokenBefore; - // uint256 userBalanceToTokenAfter; - // - // if (isFromNative && !isToNative) { - // deal(sender, swapData[0].fromAmount); - // - // userBalanceFromTokenBefore = sender.balance; - // userBalanceToTokenBefore = IERC20(swapData[0].toToken).balanceOf(sender); - // - // vm.prank(sender); - // orchestrator.swap{value: swapData[0].fromAmount}(swapData, sender, integration); - // - // userBalanceFromTokenAfter = sender.balance; - // userBalanceToTokenAfter = IERC20(swapData[0].toToken).balanceOf(sender); - // } else if (isToNative && !isFromNative) { - // _dealERC20AndApprove(swapData[0].fromToken, sender, swapData[0].fromAmount, proxy); - // - // userBalanceFromTokenBefore = IERC20(swapData[0].fromToken).balanceOf(sender); - // userBalanceToTokenBefore = sender.balance; - // - // vm.prank(sender); - // orchestrator.swap(swapData, sender, integration); - // - // userBalanceFromTokenAfter = IERC20(swapData[0].fromToken).balanceOf(sender); - // userBalanceToTokenAfter = sender.balance; - // } else if (!isFromNative && !isToNative) { - // _dealERC20AndApprove(swapData[0].fromToken, sender, swapData[0].fromAmount, proxy); - // - // userBalanceFromTokenBefore = IERC20(swapData[0].fromToken).balanceOf(sender); - // userBalanceToTokenBefore = IERC20(swapData[0].toToken).balanceOf(sender); - // - // vm.prank(sender); - // orchestrator.swap(swapData, sender, integration); - // - // userBalanceFromTokenAfter = IERC20(swapData[0].fromToken).balanceOf(sender); - // userBalanceToTokenAfter = IERC20(swapData[0].toToken).balanceOf(sender); - // } - // - // console.log("userBalanceFromTokenBefore: ", userBalanceFromTokenBefore); - // console.log("userBalanceFromTokenAfter: ", userBalanceFromTokenAfter); - // console.log("userBalanceToTokenBefore: ", userBalanceToTokenBefore); - // console.log("userBalanceToTokenAfter: ", userBalanceToTokenAfter); - // - // assertGt(userBalanceToTokenAfter, userBalanceToTokenBefore); - // assertLt(userBalanceFromTokenAfter, userBalanceFromTokenBefore); - // } - // - // function _allowRouter(address router, address orchestratorProxy) internal { - // vm.prank(deployer); - // (bool success, ) = address(orchestratorProxy).call( - // abi.encodeWithSignature("setDexRouterAddress(address,bool)", router, true) - // ); - // /// @dev assert it is set correctly - // (, bytes memory returnData) = address(orchestratorProxy).call( - // abi.encodeWithSignature("s_routerAllowed(address)", router) - // ); - // bool returnedValue = abi.decode(returnData, (bool)); - // assertEq(returnedValue, true); - // } - // - // function _dealERC20AndApprove( - // address token, - // address _caller, - // uint256 _amount, - // address proxy - // ) internal { - // deal(token, _caller, _amount); - // vm.prank(_caller); - // IERC20(token).approve(proxy, _amount); - // } } From 0eeda0fbcc8a29676b2ec32733242297f096890d Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Tue, 17 Dec 2024 18:15:27 +0300 Subject: [PATCH 30/54] uni, quickswap and alienbase tests --- .../InfraOrchestrator.swap.t.sol | 268 +++++++++++++++++- 1 file changed, 265 insertions(+), 3 deletions(-) diff --git a/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol index 10c31806..d7b13888 100644 --- a/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol +++ b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol @@ -138,6 +138,93 @@ contract DexSwapTest is Test { _performSwapAndCheck(swapData, user); } + function testFork_UniV3Erc20ToNativePolygonViaRangoRouting() + public + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("POLYGON_RPC_URL"), 65591280)) + { + uint256 fromAmount = 100e6; + uint256 toAmount = 167.372749758706748385e18; + uint256 toAmountMin = 166.535886009913214643e18; + address fromToken = vm.envAddress("USDC_POLYGON"); + address toToken = NATIVE_TOKEN; + address user = makeAddr("user"); + + // @notice swap data generated by rango + bytes + memory dexData = hex"ac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000193d47a6c030000000000000000000000000000000000000000000000000000000005f21106000000000000000000000000000000000000000000000009072651fb27d286b3000000000000000000000000000000000000000000000000000000000000002b3c499c542cef5e3811e1192ce70d8cc03d5c33590001f40d500b1d8e8ef31e21c99d1db9a6444d3adf127000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004449404b7c000000000000000000000000000000000000000000000009072651fb27d286b3000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000000"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: vm.envAddress("UNISWAP_ROUTER_POLYGON"), + fromToken: fromToken, + fromAmount: fromAmount, + toToken: toToken, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _performSwapAndCheck(swapData, user); + } + + function testFork_UniV3Erc20ToErc20PolygonViaRangoRouting() + public + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("POLYGON_RPC_URL"), 65591280)) + { + uint256 fromAmount = 100e6; + uint256 toAmount = 0.024927817380526721e18; + uint256 toAmountMin = 0.024803178293624087e18; + address fromToken = vm.envAddress("USDC_POLYGON"); + address toToken = address(0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619); // @notice WETH; + address user = makeAddr("user"); + + // @notice swap data generated by rango + bytes + memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000193d476af910000000000000000000000000000000000000000000000000000000005f2110600000000000000000000000000000000000000000000000000581e5bf77dfd17000000000000000000000000000000000000000000000000000000000000002b3c499c542cef5e3811e1192ce70d8cc03d5c33590001f47ceb23fd6bc0add59e62ac25578270cff1b9f61900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: vm.envAddress("UNISWAP_ROUTER_POLYGON"), + fromToken: fromToken, + fromAmount: fromAmount, + toToken: toToken, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _performSwapAndCheck(swapData, user); + } + + function testFork_UniV3NativeToErc20PolygonViaRangoRouting() + public + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("POLYGON_RPC_URL"), 65591280)) + { + uint256 fromAmount = 0.1 ether; + uint256 toAmount = 0.059424e6; + uint256 toAmountMin = 0.059126e6; + address fromToken = NATIVE_TOKEN; + address toToken = vm.envAddress("USDC_POLYGON"); + address user = makeAddr("user"); + + // @notice swap data generated by rango + bytes + memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000193d47dcd690000000000000000000000000000000000000000000000000162623ba10abc00000000000000000000000000000000000000000000000000000000000000e6f6000000000000000000000000000000000000000000000000000000000000002b0d500b1d8e8ef31e21c99d1db9a6444d3adf12700001f43c499c542cef5e3811e1192ce70d8cc03d5c335900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: vm.envAddress("UNISWAP_ROUTER_POLYGON"), + fromToken: fromToken, + fromAmount: fromAmount, + toToken: toToken, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _performSwapAndCheck(swapData, user); + } + function testFork_SushiSwapErc20ToNativeBaseViaRangoRouting() public selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("BASE_RPC_URL"), 23820938)) @@ -167,6 +254,183 @@ contract DexSwapTest is Test { _performSwapAndCheck(swapData, user); } + function testFork_QuickSwapErc20ToErc20PolygonViaRangoRouting() + public + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("POLYGON_RPC_URL"), 65590432)) + { + uint256 fromAmount = 100e6; + uint256 toAmount = 0.024602625471287558e18; + uint256 toAmountMin = 0.02447961234393112e18; + address fromToken = vm.envAddress("USDC_POLYGON"); + address toToken = address(0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619); // @notice WETH + address user = makeAddr("user"); + + // @notice swap data generated by rango + bytes + memory dexData = hex"38ed17390000000000000000000000000000000000000000000000000000000005f211060000000000000000000000000000000000000000000000000056f813e5ffd0f000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E00000000000000000000000000000000000000000000000000000000006761666500000000000000000000000000000000000000000000000000000000000000020000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c33590000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f619"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: vm.envAddress("QUICKSWAP_ROUTER_POLYGON"), + fromToken: fromToken, + fromAmount: fromAmount, + toToken: toToken, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _performSwapAndCheck(swapData, user); + } + + function testFork_QuickSwapErc20ToNativePolygonViaRangoRouting() + public + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("POLYGON_RPC_URL"), 65590432)) + { + uint256 fromAmount = 100e6; + uint256 toAmount = 164.7644071672720239e18; + uint256 toAmountMin = 163.94058513143566378e18; + address fromToken = vm.envAddress("USDC_POLYGON"); + address toToken = NATIVE_TOKEN; // @notice WETH + address user = makeAddr("user"); + + // @notice swap data generated by rango + bytes + memory dexData = hex"18cbafe50000000000000000000000000000000000000000000000000000000005f21106000000000000000000000000000000000000000000000008e321f59524e8a1a400000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000000676167e200000000000000000000000000000000000000000000000000000000000000030000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c33590000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf1270"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: vm.envAddress("QUICKSWAP_ROUTER_POLYGON"), + fromToken: fromToken, + fromAmount: fromAmount, + toToken: toToken, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _performSwapAndCheck(swapData, user); + } + + function testFork_QuickSwapNativeToErc20PolygonViaRangoRouting() + public + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("POLYGON_RPC_URL"), 65590432)) + { + uint256 fromAmount = 0.1 ether; + uint256 toAmount = 0.059574e6; + uint256 toAmountMin = 0.059276e6; + address fromToken = NATIVE_TOKEN; + address toToken = vm.envAddress("USDC_POLYGON"); + address user = makeAddr("user"); + + // @notice swap data generated by rango + bytes + memory dexData = hex"7ff36ab5000000000000000000000000000000000000000000000000000000000000e78c0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E00000000000000000000000000000000000000000000000000000000006761687b00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf12700000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c3359"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: vm.envAddress("QUICKSWAP_ROUTER_POLYGON"), + fromToken: fromToken, + fromAmount: fromAmount, + toToken: toToken, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _performSwapAndCheck(swapData, user); + } + + ////////////////////////////////////// + ///// AlienBase ///// + ////////////////////////////////////// + function testFork_AlienBaseErc20ToErc20BaseViaRangoRouting() + public + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("BASE_RPC_URL"), 23823119)) + { + uint256 fromAmount = 10e6; + uint256 toAmount = 9.817208378742733493e18; + uint256 toAmountMin = 9.768122336849019825e18; + address fromToken = vm.envAddress("USDC_BASE"); + address toToken = address(0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb); // @ notice DAI + address user = makeAddr("user"); + + // @notice swap data generated by rango + bytes + memory dexData = hex"38ed173900000000000000000000000000000000000000000000000000000000009834e7000000000000000000000000000000000000000000000000878f5782fa71c3b100000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E000000000000000000000000000000000000000000000000000000000067616a420000000000000000000000000000000000000000000000000000000000000004000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000004200000000000000000000000000000000000006000000000000000000000000d9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca00000000000000000000000050c5725949a6f0c72e6c4a641f24049a917db0cb"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: vm.envAddress("ALIENBASE_ROUTER_BASE"), + fromToken: fromToken, + fromAmount: fromAmount, + toToken: toToken, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _performSwapAndCheck(swapData, user); + } + + function testFork_AlienBaseErc20ToNativeBaseViaRangoRouting() + public + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("BASE_RPC_URL"), 23823119)) + { + uint256 fromAmount = 10e6; + uint256 toAmount = 0.0024663148464185e18; + uint256 toAmountMin = 0.002453983272186407e18; + address fromToken = vm.envAddress("USDC_BASE"); + address toToken = NATIVE_TOKEN; + address user = makeAddr("user"); + + // @notice swap data generated by rango + bytes + memory dexData = hex"18cbafe500000000000000000000000000000000000000000000000000000000009834e70000000000000000000000000000000000000000000000000008b7e28139322800000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E000000000000000000000000000000000000000000000000000000000067616b160000000000000000000000000000000000000000000000000000000000000002000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000004200000000000000000000000000000000000006"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: vm.envAddress("ALIENBASE_ROUTER_BASE"), + fromToken: fromToken, + fromAmount: fromAmount, + toToken: toToken, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _performSwapAndCheck(swapData, user); + } + + function testFork_AlienBaseNativeToErc20BaseViaRangoRouting() + public + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("BASE_RPC_URL"), 23823345)) + { + uint256 fromAmount = 0.1 ether; + uint256 toAmount = 311.050561e6; + uint256 toAmountMin = 309.495308e6; + address fromToken = NATIVE_TOKEN; + address toToken = vm.envAddress("USDC_BASE"); + address user = makeAddr("user"); + + // @notice swap data generated by rango + bytes + memory dexData = hex"7ff36ab5000000000000000000000000000000000000000000000000000000001272860c0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E000000000000000000000000000000000000000000000000000000000067616bd700000000000000000000000000000000000000000000000000000000000000020000000000000000000000004200000000000000000000000000000000000006000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: vm.envAddress("ALIENBASE_ROUTER_BASE"), + fromToken: fromToken, + fromAmount: fromAmount, + toToken: toToken, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _performSwapAndCheck(swapData, user); + } + function _performSwapAndCheck(IDexSwap.SwapData[] memory swapData, address recipient) internal { address fromToken = swapData[0].fromToken; address toToken = swapData[swapData.length - 1].toToken; @@ -344,9 +608,7 @@ contract DexSwapTest is Test { // _callTestWithRouter(swapData, address(baseOrchestratorProxy)); // } // - // ////////////////////////////////////////////////////////// - // ////////////////// Curve //////////////////////// - // ////////////////////////////////////////////////////////// + // за // // //passed // function test_dexSwapCurveRouterUSDCToWETHBase() From 489a2efc09a2f73427507c2c54b799fa7df4d28a Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Tue, 17 Dec 2024 18:15:50 +0300 Subject: [PATCH 31/54] add polygon, avalanche, optimism --- test/foundry/utils/DeployHelper.sol | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/test/foundry/utils/DeployHelper.sol b/test/foundry/utils/DeployHelper.sol index 65e8e56a..36aa169b 100644 --- a/test/foundry/utils/DeployHelper.sol +++ b/test/foundry/utils/DeployHelper.sol @@ -151,9 +151,29 @@ contract DeployHelper is Script { uint256 chainId = block.chainid; if (chainId == vm.envUint("BASE_CHAIN_ID")) { - address[] memory routers = new address[](2); + address[] memory routers = new address[](3); routers[0] = vm.envAddress("UNISWAP_ROUTER_BASE"); routers[1] = vm.envAddress("SUSHISWAP_ROUTER_BASE"); + routers[2] = vm.envAddress("ALIENBASE_ROUTER_BASE"); + return routers; + } + + if (chainId == vm.envUint("POLYGON_CHAIN_ID")) { + address[] memory routers = new address[](2); + routers[0] = vm.envAddress("QUICKSWAP_ROUTER_POLYGON"); + routers[1] = vm.envAddress("UNISWAP_ROUTER_POLYGON"); + return routers; + } + + if (chainId == vm.envUint("AVALANCHE_CHAIN_ID")) { + address[] memory routers = new address[](1); + routers[0] = vm.envAddress("PARASWAP_ROUTER_AVALANCHE"); + return routers; + } + + if (chainId == vm.envUint("OPTIMISM_CHAIN_ID")) { + address[] memory routers = new address[](1); + routers[0] = vm.envAddress("ODOS_ROUTER_OPTIMISM"); return routers; } From 84e84ba594aae125b8080e89e404019d16f3e0f6 Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Tue, 17 Dec 2024 18:23:45 +0300 Subject: [PATCH 32/54] reorder tests and fix name --- .../InfraOrchestrator.swap.t.sol | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol index 976ee094..6e975560 100644 --- a/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol +++ b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol @@ -26,7 +26,7 @@ contract DexSwapTest is Test { // @dev UNISWAP - function testFork_Univ3BaseNativeToErc20ViaRangoRouting() + function testFork_Univ3NativeToErc20BaseViaRangoRouting() public selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("BASE_RPC_URL"), 23814899)) { @@ -111,37 +111,6 @@ contract DexSwapTest is Test { _performSwapAndCheck(swapData, user); } - // @dev SUSHI SWAP - - function testFork_SushiSwapErc20ToErc20BaseViaRangoRouting() - public - selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("BASE_RPC_URL"), 23818245)) - { - uint256 fromAmount = 100e6; - uint256 toAmount = 0.023621031555323924e18; - uint256 toAmountMin = 0.021258928399791531e18; - address fromToken = vm.envAddress("USDC_BASE"); - address toToken = address(0x4200000000000000000000000000000000000006); // @notice weth token - address user = makeAddr("user"); - - // @notice swap data generated by rango - bytes - memory dexData = hex"38ed17390000000000000000000000000000000000000000000000000000000005f21106000000000000000000000000000000000000000000000000004b86e1fb9335ac00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000000676146d70000000000000000000000000000000000000000000000000000000000000002000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000004200000000000000000000000000000000000006"; - - IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - swapData[0] = IDexSwap.SwapData({ - dexRouter: vm.envAddress("SUSHISWAP_ROUTER_BASE"), - fromToken: fromToken, - fromAmount: fromAmount, - toToken: toToken, - toAmount: toAmount, - toAmountMin: toAmountMin, - dexData: dexData - }); - - _performSwapAndCheck(swapData, user); - } - function testFork_UniV3Erc20ToNativePolygonViaRangoRouting() public selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("POLYGON_RPC_URL"), 65591280)) @@ -229,6 +198,37 @@ contract DexSwapTest is Test { _performSwapAndCheck(swapData, user); } + // @dev SUSHI SWAP + + function testFork_SushiSwapErc20ToErc20BaseViaRangoRouting() + public + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("BASE_RPC_URL"), 23818245)) + { + uint256 fromAmount = 100e6; + uint256 toAmount = 0.023621031555323924e18; + uint256 toAmountMin = 0.021258928399791531e18; + address fromToken = vm.envAddress("USDC_BASE"); + address toToken = address(0x4200000000000000000000000000000000000006); // @notice weth token + address user = makeAddr("user"); + + // @notice swap data generated by rango + bytes + memory dexData = hex"38ed17390000000000000000000000000000000000000000000000000000000005f21106000000000000000000000000000000000000000000000000004b86e1fb9335ac00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000000676146d70000000000000000000000000000000000000000000000000000000000000002000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000004200000000000000000000000000000000000006"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: vm.envAddress("SUSHISWAP_ROUTER_BASE"), + fromToken: fromToken, + fromAmount: fromAmount, + toToken: toToken, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexData: dexData + }); + + _performSwapAndCheck(swapData, user); + } + function testFork_SushiSwapErc20ToNativeBaseViaRangoRouting() public selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("BASE_RPC_URL"), 23820938)) From 5dff76824e172b1c7b73cbb924388a90534bf351 Mon Sep 17 00:00:00 2001 From: lufaque <95128636+lufaque@users.noreply.github.com> Date: Wed, 18 Dec 2024 12:26:54 +0300 Subject: [PATCH 33/54] remove comments --- .../InfraOrchestrator.swap.t.sol | 865 ------------------ 1 file changed, 865 deletions(-) diff --git a/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol index 6e975560..6c752071 100644 --- a/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol +++ b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol @@ -469,869 +469,4 @@ contract DexSwapTest is Test { assert(toTokenReceived >= toAmountMin); } - - // address internal constant ETH_TOKEN = address(0); - // address internal constant POL_TOKEN = address(0); - // - // // Base tokens - // address internal usdcTokenBase = vm.envAddress("USDC_BASE"); - // address internal wethTokenBase = vm.envAddress("WETH_BASE"); - // address internal daiTokenBase = vm.envAddress("DAI_BASE"); - // address internal sushiTokenBase = vm.envAddress("SUSHI_BASE"); - // address internal oneInchTokenBase = vm.envAddress("1INCH_BASE"); - // - // //Arbitrum tokens - // address internal usdcTokenArbitrum = vm.envAddress("USDC_ARBITRUM"); - // address internal usdtTokenArbitrum = vm.envAddress("USDT_ARBITRUM"); - // address internal wethTokenArbitrum = vm.envAddress("WETH_ARBITRUM"); - // - // //Polygon tokens - // address internal usdcTokenPolygon = vm.envAddress("USDC_POLYGON"); - // address internal wethTokenPolygon = vm.envAddress("WETH_POLYGON"); - // - // //Avalanche tokens - // address internal usdcTokenAvalanche = vm.envAddress("USDC_AVALANCHE"); - // address internal wavaxTokenAvalanche = vm.envAddress("WAVAX_AVALANCHE"); - // - // //Arbitrum Routers - // address internal sushiRouterArbitrum = vm.envAddress("SUSHISWAP_ROUTER_ARBITRUM_ADDRESS"); - // address internal uniV3RouterArbitrum = vm.envAddress("UNI_V3_ROUTER_ARBITRUM_ADDRESS"); - // address internal paraSwapV5RouterArbitrum = - // vm.envAddress("PARASWAP_V5_ROUTER_ARBITRUM_ADDRESS"); - // - // //Base Routers - // address internal uniV3RouterBase = vm.envAddress("UNI_V3_ROUTER02_BASE_ADDRESS"); - // address internal paraSwapV6_2RouterBase = vm.envAddress("PARASWAP_V6_2_ROUTER_BASE_ADDRESS"); - // address internal odosRouterV2Base = vm.envAddress("ODOS_ROUTER_V2_BASE_ADDRESS"); - // address internal oneInchRouterV5Base = vm.envAddress("1INCH_ROUTER_V5_BASE_ADDRESS"); - // address internal curveRouterBase = vm.envAddress("CURVE_ROUTER_BASE_ADDRESS"); - // address internal alienbaseRouterBase = vm.envAddress("ALIENBASE_ROUTER_BASE_ADDRESS"); - // - // //Polygon Routers - // address internal quickSwapRouterPolygon = vm.envAddress("QUICKSWAP_ROUTER_POLYGON_ADDRESS"); - // - // //Avalanche Routers - // address internal pangolinRouterAvalanche = vm.envAddress("PANGOLIN_ROUTER_AVALANCHE_ADDRESS"); - // - // address payable internal sender = payable(makeAddr("sender")); - // address internal integrator = makeAddr("integrator"); - // - // modifier addRouterInWhiteList(address router, address proxy) { - // _allowRouter(router, address(proxy)); - // _; - // } - // - // function setUp() public override setFork(polygonAnvilForkId) { - // super.setUp(); - // } - // - // //////////////////// Base /////////////////////////////// - // //////////////////// Block number 22713659 ////////////// - // - // ////////////////////////////////////////////////////////// - // ////////////////// Alienbase //////////////////// - // ////////////////////////////////////////////////////////// - // - // //passed - // function test_dexSwapAlienbaseRouterETHToUSDCBase() - // public - // setFork(baseAnvilForkId) - // addRouterInWhiteList(alienbaseRouterBase, address(baseOrchestratorProxy)) - // { - // uint256 fromAmount = 0.1 ether; - // uint256 toAmount = 267.528449e6; - // uint256 toAmountMin = 266.190806e6; - // - // bytes - // memory dexData = hex"7ff36ab5000000000000000000000000000000000000000000000000000000000fddbfd70000000000000000000000000000000000000000000000000000000000000080000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673fb53400000000000000000000000000000000000000000000000000000000000000020000000000000000000000004200000000000000000000000000000000000006000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: alienbaseRouterBase, - // fromToken: ETH_TOKEN, - // fromAmount: fromAmount, - // toToken: usdcTokenBase, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(baseOrchestratorProxy)); - // } - // - // //passed - // function test_dexSwapAlienbaseRouterUSDCToWETHBase() - // public - // setFork(baseAnvilForkId) - // addRouterInWhiteList(alienbaseRouterBase, address(baseOrchestratorProxy)) - // { - // uint256 fromAmount = 10e6; //10 usdc - // uint256 toAmount = 0.002945698049459263e18; - // uint256 toAmountMin = 0.002930969559211966e18; - // - // bytes - // memory dexData = hex"38ed173900000000000000000000000000000000000000000000000000000000009834e7000000000000000000000000000000000000000000000000000a69b3876c9fbe00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673fb6140000000000000000000000000000000000000000000000000000000000000002000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000004200000000000000000000000000000000000006"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: alienbaseRouterBase, - // fromToken: usdcTokenBase, - // fromAmount: fromAmount, - // toToken: wethTokenBase, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(baseOrchestratorProxy)); - // } - // - // //passed - // function test_dexSwapAlienbaseRouterUSDCToETHBase() - // public - // setFork(baseAnvilForkId) - // addRouterInWhiteList(alienbaseRouterBase, address(baseOrchestratorProxy)) - // { - // uint256 fromAmount = 10e6; - // uint256 toAmount = 0.002945698049459263 ether; - // uint256 toAmountMin = 0.002930969559211966 ether; - // - // bytes - // memory dexData = hex"18cbafe500000000000000000000000000000000000000000000000000000000009834e7000000000000000000000000000000000000000000000000000a69b3876c9fbe00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673fb67c0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000004200000000000000000000000000000000000006"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: alienbaseRouterBase, - // fromToken: usdcTokenBase, - // fromAmount: fromAmount, - // toToken: ETH_TOKEN, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(baseOrchestratorProxy)); - // } - // - // за - // - // //passed - // function test_dexSwapCurveRouterUSDCToWETHBase() - // public - // setFork(baseAnvilForkId) - // addRouterInWhiteList(curveRouterBase, address(baseOrchestratorProxy)) - // { - // uint256 fromAmount = 10e6; //1 usdc - // uint256 toAmount = 0.002950528095025959e18; - // uint256 toAmountMin = 0.002935775454550829e18; - // - // bytes - // memory dexData = hex"c872a3c5000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f000000000000000000000000417ac0e078398c154edfadd9ef675d30be60af930000000000000000000000006e53131f68a034873b6bfa15502af094ef0c58540000000000000000000000004200000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009834e7000000000000000000000000000000000000000000000000000a6e127d1bdb2d000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f0000000000000000000000006e53131f68a034873b6bfa15502af094ef0c5854000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: curveRouterBase, - // fromToken: usdcTokenBase, - // fromAmount: fromAmount, - // toToken: wethTokenBase, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(baseOrchestratorProxy)); - // } - // - // //not working - // function test_dexSwapCurveRouterETHToUSDCBase() - // public - // setFork(baseAnvilForkId) - // addRouterInWhiteList(curveRouterBase, address(baseOrchestratorProxy)) - // { - // uint256 fromAmount = 0.0003 ether; - // uint256 toAmount = 0.993336e6; - // uint256 toAmountMin = 0.988369e6; - // - // bytes - // memory dexData = hex"c872a3c5000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000420000000000000000000000000000000000000600000000000000000000000042000000000000000000000000000000000000060000000000000000000000006e53131f68a034873b6bfa15502af094ef0c5854000000000000000000000000417ac0e078398c154edfadd9ef675d30be60af93000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001102aacc5688000000000000000000000000000000000000000000000000000000000000f14d100000000000000000000000042000000000000000000000000000000000000060000000000000000000000006e53131f68a034873b6bfa15502af094ef0c5854000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: curveRouterBase, - // fromToken: ETH_TOKEN, - // fromAmount: fromAmount, - // toToken: usdcTokenBase, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(baseOrchestratorProxy)); - // } - // - // //passed - // function test_dexSwapCurveRouterUSDCToETHBase() - // public - // setFork(baseAnvilForkId) - // addRouterInWhiteList(curveRouterBase, address(baseOrchestratorProxy)) - // { - // uint256 fromAmount = 1e6; - // uint256 toAmount = 0.00029502055232845 ether; - // uint256 toAmountMin = 0.000293545449566807 ether; - // - // bytes - // memory dexData = hex"c872a3c5000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f000000000000000000000000417ac0e078398c154edfadd9ef675d30be60af930000000000000000000000006e53131f68a034873b6bfa15502af094ef0c585400000000000000000000000042000000000000000000000000000000000000060000000000000000000000004200000000000000000000000000000000000006000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010afa71c98c9d000000000000000000000000f6c5f01c7f3148891ad0e19df78743d31e390d1f0000000000000000000000006e53131f68a034873b6bfa15502af094ef0c5854000000000000000000000000420000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: curveRouterBase, - // fromToken: usdcTokenBase, - // fromAmount: fromAmount, - // toToken: ETH_TOKEN, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(baseOrchestratorProxy)); - // } - // - // ////////////////////////////////////////////////////////// - // ////////////////// Odos Router V2 //////////////////////// - // ////////////////////////////////////////////////////////// - // - // //passed - // function test_dexSwapOdosRouterV2USDCToWETHBase() - // public - // setFork(baseAnvilForkId) - // addRouterInWhiteList(odosRouterV2Base, address(baseOrchestratorProxy)) - // { - // uint256 fromAmount = 1e6; //1 usdc - // uint256 toAmount = 0.000295473686245412e18; - // uint256 toAmountMin = 0.000293996317814184e18; - // - // bytes - // memory dexData = hex"83bd37f900040002030f387e07010cbb65c26b5000c49b00017882570840a97a490a37bd8db9e1ae39165bfbd600000001cd1722f3947def4cf144679da39c4c32bdc356810000000003010203000a0101010200ff000000000000000000000000000000000000000000883e4ae0a817f2901500971b353b5dd89aa52184833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000000000000000000000000000"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: odosRouterV2Base, - // fromToken: usdcTokenBase, - // fromAmount: fromAmount, - // toToken: wethTokenBase, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(baseOrchestratorProxy)); - // } - // - // //doesnt work with native - // function test_dexSwapOdosRouterV2ETHToUSDCBase() - // public - // setFork(baseAnvilForkId) - // addRouterInWhiteList(odosRouterV2Base, address(baseOrchestratorProxy)) - // { - // uint256 fromAmount = 0.001 ether; - // uint256 toAmount = 3.355603e6; - // uint256 toAmountMin = 3.338824e6; - // - // bytes - // memory dexData = hex"83bd37f90000000407038b38ea920700033333d300c49b00017882570840a97a490a37bd8db9e1ae39165bfbd600000001cd1722f3947def4cf144679da39c4c32bdc35681000000000301020300040101022b000101010201ff000000000000000000000000000000005b52dfa81e7409df9390c9403aceb51ea3df4f204200000000000000000000000000000000000006000000000000000000000000000000000000000000000000"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: odosRouterV2Base, - // fromToken: ETH_TOKEN, - // fromAmount: fromAmount, - // toToken: usdcTokenBase, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(baseOrchestratorProxy)); - // } - // - // ////////////////////////////////////////////////////////// - // ////////////////// 1Inch //////////////////////// - // ////////////////////////////////////////////////////////// - // - // function test_dexSwap1InchV5USDCTo1InchTokenBase() - // public - // setFork(baseAnvilForkId) - // addRouterInWhiteList(oneInchRouterV5Base, address(baseOrchestratorProxy)) - // { - // uint256 fromAmount = 10e6; //10 usdc - // uint256 toAmount = 29.186618652079786377e18; - // uint256 toAmountMin = 29.040685558819387445e18; - // - // bytes - // memory dexData = hex"12aa3caf000000000000000000000000e37e799d5077682fa0a244d46e5649f71457bd09000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000c5fecc3a29fb57b5024eec8a2239d4621e111cbe000000000000000000000000e37e799d5077682fa0a244d46e5649f71457bd09000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000009834e700000000000000000000000000000000000000000000000193053da6cf3ef835000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004af00000000000000000000000000000000000000000000000000000000049100a007e5c0d200000000000000000000000000000000000000000000046d00040a0003f0512003c01acae3d0173a93d819efdc832c7c4f153b06833589fcd6edb6e08f4c7c32d4f71b54bda02913016452bbbe2900000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000e37e799d5077682fa0a244d46e5649f71457bd090000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e37e799d5077682fa0a244d46e5649f71457bd090000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000673f9a44def66c6c178087fd931514e99b04479e4d3d956c0002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009834e700000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000062769914a469c00000000000000000000000000000000000000000000000000000000673f9a4400000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000005af3107a400000000000000000b671b09bd7eb7a242300000000000000008bd0c186893c2c000000000000000dd975ede04e7dbbc0000000000000000005aab64d6906dbaed800000000000000000000000000000000000000000004ee7259d6914ae6c461bc00000000000000004563918244f400000000000000000000006a94d74f430000000000000000000000000000673f99ea000000000000000000003b1dfde910000000000000000000000000000000000000000000000000000000000000000041b0087e9968881cc03a4f3270b3086fd3a18f6587c3179ad985c8c406056d7b98035f5800bbb63a992a30c39c7224be035751091573a74d263682a8536b8d51711c0000000000000000000000000000000000000000000000000000000000000040414200000000000000000000000000000000000006d0e30db002a000000000000000000000000000000000000000000000000190fec846c67c66e1ee63c1e5814af5a3adb853290bc9f909138fbf1a3c3feb086842000000000000000000000000000000000000061111111254eeb25477b68fb85ed929f73a96058200000000000000000000000000000000007787a5c8"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: oneInchRouterV5Base, - // fromToken: usdcTokenBase, - // fromAmount: fromAmount, - // toToken: oneInchTokenBase, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(baseOrchestratorProxy)); - // } - // - // //////////////////// Arbitrum //////////////////////////// - // //////////////////// Block number 276843772 ////////////// - // - // ////////////////////////////////////////////////////////// - // ////////////////// Sushi Swap /////////////////////////// - // ////////////////////////////////////////////////////////// - // - // //passed - // function test_dexSwapSushiSwapRouterUSDCToUSDT() - // public - // setFork(arbitrumAnvilForkId) - // addRouterInWhiteList(sushiRouterArbitrum, address(arbitrumOrchestratorProxy)) - // { - // uint256 fromAmount = 1e6; //1 usdc - // uint256 toAmount = 0.993041e6; - // uint256 toAmountMin = 0.988075e6; - // - // bytes - // memory dexData = hex"38ed173900000000000000000000000000000000000000000000000000000000000f381a00000000000000000000000000000000000000000000000000000000000f13ac00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673f6a920000000000000000000000000000000000000000000000000000000000000003000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000fd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: sushiRouterArbitrum, - // fromToken: usdcTokenArbitrum, - // fromAmount: fromAmount, - // toToken: usdtTokenArbitrum, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - // } - // - // //passed - // function test_dexSwapSushiSwapRouterUSDCToWETH() - // public - // setFork(arbitrumAnvilForkId) - // addRouterInWhiteList(sushiRouterArbitrum, address(arbitrumOrchestratorProxy)) - // { - // uint256 fromAmount = 1e6; //1 usdc - // uint256 toAmount = 0.00029991786617675e18; - // uint256 toAmountMin = 0.000298418276845866e18; - // - // bytes - // memory dexData = hex"38ed173900000000000000000000000000000000000000000000000000000000000f381a00000000000000000000000000000000000000000000000000010f68f44ac36b00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673f697d0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: sushiRouterArbitrum, - // fromToken: usdcTokenArbitrum, - // fromAmount: fromAmount, - // toToken: wethTokenArbitrum, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - // } - // - // //passed - // function test_dexSwapSushiSwapRouterUSDCToETH() - // public - // setFork(arbitrumAnvilForkId) - // addRouterInWhiteList(sushiRouterArbitrum, address(arbitrumOrchestratorProxy)) - // { - // uint256 fromAmount = 1e6; //usdc - // uint256 toAmount = 0.00029991786617675 ether; - // uint256 toAmountMin = 0.000298418276845866 ether; - // - // bytes - // memory dexData = hex"18cbafe500000000000000000000000000000000000000000000000000000000000f381a00000000000000000000000000000000000000000000000000010f68f44ac36b00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673f69fe0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: sushiRouterArbitrum, - // fromToken: usdcTokenArbitrum, - // fromAmount: fromAmount, - // toToken: address(0), - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - // } - // - // //passed - // function test_dexSwapSushiSwapRouterETHToUSDC() - // public - // setFork(arbitrumAnvilForkId) - // addRouterInWhiteList(sushiRouterArbitrum, address(arbitrumOrchestratorProxy)) - // { - // uint256 fromAmount = 0.0001 ether; //ETH - // uint256 toAmount = 0.33059e6; //usdc - // uint256 toAmountMin = 0.328937e6; //usdc - // - // bytes - // memory dexData = hex"7ff36ab500000000000000000000000000000000000000000000000000000000000504e90000000000000000000000000000000000000000000000000000000000000080000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000673f6b16000000000000000000000000000000000000000000000000000000000000000200000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: sushiRouterArbitrum, - // fromToken: address(0), - // fromAmount: fromAmount, - // toToken: usdcTokenArbitrum, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - // } - // - // ////////////////////////////////////////////////////////// - // ////////////////// Uniswap /////////////////////// - // ////////////////////////////////////////////////////////// - // - // //passed - // function test_dexSwapUniSwapRouterUSDCToUSDT() - // public - // setFork(arbitrumAnvilForkId) - // addRouterInWhiteList(uniV3RouterArbitrum, address(arbitrumOrchestratorProxy)) - // { - // uint256 fromAmount = 1e6; //1 usdc - // uint256 toAmount = 0.996903e6; - // uint256 toAmountMin = 0.991918e6; - // - // bytes - // memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681000000000000000000000000000000000000000000000000000001934fbb778500000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000000000000f22af000000000000000000000000000000000000000000000000000000000000002baf88d065e77c8cc2239327c5edb3a432268e5831000064fd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: uniV3RouterArbitrum, - // fromToken: usdcTokenArbitrum, - // fromAmount: fromAmount, - // toToken: usdtTokenArbitrum, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - // } - // - // //passed - // function test_dexSwapUniSwapRouterUSDCToWETH() - // public - // setFork(arbitrumAnvilForkId) - // addRouterInWhiteList(uniV3RouterArbitrum, address(arbitrumOrchestratorProxy)) - // { - // uint256 fromAmount = 1e6; //1 usdc - // uint256 toAmount = 0.000299377182115898e18; - // uint256 toAmountMin = 0.000297880296205318e18; - // - // bytes - // memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681000000000000000000000000000000000000000000000000000001934fbd59aa00000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010eebbb0ca1e0000000000000000000000000000000000000000000000000000000000000002baf88d065e77c8cc2239327c5edb3a432268e58310001f482af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: uniV3RouterArbitrum, - // fromToken: usdcTokenArbitrum, - // fromAmount: fromAmount, - // toToken: wethTokenArbitrum, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - // } - // - // //passed - // function test_dexSwapUniSwapRouterUSDCToETH() - // public - // setFork(arbitrumAnvilForkId) - // addRouterInWhiteList(uniV3RouterArbitrum, address(arbitrumOrchestratorProxy)) - // { - // uint256 fromAmount = 1e6; //usdc - // uint256 toAmount = 0.000300419724797236 ether; - // uint256 toAmountMin = 0.000298917626173249 ether; - // - // bytes - // memory dexData = hex"ac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001934fb896d900000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010fdd40cbad5d000000000000000000000000000000000000000000000000000000000000002baf88d065e77c8cc2239327c5edb3a432268e58310001f482af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004449404b7c00000000000000000000000000000000000000000000000000010fdd2eecd741000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: uniV3RouterArbitrum, - // fromToken: usdcTokenArbitrum, - // fromAmount: fromAmount, - // toToken: address(0), - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - // } - // - // //passed - // function test_dexSwapUniSwapRouterETHToUSDC() - // public - // setFork(arbitrumAnvilForkId) - // addRouterInWhiteList(uniV3RouterArbitrum, address(arbitrumOrchestratorProxy)) - // { - // uint256 fromAmount = 0.0001 ether; //ETH - // uint256 toAmount = 0.331996e6; //usdc - // uint256 toAmountMin = 0.330336e6; //usdc - // - // bytes - // memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681000000000000000000000000000000000000000000000000000001934fad171000000000000000000000000000000000000000000000000000005ab8e441cd800000000000000000000000000000000000000000000000000000000000050a60000000000000000000000000000000000000000000000000000000000000002b82af49447d8a07e3bd95bd0d56f35241523fbab10001f4af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: uniV3RouterArbitrum, - // fromToken: address(0), - // fromAmount: fromAmount, - // toToken: usdcTokenArbitrum, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - // } - // - // ////////////////////////////////////////////////////////// - // ////////////////// ParaSwap //////////////////////// - // ////////////////////////////////////////////////////////// - // - // //does not work - // function test_dexSwapParaSwapRouterUSDCToUSDT() - // public - // setFork(arbitrumAnvilForkId) - // addRouterInWhiteList(paraSwapV5RouterArbitrum, address(arbitrumOrchestratorProxy)) - // { - // uint256 fromAmount = 1e6; //1 usdc - // uint256 toAmount = 0.996903e6; - // uint256 toAmountMin = 0.991918e6; - // - // bytes - // memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681000000000000000000000000000000000000000000000000000001934fbb778500000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000000000000f22af000000000000000000000000000000000000000000000000000000000000002baf88d065e77c8cc2239327c5edb3a432268e5831000064fd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: paraSwapV5RouterArbitrum, - // fromToken: usdcTokenArbitrum, - // fromAmount: fromAmount, - // toToken: usdtTokenArbitrum, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - // } - // - // //does not work - // function test_dexSwapParaSwapRouterUSDCToWETH() public setFork(arbitrumAnvilForkId) { - // _allowRouter(paraSwapV5RouterArbitrum, address(arbitrumOrchestratorProxy)); - // - // uint256 fromAmount = 1e6; //1 usdc - // uint256 toAmount = 0.00029758021792574 ether; - // uint256 toAmountMin = 0.000296092316836111 ether; - // - // bytes - // memory dexData = hex"54e3f31b0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010d4b6f1016c900000000000000000000000000000000000000000000000000010ea5dcf7ba4600000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000003800000000000000000000000000000000000000000000000000000000000000400000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000046000000000000000000000000000000000000000000000000000000000673f779551436a490fb745e4a0a79829c8000ce6000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831000000000000000000000000ed9e3f98bbed560e66b89aac922e29d4596a96420000000000000000000000000000000000000000000000000000000000000108a9059cbb000000000000000000000000ed9e3f98bbed560e66b89aac922e29d4596a964200000000000000000000000000000000000000000000000000000000000f387e7dc20382000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000f387e0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee57000000000000000000000000d5b927956057075377263aab7f8afc12f85100db00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000001080000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: paraSwapV5RouterArbitrum, - // fromToken: usdcTokenArbitrum, - // fromAmount: fromAmount, - // toToken: wethTokenArbitrum, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - // } - // - // //does not work - // function test_dexSwapParaSwapRouterUSDCToETH() - // public - // setFork(arbitrumAnvilForkId) - // addRouterInWhiteList(paraSwapV5RouterArbitrum, address(arbitrumOrchestratorProxy)) - // { - // uint256 fromAmount = 1e6; //usdc - // uint256 toAmount = 0.000300419724797236 ether; - // uint256 toAmountMin = 0.000298917626173249 ether; - // - // bytes - // memory dexData = hex"ac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001934fb896d900000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010fdd40cbad5d000000000000000000000000000000000000000000000000000000000000002baf88d065e77c8cc2239327c5edb3a432268e58310001f482af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004449404b7c00000000000000000000000000000000000000000000000000010fdd2eecd741000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: paraSwapV5RouterArbitrum, - // fromToken: usdcTokenArbitrum, - // fromAmount: fromAmount, - // toToken: address(0), - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - // } - // - // //does not work - // function test_dexSwapParaSwapRouterETHToUSDC() - // public - // setFork(arbitrumAnvilForkId) - // addRouterInWhiteList(paraSwapV5RouterArbitrum, address(arbitrumOrchestratorProxy)) - // { - // uint256 fromAmount = 0.001 ether; //ETH - // uint256 toAmount = 3.334998e6; //usdc - // uint256 toAmountMin = 3.318323e6; //usdc - // - // bytes - // memory dexData = hex"54e3f31b0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000038b38ea920700000000000000000000000000000000000000000000000000000000000032a1e5000000000000000000000000000000000000000000000000000000000032e30700000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000003a00000000000000000000000000000000000000000000000000000000000000440000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc356810000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000004c000000000000000000000000000000000000000000000000000000000673f7930962cd732e34c45a093489154807ea37000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000ed9e3f98bbed560e66b89aac922e29d4596a9642000000000000000000000000000000000000000000000000000000000000010cd0e30db0a9059cbb000000000000000000000000ed9e3f98bbed560e66b89aac922e29d4596a964200000000000000000000000000000000000000000000000000038b38ea9207007dc2038200000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000038b38ea9207000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee57000000000000000000000000d5b927956057075377263aab7f8afc12f85100db00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000048000000000000000000000000000000000000000000000000000000000000010c000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000038b38ea920700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: paraSwapV5RouterArbitrum, - // fromToken: address(0), - // fromAmount: fromAmount, - // toToken: usdcTokenArbitrum, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(arbitrumOrchestratorProxy)); - // } - // - // //////////////////// Polygon //////////////////////////// - // //////////////////// Block number 64588691 ////////////// - // - // ////////////////////////////////////////////////////////// - // ////////////////// Quick Swap //////////////////// - // ////////////////////////////////////////////////////////// - // - // //passed - // function test_dexSwapQuickSwapRouterUSDCToWETH() - // public - // setFork(polygonAnvilForkId) - // addRouterInWhiteList(quickSwapRouterPolygon, address(polygonOrchestratorProxy)) - // { - // uint256 fromAmount = 1e6; //1 usdc - // uint256 toAmount = 0.000294773721275645e18; - // uint256 toAmountMin = 0.000293299852669266e18; - // - // bytes - // memory dexData = hex"38ed173900000000000000000000000000000000000000000000000000000000000f387e00000000000000000000000000000000000000000000000000010ac13a4b12cf00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681000000000000000000000000000000000000000000000000000000006740511a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c33590000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f619"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: quickSwapRouterPolygon, - // fromToken: usdcTokenPolygon, - // fromAmount: fromAmount, - // toToken: wethTokenPolygon, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(polygonOrchestratorProxy)); - // } - // - // //passed - // function test_dexSwapQuickSwapRouterPOLToUSDC() - // public - // setFork(polygonAnvilForkId) - // addRouterInWhiteList(quickSwapRouterPolygon, address(polygonOrchestratorProxy)) - // { - // uint256 fromAmount = 0.001e18; //POL - // uint256 toAmount = 0.000457e6; //usdc - // uint256 toAmountMin = 0.000454e6; //usdc - // - // bytes - // memory dexData = hex"7ff36ab500000000000000000000000000000000000000000000000000000000000001c70000000000000000000000000000000000000000000000000000000000000080000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000674056ac00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf12700000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c3359"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: quickSwapRouterPolygon, - // fromToken: POL_TOKEN, - // fromAmount: fromAmount, - // toToken: usdcTokenPolygon, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(polygonOrchestratorProxy)); - // } - // - // //passed - // function test_dexSwapQuickSwapRouterUSDCToPOL() - // public - // setFork(polygonAnvilForkId) - // addRouterInWhiteList(quickSwapRouterPolygon, address(polygonOrchestratorProxy)) - // { - // uint256 fromAmount = 1e6; //usdc - // uint256 toAmount = 2.16620982591814043e18; //pol - // uint256 toAmountMin = 2.155378776788549727e18; //pol - // - // bytes - // memory dexData = hex"18cbafe500000000000000000000000000000000000000000000000000000000000f387e0000000000000000000000000000000000000000000000001de9728f133bb56100000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000674057b000000000000000000000000000000000000000000000000000000000000000020000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c33590000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf1270"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: quickSwapRouterPolygon, - // fromToken: usdcTokenPolygon, - // fromAmount: fromAmount, - // toToken: POL_TOKEN, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(polygonOrchestratorProxy)); - // } - // - // //////////////////// Avalanche //////////////////////////// - // //////////////////// Block number 53397798 ////////////// - // - // ////////////////////////////////////////////////////////// - // ////////////////// Pangolin Swap ///////////////// - // ////////////////////////////////////////////////////////// - // - // //doesnt work - // function test_dexSwapPangolinSwapRouterUSDCToWAVAX() - // public - // setFork(avalancheAnvilForkId) - // addRouterInWhiteList(pangolinRouterAvalanche, address(avalancheOrchestratorProxy)) - // { - // uint256 fromAmount = 1e6; //1 usdc - // uint256 toAmount = 0.027249956050478939e18; - // uint256 toAmountMin = 0.027113706270226544e18; - // - // bytes - // memory dexData = hex"38ed173900000000000000000000000000000000000000000000000000000000000f387e000000000000000000000000000000000000000000000000006053c8d8cb68b600000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc3568100000000000000000000000000000000000000000000000000000000674060d40000000000000000000000000000000000000000000000000000000000000003000000000000000000000000b97ef9ef8734c71904d8002f8b6bc66dd9c48a6e00000000000000000000000060781c2586d68229fde47564546784ab3faca982000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c7"; - // - // IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - // swapData[0] = IDexSwap.SwapData({ - // dexRouter: pangolinRouterAvalanche, - // fromToken: usdcTokenAvalanche, - // fromAmount: fromAmount, - // toToken: wavaxTokenAvalanche, - // toAmount: toAmount, - // toAmountMin: toAmountMin, - // dexData: dexData - // }); - // - // _callTestWithRouter(swapData, address(avalancheOrchestratorProxy)); - // } - // - // ////////////////////////////////////////////////////////// - // ////////////////// Utils ///////////////////////// - // ////////////////////////////////////////////////////////// - // - // function _callTestWithRouter(IDexSwap.SwapData[] memory swapData, address proxy) internal { - // console.log("block.number", block.number); - // console.log("fromAmount: ", swapData[0].fromAmount); - // console.log("toAmount: ", swapData[0].toAmount); - // console.log("toAmountMin: ", swapData[0].toAmountMin); - // - // InfraOrchestrator orchestrator = InfraOrchestrator(payable(proxy)); - // - // IInfraOrchestrator.Integration memory integration = IInfraOrchestrator.Integration({ - // integrator: integrator, - // feeBps: 0 - // }); - // bool isFromNative = swapData[0].fromToken == address(0); - // bool isToNative = swapData[0].toToken == address(0); - // - // uint256 userBalanceFromTokenBefore; - // uint256 userBalanceFromTokenAfter; - // uint256 userBalanceToTokenBefore; - // uint256 userBalanceToTokenAfter; - // - // if (isFromNative && !isToNative) { - // deal(sender, swapData[0].fromAmount); - // - // userBalanceFromTokenBefore = sender.balance; - // userBalanceToTokenBefore = IERC20(swapData[0].toToken).balanceOf(sender); - // - // vm.prank(sender); - // orchestrator.swap{value: swapData[0].fromAmount}(swapData, sender, integration); - // - // userBalanceFromTokenAfter = sender.balance; - // userBalanceToTokenAfter = IERC20(swapData[0].toToken).balanceOf(sender); - // } else if (isToNative && !isFromNative) { - // _dealERC20AndApprove(swapData[0].fromToken, sender, swapData[0].fromAmount, proxy); - // - // userBalanceFromTokenBefore = IERC20(swapData[0].fromToken).balanceOf(sender); - // userBalanceToTokenBefore = sender.balance; - // - // vm.prank(sender); - // orchestrator.swap(swapData, sender, integration); - // - // userBalanceFromTokenAfter = IERC20(swapData[0].fromToken).balanceOf(sender); - // userBalanceToTokenAfter = sender.balance; - // } else if (!isFromNative && !isToNative) { - // _dealERC20AndApprove(swapData[0].fromToken, sender, swapData[0].fromAmount, proxy); - // - // userBalanceFromTokenBefore = IERC20(swapData[0].fromToken).balanceOf(sender); - // userBalanceToTokenBefore = IERC20(swapData[0].toToken).balanceOf(sender); - // - // vm.prank(sender); - // orchestrator.swap(swapData, sender, integration); - // - // userBalanceFromTokenAfter = IERC20(swapData[0].fromToken).balanceOf(sender); - // userBalanceToTokenAfter = IERC20(swapData[0].toToken).balanceOf(sender); - // } - // - // console.log("userBalanceFromTokenBefore: ", userBalanceFromTokenBefore); - // console.log("userBalanceFromTokenAfter: ", userBalanceFromTokenAfter); - // console.log("userBalanceToTokenBefore: ", userBalanceToTokenBefore); - // console.log("userBalanceToTokenAfter: ", userBalanceToTokenAfter); - // - // assertGt(userBalanceToTokenAfter, userBalanceToTokenBefore); - // assertLt(userBalanceFromTokenAfter, userBalanceFromTokenBefore); - // } - // - // function _allowRouter(address router, address orchestratorProxy) internal { - // vm.prank(deployer); - // (bool success, ) = address(orchestratorProxy).call( - // abi.encodeWithSignature("setDexRouterAddress(address,bool)", router, true) - // ); - // /// @dev assert it is set correctly - // (, bytes memory returnData) = address(orchestratorProxy).call( - // abi.encodeWithSignature("s_routerAllowed(address)", router) - // ); - // bool returnedValue = abi.decode(returnData, (bool)); - // assertEq(returnedValue, true); - // } - // - // function _dealERC20AndApprove( - // address token, - // address _caller, - // uint256 _amount, - // address proxy - // ) internal { - // deal(token, _caller, _amount); - // vm.prank(_caller); - // IERC20(token).approve(proxy, _amount); - // } } From a41d35fd7f85bf9d86ee9bd53ccaec9a78fbb987 Mon Sep 17 00:00:00 2001 From: lufaque <95128636+lufaque@users.noreply.github.com> Date: Wed, 18 Dec 2024 13:29:48 +0300 Subject: [PATCH 34/54] fix env names --- .env.clccip | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.clccip b/.env.clccip index 66d72245..089dc934 100644 --- a/.env.clccip +++ b/.env.clccip @@ -53,7 +53,7 @@ SUSHISWAP_ROUTER_ARBITRUM=0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506 SUSHISWAP_ROUTER_BASE=0x6BDED42c6DA8FBf0d2bA55B2fa120C5e0c8D7891 # QUICKSWAP ROUTERS -QUICKSWAP_ROUTER_POLYGON_ADDRESS=0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff +QUICKSWAP_ROUTER_POLYGON=0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff # ODOS ODOS_ROUTER_V2_BASE=0x19cEeAd7105607Cd444F5ad10dd51356436095a1 From 01737df1711ffb1935f0ca214f5a646af4ce8036 Mon Sep 17 00:00:00 2001 From: lufaque <95128636+lufaque@users.noreply.github.com> Date: Wed, 18 Dec 2024 16:05:01 +0300 Subject: [PATCH 35/54] remove unused imports --- contracts/DexSwap.sol | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/contracts/DexSwap.sol b/contracts/DexSwap.sol index 5366a69a..8eb5eb49 100644 --- a/contracts/DexSwap.sol +++ b/contracts/DexSwap.sol @@ -8,7 +8,6 @@ pragma solidity 0.8.20; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; -import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol"; import {InfraStorage} from "./Libraries/InfraStorage.sol"; import {IDexSwap} from "./Interfaces/IDexSwap.sol"; import {LibConcero} from "./Libraries/LibConcero.sol"; @@ -33,11 +32,6 @@ error SwapFailed(); contract DexSwap is IDexSwap, InfraCommon, InfraStorage { using SafeERC20 for IERC20; - using BytesLib for bytes; - - /* CONSTANT VARIABLES */ - uint256 private constant BASE_CHAIN_ID = 8453; - uint256 private constant AVAX_CHAIN_ID = 43114; /* IMMUTABLE VARIABLES */ address private immutable i_proxy; @@ -87,6 +81,10 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { } } + if (balanceAfter == 0) { + revert InvalidDexData(); + } + uint256 dstTokenReceived = balanceAfter - addressThisBalanceBefore; if (recipient != address(this)) { @@ -104,21 +102,6 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { return dstTokenReceived; } - function _transferTokenToUser(address recipient, address token, uint256 amount) internal { - if (amount == 0 || recipient == address(0)) { - revert InvalidDexData(); - } - - if (token == address(0)) { - (bool success, ) = recipient.call{value: amount}(""); - if (!success) { - revert TransferFailed(); - } - } else { - IERC20(token).safeTransfer(recipient, amount); - } - } - function _performSwap(IDexSwap.SwapData memory swapData) private { if (swapData.dexData.length == 0) revert EmptyDexData(); @@ -140,4 +123,19 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { revert SwapFailed(); } } + + function _transferTokenToUser(address recipient, address token, uint256 amount) internal { + if (amount == 0 || recipient == address(0)) { + revert InvalidDexData(); + } + + if (token == address(0)) { + (bool success, ) = recipient.call{value: amount}(""); + if (!success) { + revert TransferFailed(); + } + } else { + IERC20(token).safeTransfer(recipient, amount); + } + } } From 7298656f41c049bff7f1cc6c23176715fab84c37 Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Wed, 18 Dec 2024 21:43:13 +0300 Subject: [PATCH 36/54] reformat label --- test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol index 6e975560..78f6a30d 100644 --- a/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol +++ b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol @@ -347,9 +347,7 @@ contract DexSwapTest is Test { _performSwapAndCheck(swapData, user); } - ////////////////////////////////////// - ///// AlienBase ///// - ////////////////////////////////////// + // @dev ALIENBASE function testFork_AlienBaseErc20ToErc20BaseViaRangoRouting() public selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("BASE_RPC_URL"), 23823119)) From 6767f7790ea59353e94027ecea845e50c18a939e Mon Sep 17 00:00:00 2001 From: lufaque <95128636+lufaque@users.noreply.github.com> Date: Fri, 20 Dec 2024 15:46:26 +0300 Subject: [PATCH 37/54] setup solhint --- .solhint.json | 39 +-- contracts/ConceroBridge.sol | 1 - contracts/InfraCLF.sol | 15 +- contracts/InfraOrchestrator.sol | 4 +- contracts/Interfaces/IParentPool.sol | 1 - contracts/ParentPool.sol | 1 - contracts/ParentPoolCLFCLA.sol | 1 + contracts/PauseDummy.sol | 9 +- package.json | 43 ++- yarn.lock | 494 +++++++++++++-------------- 10 files changed, 287 insertions(+), 321 deletions(-) diff --git a/.solhint.json b/.solhint.json index bb227394..3906432e 100755 --- a/.solhint.json +++ b/.solhint.json @@ -1,51 +1,34 @@ { "extends": "solhint:recommended", - "plugins": [ - "chainlink-solidity" - ], + "plugins": ["chainlink-solidity"], "rules": { - "prettier/prettier": "error", - "no-unused-vars": "error", - "contract-name-camelcase": "error", - "event-name-camelcase": "error", - "func-name-mixedcase": "error", - "func-param-name-mixedcase": "error", - "modifier-name-mixedcase": "error", - "imports-on-top": "error", - "compiler-version": [ - "off", - "^0.8.20" - ], + "compiler-version": ["off", "^0.8.0"], "const-name-snakecase": "off", "constructor-syntax": "error", "var-name-mixedcase": "off", + "avoid-low-level-calls": "off", + "chainlink-solidity/no-block-single-if-reverts": "off", + "no-inline-assembly": "off", "func-visibility": [ "error", { "ignoreConstructors": true } ], - "max-line-length": [ - "error", - 160 - ], "not-rely-on-time": "off", - "no-empty-blocks": "warn", - "quotes": [ - "error", - "double" - ], + "no-empty-blocks": "off", "reason-string": [ "warn", { "maxLength": 64 } ], - "named-return-values": "off", "chainlink-solidity/prefix-internal-functions-with-underscore": "warn", "chainlink-solidity/prefix-private-functions-with-underscore": "warn", - "chainlink-solidity/inherited-constructor-args-not-in-contract-definition": "warn", - "chainlink-solidity/no-block-single-if-reverts": "off", - "chainlink-solidity/explicit-returns": "warn" + "chainlink-solidity/prefix-storage-variables-with-s-underscore": "warn", + "chainlink-solidity/prefix-immutable-variables-with-i": "warn", + "chainlink-solidity/all-caps-constant-storage-variables": "warn", + "chainlink-solidity/no-hardhat-imports": "warn", + "chainlink-solidity/inherited-constructor-args-not-in-contract-definition": "warn" } } diff --git a/contracts/ConceroBridge.sol b/contracts/ConceroBridge.sol index 758940fc..2afd9c82 100644 --- a/contracts/ConceroBridge.sol +++ b/contracts/ConceroBridge.sol @@ -10,7 +10,6 @@ import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {InfraCCIP} from "./InfraCCIP.sol"; import {IConceroBridge} from "./Interfaces/IConceroBridge.sol"; -import {IInfraStorage} from "./Interfaces/IInfraStorage.sol"; /* ERRORS */ ///@notice error emitted when the input amount is less than the fees diff --git a/contracts/InfraCLF.sol b/contracts/InfraCLF.sol index 90ccd19d..68bc69d0 100644 --- a/contracts/InfraCLF.sol +++ b/contracts/InfraCLF.sol @@ -131,7 +131,11 @@ contract InfraCLF is IInfraCLF, FunctionsClient, InfraCommon, InfraStorage { args[5] = abi.encodePacked(conceroMessageId); args[6] = abi.encodePacked(txDataHash); - bytes32 reqId = sendRequest(args, CL_JS_CODE, CL_FUNCTIONS_DST_CALLBACK_GAS_LIMIT); + bytes32 reqId = _initializeAndSendClfRequest( + args, + CL_JS_CODE, + CL_FUNCTIONS_DST_CALLBACK_GAS_LIMIT + ); s_requests[reqId].requestType = RequestType.checkTxSrc; s_requests[reqId].isPending = true; @@ -145,7 +149,7 @@ contract InfraCLF is IInfraCLF, FunctionsClient, InfraCommon, InfraStorage { * @param args the arguments for the request as bytes array * @param jsCode the JScode that will be executed. */ - function sendRequest( + function _initializeAndSendClfRequest( bytes[] memory args, string memory jsCode, uint32 gasLimit @@ -184,6 +188,7 @@ contract InfraCLF is IInfraCLF, FunctionsClient, InfraCommon, InfraStorage { * @param err the error * @dev response and error will never be populated at the same time. */ + // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore function fulfillRequest( bytes32 requestId, bytes memory response, @@ -235,7 +240,11 @@ contract InfraCLF is IInfraCLF, FunctionsClient, InfraCommon, InfraStorage { args[6] = abi.encodePacked(dstChainSelector); args[7] = abi.encodePacked(txDataHash); - bytes32 reqId = sendRequest(args, CL_JS_CODE, CL_FUNCTIONS_SRC_CALLBACK_GAS_LIMIT); + bytes32 reqId = _initializeAndSendClfRequest( + args, + CL_JS_CODE, + CL_FUNCTIONS_SRC_CALLBACK_GAS_LIMIT + ); s_requests[reqId].requestType = RequestType.addUnconfirmedTxDst; s_requests[reqId].isPending = true; diff --git a/contracts/InfraOrchestrator.sol b/contracts/InfraOrchestrator.sol index 28d32df0..0cfd395b 100644 --- a/contracts/InfraOrchestrator.sol +++ b/contracts/InfraOrchestrator.sol @@ -1,14 +1,12 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.20; -import {CHAIN_SELECTOR_ARBITRUM, CHAIN_SELECTOR_BASE, CHAIN_SELECTOR_OPTIMISM, CHAIN_SELECTOR_POLYGON, CHAIN_SELECTOR_AVALANCHE, CHAIN_SELECTOR_ETHEREUM, USDC_ARBITRUM, USDC_BASE, USDC_POLYGON, USDC_AVALANCHE, USDC_OPTIMISM, USDC_ETHEREUM} from "./Constants.sol"; +import {CHAIN_SELECTOR_ARBITRUM, CHAIN_SELECTOR_BASE, CHAIN_SELECTOR_OPTIMISM, CHAIN_SELECTOR_POLYGON, CHAIN_SELECTOR_AVALANCHE, CHAIN_SELECTOR_ETHEREUM} from "./Constants.sol"; import {InfraCommon} from "./InfraCommon.sol"; import {IConceroBridge} from "./Interfaces/IConceroBridge.sol"; import {IDexSwap} from "./Interfaces/IDexSwap.sol"; import {IInfraCLF} from "./Interfaces/IInfraCLF.sol"; import {IInfraOrchestrator, IOrchestratorViewDelegate} from "./Interfaces/IInfraOrchestrator.sol"; -import {IInfraStorage} from "./Interfaces/IInfraStorage.sol"; -import {InfraStorage} from "./Libraries/InfraStorage.sol"; import {InfraStorageSetters} from "./Libraries/InfraStorageSetters.sol"; import {LibConcero} from "./Libraries/LibConcero.sol"; import {IFunctionsClient} from "@chainlink/contracts/src/v0.8/functions/v1_0_0/interfaces/IFunctionsClient.sol"; diff --git a/contracts/Interfaces/IParentPool.sol b/contracts/Interfaces/IParentPool.sol index b5783465..c7e85573 100644 --- a/contracts/Interfaces/IParentPool.sol +++ b/contracts/Interfaces/IParentPool.sol @@ -2,7 +2,6 @@ pragma solidity 0.8.20; import {IPool} from "./IPool.sol"; -import {ICCIP} from "./ICCIP.sol"; interface IParentPool is IPool { /* TYPE DECLARATIONS */ diff --git a/contracts/ParentPool.sol b/contracts/ParentPool.sol index c6d774c9..a92bebf6 100644 --- a/contracts/ParentPool.sol +++ b/contracts/ParentPool.sol @@ -17,7 +17,6 @@ import {IInfraStorage} from "./Interfaces/IInfraStorage.sol"; import {IParentPoolCLFCLA, IParentPoolCLFCLAViewDelegate} from "./Interfaces/IParentPoolCLFCLA.sol"; import {IParentPool} from "./Interfaces/IParentPool.sol"; import {IRouterClient} from "@chainlink/contracts-ccip/src/v0.8/ccip/interfaces/IRouterClient.sol"; -import {LPToken} from "./LPToken.sol"; import {LibConcero} from "./Libraries/LibConcero.sol"; import {LinkTokenInterface} from "@chainlink/contracts/src/v0.8/shared/interfaces/LinkTokenInterface.sol"; import {ParentPoolCommon} from "./ParentPoolCommon.sol"; diff --git a/contracts/ParentPoolCLFCLA.sol b/contracts/ParentPoolCLFCLA.sol index 1b0827c1..0ad9bf46 100644 --- a/contracts/ParentPoolCLFCLA.sol +++ b/contracts/ParentPoolCLFCLA.sol @@ -72,6 +72,7 @@ contract ParentPoolCLFCLA is * @param err the error of the request sent * @dev response & err will never be empty or populated at same time. */ + // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore function fulfillRequest( bytes32 requestId, bytes memory response, diff --git a/contracts/PauseDummy.sol b/contracts/PauseDummy.sol index 3de6dd4c..6ec6a7eb 100644 --- a/contracts/PauseDummy.sol +++ b/contracts/PauseDummy.sol @@ -1,13 +1,14 @@ -// SPDX-License-Identifier: UNLICENSED // deployed with salt: 0xdddd5f804b9d293dce8819d232e8d76381605a62f2d34c122b9ca6815a0000c8 // to address: 0x00c4d25487297C4fc1341aa840a4F56e474f6A0d pragma solidity ^0.8.20; +error Paused(); + contract PauseDummy { - fallback() external { - revert("paused"); + fallback() external payable { + revert Paused(); } receive() external payable { - revert("paused"); + revert Paused(); } } diff --git a/package.json b/package.json index 60742cf8..fa994f88 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "scripts": { "chain": "hardhat node --network hardhat --no-deploy", "fork": "MAINNET_FORKING_ENABLED=true hardhat node --network hardhat --no-deploy", - "compile": "hardhat compile", + "compile": "yarn lint:sol && hardhat compile", "deploy": "hardhat deploy", "test": "REPORT_GAS=true hardhat test --network hardhat", "lint:ts": "echo 'not working yet'", @@ -43,23 +43,23 @@ "ora": "^8.0.1", "prettier": "^3.3.3", "prettier-plugin-solidity": "^1.3.1", - "qrcode": "^1.5.1", - "solhint": "^5.0.3", - "solhint-community": "^4.0.0", - "solhint-plugin-prettier": "^0.1.0", + "qrcode": "1.5.1", + "solhint": "5.0.3", + "solhint-community": "3.7.0", + "solhint-plugin-prettier": "0.1.0", "solidity-coverage": "^0.8.12", - "ts-node": "^10.9.2", + "ts-node": "10.9.2", "typechain": "^8.3.2", "typescript": "^5.5.4" }, "dependencies": { - "@chainlink/contracts": "^1.2.0", - "@chainlink/contracts-ccip": "^1.4.0", - "@chainlink/env-enc": "^1.0.5", - "@chainlink/functions-toolkit": "^0.3.0", - "@chainlink/hardhat-chainlink": "^0.0.4", - "@chainlink/local": "^0.2.2", - "@chainlink/solhint-plugin-chainlink-solidity": "^1.0.1", + "@chainlink/contracts": "1.2.0", + "@chainlink/contracts-ccip": "1.4.0", + "@chainlink/env-enc": "1.0.5", + "@chainlink/functions-toolkit": "0.3.0", + "@chainlink/hardhat-chainlink": "0.0.4", + "@chainlink/local": "0.2.2", + "@chainlink/solhint-plugin-chainlink-solidity": "1.0.1", "@nomicfoundation/hardhat-viem": "^2.0.3", "@openzeppelin/contracts": "5.0.2", "@tenderly/hardhat-tenderly": "^2.5.1", @@ -67,24 +67,23 @@ "@uniswap/swap-router-contracts": "https://github.com/Uniswap/swap-router-contracts", "@uniswap/v2-periphery": "https://github.com/Uniswap/v2-periphery", "@uniswap/v3-periphery": "https://github.com/sushiswap/v3-periphery", - "asciichart": "^1.5.25", - "dotenv": "^16.4.5", + "asciichart": "1.5.25", + "dotenv": "16.4.5", "ds-test": "https://github.com/dapphub/ds-test.git", - "envfile": "^7.1.0", + "envfile": "7.1.0", "ethers": "6.12.1", "forge-std": "https://github.com/foundry-rs/forge-std.git", "hardhat-docgen": "^1.3.0", "husky": "^9.1.6", "prettier": "^3.3.3", "prettier-plugin-solidity": "^1.3.1", - "qrcode": "^1.5.1", - "readline": "^1.3.0", - "regenerator-runtime": "^0.14.1", - "solady": "^0.0.273", + "readline": "1.3.0", + "regenerator-runtime": "0.14.1", + "solady": "0.0.273", "solhint-plugin-chainlink-solidity": "npm:@chainlink/solhint-plugin-chainlink-solidity", - "solhint-plugin-prettier": "^0.1.0", + "solhint-plugin-prettier": "0.1.0", "solidity-bytes-utils": "0.8.0", "sushiswap-v3-periphery": "https://github.com/sushiswap/v3-periphery", - "viem": "^2.19.1" + "viem": "2.19.1" } } diff --git a/yarn.lock b/yarn.lock index 166bf3ba..5cce9c0a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,16 +2,16 @@ # yarn lockfile v1 +"@adraffy/ens-normalize@1.10.0": + version "1.10.0" + resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.10.0.tgz#d2a39395c587e092d77cbbc80acf956a54f38bf7" + integrity sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q== + "@adraffy/ens-normalize@1.10.1": version "1.10.1" resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.10.1.tgz#63430d04bd8c5e74f8d7d049338f1cd9d4f02069" integrity sha512-96Z2IP3mYmF1Xg2cDm8f1gWGf/HUVedQ3FMifV4kG/PQ4yEP51xDtRAEfhVNt5f/uzpNkZHwWQuUcu6D6K+Ekw== -"@adraffy/ens-normalize@^1.10.1": - version "1.11.0" - resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.11.0.tgz#42cc67c5baa407ac25059fcd7d405cc5ecdb0c33" - integrity sha512-/3DDPKHqqIqxUULp8yP4zODUY1i+2xvVWsv8A79xGWdCAG+8sb0hRh0Rk2QyOJUnnbyPUAZYcpBuRe3nS2OIUg== - "@arbitrum/nitro-contracts@1.1.1": version "1.1.1" resolved "https://registry.yarnpkg.com/@arbitrum/nitro-contracts/-/nitro-contracts-1.1.1.tgz#2d8a2f9ab757bb7654562aebe435bff833c4b98d" @@ -63,9 +63,9 @@ tslib "^1.11.1" "@aws-sdk/types@^3.1.0": - version "3.709.0" - resolved "https://registry.yarnpkg.com/@aws-sdk/types/-/types-3.709.0.tgz#f8d7ab07e253d3ed0e3b360e09fc67c7430a73b9" - integrity sha512-ArtLTMxgjf13Kfu3gWH3Ez9Q5TkDdcRZUofpKH3pMGB/C6KAbeSCtIIDKfoRTUABzyGlPyCrZdnFjKyH+ypIpg== + version "3.714.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/types/-/types-3.714.0.tgz#de6afee1436d2d95364efa0663887f3bf0b1303a" + integrity sha512-ZjpP2gYbSFlxxaUDa1Il5AVvfggvUPbjzzB/l3q0gIE5Thd6xKW+yzEpt2mLZ5s5UaYSABZbF94g8NUOF4CVGA== dependencies: "@smithy/types" "^3.7.2" tslib "^2.6.2" @@ -218,26 +218,22 @@ resolved "https://registry.yarnpkg.com/@bytecodealliance/preview2-shim/-/preview2-shim-0.17.0.tgz#9bc1cadbb9f86c446c6f579d3431c08a06a6672e" integrity sha512-JorcEwe4ud0x5BS/Ar2aQWOQoFzjq/7jcnxYXCvSMh0oRm0dQXzOA+hqLDBnOMks1LLBA7dmiLLsEBl09Yd6iQ== -"@chainlink/contracts-ccip@^1.4.0": - version "1.5.0" - resolved "https://registry.yarnpkg.com/@chainlink/contracts-ccip/-/contracts-ccip-1.5.0.tgz#bf7523255e8e79dd0a1874e96d0fdfb260fb80d3" - integrity sha512-pz6vhAY6ey5vLjU6mUv7rapRIKXWS2kEhd+J4axdeQhyClfyl+HyzqBTL+Jd/tbekhrfEn2YbkhIZXlovvUk7w== +"@chainlink/contracts-ccip@1.4.0": + version "1.4.0" + resolved "https://registry.yarnpkg.com/@chainlink/contracts-ccip/-/contracts-ccip-1.4.0.tgz#54fda7df2350921b2335796a57637f2d958f7bcd" + integrity sha512-8F0OpmXy73vSbOvnKPL0DcYLA6FTiwQSKw1+DQzKyBYVbFk4vtijzs+5Ts/Beu6EIPqXlmLq7WVFZFHiDOBjCg== dependencies: "@arbitrum/nitro-contracts" "1.1.1" "@arbitrum/token-bridge-contracts" "1.1.2" - "@changesets/changelog-github" "^0.5.0" - "@changesets/cli" "~2.27.7" "@eth-optimism/contracts" "0.6.0" - "@matterlabs/hardhat-zksync-verify" "^1.6.0" "@openzeppelin/contracts" "4.9.3" "@openzeppelin/contracts-upgradeable" "4.9.3" "@scroll-tech/contracts" "0.1.0" - semver "^7.6.3" -"@chainlink/contracts-ccip@^1.5.1-beta.0": - version "1.5.1-beta.2" - resolved "https://registry.yarnpkg.com/@chainlink/contracts-ccip/-/contracts-ccip-1.5.1-beta.2.tgz#ccdaf0e74887db74f0b95acec26ac3cf440b7cda" - integrity sha512-Hjx2N/YSfsI7QrUTKY4HTBCyPDCxcL5VLcSDaYb6/V0hYmUdjvPa4ghYtFIXCjardshMHt6GtYFxpTyYAEzvcg== +"@chainlink/contracts-ccip@^1.5.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@chainlink/contracts-ccip/-/contracts-ccip-1.5.0.tgz#bf7523255e8e79dd0a1874e96d0fdfb260fb80d3" + integrity sha512-pz6vhAY6ey5vLjU6mUv7rapRIKXWS2kEhd+J4axdeQhyClfyl+HyzqBTL+Jd/tbekhrfEn2YbkhIZXlovvUk7w== dependencies: "@arbitrum/nitro-contracts" "1.1.1" "@arbitrum/token-bridge-contracts" "1.1.2" @@ -248,7 +244,6 @@ "@openzeppelin/contracts" "4.9.3" "@openzeppelin/contracts-upgradeable" "4.9.3" "@scroll-tech/contracts" "0.1.0" - "@zksync/contracts" "git+https://github.com/matter-labs/era-contracts.git#446d391d34bdb48255d5f8fef8a8248925fc98b9" semver "^7.6.3" "@chainlink/contracts@0.8.0": @@ -261,7 +256,20 @@ "@openzeppelin/contracts-upgradeable-4.7.3" "npm:@openzeppelin/contracts-upgradeable@v4.7.3" "@openzeppelin/contracts-v0.7" "npm:@openzeppelin/contracts@v3.4.2" -"@chainlink/contracts@^1.1.1", "@chainlink/contracts@^1.2.0": +"@chainlink/contracts@1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@chainlink/contracts/-/contracts-1.2.0.tgz#e1706038477c58045323a854c31a2aca34770039" + integrity sha512-rcHxzYKcVErANPiLTfL+KOklmHGu8eCB3XtPZolJSQLbH3ZNw9IkaGynQ1IjNUlAnTwFw5c72FCKrNN023xD7g== + dependencies: + "@changesets/changelog-github" "^0.5.0" + "@changesets/cli" "~2.27.3" + "@eth-optimism/contracts" "0.6.0" + "@openzeppelin/contracts" "4.9.3" + "@openzeppelin/contracts-upgradeable" "4.9.3" + "@scroll-tech/contracts" "0.1.0" + semver "^7.6.2" + +"@chainlink/contracts@^1.1.1": version "1.3.0" resolved "https://registry.yarnpkg.com/@chainlink/contracts/-/contracts-1.3.0.tgz#21fd0153867f46b607175eb09fc5027735f700ee" integrity sha512-Vk93nijTC5iRFW/L6FKUzeMuJy7k5dNzAtqlHpdreqtzL7efO/qXbYCkqjJFNXGurfOXVehHlehFoH4tWvSbfw== @@ -277,7 +285,7 @@ "@zksync/contracts" "git+https://github.com/matter-labs/era-contracts.git#446d391d34bdb48255d5f8fef8a8248925fc98b9" semver "^7.6.3" -"@chainlink/env-enc@^1.0.5": +"@chainlink/env-enc@1.0.5": version "1.0.5" resolved "https://registry.yarnpkg.com/@chainlink/env-enc/-/env-enc-1.0.5.tgz#101c84d3a20ee8f4061a35695c2533956ee1455d" integrity sha512-hT7W+tEq/kzkf/yn9sIBsMDcpvbuoPk0JPVGfgygfPJxfS3YUyeen6CdEwJ9o+A7GTWxz/ZnPolpUveX3BUCBQ== @@ -297,10 +305,10 @@ ganache "^7.9.1" uniq "^1.0.1" -"@chainlink/functions-toolkit@^0.3.0": - version "0.3.2" - resolved "https://registry.yarnpkg.com/@chainlink/functions-toolkit/-/functions-toolkit-0.3.2.tgz#63f2f5ae818c05a1ac90589b9127d51748a28c95" - integrity sha512-83SKnDe4E/q7T1ERDKawUkobIYURqS1tfh32xm6Cr1Y/efy+qhcR7wvN95tgTxbk1eNLIX4XFz/2t4AZBBJIow== +"@chainlink/functions-toolkit@0.3.0": + version "0.3.0" + resolved "https://registry.yarnpkg.com/@chainlink/functions-toolkit/-/functions-toolkit-0.3.0.tgz#e535987c25e2668a1f7639cd86172af339969300" + integrity sha512-QqVIVysN+NwtfZQgvyx2EqQHWKFXh0oDWu2q2GjWk2oun2Q+hUD1ksJ1BAFyjfhdIV8IpNRSjnA+IaBxopijCA== dependencies: axios "^1.4.0" bcrypto "^5.4.0" @@ -310,7 +318,7 @@ ganache "^7.9.1" uniq "^1.0.1" -"@chainlink/hardhat-chainlink@^0.0.4": +"@chainlink/hardhat-chainlink@0.0.4": version "0.0.4" resolved "https://registry.yarnpkg.com/@chainlink/hardhat-chainlink/-/hardhat-chainlink-0.0.4.tgz#19c951d5c3d589f2bf82663be9777f3e28c38f48" integrity sha512-fl+cRYm0qTLIMLrc1HzUVetxKF+ndOY8b423aLC2WBE24vwpuuQMejeyT1AvJE8w+9m1coyggA7xypZPHJoPnA== @@ -326,25 +334,25 @@ docker-compose "^0.24.1" ethers "^5.4.7" -"@chainlink/local@^0.2.2": - version "0.2.3" - resolved "https://registry.yarnpkg.com/@chainlink/local/-/local-0.2.3.tgz#0aa89f87169d9a2b6356e753e822c868f9f8b2f4" - integrity sha512-NfvXSuLsVXLnqAtV+GxQwSt5fynn9UDZxL2DPSBtBK5mKSVy74gt6FTWZjrnmXO79f2Ebzat+7tP8bPUEYOZQA== +"@chainlink/local@0.2.2": + version "0.2.2" + resolved "https://registry.yarnpkg.com/@chainlink/local/-/local-0.2.2.tgz#d69fbac5a55ceaa93ba00350942368cf1ec49156" + integrity sha512-6CY8mjJir/V2IWjNLmgJveMuGtsKGvhyEBqCT13LKMQhpJmIw79mGU5240fbwTS+RhFv93ovaJRAVLhzzqg8iQ== dependencies: "@chainlink/contracts" "^1.1.1" - "@chainlink/contracts-ccip" "^1.5.1-beta.0" + "@chainlink/contracts-ccip" "^1.5.0" -"@chainlink/solhint-plugin-chainlink-solidity@^1.0.1", "solhint-plugin-chainlink-solidity@npm:@chainlink/solhint-plugin-chainlink-solidity": +"@chainlink/solhint-plugin-chainlink-solidity@1.0.1", "solhint-plugin-chainlink-solidity@npm:@chainlink/solhint-plugin-chainlink-solidity": version "1.0.1" resolved "https://registry.yarnpkg.com/@chainlink/solhint-plugin-chainlink-solidity/-/solhint-plugin-chainlink-solidity-1.0.1.tgz#bc4c417fe068ed3b13c239e071f550cc130f6bee" integrity sha512-ld0eHzKJZjs/iNKfZtwbR4yP/0YdkBiB+GASYCUz89V+hEn6nCaRoRywgIONRERhHIv5DEDOhcKjo2u2zYHIUA== -"@changesets/apply-release-plan@^7.0.6": - version "7.0.6" - resolved "https://registry.yarnpkg.com/@changesets/apply-release-plan/-/apply-release-plan-7.0.6.tgz#39af3f80f3ba287920271d1a542ef5394eb0bf8a" - integrity sha512-TKhVLtiwtQOgMAC0fCJfmv93faiViKSDqr8oMEqrnNs99gtSC1sZh/aEMS9a+dseU1ESZRCK+ofLgGY7o0fw/Q== +"@changesets/apply-release-plan@^7.0.7": + version "7.0.7" + resolved "https://registry.yarnpkg.com/@changesets/apply-release-plan/-/apply-release-plan-7.0.7.tgz#cabeaed77de07c6bd9878a9bc5ffd3ea7db7f7ff" + integrity sha512-qnPOcmmmnD0MfMg9DjU1/onORFyRpDXkMMl2IJg9mECY6RnxL3wN0TCCc92b2sXt1jt8DgjAUUsZYGUGTdYIXA== dependencies: - "@changesets/config" "^3.0.4" + "@changesets/config" "^3.0.5" "@changesets/get-version-range-type" "^0.4.0" "@changesets/git" "^3.0.2" "@changesets/should-skip-package" "^0.1.1" @@ -386,18 +394,18 @@ "@changesets/types" "^6.0.0" dotenv "^8.1.0" -"@changesets/cli@~2.27.7", "@changesets/cli@~2.27.8": - version "2.27.10" - resolved "https://registry.yarnpkg.com/@changesets/cli/-/cli-2.27.10.tgz#b2b98caaf6f8a6630592456f07a881e7684f6ada" - integrity sha512-PfeXjvs9OfQJV8QSFFHjwHX3QnUL9elPEQ47SgkiwzLgtKGyuikWjrdM+lO9MXzOE22FO9jEGkcs4b+B6D6X0Q== +"@changesets/cli@~2.27.3", "@changesets/cli@~2.27.7", "@changesets/cli@~2.27.8": + version "2.27.11" + resolved "https://registry.yarnpkg.com/@changesets/cli/-/cli-2.27.11.tgz#1d510044b350a7c78a8b55a0591637d7ad224469" + integrity sha512-1QislpE+nvJgSZZo9+Lj3Lno5pKBgN46dAV8IVxKJy9wX8AOrs9nn5pYVZuDpoxWJJCALmbfOsHkyxujgetQSg== dependencies: - "@changesets/apply-release-plan" "^7.0.6" + "@changesets/apply-release-plan" "^7.0.7" "@changesets/assemble-release-plan" "^6.0.5" "@changesets/changelog-git" "^0.2.0" - "@changesets/config" "^3.0.4" + "@changesets/config" "^3.0.5" "@changesets/errors" "^0.2.0" "@changesets/get-dependents-graph" "^2.1.2" - "@changesets/get-release-plan" "^4.0.5" + "@changesets/get-release-plan" "^4.0.6" "@changesets/git" "^3.0.2" "@changesets/logger" "^0.1.1" "@changesets/pre" "^2.0.1" @@ -408,7 +416,7 @@ "@manypkg/get-packages" "^1.1.3" ansi-colors "^4.1.3" ci-info "^3.7.0" - enquirer "^2.3.0" + enquirer "^2.4.1" external-editor "^3.1.0" fs-extra "^7.0.1" mri "^1.2.0" @@ -420,10 +428,10 @@ spawndamnit "^3.0.1" term-size "^2.1.0" -"@changesets/config@^3.0.4": - version "3.0.4" - resolved "https://registry.yarnpkg.com/@changesets/config/-/config-3.0.4.tgz#2acfdf3e09424149684b3bd10c88074becf251aa" - integrity sha512-+DiIwtEBpvvv1z30f8bbOsUQGuccnZl9KRKMM/LxUHuDu5oEjmN+bJQ1RIBKNJjfYMQn8RZzoPiX0UgPaLQyXw== +"@changesets/config@^3.0.5": + version "3.0.5" + resolved "https://registry.yarnpkg.com/@changesets/config/-/config-3.0.5.tgz#cb59e9f338a4b35d3266af8a32799cb940d54ee0" + integrity sha512-QyXLSSd10GquX7hY0Mt4yQFMEeqnO5z/XLpbIr4PAkNNoQNKwDyiSrx4yd749WddusH1v3OSiA0NRAYmH/APpQ== dependencies: "@changesets/errors" "^0.2.0" "@changesets/get-dependents-graph" "^2.1.2" @@ -458,13 +466,13 @@ dataloader "^1.4.0" node-fetch "^2.5.0" -"@changesets/get-release-plan@^4.0.5": - version "4.0.5" - resolved "https://registry.yarnpkg.com/@changesets/get-release-plan/-/get-release-plan-4.0.5.tgz#2c857ce2f1942b88ff6ffcb24667edc52bcbfaea" - integrity sha512-E6wW7JoSMcctdVakut0UB76FrrN3KIeJSXvB+DHMFo99CnC3ZVnNYDCVNClMlqAhYGmLmAj77QfApaI3ca4Fkw== +"@changesets/get-release-plan@^4.0.6": + version "4.0.6" + resolved "https://registry.yarnpkg.com/@changesets/get-release-plan/-/get-release-plan-4.0.6.tgz#40d70c2524be51a70b7e1a778826854bb6c8562a" + integrity sha512-FHRwBkY7Eili04Y5YMOZb0ezQzKikTka4wL753vfUA5COSebt7KThqiuCN9BewE4/qFGgF/5t3AuzXx1/UAY4w== dependencies: "@changesets/assemble-release-plan" "^6.0.5" - "@changesets/config" "^3.0.4" + "@changesets/config" "^3.0.5" "@changesets/pre" "^2.0.1" "@changesets/read" "^0.6.2" "@changesets/types" "^6.0.0" @@ -1292,6 +1300,13 @@ dependencies: "@noble/hashes" "1.3.2" +"@noble/curves@1.4.0": + version "1.4.0" + resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.4.0.tgz#f05771ef64da724997f69ee1261b2417a49522d6" + integrity sha512-p+4cb332SFCrReJkCYe8Xzm0OWi4Jji5jVdIZRL/PmacmDkFNw6MrrV+gGpiPxLHbV+zKFRywUWbaseT+tZRXg== + dependencies: + "@noble/hashes" "1.4.0" + "@noble/curves@1.4.2", "@noble/curves@~1.4.0": version "1.4.2" resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.4.2.tgz#40309198c76ed71bc6dbf7ba24e81ceb4d0d1fe9" @@ -1299,7 +1314,7 @@ dependencies: "@noble/hashes" "1.4.0" -"@noble/curves@1.7.0", "@noble/curves@^1.4.0", "@noble/curves@^1.6.0", "@noble/curves@~1.7.0": +"@noble/curves@^1.4.0": version "1.7.0" resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.7.0.tgz#0512360622439256df892f21d25b388f52505e45" integrity sha512-UTMhXK9SeDhFJVrHeUJ5uZlI6ajXg10O6Ddocf9S6GjbSBVZsJo88HzKwXznNfGpMTRDyJkqMjNDPYgf0qFWnw== @@ -1331,7 +1346,7 @@ resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.6.0.tgz#d4bfb516ad6e7b5111c216a5cc7075f4cf19e6c5" integrity sha512-YUULf0Uk4/mAA89w+k3+yUYh6NrEvxZa5T6SY3wlMvE2chHkxFUUIDI8/XW1QSC357iA5pSnqt7XEhvFOqmDyQ== -"@noble/hashes@1.6.1", "@noble/hashes@^1.4.0", "@noble/hashes@^1.5.0", "@noble/hashes@~1.6.0": +"@noble/hashes@^1.4.0": version "1.6.1" resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.6.1.tgz#df6e5943edcea504bac61395926d6fd67869a0d5" integrity sha512-pq5D8h10hHBjyqX+cfBm0i8JUXJ0UhczFc4r74zbuT9XgewFo2E3J1cOaGtdZynILNmQ685YWGzGE1Zv6io50w== @@ -1469,12 +1484,12 @@ lodash.isequal "^4.5.0" "@nomicfoundation/hardhat-ignition@^0.15.5": - version "0.15.8" - resolved "https://registry.yarnpkg.com/@nomicfoundation/hardhat-ignition/-/hardhat-ignition-0.15.8.tgz#d1a6bb508740959986ad256a4403570aec3d40d0" - integrity sha512-TN8TFQokcd7VyqGfbXO+KS8Q4K/gmsOFlv8dPnt/N596AncgV2Igxh5C3O+KVez11PDHNqoj1JzcDzzNVHrIRw== + version "0.15.9" + resolved "https://registry.yarnpkg.com/@nomicfoundation/hardhat-ignition/-/hardhat-ignition-0.15.9.tgz#7f66ad928308f391e3ba8241655f835c7bb3546c" + integrity sha512-lSWqhaDOBt6gsqMadkRLvH6HdoFV1v8/bx7z+12cghaOloVwwn48CPoTH2iXXnkqilPGw8rdH5eVTE6UM+2v6Q== dependencies: - "@nomicfoundation/ignition-core" "^0.15.8" - "@nomicfoundation/ignition-ui" "^0.15.8" + "@nomicfoundation/ignition-core" "^0.15.9" + "@nomicfoundation/ignition-ui" "^0.15.9" chalk "^4.0.0" debug "^4.3.2" fs-extra "^10.0.0" @@ -1504,10 +1519,10 @@ abitype "^0.9.8" lodash.memoize "^4.1.2" -"@nomicfoundation/ignition-core@^0.15.8": - version "0.15.8" - resolved "https://registry.yarnpkg.com/@nomicfoundation/ignition-core/-/ignition-core-0.15.8.tgz#a5bf84f52d029d0305b5a34a289e6bb64bdcb5e6" - integrity sha512-U+CmTjKU9uwvh7qIabqboy/K/sDoClDgpsFRHoFvAj87DPDkXYb/mZBSkXPTU1wxTxrW6GTFE4lG3e7LAyF+kw== +"@nomicfoundation/ignition-core@^0.15.9": + version "0.15.9" + resolved "https://registry.yarnpkg.com/@nomicfoundation/ignition-core/-/ignition-core-0.15.9.tgz#5c9401ad93e0c15f633afaf9b3d055b57a881604" + integrity sha512-X8W+7UP/UQPorpHUnGvA1OdsEr/edGi8tDpNwEqzaLm83FMZVbRWdOsr3vNICHN2XMzNY/xIm18Cx7xGKL2PQw== dependencies: "@ethersproject/address" "5.6.1" "@nomicfoundation/solidity-analyzer" "^0.1.1" @@ -1519,10 +1534,10 @@ lodash "4.17.21" ndjson "2.0.0" -"@nomicfoundation/ignition-ui@^0.15.8": - version "0.15.8" - resolved "https://registry.yarnpkg.com/@nomicfoundation/ignition-ui/-/ignition-ui-0.15.8.tgz#8c0dacec4809d8b90724a1901866656222beeda9" - integrity sha512-VUD5MsWrrv7E2P0AJO01pV8w8m66Du0uwBKXM0oUV5DRIzqm6eYHt9eCDb1KBINDpiFxOQiuyWQMdeKxgPp3qw== +"@nomicfoundation/ignition-ui@^0.15.9": + version "0.15.9" + resolved "https://registry.yarnpkg.com/@nomicfoundation/ignition-ui/-/ignition-ui-0.15.9.tgz#ba94174f44e5c0de01d9968633fdf925a9585768" + integrity sha512-8lzbT7gpJ5PoowPQDQilkwdyqBviUKDMoHp/5rhgnwG1bDslnCS+Lxuo6s9R2akWu9LtEL14dNyqQb6WsURTag== "@nomicfoundation/slang@^0.18.3": version "0.18.3" @@ -1711,9 +1726,9 @@ lodash "^4.17.21" "@openzeppelin/hardhat-upgrades@^3.3.0": - version "3.7.0" - resolved "https://registry.yarnpkg.com/@openzeppelin/hardhat-upgrades/-/hardhat-upgrades-3.7.0.tgz#fc9562ab01edfa1eafb49870d8bf37e038a3ce49" - integrity sha512-dTnqqTIZUOyEzL62FIusZPeac9CqTD+x3Q5h+46JBALgS9DubUq/jXMhiE3JKLco3RELZQCh/9GYKBoUA0R2DQ== + version "3.8.0" + resolved "https://registry.yarnpkg.com/@openzeppelin/hardhat-upgrades/-/hardhat-upgrades-3.8.0.tgz#df865f208a8fd379e136b5f8454e1bcc5417dedb" + integrity sha512-NwRk14ykTVilQqB0Vzd0vOWvUE8gpyn+SSwdzyHECRc5fuSSPDt/cIdadG9Hd6AKMPXfY+CS6G7q0+nDLng2Zw== dependencies: "@openzeppelin/defender-sdk-base-client" "^1.14.4" "@openzeppelin/defender-sdk-deploy-client" "^1.14.4" @@ -1787,11 +1802,6 @@ resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.9.tgz#e5e142fbbfe251091f9c5f1dd4c834ac04c3dbd1" integrity sha512-8YKhl8GHiNI/pU2VMaofa2Tor7PJRAjwQLBBuilkJ9L5+13yVbC7JO/wS7piioAvPSwR3JKM1IJ/u4xQzbcXKg== -"@scure/base@~1.2.1": - version "1.2.1" - resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.2.1.tgz#dd0b2a533063ca612c17aa9ad26424a2ff5aa865" - integrity sha512-DGmGtC8Tt63J5GfHgfl5CuAXh96VF/LD8K9Hr/Gv0J2lAoRGlPOMpqMpMbCTOoOJMZCk2Xt+DskdDyn6dEFdzQ== - "@scure/bip32@1.1.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.1.0.tgz#dea45875e7fbc720c2b4560325f1cf5d2246d95b" @@ -1819,15 +1829,6 @@ "@noble/hashes" "~1.4.0" "@scure/base" "~1.1.6" -"@scure/bip32@1.6.0", "@scure/bip32@^1.5.0": - version "1.6.0" - resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.6.0.tgz#6dbc6b4af7c9101b351f41231a879d8da47e0891" - integrity sha512-82q1QfklrUUdXJzjuRU7iG7D7XiFx5PHYVS0+oeNKhyDLT7WPqs6pBcM2W5ZdwOwKCwoE1Vy1se+DHjcXwCYnA== - dependencies: - "@noble/curves" "~1.7.0" - "@noble/hashes" "~1.6.0" - "@scure/base" "~1.2.1" - "@scure/bip39@1.1.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.1.0.tgz#92f11d095bae025f166bef3defcc5bf4945d419a" @@ -1852,14 +1853,6 @@ "@noble/hashes" "~1.4.0" "@scure/base" "~1.1.6" -"@scure/bip39@1.5.0", "@scure/bip39@^1.4.0": - version "1.5.0" - resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.5.0.tgz#c8f9533dbd787641b047984356531d84485f19be" - integrity sha512-Dop+ASYhnrwm9+HA/HwXg7j2ZqM6yk2fyLWb5znexjctFY3+E+eU8cIWI0Pql0Qx4hPZCijlGq4OL71g+Uz30A== - dependencies: - "@noble/hashes" "~1.6.0" - "@scure/base" "~1.2.1" - "@sentry/core@5.30.0": version "5.30.0" resolved "https://registry.yarnpkg.com/@sentry/core/-/core-5.30.0.tgz#6b203664f69e75106ee8b5a2fe1d717379b331f3" @@ -2384,61 +2377,61 @@ integrity sha512-ltIpx+kM7g/MLRZfkbL7EsCEjfzCcScLpkg37eXEtx5kmrAKBkTJwd1GIAjDSL8wTpM6Hzn5YO4pSb91BEwu1g== "@typescript-eslint/eslint-plugin@^8.7.0": - version "8.18.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.18.0.tgz#0901933326aea4443b81df3f740ca7dfc45c7bea" - integrity sha512-NR2yS7qUqCL7AIxdJUQf2MKKNDVNaig/dEB0GBLU7D+ZdHgK1NoH/3wsgO3OnPVipn51tG3MAwaODEGil70WEw== + version "8.18.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.18.1.tgz#992e5ac1553ce20d0d46aa6eccd79dc36dedc805" + integrity sha512-Ncvsq5CT3Gvh+uJG0Lwlho6suwDfUXH0HztslDf5I+F2wAFAZMRwYLEorumpKLzmO2suAXZ/td1tBg4NZIi9CQ== dependencies: "@eslint-community/regexpp" "^4.10.0" - "@typescript-eslint/scope-manager" "8.18.0" - "@typescript-eslint/type-utils" "8.18.0" - "@typescript-eslint/utils" "8.18.0" - "@typescript-eslint/visitor-keys" "8.18.0" + "@typescript-eslint/scope-manager" "8.18.1" + "@typescript-eslint/type-utils" "8.18.1" + "@typescript-eslint/utils" "8.18.1" + "@typescript-eslint/visitor-keys" "8.18.1" graphemer "^1.4.0" ignore "^5.3.1" natural-compare "^1.4.0" ts-api-utils "^1.3.0" "@typescript-eslint/parser@^8.7.0": - version "8.18.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-8.18.0.tgz#a1c9456cbb6a089730bf1d3fc47946c5fb5fe67b" - integrity sha512-hgUZ3kTEpVzKaK3uNibExUYm6SKKOmTU2BOxBSvOYwtJEPdVQ70kZJpPjstlnhCHcuc2WGfSbpKlb/69ttyN5Q== - dependencies: - "@typescript-eslint/scope-manager" "8.18.0" - "@typescript-eslint/types" "8.18.0" - "@typescript-eslint/typescript-estree" "8.18.0" - "@typescript-eslint/visitor-keys" "8.18.0" + version "8.18.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-8.18.1.tgz#c258bae062778b7696793bc492249027a39dfb95" + integrity sha512-rBnTWHCdbYM2lh7hjyXqxk70wvon3p2FyaniZuey5TrcGBpfhVp0OxOa6gxr9Q9YhZFKyfbEnxc24ZnVbbUkCA== + dependencies: + "@typescript-eslint/scope-manager" "8.18.1" + "@typescript-eslint/types" "8.18.1" + "@typescript-eslint/typescript-estree" "8.18.1" + "@typescript-eslint/visitor-keys" "8.18.1" debug "^4.3.4" -"@typescript-eslint/scope-manager@8.18.0": - version "8.18.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-8.18.0.tgz#30b040cb4557804a7e2bcc65cf8fdb630c96546f" - integrity sha512-PNGcHop0jkK2WVYGotk/hxj+UFLhXtGPiGtiaWgVBVP1jhMoMCHlTyJA+hEj4rszoSdLTK3fN4oOatrL0Cp+Xw== +"@typescript-eslint/scope-manager@8.18.1": + version "8.18.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-8.18.1.tgz#52cedc3a8178d7464a70beffed3203678648e55b" + integrity sha512-HxfHo2b090M5s2+/9Z3gkBhI6xBH8OJCFjH9MhQ+nnoZqxU3wNxkLT+VWXWSFWc3UF3Z+CfPAyqdCTdoXtDPCQ== dependencies: - "@typescript-eslint/types" "8.18.0" - "@typescript-eslint/visitor-keys" "8.18.0" + "@typescript-eslint/types" "8.18.1" + "@typescript-eslint/visitor-keys" "8.18.1" -"@typescript-eslint/type-utils@8.18.0": - version "8.18.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-8.18.0.tgz#6f0d12cf923b6fd95ae4d877708c0adaad93c471" - integrity sha512-er224jRepVAVLnMF2Q7MZJCq5CsdH2oqjP4dT7K6ij09Kyd+R21r7UVJrF0buMVdZS5QRhDzpvzAxHxabQadow== +"@typescript-eslint/type-utils@8.18.1": + version "8.18.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-8.18.1.tgz#10f41285475c0bdee452b79ff7223f0e43a7781e" + integrity sha512-jAhTdK/Qx2NJPNOTxXpMwlOiSymtR2j283TtPqXkKBdH8OAMmhiUfP0kJjc/qSE51Xrq02Gj9NY7MwK+UxVwHQ== dependencies: - "@typescript-eslint/typescript-estree" "8.18.0" - "@typescript-eslint/utils" "8.18.0" + "@typescript-eslint/typescript-estree" "8.18.1" + "@typescript-eslint/utils" "8.18.1" debug "^4.3.4" ts-api-utils "^1.3.0" -"@typescript-eslint/types@8.18.0": - version "8.18.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-8.18.0.tgz#3afcd30def8756bc78541268ea819a043221d5f3" - integrity sha512-FNYxgyTCAnFwTrzpBGq+zrnoTO4x0c1CKYY5MuUTzpScqmY5fmsh2o3+57lqdI3NZucBDCzDgdEbIaNfAjAHQA== +"@typescript-eslint/types@8.18.1": + version "8.18.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-8.18.1.tgz#d7f4f94d0bba9ebd088de840266fcd45408a8fff" + integrity sha512-7uoAUsCj66qdNQNpH2G8MyTFlgerum8ubf21s3TSM3XmKXuIn+H2Sifh/ES2nPOPiYSRJWAk0fDkW0APBWcpfw== -"@typescript-eslint/typescript-estree@8.18.0": - version "8.18.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-8.18.0.tgz#d8ca785799fbb9c700cdff1a79c046c3e633c7f9" - integrity sha512-rqQgFRu6yPkauz+ms3nQpohwejS8bvgbPyIDq13cgEDbkXt4LH4OkDMT0/fN1RUtzG8e8AKJyDBoocuQh8qNeg== +"@typescript-eslint/typescript-estree@8.18.1": + version "8.18.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-8.18.1.tgz#2a86cd64b211a742f78dfa7e6f4860413475367e" + integrity sha512-z8U21WI5txzl2XYOW7i9hJhxoKKNG1kcU4RzyNvKrdZDmbjkmLBo8bgeiOJmA06kizLI76/CCBAAGlTlEeUfyg== dependencies: - "@typescript-eslint/types" "8.18.0" - "@typescript-eslint/visitor-keys" "8.18.0" + "@typescript-eslint/types" "8.18.1" + "@typescript-eslint/visitor-keys" "8.18.1" debug "^4.3.4" fast-glob "^3.3.2" is-glob "^4.0.3" @@ -2446,22 +2439,22 @@ semver "^7.6.0" ts-api-utils "^1.3.0" -"@typescript-eslint/utils@8.18.0": - version "8.18.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-8.18.0.tgz#48f67205d42b65d895797bb7349d1be5c39a62f7" - integrity sha512-p6GLdY383i7h5b0Qrfbix3Vc3+J2k6QWw6UMUeY5JGfm3C5LbZ4QIZzJNoNOfgyRe0uuYKjvVOsO/jD4SJO+xg== +"@typescript-eslint/utils@8.18.1": + version "8.18.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-8.18.1.tgz#c4199ea23fc823c736e2c96fd07b1f7235fa92d5" + integrity sha512-8vikiIj2ebrC4WRdcAdDcmnu9Q/MXXwg+STf40BVfT8exDqBCUPdypvzcUPxEqRGKg9ALagZ0UWcYCtn+4W2iQ== dependencies: "@eslint-community/eslint-utils" "^4.4.0" - "@typescript-eslint/scope-manager" "8.18.0" - "@typescript-eslint/types" "8.18.0" - "@typescript-eslint/typescript-estree" "8.18.0" + "@typescript-eslint/scope-manager" "8.18.1" + "@typescript-eslint/types" "8.18.1" + "@typescript-eslint/typescript-estree" "8.18.1" -"@typescript-eslint/visitor-keys@8.18.0": - version "8.18.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-8.18.0.tgz#7b6d33534fa808e33a19951907231ad2ea5c36dd" - integrity sha512-pCh/qEA8Lb1wVIqNvBke8UaRjJ6wrAWkJO5yyIbs8Yx6TNGYyfNjOo61tLv+WwLvoLPp4BQ8B7AHKijl8NGUfw== +"@typescript-eslint/visitor-keys@8.18.1": + version "8.18.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-8.18.1.tgz#344b4f6bc83f104f514676facf3129260df7610a" + integrity sha512-Vj0WLm5/ZsD013YeUKn+K0y8p1M0jPpxOkKdbD1wB0ns53a5piVY02zjf072TblEweAbcYiFiPoSMF3kp+VhhQ== dependencies: - "@typescript-eslint/types" "8.18.0" + "@typescript-eslint/types" "8.18.1" eslint-visitor-keys "^4.2.0" "@uniswap/lib@4.0.1-alpha", "@uniswap/lib@^4.0.1-alpha": @@ -2713,10 +2706,10 @@ abbrev@1.0.x: resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.0.9.tgz#91b4792588a7738c25f35dd6f63752a2f8776135" integrity sha512-LEyx4aLEC3x6T0UguF6YILf+ntvmOaWsVfENmIW0E9H09vKlLDGelMjjSm0jkDHALj8A8quZ/HapKNigzwge+Q== -abitype@1.0.7, abitype@^1.0.6: - version "1.0.7" - resolved "https://registry.yarnpkg.com/abitype/-/abitype-1.0.7.tgz#876a0005d211e1c9132825d45bcee7b46416b284" - integrity sha512-ZfYYSktDQUwc2eduYu8C4wOs+RDPmnRYMh7zNfzeMtGGgb0U+6tLGjixUic6mXf5xKKCcgT5Qp6cv39tOARVFw== +abitype@1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/abitype/-/abitype-1.0.5.tgz#29d0daa3eea867ca90f7e4123144c1d1270774b6" + integrity sha512-YzDhti7cjlfaBhHutMaboYB21Ha3rXR9QTkNJFzYC4kC8YclaiwPBBBJY8ejFdu2wnJeZCVZSMlQJ7fi8S6hsw== abitype@^0.9.8: version "0.9.10" @@ -3005,7 +2998,7 @@ asap@~2.0.6: resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46" integrity sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA== -asciichart@^1.5.25: +asciichart@1.5.25: version "1.5.25" resolved "https://registry.yarnpkg.com/asciichart/-/asciichart-1.5.25.tgz#f5aca189801b4e58019139bbb5922ab3cae3ca90" integrity sha512-PNxzXIPPOtWq8T7bgzBtk9cI2lgS4SJZthUHEiQ1aoIc3lNzGfUvIvo9LiAnq26TACo9t1/4qP6KTGAUbzX9Xg== @@ -3560,7 +3553,7 @@ call-bind-apply-helpers@^1.0.0, call-bind-apply-helpers@^1.0.1: es-errors "^1.3.0" function-bind "^1.1.2" -call-bind@^1.0.5, call-bind@^1.0.7, call-bind@^1.0.8: +call-bind@^1.0.8: version "1.0.8" resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.8.tgz#0736a9660f537e3388826f440d5ec45f744eaa4c" integrity sha512-oKlSFMcMwpUg2ednkhQ454wfWiU/ul3CkJe/PEHcTKuiX6RpbehUiFMXu13HalGZxfUwCQzZG747YXBn1im9ww== @@ -3570,13 +3563,13 @@ call-bind@^1.0.5, call-bind@^1.0.7, call-bind@^1.0.8: get-intrinsic "^1.2.4" set-function-length "^1.2.2" -call-bound@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/call-bound/-/call-bound-1.0.2.tgz#9dbd4daf9f5f753bec3e4c8fbb8a2ecc4de6c39b" - integrity sha512-0lk0PHFe/uz0vl527fG9CgdE9WdafjDbCXvBbs+LUv000TVt2Jjhqbs4Jwm8gz070w8xXyEAxrPOMullsxXeGg== +call-bound@^1.0.2, call-bound@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/call-bound/-/call-bound-1.0.3.tgz#41cfd032b593e39176a71533ab4f384aa04fd681" + integrity sha512-YTd+6wGlNlPxSuri7Y6X8tY2dmm12UMH66RpKMhiX6rsk5wXXnYgbUcOt8kiS31/AjfoTOvCsE+w8nZQLQnzHA== dependencies: - call-bind "^1.0.8" - get-intrinsic "^1.2.5" + call-bind-apply-helpers "^1.0.1" + get-intrinsic "^1.2.6" callsites@^3.0.0: version "3.1.0" @@ -3602,9 +3595,9 @@ camelcase@^6.0.0, camelcase@^6.2.0: integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== caniuse-lite@^1.0.30001688: - version "1.0.30001688" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001688.tgz#f9d3ede749f083ce0db4c13db9d828adaf2e8d0a" - integrity sha512-Nmqpru91cuABu/DTCXbM2NSRHzM2uVHfPnhJ/1zEAJx/ILBRVmz3pzH4N7DZqbdG0gWClsCC05Oj0mJ/1AWMbA== + version "1.0.30001690" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001690.tgz#f2d15e3aaf8e18f76b2b8c1481abde063b8104c8" + integrity sha512-5ExiE3qQN6oF8Clf8ifIDcMRCRE/dMGcETG/XGMD8/XiXm6HXQgQTh1yZYLXXpSOsEUlJm1Xr7kGULZTuGtP/w== caseless@^0.12.0, caseless@~0.12.0: version "0.12.0" @@ -3668,9 +3661,9 @@ chalk@^2.4.2: supports-color "^5.3.0" chalk@^5.3.0: - version "5.3.0" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.3.0.tgz#67c20a7ebef70e7f3970a01f90fa210cb6860385" - integrity sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w== + version "5.4.0" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.4.0.tgz#846fdb5d5d939d6fa3d565cd5545697b6f8b6923" + integrity sha512-ZkD35Mx92acjB2yNJgziGqT9oKHEOxjTBTDRpOsRWtdecL/0jM3z5kM/CTzHWvHIen1GvkM85p6TuFfDGfc8/Q== chardet@^0.7.0: version "0.7.0" @@ -3712,9 +3705,9 @@ chokidar@^3.5.2, chokidar@^3.5.3: fsevents "~2.3.2" chokidar@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-4.0.1.tgz#4a6dff66798fb0f72a94f616abbd7e1a19f31d41" - integrity sha512-n8enUVCED/KVRQlab1hr3MVpcVMvxtZjmEa956u+4YijlmQED223XMSYj2tLuKvr4jcCTzNNMpQDUer72MMmzA== + version "4.0.3" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-4.0.3.tgz#7be37a4c03c9aee1ecfe862a4a23b2c70c205d30" + integrity sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA== dependencies: readdirp "^4.0.1" @@ -4439,6 +4432,11 @@ dot-case@^3.0.4: no-case "^3.0.4" tslib "^2.0.3" +dotenv@16.4.5: + version "16.4.5" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.5.tgz#cdd3b3b604cb327e286b4762e13502f717cb099f" + integrity sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg== + dotenv@^14.2.0: version "14.3.2" resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-14.3.2.tgz#7c30b3a5f777c79a3429cb2db358eef6751e8369" @@ -4468,11 +4466,11 @@ drbg.js@^1.0.1: resolved "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0" dunder-proto@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/dunder-proto/-/dunder-proto-1.0.0.tgz#c2fce098b3c8f8899554905f4377b6d85dabaa80" - integrity sha512-9+Sj30DIu+4KvHqMfLUGLFYL2PkURSYMVXJyXe92nFRvlYq5hBjLEhblKB+vkd/WVlUYMWigiY07T91Fkk0+4A== + version "1.0.1" + resolved "https://registry.yarnpkg.com/dunder-proto/-/dunder-proto-1.0.1.tgz#d7ae667e1dc83482f8b70fd0f6eefc50da30f58a" + integrity sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A== dependencies: - call-bind-apply-helpers "^1.0.0" + call-bind-apply-helpers "^1.0.1" es-errors "^1.3.0" gopd "^1.2.0" @@ -4507,9 +4505,9 @@ ee-first@1.1.1: integrity sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow== electron-to-chromium@^1.5.73: - version "1.5.73" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.73.tgz#f32956ce40947fa3c8606726a96cd8fb5bb5f720" - integrity sha512-8wGNxG9tAG5KhGd3eeA0o6ixhiNdgr0DcHWm85XPCphwZgD1lIEoi6t3VERayWao7SF7AAZTw6oARGJeVjH8Kg== + version "1.5.75" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.75.tgz#bba96eabf0e8ca36324679caa38b982800acc87d" + integrity sha512-Lf3++DumRE/QmweGjU+ZcKqQ+3bKkU/qjaKYhIJKEOhgIO9Xs6IiAQFkfFoj+RhgDk4LUeNsLo6plExHqSyu6Q== elliptic@6.5.4: version "6.5.4" @@ -4562,7 +4560,7 @@ emojis-list@^3.0.0: resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-3.0.0.tgz#5570662046ad29e2e916e71aae260abdff4f6a78" integrity sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q== -encode-utf8@^1.0.2: +encode-utf8@^1.0.2, encode-utf8@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/encode-utf8/-/encode-utf8-1.0.3.tgz#f30fdd31da07fb596f281beb2f6b027851994cda" integrity sha512-ucAnuBEhUK4boH2HjVYG5Q2mQyPorvv0u/ocS+zhdw0S8AlHYY+GOFhP1Gio5z4icpP2ivFSvhtFjQi8+T9ppw== @@ -4599,7 +4597,7 @@ enhanced-resolve@^5.17.1: graceful-fs "^4.2.4" tapable "^2.2.0" -enquirer@^2.3.0, enquirer@^2.3.6: +enquirer@^2.3.0, enquirer@^2.3.6, enquirer@^2.4.1: version "2.4.1" resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.4.1.tgz#93334b3fbd74fc7097b224ab4a8fb7e40bf4ae56" integrity sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ== @@ -4617,7 +4615,7 @@ env-paths@^2.2.0: resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-2.2.1.tgz#420399d416ce1fbe9bc0a07c62fa68d67fd0f8f2" integrity sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A== -envfile@^7.1.0: +envfile@7.1.0: version "7.1.0" resolved "https://registry.yarnpkg.com/envfile/-/envfile-7.1.0.tgz#c0b101279dc710c25546602d5d17cfb9ab132e48" integrity sha512-dyH4QnnZsArCLhPASr29eqBWDvKpq0GggQFTmysTT/S9TTmt1JrEKNvTBc09Cd7ujVZQful2HBGRMe2agu7Krg== @@ -5301,11 +5299,6 @@ eventemitter3@4.0.4: resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.4.tgz#b5463ace635a083d018bdc7c917b4c5f10a85384" integrity sha512-rlaVLnVxtxvoyLsQQFBx53YmXHDxRIzzTLbdfxqi4yocpSjAxXwkU0cScM5JgSKMqEhrZpnvQ2D9gjylR0AimQ== -eventemitter3@5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-5.0.1.tgz#53f5ffd0a492ac800721bb42c66b841de96423c4" - integrity sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA== - events@^3.0.0, events@^3.2.0: version "3.3.0" resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" @@ -5577,8 +5570,8 @@ forever-agent@~0.6.1: integrity sha512-j0KLYPhm6zeac4lz3oJ3o65qvgQCcPubiyotZrXqEaG4hNagNYO8qdlUrX5vwqv9ohqeT/Z3j6+yW067yWWdUw== "forge-std@https://github.com/foundry-rs/forge-std.git": - version "1.9.4" - resolved "https://github.com/foundry-rs/forge-std.git#d3db4ef90a72b7d24aa5a2e5c649593eaef7801d" + version "1.9.5" + resolved "https://github.com/foundry-rs/forge-std.git#b93cf4bc34ff214c099dc970b153f85ade8c9f66" form-data-encoder@1.7.1: version "1.7.1" @@ -5780,7 +5773,7 @@ get-func-name@^2.0.1, get-func-name@^2.0.2: resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.2.tgz#0d7cf20cd13fda808669ffa88f4ffc7a3943fc41" integrity sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ== -get-intrinsic@^1.2.4, get-intrinsic@^1.2.5: +get-intrinsic@^1.2.4, get-intrinsic@^1.2.5, get-intrinsic@^1.2.6: version "1.2.6" resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.6.tgz#43dd3dd0e7b49b82b2dfcad10dc824bf7fc265d5" integrity sha512-qxsEs+9A+u85HhllWJJFicJfPDhRmjzoYdl64aMWW9yRIJmSyxdn8IEkuIM530/7T+lv0TIHd8L6Q/ra0tEoeA== @@ -6674,11 +6667,11 @@ is-subdir@^1.1.1: better-path-resolve "1.0.0" is-typed-array@^1.1.3: - version "1.1.13" - resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.13.tgz#d6c5ca56df62334959322d7d7dd1cca50debe229" - integrity sha512-uZ25/bUAlUY5fR4OKT4rZQEBrzQWYV9ZJYGGsUmEJ6thodVJ1HX64ePQ6Z0qPWP+m+Uq6e9UugrE38jeYsDSMw== + version "1.1.15" + resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.15.tgz#4bfb4a45b61cee83a5a46fba778e4e8d59c0ce0b" + integrity sha512-p3EcsicXjit7SaskXHs1hA91QxgTw46Fv6EFKKGS5DRFLD8yKnohjF3hxoju94b/OcMZoQukzpPpBE9uLVKzgQ== dependencies: - which-typed-array "^1.1.14" + which-typed-array "^1.1.16" is-typedarray@^1.0.0, is-typedarray@~1.0.0: version "1.0.0" @@ -6740,10 +6733,10 @@ isomorphic-unfetch@^3.0.0: node-fetch "^2.6.1" unfetch "^4.2.0" -isows@1.0.6: - version "1.0.6" - resolved "https://registry.yarnpkg.com/isows/-/isows-1.0.6.tgz#0da29d706fa51551c663c627ace42769850f86e7" - integrity sha512-lPHCayd40oW98/I0uvgaHKWCSvkzY27LjWLbtzOm64yQ+G3Q5npjjbdppU65iZXkK1Zt+kH9pfegli0AYfwYYw== +isows@1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/isows/-/isows-1.0.4.tgz#810cd0d90cc4995c26395d2aa4cfa4037ebdf061" + integrity sha512-hEzjY+x9u9hPmBom9IIAqdJCwNLax+xrPb51vEPpERoFlIxgmZcHzsT5jKG06nvInKOBGvReAVz80Umed5CczQ== isstream@~0.1.2: version "0.1.2" @@ -6870,11 +6863,12 @@ json-stable-stringify-without-jsonify@^1.0.1: integrity sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw== json-stable-stringify@^1.0.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.1.1.tgz#52d4361b47d49168bcc4e564189a42e5a7439454" - integrity sha512-SU/971Kt5qVQfJpyDveVhQ/vya+5hvrjClFOcr8c0Fq5aODJjMwutrOfCU+eCnVD5gpx1Q3fEqkyom77zH1iIg== + version "1.2.0" + resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.2.0.tgz#2c974b1e9e8c0655cc32d4a7315c23bf122e3d3a" + integrity sha512-ex8jk9BZHBolvbd5cRnAgwyaYcYB0qZldy1e+LCOdcF6+AUmVZ6LcGUMzsRTW83QMeu+GxZGrcLqxqrgfXGvIw== dependencies: - call-bind "^1.0.5" + call-bind "^1.0.8" + call-bound "^1.0.3" isarray "^2.0.5" jsonify "^0.0.1" object-keys "^1.1.1" @@ -7288,9 +7282,9 @@ match-all@^1.2.6: integrity sha512-0EESkXiTkWzrQQntBu2uzKvLu6vVkUGz40nGPbSZuegcfE5UuSzNjLaIu76zJWuaT/2I3Z/8M06OlUOZLGwLlQ== math-intrinsics@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/math-intrinsics/-/math-intrinsics-1.0.0.tgz#4e04bf87c85aa51e90d078dac2252b4eb5260817" - integrity sha512-4MqMiKP90ybymYvsut0CH2g4XWbfLtmlCkXmtmdcDCxNB+mQcu1w/1+L/VD7vi/PSv7X2JYV7SCcR+jiPXnQtA== + version "1.1.0" + resolved "https://registry.yarnpkg.com/math-intrinsics/-/math-intrinsics-1.1.0.tgz#a0dd74be81e2aa5c2f27e65ce283605ee4e2b7f9" + integrity sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g== md5.js@^1.3.4: version "1.3.5" @@ -7996,19 +7990,6 @@ outdent@^0.5.0: resolved "https://registry.yarnpkg.com/outdent/-/outdent-0.5.0.tgz#9e10982fdc41492bb473ad13840d22f9655be2ff" integrity sha512-/jHxFIzoMXdqPzTaCpFzAAWhpkSjZPF4Vsn6jAfNpmbH/ymsmd7Qc6VE9BGn0L6YMj6uwpQLxCECpus4ukKS9Q== -ox@0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/ox/-/ox-0.1.2.tgz#0f791be2ccabeaf4928e6d423498fe1c8094e560" - integrity sha512-ak/8K0Rtphg9vnRJlbOdaX9R7cmxD2MiSthjWGaQdMk3D7hrAlDoM+6Lxn7hN52Za3vrXfZ7enfke/5WjolDww== - dependencies: - "@adraffy/ens-normalize" "^1.10.1" - "@noble/curves" "^1.6.0" - "@noble/hashes" "^1.5.0" - "@scure/bip32" "^1.5.0" - "@scure/bip39" "^1.4.0" - abitype "^1.0.6" - eventemitter3 "5.0.1" - p-cancelable@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-2.1.1.tgz#aab7fbd416582fa32a3db49859c122487c5ed2cf" @@ -8508,12 +8489,13 @@ punycode@^2.1.0, punycode@^2.1.1, punycode@^2.3.1: resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5" integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== -qrcode@^1.5.1: - version "1.5.4" - resolved "https://registry.yarnpkg.com/qrcode/-/qrcode-1.5.4.tgz#5cb81d86eb57c675febb08cf007fff963405da88" - integrity sha512-1ca71Zgiu6ORjHqFBDpnSMTR2ReToX4l1Au1VFLyVeBTFavzQnv5JxMFr3ukHVKpSrSA2MCk0lNJSykjUfz7Zg== +qrcode@1.5.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/qrcode/-/qrcode-1.5.1.tgz#0103f97317409f7bc91772ef30793a54cd59f0cb" + integrity sha512-nS8NJ1Z3md8uTjKtP+SGGhfqmTCs5flU/xR623oI0JX+Wepz9R8UrRVCTBTJm3qGw3rH6jJ6MUHjkDx15cxSSg== dependencies: dijkstrajs "^1.0.1" + encode-utf8 "^1.0.3" pngjs "^5.0.0" yargs "^15.3.1" @@ -8651,7 +8633,7 @@ readdirp@~3.6.0: dependencies: picomatch "^2.2.1" -readline@^1.3.0: +readline@1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/readline/-/readline-1.3.0.tgz#c580d77ef2cfc8752b132498060dc9793a7ac01c" integrity sha512-k2d6ACCkiNYz222Fs/iNze30rRJ1iIicW7JuX/7/cozvih6YCkFZH+J6mAFDVgv0dRBaAyr4jDqC95R2y4IADg== @@ -8675,7 +8657,7 @@ reduce-flatten@^2.0.0: resolved "https://registry.yarnpkg.com/reduce-flatten/-/reduce-flatten-2.0.0.tgz#734fd84e65f375d7ca4465c69798c25c9d10ae27" integrity sha512-EJ4UNY/U1t2P/2k6oqotuX2Cc3T6nxJwsM0N0asT7dhrtH1ltUxDn4NalSYmPE2rCkVpcf/X6R0wDwcFpzhd4w== -regenerator-runtime@^0.14.0, regenerator-runtime@^0.14.1: +regenerator-runtime@0.14.1, regenerator-runtime@^0.14.0: version "0.14.1" resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz#356ade10263f685dda125100cd862c1db895327f" integrity sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw== @@ -8798,9 +8780,9 @@ resolve@1.17.0: path-parse "^1.0.6" resolve@^1.1.6, resolve@^1.14.2: - version "1.22.9" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.9.tgz#6da76e4cdc57181fa4471231400e8851d0a924f3" - integrity sha512-QxrmX1DzraFIi9PxdG5VkRfRwIgjwyud+z/iBwfRRrVmHc+P9Q7u2lSSpQ6bjr2gy5lrqIiU9vb6iAeGf2400A== + version "1.22.10" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.10.tgz#b663e83ffb09bbf2386944736baae803029b8b39" + integrity sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w== dependencies: is-core-module "^2.16.0" path-parse "^1.0.7" @@ -9269,7 +9251,7 @@ socks@^2.8.3: ip-address "^9.0.5" smart-buffer "^4.2.0" -solady@^0.0.273: +solady@0.0.273: version "0.0.273" resolved "https://registry.yarnpkg.com/solady/-/solady-0.0.273.tgz#4d97ff0f8d7fe21a6d8e4e933d367e4a0d59d4af" integrity sha512-pzIl6AR7Qmlcxh8CNzcdlw7NCp4HnIZgrl4zecGCDSO6e3jWNm7jKkt8uxu7xjmqJ5z7LVgmVAK2QOmnCEvKNA== @@ -9287,10 +9269,10 @@ solc@0.8.26: semver "^5.5.0" tmp "0.0.33" -solhint-community@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/solhint-community/-/solhint-community-4.0.0.tgz#4dba66932ff54ced426a8c035b7ceaa13a224f24" - integrity sha512-BERw3qYzkJE64EwvYrp2+iiTN8yAZOJ74FCiL4bTBp7v0JFUvRYCEGZKAqfHcfi/koKkzM6qThsJUceKm9vvfg== +solhint-community@3.7.0: + version "3.7.0" + resolved "https://registry.yarnpkg.com/solhint-community/-/solhint-community-3.7.0.tgz#5d8bd4a2137d44dd636272edce93cb754184c09b" + integrity sha512-8nfdaxVll+IIaEBHFz3CzagIZNNTGp4Mrr+6O4m7c9Bs/L8OcgR/xzZJFwROkGAhV8Nbiv4gqJ42nEXZPYl3Qw== dependencies: "@solidity-parser/parser" "^0.16.0" ajv "^6.12.6" @@ -9312,7 +9294,7 @@ solhint-community@^4.0.0: optionalDependencies: prettier "^2.8.3" -solhint-plugin-prettier@^0.1.0: +solhint-plugin-prettier@0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/solhint-plugin-prettier/-/solhint-plugin-prettier-0.1.0.tgz#2f46999e26d6c6bc80281c22a7a21e381175bef7" integrity sha512-SDOTSM6tZxZ6hamrzl3GUgzF77FM6jZplgL2plFBclj/OjKP8Z3eIPojKU73gRr0MvOS8ACZILn8a5g0VTz/Gw== @@ -9320,7 +9302,7 @@ solhint-plugin-prettier@^0.1.0: "@prettier/sync" "^0.3.0" prettier-linter-helpers "^1.0.0" -solhint@^5.0.3: +solhint@5.0.3: version "5.0.3" resolved "https://registry.yarnpkg.com/solhint/-/solhint-5.0.3.tgz#b57f6d2534fe09a60f9db1b92e834363edd1cbde" integrity sha512-OLCH6qm/mZTCpplTXzXTJGId1zrtNuDYP5c2e6snIv/hdRVxPfBBz/bAlL91bY/Accavkayp2Zp2BaDSrLVXTQ== @@ -9894,7 +9876,7 @@ ts-essentials@^7.0.1: resolved "https://registry.yarnpkg.com/ts-essentials/-/ts-essentials-7.0.3.tgz#686fd155a02133eedcc5362dc8b5056cde3e5a38" integrity sha512-8+gr5+lqO3G84KdiTSMRLtuyJ+nTBVRKuCrK4lidMPdVeEp0uqC875uE5NMcaA7YYMN7XsNiFQuMvasF8HT/xQ== -ts-node@^10.9.1, ts-node@^10.9.2: +ts-node@10.9.2, ts-node@^10.9.1: version "10.9.2" resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.2.tgz#70f021c9e185bccdca820e26dc413805c101c71f" integrity sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ== @@ -10247,20 +10229,20 @@ verror@1.10.0: core-util-is "1.0.2" extsprintf "^1.2.0" -viem@^2.19.1: - version "2.21.55" - resolved "https://registry.yarnpkg.com/viem/-/viem-2.21.55.tgz#a57ad31fcf2a0f6c011b1909f02c94421ec4f781" - integrity sha512-PgXew7C11cAuEtOSgRyQx2kJxEOPUwIwZA9dMglRByqJuFVA7wSGZZOOo/93iylAA8E15bEdqy9xulU3oKZ70Q== - dependencies: - "@noble/curves" "1.7.0" - "@noble/hashes" "1.6.1" - "@scure/bip32" "1.6.0" - "@scure/bip39" "1.5.0" - abitype "1.0.7" - isows "1.0.6" - ox "0.1.2" - webauthn-p256 "0.0.10" - ws "8.18.0" +viem@2.19.1: + version "2.19.1" + resolved "https://registry.yarnpkg.com/viem/-/viem-2.19.1.tgz#38ccffbacf69d8a2f940ff35be8ea3ac42ea5d61" + integrity sha512-a0ca/ACEz3FRZB3OmiSfRUogWZGQh700wu7Pg3GmAWiGD+0PS9bVaWG67JQ+9azFZLq0BU/m0t2CeWd3xi8IzQ== + dependencies: + "@adraffy/ens-normalize" "1.10.0" + "@noble/curves" "1.4.0" + "@noble/hashes" "1.4.0" + "@scure/bip32" "1.4.0" + "@scure/bip39" "1.3.0" + abitype "1.0.5" + isows "1.0.4" + webauthn-p256 "0.0.5" + ws "8.17.1" vue-hot-reload-api@^2.3.0: version "2.3.4" @@ -10591,10 +10573,10 @@ web3@1.10.0: web3-shh "1.10.0" web3-utils "1.10.0" -webauthn-p256@0.0.10: - version "0.0.10" - resolved "https://registry.yarnpkg.com/webauthn-p256/-/webauthn-p256-0.0.10.tgz#877e75abe8348d3e14485932968edf3325fd2fdd" - integrity sha512-EeYD+gmIT80YkSIDb2iWq0lq2zbHo1CxHlQTeJ+KkCILWpVy3zASH3ByD4bopzfk0uCwXxLqKGLqp2W4O28VFA== +webauthn-p256@0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/webauthn-p256/-/webauthn-p256-0.0.5.tgz#0baebd2ba8a414b21cc09c0d40f9dd0be96a06bd" + integrity sha512-drMGNWKdaixZNobeORVIqq7k5DsRC9FnG201K2QjeOoQLmtSDaSsVZdkg6n5jUALJKcAG++zBPJXmv6hy0nWFg== dependencies: "@noble/curves" "^1.4.0" "@noble/hashes" "^1.4.0" @@ -10668,15 +10650,16 @@ which-module@^2.0.0: resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.1.tgz#776b1fe35d90aebe99e8ac15eb24093389a4a409" integrity sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ== -which-typed-array@^1.1.14, which-typed-array@^1.1.2: - version "1.1.16" - resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.16.tgz#db4db429c4706feca2f01677a144278e4a8c216b" - integrity sha512-g+N+GAWiRj66DngFwHvISJd+ITsyphZvD1vChfVg6cEdnzy53GzB3oy0fUNlvhz7H7+MiqhYr26qxQShCpKTTQ== +which-typed-array@^1.1.16, which-typed-array@^1.1.2: + version "1.1.18" + resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.18.tgz#df2389ebf3fbb246a71390e90730a9edb6ce17ad" + integrity sha512-qEcY+KJYlWyLH9vNbsr6/5j59AXk5ni5aakf8ldzBvGde6Iz4sxZGkJyWSAueTG7QhOvNRYb1lDdFmL5Td0QKA== dependencies: available-typed-arrays "^1.0.7" - call-bind "^1.0.7" + call-bind "^1.0.8" + call-bound "^1.0.3" for-each "^0.3.3" - gopd "^1.0.1" + gopd "^1.2.0" has-tostringtag "^1.0.2" which@^1.1.1, which@^1.2.9, which@^1.3.1: @@ -10770,11 +10753,6 @@ ws@8.17.1: resolved "https://registry.yarnpkg.com/ws/-/ws-8.17.1.tgz#9293da530bb548febc95371d90f9c878727d919b" integrity sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ== -ws@8.18.0: - version "8.18.0" - resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.0.tgz#0d7505a6eafe2b0e712d232b42279f53bc289bbc" - integrity sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw== - ws@8.5.0: version "8.5.0" resolved "https://registry.yarnpkg.com/ws/-/ws-8.5.0.tgz#bfb4be96600757fe5382de12c670dab984a1ed4f" From 6f6634e4adf1275a2e621453d4e9282220191801 Mon Sep 17 00:00:00 2001 From: lufaque <95128636+lufaque@users.noreply.github.com> Date: Mon, 23 Dec 2024 17:58:21 +0300 Subject: [PATCH 38/54] update set contracts task --- constants/rpcUrls.ts | 7 +-- .../deployInfra/setContractVariables.ts | 54 +++++++++++-------- 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/constants/rpcUrls.ts b/constants/rpcUrls.ts index 998253f7..f4073b1d 100644 --- a/constants/rpcUrls.ts +++ b/constants/rpcUrls.ts @@ -43,12 +43,7 @@ export const urls: Record = { `https://avalanche-fuji.core.chainstack.com/ext/bc/C/rpc/${CHAINSTACK_API_KEY}`, `https://ava-testnet.blastapi.io/${BLAST_API_KEY}ext/bc/C/rpc`, ], - arbitrum: [ - `https://lb.drpc.org/ogrpc?network=arbitrum&dkey=${DRPC_API_KEY}`, - `https://arb-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}`, - `https://arbitrum-one.blastapi.io/${BLAST_API_KEY}`, - "https://rpc.ankr.com/arbitrum", - ], + arbitrum: ["https://rpc.ankr.com/arbitrum", "https://arbitrum-one-rpc.publicnode.com"], arbitrumSepolia: [ `https://lb.drpc.org/ogrpc?network=arbitrum-sepolia&dkey=${DRPC_API_KEY}`, `https://arbitrum-sepolia.infura.io/v3/${INFURA_API_KEY}`, diff --git a/tasks/concero/deployInfra/setContractVariables.ts b/tasks/concero/deployInfra/setContractVariables.ts index 25909909..038d3743 100644 --- a/tasks/concero/deployInfra/setContractVariables.ts +++ b/tasks/concero/deployInfra/setContractVariables.ts @@ -1,4 +1,4 @@ -import { CNetwork } from "../../../types/CNetwork"; +import { CNetwork, CNetworkNames } from "../../../types/CNetwork"; import { err, formatGas, @@ -25,6 +25,7 @@ import { viemReceiptConfig, } from "../../../constants"; import { ethersV6CodeUrl, infraDstJsCodeUrl, infraSrcJsCodeUrl } from "../../../constants/functionsJsCodeUrls"; +import { Address } from "viem"; const resetLastGasPrices = async (deployableChain: CNetwork, chains: CNetwork[], abi: any) => { const conceroProxyAddress = getEnvVar(`CONCERO_INFRA_PROXY_${networkEnvKeys[deployableChain.name]}`); @@ -267,33 +268,40 @@ export async function setDonSecretsSlotId(deployableChain: CNetwork, slotId: num } } +const allowedRoutersByChain: Record, Array
> = { + arbitrum: [getEnvVar("SUSHISWAP_ROUTER_ARBITRUM"), getEnvVar("UNISWAP_ROUTER_ARBITRUM")], +}; + export async function setDexSwapAllowedRouters(deployableChain: CNetwork, abi: any) { const { viemChain: dcViemChain, name: dcName } = deployableChain; const [conceroProxy, conceroProxyAlias] = getEnvAddress(ProxyEnum.infraProxy, dcName); - const [allowedRouter, allowedRouterAlias] = getEnvAddress("uniswapRouter", dcName); const { walletClient, publicClient, account } = getFallbackClients(deployableChain); + const allowedRouters = allowedRoutersByChain[dcName]; - try { - const { request: setDexRouterReq } = await publicClient.simulateContract({ - address: conceroProxy, - abi, - functionName: "setDexRouterAddress", - account, - args: [allowedRouter, true], - chain: dcViemChain, - }); - const setDexRouterHash = await walletClient.writeContract(setDexRouterReq); - const { cumulativeGasUsed: setDexRouterGasUsed } = await publicClient.waitForTransactionReceipt({ - ...viemReceiptConfig, - hash: setDexRouterHash, - }); - log( - `[Set] ${conceroProxyAlias}.dexRouterAddress -> ${allowedRouterAlias}. Gas: ${formatGas(setDexRouterGasUsed)}`, - "setDexRouterAddress", - dcName, - ); - } catch (error) { - err(`${error.message}`, "setDexRouterAddress", dcName); + for (const allowedRouter of allowedRouters) { + console.log(allowedRouter); + try { + const { request: setDexRouterReq } = await publicClient.simulateContract({ + address: conceroProxy, + abi, + functionName: "setDexRouterAddress", + account, + args: [allowedRouter, true], + chain: dcViemChain, + }); + const setDexRouterHash = await walletClient.writeContract(setDexRouterReq); + const { cumulativeGasUsed: setDexRouterGasUsed } = await publicClient.waitForTransactionReceipt({ + ...viemReceiptConfig, + hash: setDexRouterHash, + }); + log( + `[Set] ${conceroProxyAlias}.dexRouterAddress -> ${allowedRouter}. Gas: ${formatGas(setDexRouterGasUsed)}`, + "setDexRouterAddress", + dcName, + ); + } catch (error) { + err(`${error.message}`, "setDexRouterAddress", dcName); + } } } From e194fe94fbe349684a9ed0a7bfad438a963640cf Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Mon, 23 Dec 2024 17:58:49 +0300 Subject: [PATCH 39/54] rename dexData to dexCallData --- contracts/Interfaces/IDexSwap.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/Interfaces/IDexSwap.sol b/contracts/Interfaces/IDexSwap.sol index 2e1ee0c8..662a8dab 100644 --- a/contracts/Interfaces/IDexSwap.sol +++ b/contracts/Interfaces/IDexSwap.sol @@ -17,7 +17,7 @@ interface IDexSwap { address toToken; uint256 toAmount; uint256 toAmountMin; - bytes dexData; + bytes dexCallData; } /** From 83ce30977501592fb2b86f15c690cbce4ddcb1f3 Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Mon, 23 Dec 2024 18:31:23 +0300 Subject: [PATCH 40/54] rename dexData to dexCallData --- contracts/DexSwap.sol | 6 +- contracts/Interfaces/IDexSwap.sol | 2 +- test/foundry/Bridge/BridgeCompression.t.sol | 8 +-- .../InfraOrchestrator.swap.t.sol | 56 +++++++++---------- 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/contracts/DexSwap.sol b/contracts/DexSwap.sol index 8eb5eb49..0dc207fd 100644 --- a/contracts/DexSwap.sol +++ b/contracts/DexSwap.sol @@ -103,7 +103,7 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { } function _performSwap(IDexSwap.SwapData memory swapData) private { - if (swapData.dexData.length == 0) revert EmptyDexData(); + if (swapData.dexCallData.length == 0) revert EmptyDexData(); address routerAddress = swapData.dexRouter; if (!s_routerAllowed[routerAddress]) revert DexRouterNotAllowed(); @@ -113,10 +113,10 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { bool success; if (isFromNative) { - (success, ) = routerAddress.call{value: fromAmount}(swapData.dexData); + (success, ) = routerAddress.call{value: fromAmount}(swapData.dexCallData); } else { IERC20(swapData.fromToken).safeIncreaseAllowance(routerAddress, fromAmount); - (success, ) = routerAddress.call(swapData.dexData); + (success, ) = routerAddress.call(swapData.dexCallData); } if (!success) { diff --git a/contracts/Interfaces/IDexSwap.sol b/contracts/Interfaces/IDexSwap.sol index 662a8dab..2a88f9f4 100644 --- a/contracts/Interfaces/IDexSwap.sol +++ b/contracts/Interfaces/IDexSwap.sol @@ -9,7 +9,7 @@ interface IDexSwap { /// @param toToken address of the token to be received /// @param toAmount amount of token to be received /// @param toAmountMin minimum amount of token to be received - /// @param dexData encoded data for the DEX + /// @param dexCallData encoded data for the DEX struct SwapData { address dexRouter; address fromToken; diff --git a/test/foundry/Bridge/BridgeCompression.t.sol b/test/foundry/Bridge/BridgeCompression.t.sol index c0a664f3..7a379cc2 100644 --- a/test/foundry/Bridge/BridgeCompression.t.sol +++ b/test/foundry/Bridge/BridgeCompression.t.sol @@ -100,8 +100,8 @@ contract BridgeCompressionTest is BridgeBaseTest { "ToAmountMin mismatch" ); assertEq( - decompressedSwapData[i].dexData, - originalSwapData[i].dexData, + decompressedSwapData[i].dexCallData, + originalSwapData[i].dexCallData, "DexData mismatch" ); } @@ -212,7 +212,7 @@ contract BridgeCompressionTest is BridgeBaseTest { uint24 fee = 3000; uint160 sqrtPriceLimitX96 = 0; uint256 deadline = block.timestamp + 3600; - bytes memory dexData = abi.encode(routerAddress, fee, sqrtPriceLimitX96, deadline); + bytes memory dexCallData = abi.encode(routerAddress, fee, sqrtPriceLimitX96, deadline); IDexSwap.SwapData[] memory _dstSwapData = new IDexSwap.SwapData[](1); IDexSwap.SwapData memory singleSwap = IDexSwap.SwapData({ @@ -222,7 +222,7 @@ contract BridgeCompressionTest is BridgeBaseTest { toToken: DAI_AVALANCHE, toAmount: TO_AMOUNT, toAmountMin: USER_FUNDS / 3, - dexData: dexData + dexCallData: dexCallData }); _dstSwapData[0] = singleSwap; diff --git a/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol index e1115768..a72ae44d 100644 --- a/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol +++ b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol @@ -37,7 +37,7 @@ contract DexSwapTest is Test { // @notice swap data generated by rango bytes - memory dexData = hex"ac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000124b858183f00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000b1311dd0855e00000000000000000000000000000000000000000000000000000000000be200d1000000000000000000000000000000000000000000000000000000000000004242000000000000000000000000000000000000060001f4d9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca000064833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000104b858183f00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000b1311dd0855e00000000000000000000000000000000000000000000000000000000000be1dfbc000000000000000000000000000000000000000000000000000000000000002b42000000000000000000000000000000000000060001f4833589fcd6edb6e08f4c7c32d4f71b54bda0291300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + memory dexCallData = hex"ac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000124b858183f00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000b1311dd0855e00000000000000000000000000000000000000000000000000000000000be200d1000000000000000000000000000000000000000000000000000000000000004242000000000000000000000000000000000000060001f4d9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca000064833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000104b858183f00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000b1311dd0855e00000000000000000000000000000000000000000000000000000000000be1dfbc000000000000000000000000000000000000000000000000000000000000002b42000000000000000000000000000000000000060001f4833589fcd6edb6e08f4c7c32d4f71b54bda0291300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); swapData[0] = IDexSwap.SwapData({ @@ -47,7 +47,7 @@ contract DexSwapTest is Test { toToken: vm.envAddress("USDC_BASE"), toAmount: toAmount, toAmountMin: toAmountMin, - dexData: dexData + dexCallData: dexCallData }); _performSwapAndCheck(swapData, user); @@ -66,7 +66,7 @@ contract DexSwapTest is Test { // @notice swap data generated by rango bytes - memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124b858183f0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000005f2110600000000000000000000000000000000000000000000632dcd75cad78e795c630000000000000000000000000000000000000000000000000000000000000042833589fcd6edb6e08f4c7c32d4f71b54bda029130001f44200000000000000000000000000000000000006002710ac1bd2486aaf3b5c0fc3fd868558b082a531b2b400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + memory dexCallData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124b858183f0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000005f2110600000000000000000000000000000000000000000000632dcd75cad78e795c630000000000000000000000000000000000000000000000000000000000000042833589fcd6edb6e08f4c7c32d4f71b54bda029130001f44200000000000000000000000000000000000006002710ac1bd2486aaf3b5c0fc3fd868558b082a531b2b400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); swapData[0] = IDexSwap.SwapData({ @@ -76,7 +76,7 @@ contract DexSwapTest is Test { toToken: toToken, toAmount: toAmount, toAmountMin: toAmountMin, - dexData: dexData + dexCallData: dexCallData }); _performSwapAndCheck(swapData, user); @@ -95,7 +95,7 @@ contract DexSwapTest is Test { // @notice swap data generated by rango bytes - memory dexData = hex"ac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000124b858183f0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000005f2110600000000000000000000000000000000000000000000000000579308104e425c0000000000000000000000000000000000000000000000000000000000000042d9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca000064833589fcd6edb6e08f4c7c32d4f71b54bda029130001f4420000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004449404b7c00000000000000000000000000000000000000000000000000579308104e425c000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000000"; + memory dexCallData = hex"ac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000124b858183f0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000005f2110600000000000000000000000000000000000000000000000000579308104e425c0000000000000000000000000000000000000000000000000000000000000042d9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca000064833589fcd6edb6e08f4c7c32d4f71b54bda029130001f4420000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004449404b7c00000000000000000000000000000000000000000000000000579308104e425c000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000000"; IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); swapData[0] = IDexSwap.SwapData({ @@ -105,7 +105,7 @@ contract DexSwapTest is Test { toToken: toToken, toAmount: toAmount, toAmountMin: toAmountMin, - dexData: dexData + dexCallData: dexCallData }); _performSwapAndCheck(swapData, user); @@ -124,7 +124,7 @@ contract DexSwapTest is Test { // @notice swap data generated by rango bytes - memory dexData = hex"ac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000193d47a6c030000000000000000000000000000000000000000000000000000000005f21106000000000000000000000000000000000000000000000009072651fb27d286b3000000000000000000000000000000000000000000000000000000000000002b3c499c542cef5e3811e1192ce70d8cc03d5c33590001f40d500b1d8e8ef31e21c99d1db9a6444d3adf127000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004449404b7c000000000000000000000000000000000000000000000009072651fb27d286b3000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000000"; + memory dexCallData = hex"ac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000193d47a6c030000000000000000000000000000000000000000000000000000000005f21106000000000000000000000000000000000000000000000009072651fb27d286b3000000000000000000000000000000000000000000000000000000000000002b3c499c542cef5e3811e1192ce70d8cc03d5c33590001f40d500b1d8e8ef31e21c99d1db9a6444d3adf127000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004449404b7c000000000000000000000000000000000000000000000009072651fb27d286b3000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000000"; IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); swapData[0] = IDexSwap.SwapData({ @@ -134,7 +134,7 @@ contract DexSwapTest is Test { toToken: toToken, toAmount: toAmount, toAmountMin: toAmountMin, - dexData: dexData + dexCallData: dexCallData }); _performSwapAndCheck(swapData, user); @@ -153,7 +153,7 @@ contract DexSwapTest is Test { // @notice swap data generated by rango bytes - memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000193d476af910000000000000000000000000000000000000000000000000000000005f2110600000000000000000000000000000000000000000000000000581e5bf77dfd17000000000000000000000000000000000000000000000000000000000000002b3c499c542cef5e3811e1192ce70d8cc03d5c33590001f47ceb23fd6bc0add59e62ac25578270cff1b9f61900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + memory dexCallData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000193d476af910000000000000000000000000000000000000000000000000000000005f2110600000000000000000000000000000000000000000000000000581e5bf77dfd17000000000000000000000000000000000000000000000000000000000000002b3c499c542cef5e3811e1192ce70d8cc03d5c33590001f47ceb23fd6bc0add59e62ac25578270cff1b9f61900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); swapData[0] = IDexSwap.SwapData({ @@ -163,7 +163,7 @@ contract DexSwapTest is Test { toToken: toToken, toAmount: toAmount, toAmountMin: toAmountMin, - dexData: dexData + dexCallData: dexCallData }); _performSwapAndCheck(swapData, user); @@ -182,7 +182,7 @@ contract DexSwapTest is Test { // @notice swap data generated by rango bytes - memory dexData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000193d47dcd690000000000000000000000000000000000000000000000000162623ba10abc00000000000000000000000000000000000000000000000000000000000000e6f6000000000000000000000000000000000000000000000000000000000000002b0d500b1d8e8ef31e21c99d1db9a6444d3adf12700001f43c499c542cef5e3811e1192ce70d8cc03d5c335900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + memory dexCallData = hex"ac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000193d47dcd690000000000000000000000000000000000000000000000000162623ba10abc00000000000000000000000000000000000000000000000000000000000000e6f6000000000000000000000000000000000000000000000000000000000000002b0d500b1d8e8ef31e21c99d1db9a6444d3adf12700001f43c499c542cef5e3811e1192ce70d8cc03d5c335900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); swapData[0] = IDexSwap.SwapData({ @@ -192,7 +192,7 @@ contract DexSwapTest is Test { toToken: toToken, toAmount: toAmount, toAmountMin: toAmountMin, - dexData: dexData + dexCallData: dexCallData }); _performSwapAndCheck(swapData, user); @@ -213,7 +213,7 @@ contract DexSwapTest is Test { // @notice swap data generated by rango bytes - memory dexData = hex"38ed17390000000000000000000000000000000000000000000000000000000005f21106000000000000000000000000000000000000000000000000004b86e1fb9335ac00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000000676146d70000000000000000000000000000000000000000000000000000000000000002000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000004200000000000000000000000000000000000006"; + memory dexCallData = hex"38ed17390000000000000000000000000000000000000000000000000000000005f21106000000000000000000000000000000000000000000000000004b86e1fb9335ac00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000000676146d70000000000000000000000000000000000000000000000000000000000000002000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000004200000000000000000000000000000000000006"; IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); swapData[0] = IDexSwap.SwapData({ @@ -223,7 +223,7 @@ contract DexSwapTest is Test { toToken: toToken, toAmount: toAmount, toAmountMin: toAmountMin, - dexData: dexData + dexCallData: dexCallData }); _performSwapAndCheck(swapData, user); @@ -242,7 +242,7 @@ contract DexSwapTest is Test { // @notice swap data generated by rango bytes - memory dexData = hex"18cbafe50000000000000000000000000000000000000000000000000000000005f21106000000000000000000000000000000000000000000000000004d14388e5f131e00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000000676159260000000000000000000000000000000000000000000000000000000000000002000000000000000000000000d9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca0000000000000000000000004200000000000000000000000000000000000006"; + memory dexCallData = hex"18cbafe50000000000000000000000000000000000000000000000000000000005f21106000000000000000000000000000000000000000000000000004d14388e5f131e00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000000676159260000000000000000000000000000000000000000000000000000000000000002000000000000000000000000d9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca0000000000000000000000004200000000000000000000000000000000000006"; IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); swapData[0] = IDexSwap.SwapData({ @@ -252,7 +252,7 @@ contract DexSwapTest is Test { toToken: toToken, toAmount: toAmount, toAmountMin: toAmountMin, - dexData: dexData + dexCallData: dexCallData }); _performSwapAndCheck(swapData, user); @@ -273,7 +273,7 @@ contract DexSwapTest is Test { // @notice swap data generated by rango bytes - memory dexData = hex"38ed17390000000000000000000000000000000000000000000000000000000005f211060000000000000000000000000000000000000000000000000056f813e5ffd0f000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E00000000000000000000000000000000000000000000000000000000006761666500000000000000000000000000000000000000000000000000000000000000020000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c33590000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f619"; + memory dexCallData = hex"38ed17390000000000000000000000000000000000000000000000000000000005f211060000000000000000000000000000000000000000000000000056f813e5ffd0f000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E00000000000000000000000000000000000000000000000000000000006761666500000000000000000000000000000000000000000000000000000000000000020000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c33590000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f619"; IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); swapData[0] = IDexSwap.SwapData({ @@ -283,7 +283,7 @@ contract DexSwapTest is Test { toToken: toToken, toAmount: toAmount, toAmountMin: toAmountMin, - dexData: dexData + dexCallData: dexCallData }); _performSwapAndCheck(swapData, user); @@ -302,7 +302,7 @@ contract DexSwapTest is Test { // @notice swap data generated by rango bytes - memory dexData = hex"18cbafe50000000000000000000000000000000000000000000000000000000005f21106000000000000000000000000000000000000000000000008e321f59524e8a1a400000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000000676167e200000000000000000000000000000000000000000000000000000000000000030000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c33590000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf1270"; + memory dexCallData = hex"18cbafe50000000000000000000000000000000000000000000000000000000005f21106000000000000000000000000000000000000000000000008e321f59524e8a1a400000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000000676167e200000000000000000000000000000000000000000000000000000000000000030000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c33590000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf1270"; IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); swapData[0] = IDexSwap.SwapData({ @@ -312,7 +312,7 @@ contract DexSwapTest is Test { toToken: toToken, toAmount: toAmount, toAmountMin: toAmountMin, - dexData: dexData + dexCallData: dexCallData }); _performSwapAndCheck(swapData, user); @@ -331,7 +331,7 @@ contract DexSwapTest is Test { // @notice swap data generated by rango bytes - memory dexData = hex"7ff36ab5000000000000000000000000000000000000000000000000000000000000e78c0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E00000000000000000000000000000000000000000000000000000000006761687b00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf12700000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c3359"; + memory dexCallData = hex"7ff36ab5000000000000000000000000000000000000000000000000000000000000e78c0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E00000000000000000000000000000000000000000000000000000000006761687b00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf12700000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c3359"; IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); swapData[0] = IDexSwap.SwapData({ @@ -341,7 +341,7 @@ contract DexSwapTest is Test { toToken: toToken, toAmount: toAmount, toAmountMin: toAmountMin, - dexData: dexData + dexCallData: dexCallData }); _performSwapAndCheck(swapData, user); @@ -361,7 +361,7 @@ contract DexSwapTest is Test { // @notice swap data generated by rango bytes - memory dexData = hex"38ed173900000000000000000000000000000000000000000000000000000000009834e7000000000000000000000000000000000000000000000000878f5782fa71c3b100000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E000000000000000000000000000000000000000000000000000000000067616a420000000000000000000000000000000000000000000000000000000000000004000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000004200000000000000000000000000000000000006000000000000000000000000d9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca00000000000000000000000050c5725949a6f0c72e6c4a641f24049a917db0cb"; + memory dexCallData = hex"38ed173900000000000000000000000000000000000000000000000000000000009834e7000000000000000000000000000000000000000000000000878f5782fa71c3b100000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E000000000000000000000000000000000000000000000000000000000067616a420000000000000000000000000000000000000000000000000000000000000004000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000004200000000000000000000000000000000000006000000000000000000000000d9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca00000000000000000000000050c5725949a6f0c72e6c4a641f24049a917db0cb"; IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); swapData[0] = IDexSwap.SwapData({ @@ -371,7 +371,7 @@ contract DexSwapTest is Test { toToken: toToken, toAmount: toAmount, toAmountMin: toAmountMin, - dexData: dexData + dexCallData: dexCallData }); _performSwapAndCheck(swapData, user); @@ -390,7 +390,7 @@ contract DexSwapTest is Test { // @notice swap data generated by rango bytes - memory dexData = hex"18cbafe500000000000000000000000000000000000000000000000000000000009834e70000000000000000000000000000000000000000000000000008b7e28139322800000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E000000000000000000000000000000000000000000000000000000000067616b160000000000000000000000000000000000000000000000000000000000000002000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000004200000000000000000000000000000000000006"; + memory dexCallData = hex"18cbafe500000000000000000000000000000000000000000000000000000000009834e70000000000000000000000000000000000000000000000000008b7e28139322800000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E000000000000000000000000000000000000000000000000000000000067616b160000000000000000000000000000000000000000000000000000000000000002000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000004200000000000000000000000000000000000006"; IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); swapData[0] = IDexSwap.SwapData({ @@ -400,7 +400,7 @@ contract DexSwapTest is Test { toToken: toToken, toAmount: toAmount, toAmountMin: toAmountMin, - dexData: dexData + dexCallData: dexCallData }); _performSwapAndCheck(swapData, user); @@ -419,7 +419,7 @@ contract DexSwapTest is Test { // @notice swap data generated by rango bytes - memory dexData = hex"7ff36ab5000000000000000000000000000000000000000000000000000000001272860c0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E000000000000000000000000000000000000000000000000000000000067616bd700000000000000000000000000000000000000000000000000000000000000020000000000000000000000004200000000000000000000000000000000000006000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913"; + memory dexCallData = hex"7ff36ab5000000000000000000000000000000000000000000000000000000001272860c0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E000000000000000000000000000000000000000000000000000000000067616bd700000000000000000000000000000000000000000000000000000000000000020000000000000000000000004200000000000000000000000000000000000006000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913"; IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); swapData[0] = IDexSwap.SwapData({ @@ -429,7 +429,7 @@ contract DexSwapTest is Test { toToken: toToken, toAmount: toAmount, toAmountMin: toAmountMin, - dexData: dexData + dexCallData: dexCallData }); _performSwapAndCheck(swapData, user); From 338da275981a49ac3ef4f1c4634f94c687ca906d Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Wed, 25 Dec 2024 14:20:28 +0300 Subject: [PATCH 41/54] add tokens --- .env.tokens | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.env.tokens b/.env.tokens index e0b385e1..d0e41481 100644 --- a/.env.tokens +++ b/.env.tokens @@ -43,6 +43,10 @@ USDT_ARBITRUM=0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9 WETH_BASE=0x4200000000000000000000000000000000000006 WETH_ARBITRUM=0x82aF49447D8a07e3bd95BD0d56f35241523fBab1 WETH_POLYGON=0x7ceb23fd6bc0add59e62ac25578270cff1b9f619 +WETH_OPTIMISM=0x4200000000000000000000000000000000000006 + +# WPOL/WMATIC MAINNET +WPOL_POLYGON=0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270 # WAVAX MAINNET WAVAX_AVALANCHE=0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7 From f929cfb89d7c3e172a5254da9dc749a2faa4da29 Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Wed, 25 Dec 2024 14:20:52 +0300 Subject: [PATCH 42/54] add wrapped to whitelist --- test/foundry/utils/DeployHelper.sol | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/test/foundry/utils/DeployHelper.sol b/test/foundry/utils/DeployHelper.sol index 36aa169b..82f6c7f3 100644 --- a/test/foundry/utils/DeployHelper.sol +++ b/test/foundry/utils/DeployHelper.sol @@ -151,29 +151,40 @@ contract DeployHelper is Script { uint256 chainId = block.chainid; if (chainId == vm.envUint("BASE_CHAIN_ID")) { - address[] memory routers = new address[](3); + address[] memory routers = new address[](4); routers[0] = vm.envAddress("UNISWAP_ROUTER_BASE"); routers[1] = vm.envAddress("SUSHISWAP_ROUTER_BASE"); routers[2] = vm.envAddress("ALIENBASE_ROUTER_BASE"); + routers[3] = vm.envAddress("WETH_BASE"); return routers; } if (chainId == vm.envUint("POLYGON_CHAIN_ID")) { - address[] memory routers = new address[](2); + address[] memory routers = new address[](3); routers[0] = vm.envAddress("QUICKSWAP_ROUTER_POLYGON"); routers[1] = vm.envAddress("UNISWAP_ROUTER_POLYGON"); + routers[2] = vm.envAddress("WPOL_POLYGON"); return routers; } if (chainId == vm.envUint("AVALANCHE_CHAIN_ID")) { - address[] memory routers = new address[](1); + address[] memory routers = new address[](2); routers[0] = vm.envAddress("PARASWAP_ROUTER_AVALANCHE"); + routers[1] = vm.envAddress("WAVAX_AVALANCHE"); return routers; } - if (chainId == vm.envUint("OPTIMISM_CHAIN_ID")) { - address[] memory routers = new address[](1); + if (chainId == vm.envUint("ARBITRUM_CHAIN_ID")) { + address[] memory routers = new address[](2); + routers[0] = vm.envAddress("UNISWAP_ROUTER_ARBITRUM"); + routers[1] = vm.envAddress("WETH_ARBITRUM"); + return routers; + } + + if (chainId == vm.envUint("OPTIMISM_CHAIN_ID")) { + address[] memory routers = new address[](2); routers[0] = vm.envAddress("ODOS_ROUTER_OPTIMISM"); + routers[1] = vm.envAddress("WETH_OPTIMISM"); return routers; } From bf187495fdcb720097e6abb24e48a7449980e23e Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Wed, 25 Dec 2024 14:21:10 +0300 Subject: [PATCH 43/54] add new tests for native and wrapped --- .../InfraOrchestrator.swap.t.sol | 292 ++++++++++++++++++ 1 file changed, 292 insertions(+) diff --git a/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol index a72ae44d..7aacde8f 100644 --- a/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol +++ b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol @@ -198,6 +198,298 @@ contract DexSwapTest is Test { _performSwapAndCheck(swapData, user); } + // @dev Arbitrum + + function testFork_UniV3NativeToWethArbitrumViaRangoRouting() + public + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("ARB_RPC_URL"), 288423660)) + { + uint256 fromAmount = 0.001 ether; + uint256 toAmount = 0.0009975015e18; + uint256 toAmountMin = 0.0009925139925e18; + address fromToken = NATIVE_TOKEN; + address toToken = vm.envAddress("WETH_ARBITRUM"); //WETH + address user = makeAddr("user"); + + // @notice swap data generated by rango + bytes memory dexCallData = hex"d0e30db0"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: vm.envAddress("WETH_ARBITRUM"), + fromToken: fromToken, + fromAmount: fromAmount, + toToken: toToken, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexCallData: dexCallData + }); + + _performSwapAndCheck(swapData, user); + } + + function testFork_UniV3WethToNativeArbitrumViaRangoRouting() + public + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("ARB_RPC_URL"), 288423660)) + { + uint256 fromAmount = 0.001e18; + uint256 toAmount = 0.0009975015 ether; + uint256 toAmountMin = 0.0009925139925 ether; + address fromToken = vm.envAddress("WETH_ARBITRUM"); + address toToken = NATIVE_TOKEN; + address user = makeAddr("user"); + + // @notice swap data generated by rango + bytes + memory dexCallData = hex"2e1a7d4d00000000000000000000000000000000000000000000000000038b38ea920700"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: vm.envAddress("WETH_ARBITRUM"), + fromToken: fromToken, + fromAmount: fromAmount, + toToken: toToken, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexCallData: dexCallData + }); + + _performSwapAndCheck(swapData, user); + } + + // @dev Base + + function testFork_UniV3NativeToWethBaseViaRangoRouting() + public + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("BASE_RPC_URL"), 24166717)) + { + uint256 fromAmount = 0.001 ether; + uint256 toAmount = 0.0009975015e18; + uint256 toAmountMin = 0.0009925139925e18; + address fromToken = NATIVE_TOKEN; + address toToken = vm.envAddress("WETH_BASE"); //WETH + address user = makeAddr("user"); + + // @notice swap data generated by rango + bytes memory dexCallData = hex"d0e30db0"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: vm.envAddress("WETH_BASE"), + fromToken: fromToken, + fromAmount: fromAmount, + toToken: toToken, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexCallData: dexCallData + }); + + _performSwapAndCheck(swapData, user); + } + + function testFork_UniV3WethToNativeBaseViaRangoRouting() + public + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("BASE_RPC_URL"), 24166717)) + { + uint256 fromAmount = 0.001e18; + uint256 toAmount = 0.0009975015 ether; + uint256 toAmountMin = 0.0009925139925 ether; + address fromToken = vm.envAddress("WETH_BASE"); + address toToken = NATIVE_TOKEN; + address user = makeAddr("user"); + + // @notice swap data generated by rango + bytes + memory dexCallData = hex"2e1a7d4d00000000000000000000000000000000000000000000000000038b38ea920700"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: vm.envAddress("WETH_BASE"), + fromToken: fromToken, + fromAmount: fromAmount, + toToken: toToken, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexCallData: dexCallData + }); + + _performSwapAndCheck(swapData, user); + } + + // @dev Avalanche + function testFork_UniV3NativeToWavaxAvalancheViaRangoRouting() + public + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("AVALANCHE_RPC_URL"), 54859236)) + { + uint256 fromAmount = 0.001 ether; + uint256 toAmount = 0.0009975015e18; + uint256 toAmountMin = 0.0009925139925e18; + address fromToken = NATIVE_TOKEN; + address toToken = vm.envAddress("WAVAX_AVALANCHE"); + address user = makeAddr("user"); + + // @notice swap data generated by rango + bytes memory dexCallData = hex"d0e30db0"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: vm.envAddress("WAVAX_AVALANCHE"), + fromToken: fromToken, + fromAmount: fromAmount, + toToken: toToken, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexCallData: dexCallData + }); + + _performSwapAndCheck(swapData, user); + } + + function testFork_UniV3WavaxToNativeAvalancheViaRangoRouting() + public + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("AVALANCHE_RPC_URL"), 54859236)) + { + uint256 fromAmount = 0.001e18; + uint256 toAmount = 0.0009975015 ether; + uint256 toAmountMin = 0.0009925139925 ether; + address fromToken = vm.envAddress("WAVAX_AVALANCHE"); + address toToken = NATIVE_TOKEN; + address user = makeAddr("user"); + + // @notice swap data generated by rango + bytes + memory dexCallData = hex"2e1a7d4d00000000000000000000000000000000000000000000000000038b38ea920700"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: vm.envAddress("WAVAX_AVALANCHE"), + fromToken: fromToken, + fromAmount: fromAmount, + toToken: toToken, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexCallData: dexCallData + }); + + _performSwapAndCheck(swapData, user); + } + + // @dev Optimism + function testFork_UniV3NativeToWethOptimismViaRangoRouting() + public + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("OPTIMISM_RPC_URL"), 129762995)) + { + uint256 fromAmount = 0.001 ether; + uint256 toAmount = 0.0009975015e18; + uint256 toAmountMin = 0.0009925139925e18; + address fromToken = NATIVE_TOKEN; + address toToken = vm.envAddress("WETH_OPTIMISM"); + address user = makeAddr("user"); + + // @notice swap data generated by rango + bytes memory dexCallData = hex"d0e30db0"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: vm.envAddress("WETH_OPTIMISM"), + fromToken: fromToken, + fromAmount: fromAmount, + toToken: toToken, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexCallData: dexCallData + }); + + _performSwapAndCheck(swapData, user); + } + + function testFork_UniV3WethToNativeOptimismViaRangoRouting() + public + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("OPTIMISM_RPC_URL"), 129762995)) + { + uint256 fromAmount = 0.001e18; + uint256 toAmount = 0.0009975015 ether; + uint256 toAmountMin = 0.0009925139925 ether; + address fromToken = vm.envAddress("WETH_OPTIMISM"); + address toToken = NATIVE_TOKEN; + address user = makeAddr("user"); + + // @notice swap data generated by rango + bytes + memory dexCallData = hex"2e1a7d4d00000000000000000000000000000000000000000000000000038b38ea920700"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: vm.envAddress("WETH_OPTIMISM"), + fromToken: fromToken, + fromAmount: fromAmount, + toToken: toToken, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexCallData: dexCallData + }); + + _performSwapAndCheck(swapData, user); + } + + // @dev Polygon + function testFork_UniV3NativeToWpolPolygonViaRangoRouting() + public + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("POLYGON_RPC_URL"), 65906603)) + { + uint256 fromAmount = 0.001 ether; + uint256 toAmount = 0.0009975015e18; + uint256 toAmountMin = 0.0009925139925e18; + address fromToken = NATIVE_TOKEN; + address toToken = vm.envAddress("WPOL_POLYGON"); + address user = makeAddr("user"); + + // @notice swap data generated by rango + bytes memory dexCallData = hex"d0e30db0"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: vm.envAddress("WPOL_POLYGON"), + fromToken: fromToken, + fromAmount: fromAmount, + toToken: toToken, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexCallData: dexCallData + }); + + _performSwapAndCheck(swapData, user); + } + + function testFork_UniV3WpolToNativePolygonViaRangoRouting() + public + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("POLYGON_RPC_URL"), 65906603)) + { + uint256 fromAmount = 0.001e18; + uint256 toAmount = 0.0009975015 ether; + uint256 toAmountMin = 0.0009925139925 ether; + address fromToken = vm.envAddress("WPOL_POLYGON"); + address toToken = NATIVE_TOKEN; + address user = makeAddr("user"); + + // @notice swap data generated by rango + bytes + memory dexCallData = hex"2e1a7d4d00000000000000000000000000000000000000000000000000038b38ea920700"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: vm.envAddress("WPOL_POLYGON"), + fromToken: fromToken, + fromAmount: fromAmount, + toToken: toToken, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexCallData: dexCallData + }); + + _performSwapAndCheck(swapData, user); + } + // @dev SUSHI SWAP function testFork_SushiSwapErc20ToErc20BaseViaRangoRouting() From 7fc08cb07d949fd52505698ea49d9fe02b15e758 Mon Sep 17 00:00:00 2001 From: lufaque <95128636+lufaque@users.noreply.github.com> Date: Wed, 25 Dec 2024 14:36:28 +0300 Subject: [PATCH 44/54] update deploy dex swap script --- tasks/concero/deployInfra/setContractVariables.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tasks/concero/deployInfra/setContractVariables.ts b/tasks/concero/deployInfra/setContractVariables.ts index 038d3743..5721f9f4 100644 --- a/tasks/concero/deployInfra/setContractVariables.ts +++ b/tasks/concero/deployInfra/setContractVariables.ts @@ -269,7 +269,7 @@ export async function setDonSecretsSlotId(deployableChain: CNetwork, slotId: num } const allowedRoutersByChain: Record, Array
> = { - arbitrum: [getEnvVar("SUSHISWAP_ROUTER_ARBITRUM"), getEnvVar("UNISWAP_ROUTER_ARBITRUM")], + arbitrum: [getEnvVar("SUSHISWAP_ROUTER_ARBITRUM"), getEnvVar("UNISWAP_ROUTER_ARBITRUM"), getEnvVar("WETH_ARBITRUM")], }; export async function setDexSwapAllowedRouters(deployableChain: CNetwork, abi: any) { @@ -279,7 +279,6 @@ export async function setDexSwapAllowedRouters(deployableChain: CNetwork, abi: a const allowedRouters = allowedRoutersByChain[dcName]; for (const allowedRouter of allowedRouters) { - console.log(allowedRouter); try { const { request: setDexRouterReq } = await publicClient.simulateContract({ address: conceroProxy, From 14a17d86f4bb15a34a3344947a7ae369aacabfe8 Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Thu, 26 Dec 2024 15:57:09 +0300 Subject: [PATCH 45/54] add pangolin --- test/foundry/utils/DeployHelper.sol | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/foundry/utils/DeployHelper.sol b/test/foundry/utils/DeployHelper.sol index 82f6c7f3..c1826529 100644 --- a/test/foundry/utils/DeployHelper.sol +++ b/test/foundry/utils/DeployHelper.sol @@ -168,9 +168,10 @@ contract DeployHelper is Script { } if (chainId == vm.envUint("AVALANCHE_CHAIN_ID")) { - address[] memory routers = new address[](2); + address[] memory routers = new address[](3); routers[0] = vm.envAddress("PARASWAP_ROUTER_AVALANCHE"); routers[1] = vm.envAddress("WAVAX_AVALANCHE"); + routers[2] = vm.envAddress("PANGOLIN_ROUTER_AVALANCHE"); return routers; } From 598bc34d2c7c18d4200b687cd909b5091e78af21 Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Thu, 26 Dec 2024 15:57:20 +0300 Subject: [PATCH 46/54] add tests for pangolin avalanche --- .../InfraOrchestrator.swap.t.sol | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol index 7aacde8f..3fb11cae 100644 --- a/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol +++ b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol @@ -727,6 +727,94 @@ contract DexSwapTest is Test { _performSwapAndCheck(swapData, user); } + // @dev Pangolin + function testFork_PangolinErc20ToNativeAvalancheViaRangoRouting() + public + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("AVALANCHE_RPC_URL"), 54906077)) + { + uint256 fromAmount = 1e6; + uint256 toAmount = 0.026255826793978565e18; + uint256 toAmountMin = 0.026124547660008672e18; + address fromToken = vm.envAddress("USDC_AVALANCHE"); + address toToken = NATIVE_TOKEN; + address user = makeAddr("user"); + + // @notice swap data generated by rango + bytes + memory dexCallData = hex"676528d100000000000000000000000000000000000000000000000000000000000f387e000000000000000000000000000000000000000000000000005cd1d609d19d3400000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000000676d55970000000000000000000000000000000000000000000000000000000000000002000000000000000000000000b97ef9ef8734c71904d8002f8b6bc66dd9c48a6e000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c7"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: vm.envAddress("PANGOLIN_ROUTER_AVALANCHE"), + fromToken: fromToken, + fromAmount: fromAmount, + toToken: toToken, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexCallData: dexCallData + }); + + _performSwapAndCheck(swapData, user); + } + + function testFork_PangolinNativeToErc20AvalancheViaRangoRouting() + public + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("AVALANCHE_RPC_URL"), 54906077)) + { + uint256 fromAmount = 0.001 ether; + uint256 toAmount = 0.037704e6; + uint256 toAmountMin = 0.037515e6; + address fromToken = NATIVE_TOKEN; + address toToken = vm.envAddress("USDC_AVALANCHE"); + address user = makeAddr("user"); + + // @notice swap data generated by rango + bytes + memory dexCallData = hex"a2a1623d000000000000000000000000000000000000000000000000000000000000928b0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000000676d55ed0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c7000000000000000000000000b97ef9ef8734c71904d8002f8b6bc66dd9c48a6e"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: vm.envAddress("PANGOLIN_ROUTER_AVALANCHE"), + fromToken: fromToken, + fromAmount: fromAmount, + toToken: toToken, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexCallData: dexCallData + }); + + _performSwapAndCheck(swapData, user); + } + + function testFork_PangolinErc20ToErc20AvalancheViaRangoRouting() + public + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("AVALANCHE_RPC_URL"), 54906077)) + { + uint256 fromAmount = 0.001e18; + uint256 toAmount = 0.037704e6; + uint256 toAmountMin = 0.037515e6; + address fromToken = vm.envAddress("WAVAX_AVALANCHE"); + address toToken = vm.envAddress("USDC_AVALANCHE"); + address user = makeAddr("user"); + + // @notice swap data generated by rango + bytes + memory dexCallData = hex"38ed173900000000000000000000000000000000000000000000000000038b38ea920700000000000000000000000000000000000000000000000000000000000000928b00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000104fBc016F4bb334D775a19E8A6510109AC63E0000000000000000000000000000000000000000000000000000000000676d565f0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c7000000000000000000000000b97ef9ef8734c71904d8002f8b6bc66dd9c48a6e"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: vm.envAddress("PANGOLIN_ROUTER_AVALANCHE"), + fromToken: fromToken, + fromAmount: fromAmount, + toToken: toToken, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexCallData: dexCallData + }); + + _performSwapAndCheck(swapData, user); + } + function _performSwapAndCheck(IDexSwap.SwapData[] memory swapData, address recipient) internal { address fromToken = swapData[0].fromToken; address toToken = swapData[swapData.length - 1].toToken; From 69f323d5d872b2fd363a97c677e39fe97ced3783 Mon Sep 17 00:00:00 2001 From: Aleksei Gerasev Date: Thu, 26 Dec 2024 15:57:24 +0300 Subject: [PATCH 47/54] rename --- .env.clccip | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.clccip b/.env.clccip index 089dc934..8518547a 100644 --- a/.env.clccip +++ b/.env.clccip @@ -65,4 +65,4 @@ ALIENBASE_ROUTER_BASE=0x8c1A3cF8f83074169FE5D7aD50B978e1cD6b37c7 CURVE_ROUTER_BASE=0xd6681e74eEA20d196c15038C580f721EF2aB6320 # PANGOLIN -PANGOLIN_ROUTER_AVALANCHE_ADDRESS=0xE54Ca86531e17Ef3616d22Ca28b0D458b6C89106 +PANGOLIN_ROUTER_AVALANCHE=0xE54Ca86531e17Ef3616d22Ca28b0D458b6C89106 From e94a7a5864a876d1f659ff7ad9556e335f8cf4c1 Mon Sep 17 00:00:00 2001 From: lufaque <95128636+lufaque@users.noreply.github.com> Date: Tue, 31 Dec 2024 18:15:51 +0300 Subject: [PATCH 48/54] rename --- contracts/InfraOrchestrator.sol | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contracts/InfraOrchestrator.sol b/contracts/InfraOrchestrator.sol index 0cfd395b..b45bd75d 100644 --- a/contracts/InfraOrchestrator.sol +++ b/contracts/InfraOrchestrator.sol @@ -145,7 +145,7 @@ contract InfraOrchestrator is revert InvalidSwapData(); } - _obtainSwapDataFromToken(srcSwapData); + _transferTokenFromUser(srcSwapData); uint256 amountReceivedFromSwap = _swap(srcSwapData, address(this)); bridgeData.amount = @@ -166,7 +166,7 @@ contract InfraOrchestrator is address receiver, Integration memory integration ) external payable validateSrcSwapData(swapData) nonReentrant { - _obtainSwapDataFromToken(swapData); + _transferTokenFromUser(swapData); swapData = _collectSwapFee(swapData, integration); _swap(swapData, receiver); } @@ -190,7 +190,7 @@ contract InfraOrchestrator is /** * @notice Wrapper function to delegate call to ConceroBridge.addUnconfirmedTX - * @param conceroMessageId the Concerro message ID + * @param conceroMessageId the Concero message ID * @param srcChainSelector the source chain selector * @param txDataHash the transaction data hash */ @@ -340,7 +340,7 @@ contract InfraOrchestrator is } /* INTERNAL FUNCTIONS */ - function _obtainSwapDataFromToken(IDexSwap.SwapData[] memory swapData) internal { + function _transferTokenFromUser(IDexSwap.SwapData[] memory swapData) internal { address initialToken = swapData[0].fromToken; uint256 initialAmount = swapData[0].fromAmount; From c491437ae6a0e650d7cb44ec6a73344d9a21ffe9 Mon Sep 17 00:00:00 2001 From: lufaque <95128636+lufaque@users.noreply.github.com> Date: Sun, 12 Jan 2025 15:01:05 +0300 Subject: [PATCH 49/54] add sushi swap routing --- .env.clccip | 4 ++- package.json | 2 +- .../deployInfra/setContractVariables.ts | 7 ++++- .../InfraOrchestrator.swap.t.sol | 31 +++++++++++++++++++ test/foundry/utils/DeployHelper.sol | 3 +- 5 files changed, 43 insertions(+), 4 deletions(-) diff --git a/.env.clccip b/.env.clccip index 8518547a..a4f007ad 100644 --- a/.env.clccip +++ b/.env.clccip @@ -47,9 +47,11 @@ UNISWAP_ROUTER_ARBITRUM=0xE592427A0AEce92De3Edee1F18E0157C05861564 UNISWAP_ROUTER_AVALANCHE=0xbb00FF08d01D300023C629E8fFfFcb65A5a578cE UNI_V3_ROUTER02_BASE=0x2626664c2603336E57B271c5C0b26F421741e481 UNI_V3_ROUTER_ARBITRUM=0xE592427A0AEce92De3Edee1F18E0157C05861564 +UNI_02_ROUTER_ARBITRUM=0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45 # SUSHISWAP ROUTERS -SUSHISWAP_ROUTER_ARBITRUM=0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506 +#SUSHISWAP_ROUTER_ARBITRUM=0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506 +SUSHISWAP_ROUTER_ARBITRUM=0xf2614A233c7C3e7f08b1F887Ba133a13f1eb2c55 SUSHISWAP_ROUTER_BASE=0x6BDED42c6DA8FBf0d2bA55B2fa120C5e0c8D7891 # QUICKSWAP ROUTERS diff --git a/package.json b/package.json index fa994f88..bf6608bb 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "scripts": { "chain": "hardhat node --network hardhat --no-deploy", "fork": "MAINNET_FORKING_ENABLED=true hardhat node --network hardhat --no-deploy", - "compile": "yarn lint:sol && hardhat compile", + "compile": "hardhat compile", "deploy": "hardhat deploy", "test": "REPORT_GAS=true hardhat test --network hardhat", "lint:ts": "echo 'not working yet'", diff --git a/tasks/concero/deployInfra/setContractVariables.ts b/tasks/concero/deployInfra/setContractVariables.ts index 5721f9f4..b2edc2aa 100644 --- a/tasks/concero/deployInfra/setContractVariables.ts +++ b/tasks/concero/deployInfra/setContractVariables.ts @@ -269,7 +269,12 @@ export async function setDonSecretsSlotId(deployableChain: CNetwork, slotId: num } const allowedRoutersByChain: Record, Array
> = { - arbitrum: [getEnvVar("SUSHISWAP_ROUTER_ARBITRUM"), getEnvVar("UNISWAP_ROUTER_ARBITRUM"), getEnvVar("WETH_ARBITRUM")], + arbitrum: [ + getEnvVar("SUSHISWAP_ROUTER_ARBITRUM"), + // getEnvVar("UNISWAP_ROUTER_ARBITRUM"), + // getEnvVar("WETH_ARBITRUM"), + // getEnvVar("UNI_02_ROUTER_ARBITRUM"), + ] as Array
, }; export async function setDexSwapAllowedRouters(deployableChain: CNetwork, abi: any) { diff --git a/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol index 3fb11cae..82fdc50e 100644 --- a/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol +++ b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol @@ -815,6 +815,37 @@ contract DexSwapTest is Test { _performSwapAndCheck(swapData, user); } + function testFork_SushiSwapErc20ToErc20ViaSushiSwapApiRouting() + public + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("ARBITRUM_RPC_URL"), 294413780)) + { + uint256 fromAmount = 3e6; + uint256 toAmount = 3001520; + uint256 toAmountMin = 3001520; + address fromToken = 0xaf88d065e77c8cC2239327C5EDb3A432268e5831; + address toToken = 0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9; + address user = makeAddr("user"); + + // @notice swap data generated by sushiswap api + bytes + memory dexCallData = hex"2646478b000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000002dc6c0000000000000000000000000fd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb900000000000000000000000000000000000000000000000000000000002b827400000000000000000000000073da61408cf3b9ede79004950fa5b149021c18d800000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000004202af88d065e77c8cC2239327C5EDb3A432268e583101ffff01bE3aD6a5669Dc0B8b12FeBC03608860C31E2eef60173DA61408Cf3B9edE79004950Fa5b149021c18d8000000000000000000000000000000000000000000000000000000000000"; + + IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); + swapData[0] = IDexSwap.SwapData({ + dexRouter: vm.envAddress("SUSHISWAP_ROUTER_ARBITRUM"), + fromToken: fromToken, + fromAmount: fromAmount, + toToken: toToken, + toAmount: toAmount, + toAmountMin: toAmountMin, + dexCallData: dexCallData + }); + + _performSwapAndCheck(swapData, user); + } + + /* HELPERS */ + function _performSwapAndCheck(IDexSwap.SwapData[] memory swapData, address recipient) internal { address fromToken = swapData[0].fromToken; address toToken = swapData[swapData.length - 1].toToken; diff --git a/test/foundry/utils/DeployHelper.sol b/test/foundry/utils/DeployHelper.sol index c1826529..f5fa2731 100644 --- a/test/foundry/utils/DeployHelper.sol +++ b/test/foundry/utils/DeployHelper.sol @@ -176,9 +176,10 @@ contract DeployHelper is Script { } if (chainId == vm.envUint("ARBITRUM_CHAIN_ID")) { - address[] memory routers = new address[](2); + address[] memory routers = new address[](3); routers[0] = vm.envAddress("UNISWAP_ROUTER_ARBITRUM"); routers[1] = vm.envAddress("WETH_ARBITRUM"); + routers[2] = vm.envAddress("SUSHISWAP_ROUTER_ARBITRUM"); return routers; } From 9bd633afdf548ed0ab54a54eeddf1c498cdd2e35 Mon Sep 17 00:00:00 2001 From: lufaque <95128636+lufaque@users.noreply.github.com> Date: Mon, 13 Jan 2025 18:02:18 +0300 Subject: [PATCH 50/54] review fixes --- contracts/DexSwap.sol | 26 +- contracts/InfraCommon.sol | 1 + contracts/InfraOrchestrator.sol | 24 +- package.json | 2 +- yarn.lock | 608 +++++++++++++++++++------------- 5 files changed, 398 insertions(+), 263 deletions(-) diff --git a/contracts/DexSwap.sol b/contracts/DexSwap.sol index 0dc207fd..cc488278 100644 --- a/contracts/DexSwap.sol +++ b/contracts/DexSwap.sol @@ -56,8 +56,9 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { if (address(this) != i_proxy) revert OnlyProxyContext(address(this)); uint256 swapDataLength = swapData.length; - address dstToken = swapData[swapDataLength - 1].toToken; - uint256 addressThisBalanceBefore = LibConcero.getBalance(dstToken, address(this)); + uint256 lastSwapStepIndex = swapDataLength - 1; + address dstToken = swapData[lastSwapStepIndex].toToken; + uint256 dstTokenProxyInitialBalance = LibConcero.getBalance(dstToken, address(this)); uint256 balanceAfter; for (uint256 i; i < swapDataLength; ++i) { @@ -72,7 +73,7 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { revert InsufficientAmount(tokenReceived); } - if (i < swapDataLength - 1) { + if (i < lastSwapStepIndex) { if (swapData[i].toToken != swapData[i + 1].fromToken) { revert InvalidTokenPath(); } @@ -81,11 +82,12 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { } } + // @dev check if swapDataLength is 0 and there were no swaps if (balanceAfter == 0) { revert InvalidDexData(); } - uint256 dstTokenReceived = balanceAfter - addressThisBalanceBefore; + uint256 dstTokenReceived = balanceAfter - dstTokenProxyInitialBalance; if (recipient != address(this)) { _transferTokenToUser(recipient, dstToken, dstTokenReceived); @@ -109,14 +111,14 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { if (!s_routerAllowed[routerAddress]) revert DexRouterNotAllowed(); uint256 fromAmount = swapData.fromAmount; - bool isFromNative = swapData.fromToken == address(0); + bool isFromNative = swapData.fromToken == ZERO_ADDRESS; bool success; - if (isFromNative) { - (success, ) = routerAddress.call{value: fromAmount}(swapData.dexCallData); - } else { + if (!isFromNative) { IERC20(swapData.fromToken).safeIncreaseAllowance(routerAddress, fromAmount); (success, ) = routerAddress.call(swapData.dexCallData); + } else { + (success, ) = routerAddress.call{value: fromAmount}(swapData.dexCallData); } if (!success) { @@ -125,17 +127,17 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { } function _transferTokenToUser(address recipient, address token, uint256 amount) internal { - if (amount == 0 || recipient == address(0)) { + if (amount == 0 || recipient == ZERO_ADDRESS) { revert InvalidDexData(); } - if (token == address(0)) { + if (token != ZERO_ADDRESS) { + IERC20(token).safeTransfer(recipient, amount); + } else { (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert TransferFailed(); } - } else { - IERC20(token).safeTransfer(recipient, amount); } } } diff --git a/contracts/InfraCommon.sol b/contracts/InfraCommon.sol index 62603c53..c0f7390f 100644 --- a/contracts/InfraCommon.sol +++ b/contracts/InfraCommon.sol @@ -19,6 +19,7 @@ contract InfraCommon { /* CONSTANT VARIABLES */ uint256 internal constant USDC_DECIMALS = 1_000_000; uint256 internal constant STANDARD_TOKEN_DECIMALS = 1 ether; + address internal constant ZERO_ADDRESS = address(0); /* IMMUTABLE VARIABLES */ address private immutable i_msgr0; diff --git a/contracts/InfraOrchestrator.sol b/contracts/InfraOrchestrator.sol index 4c3fbf5b..734c6449 100644 --- a/contracts/InfraOrchestrator.sol +++ b/contracts/InfraOrchestrator.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.20; -import {CHAIN_SELECTOR_ARBITRUM, CHAIN_SELECTOR_BASE, CHAIN_SELECTOR_OPTIMISM, CHAIN_SELECTOR_POLYGON, CHAIN_SELECTOR_AVALANCHE, CHAIN_SELECTOR_ETHEREUM, USDC_ARBITRUM, USDC_BASE, USDC_POLYGON, USDC_AVALANCHE, USDC_OPTIMISM, USDC_ETHEREUM} from "./Constants.sol"; +import {CHAIN_SELECTOR_ARBITRUM, CHAIN_SELECTOR_BASE, CHAIN_SELECTOR_OPTIMISM, CHAIN_SELECTOR_POLYGON, CHAIN_SELECTOR_AVALANCHE, CHAIN_SELECTOR_ETHEREUM} from "./Constants.sol"; import {InfraCommon} from "./InfraCommon.sol"; import {IConceroBridge} from "./Interfaces/IConceroBridge.sol"; import {IDexSwap} from "./Interfaces/IDexSwap.sol"; @@ -12,7 +12,6 @@ import {LibConcero} from "./Libraries/LibConcero.sol"; import {IFunctionsClient} from "@chainlink/contracts/src/v0.8/functions/v1_0_0/interfaces/IFunctionsClient.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; -import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; /* ERRORS */ ///@notice error emitted when the balance input is smaller than the specified amount param @@ -132,13 +131,13 @@ contract InfraOrchestrator is BridgeData memory bridgeData, IDexSwap.SwapData[] calldata srcSwapData, bytes memory compressedDstSwapData, - Integration memory integration + Integration calldata integration ) external payable + nonReentrant validateSrcSwapData(srcSwapData) validateBridgeData(bridgeData) - nonReentrant { address usdc = _getUSDCAddressByChainIndex(CCIPToken.usdc, i_chainIndex); @@ -165,8 +164,8 @@ contract InfraOrchestrator is function swap( IDexSwap.SwapData[] memory swapData, address receiver, - Integration memory integration - ) external payable validateSrcSwapData(swapData) nonReentrant { + Integration calldata integration + ) external payable nonReentrant validateSrcSwapData(swapData) { _transferTokenFromUser(swapData); swapData = _collectSwapFee(swapData, integration); _swap(swapData, receiver); @@ -180,8 +179,8 @@ contract InfraOrchestrator is function bridge( BridgeData memory bridgeData, bytes memory compressedDstSwapData, - Integration memory integration - ) external payable validateBridgeData(bridgeData) nonReentrant { + Integration calldata integration + ) external payable nonReentrant validateBridgeData(bridgeData) { address fromToken = _getUSDCAddressByChainIndex(CCIPToken.usdc, i_chainIndex); LibConcero.transferFromERC20(fromToken, msg.sender, address(this), bridgeData.amount); bridgeData.amount -= _collectIntegratorFee(fromToken, bridgeData.amount, integration); @@ -269,7 +268,7 @@ contract InfraOrchestrator is function withdrawConceroFees( address recipient, address[] calldata tokens - ) external payable onlyOwner nonReentrant { + ) external payable nonReentrant onlyOwner { if (recipient == address(0)) { revert InvalidRecipient(); } @@ -397,7 +396,7 @@ contract InfraOrchestrator is function _collectSwapFee( IDexSwap.SwapData[] memory swapData, - Integration memory integration + Integration calldata integration ) internal returns (IDexSwap.SwapData[] memory) { swapData[0].fromAmount -= (swapData[0].fromAmount / CONCERO_FEE_FACTOR); @@ -413,13 +412,12 @@ contract InfraOrchestrator is function _collectIntegratorFee( address token, uint256 amount, - Integration memory integration + Integration calldata integration ) internal returns (uint256) { - if (integration.integrator == address(0)) return 0; + if (integration.integrator == ZERO_ADDRESS || integration.feeBps == 0) return 0; if (integration.feeBps > MAX_INTEGRATOR_FEE_BPS) revert InvalidIntegratorFeeBps(); uint256 integratorFeeAmount = (amount * integration.feeBps) / BPS_DIVISOR; - if (integratorFeeAmount == 0) return 0; s_integratorFeesAmountByToken[integration.integrator][token] += integratorFeeAmount; s_totalIntegratorFeesAmountByToken[token] += integratorFeeAmount; diff --git a/package.json b/package.json index bf6608bb..fa994f88 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "scripts": { "chain": "hardhat node --network hardhat --no-deploy", "fork": "MAINNET_FORKING_ENABLED=true hardhat node --network hardhat --no-deploy", - "compile": "hardhat compile", + "compile": "yarn lint:sol && hardhat compile", "deploy": "hardhat deploy", "test": "REPORT_GAS=true hardhat test --network hardhat", "lint:ts": "echo 'not working yet'", diff --git a/yarn.lock b/yarn.lock index 5cce9c0a..525fb971 100644 --- a/yarn.lock +++ b/yarn.lock @@ -63,11 +63,11 @@ tslib "^1.11.1" "@aws-sdk/types@^3.1.0": - version "3.714.0" - resolved "https://registry.yarnpkg.com/@aws-sdk/types/-/types-3.714.0.tgz#de6afee1436d2d95364efa0663887f3bf0b1303a" - integrity sha512-ZjpP2gYbSFlxxaUDa1Il5AVvfggvUPbjzzB/l3q0gIE5Thd6xKW+yzEpt2mLZ5s5UaYSABZbF94g8NUOF4CVGA== + version "3.723.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/types/-/types-3.723.0.tgz#f0c5a6024a73470421c469b6c1dd5bc4b8fb851b" + integrity sha512-LmK3kwiMZG1y5g3LGihT9mNkeNOmwEyPk6HGcJqh0wOSV4QpWoKu2epyKE4MLQNUUlz2kOVbVbOrwmI6ZcteuA== dependencies: - "@smithy/types" "^3.7.2" + "@smithy/types" "^4.0.0" tslib "^2.6.2" "@aws-sdk/util-utf8-browser@^3.0.0": @@ -86,28 +86,28 @@ js-tokens "^4.0.0" picocolors "^1.0.0" -"@babel/compat-data@^7.22.6", "@babel/compat-data@^7.25.9": - version "7.26.3" - resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.26.3.tgz#99488264a56b2aded63983abd6a417f03b92ed02" - integrity sha512-nHIxvKPniQXpmQLb0vhY3VaFb3S0YrTAwpOWJZh1wn3oJPjJk9Asva204PsBdmAE8vpzfHudT8DB0scYvy9q0g== +"@babel/compat-data@^7.22.6", "@babel/compat-data@^7.26.5": + version "7.26.5" + resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.26.5.tgz#df93ac37f4417854130e21d72c66ff3d4b897fc7" + integrity sha512-XvcZi1KWf88RVbF9wn8MN6tYFloU5qX8KjuF3E1PVBmJ9eypXfs4GRiJwLuTZL0iSnJUKn1BFPa5BPZZJyFzPg== -"@babel/generator@^7.26.3": - version "7.26.3" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.26.3.tgz#ab8d4360544a425c90c248df7059881f4b2ce019" - integrity sha512-6FF/urZvD0sTeO7k6/B15pMLC4CHUv1426lzr3N01aHJTl046uCAh9LXW/fzeXXjPNCJ6iABW5XaWOsIZB93aQ== +"@babel/generator@^7.26.5": + version "7.26.5" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.26.5.tgz#e44d4ab3176bbcaf78a5725da5f1dc28802a9458" + integrity sha512-2caSP6fN9I7HOe6nqhtft7V4g7/V/gfDsC3Ag4W7kEzzvRGKqiv0pu0HogPiZ3KaVSoNDhUws6IJjDjpfmYIXw== dependencies: - "@babel/parser" "^7.26.3" - "@babel/types" "^7.26.3" + "@babel/parser" "^7.26.5" + "@babel/types" "^7.26.5" "@jridgewell/gen-mapping" "^0.3.5" "@jridgewell/trace-mapping" "^0.3.25" jsesc "^3.0.2" "@babel/helper-compilation-targets@^7.22.6": - version "7.25.9" - resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.25.9.tgz#55af025ce365be3cdc0c1c1e56c6af617ce88875" - integrity sha512-j9Db8Suy6yV/VHa4qzrj9yZfZxhLWQdVnRlXxmKLYlhWUVB1sB2G5sxuWYXk/whHD9iW76PmNzxZ4UCnTQTVEQ== + version "7.26.5" + resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.26.5.tgz#75d92bb8d8d51301c0d49e52a65c9a7fe94514d8" + integrity sha512-IXuyn5EkouFJscIDuFF5EsiSolseme1s0CZB+QxVugqJLYmKdxI1VfIBOst0SUu4rnk2Z7kqTwmoO1lp3HIfnA== dependencies: - "@babel/compat-data" "^7.25.9" + "@babel/compat-data" "^7.26.5" "@babel/helper-validator-option" "^7.25.9" browserslist "^4.24.0" lru-cache "^5.1.1" @@ -133,9 +133,9 @@ "@babel/types" "^7.25.9" "@babel/helper-plugin-utils@^7.22.5", "@babel/helper-plugin-utils@^7.25.9": - version "7.25.9" - resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.25.9.tgz#9cbdd63a9443a2c92a725cca7ebca12cc8dd9f46" - integrity sha512-kSMlyUVdWe25rEsRGviIgOWnoT/nfABVWlqt9N19/dIPWViAOW2s9wznP5tURbs/IDuNk4gPy3YdYRgH3uxhBw== + version "7.26.5" + resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.26.5.tgz#18580d00c9934117ad719392c4f6585c9333cc35" + integrity sha512-RS+jZcRdZdRFzMyr+wcsaqOmld1/EqTghfaBGQQd/WnRdzdlvSZ//kF7U8VQTxf1ynZ4cjUcYgjVGx13ewNPMg== "@babel/helper-string-parser@^7.25.9": version "7.25.9" @@ -152,12 +152,12 @@ resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.25.9.tgz#86e45bd8a49ab7e03f276577f96179653d41da72" integrity sha512-e/zv1co8pp55dNdEcCynfj9X7nyUKUXoUEwfXqaZt0omVOmDe9oOTdKStH4GmAw6zxMFs50ZayuMfHDKlO7Tfw== -"@babel/parser@^7.23.5", "@babel/parser@^7.25.9", "@babel/parser@^7.26.3": - version "7.26.3" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.26.3.tgz#8c51c5db6ddf08134af1ddbacf16aaab48bac234" - integrity sha512-WJ/CvmY8Mea8iDXo6a7RK2wbmJITT5fN3BEkRuFlxVyNx8jOKIIhmC4fSkTcPcf8JyavbBwIe6OpiCOBXt/IcA== +"@babel/parser@^7.23.5", "@babel/parser@^7.25.9", "@babel/parser@^7.26.5": + version "7.26.5" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.26.5.tgz#6fec9aebddef25ca57a935c86dbb915ae2da3e1f" + integrity sha512-SRJ4jYmXRqV1/Xc+TIVG84WjHBXKlxO9sHQnA2Pf12QQEAp1LOh6kDzNHXcUnbH1QI0FDoPPVOt+vyUDucxpaw== dependencies: - "@babel/types" "^7.26.3" + "@babel/types" "^7.26.5" "@babel/plugin-transform-runtime@^7.5.5": version "7.25.9" @@ -188,22 +188,22 @@ "@babel/types" "^7.25.9" "@babel/traverse@^7.25.9": - version "7.26.4" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.26.4.tgz#ac3a2a84b908dde6d463c3bfa2c5fdc1653574bd" - integrity sha512-fH+b7Y4p3yqvApJALCPJcwb0/XaOSgtK4pzV6WVjPR5GLFQBRI7pfoX2V2iM48NXvX07NUxxm1Vw98YjqTcU5w== + version "7.26.5" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.26.5.tgz#6d0be3e772ff786456c1a37538208286f6e79021" + integrity sha512-rkOSPOw+AXbgtwUga3U4u8RpoK9FEFWBNAlTpcnkLFjL5CT+oyHNuUUC/xx6XefEJ16r38r8Bc/lfp6rYuHeJQ== dependencies: "@babel/code-frame" "^7.26.2" - "@babel/generator" "^7.26.3" - "@babel/parser" "^7.26.3" + "@babel/generator" "^7.26.5" + "@babel/parser" "^7.26.5" "@babel/template" "^7.25.9" - "@babel/types" "^7.26.3" + "@babel/types" "^7.26.5" debug "^4.3.1" globals "^11.1.0" -"@babel/types@^7.25.9", "@babel/types@^7.26.3": - version "7.26.3" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.26.3.tgz#37e79830f04c2b5687acc77db97fbc75fb81f3c0" - integrity sha512-vN5p+1kl59GVKMvTHt55NzzmYVxprfJD+ql7U9NFIfKCBkYE55LYtS+WtPlaYOyzydrKI8Nezd+aZextrd+FMA== +"@babel/types@^7.25.9", "@babel/types@^7.26.5": + version "7.26.5" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.26.5.tgz#7a1e1c01d28e26d1fe7f8ec9567b3b92b9d07747" + integrity sha512-L6mZmwFDK6Cjh1nRCLXpa6no13ZIioJDz7mdkzHv399pThrTa/k0nUlNaenOeh2kWu/iaOQYElEpKPUswUa9Vg== dependencies: "@babel/helper-string-parser" "^7.25.9" "@babel/helper-validator-identifier" "^7.25.9" @@ -593,10 +593,10 @@ debug "^4.3.1" minimatch "^3.1.2" -"@eslint/core@^0.9.0": - version "0.9.1" - resolved "https://registry.yarnpkg.com/@eslint/core/-/core-0.9.1.tgz#31763847308ef6b7084a4505573ac9402c51f9d1" - integrity sha512-GuUdqkyyzQI5RMIWkHhvTWLCyLo1jNK3vzkSyaExH5kHPDHcuL2VOpHjmMY+y3+NC69qAKToBqldTBgYeLSr9Q== +"@eslint/core@^0.10.0": + version "0.10.0" + resolved "https://registry.yarnpkg.com/@eslint/core/-/core-0.10.0.tgz#23727063c21b335f752dbb3a16450f6f9cbc9091" + integrity sha512-gFHJ+xBOo4G3WRlR1e/3G8A6/KZAH6zcE/hkLRCZTi/B9avAG365QhFA8uOGzTMqgTghpn7/fSnscW++dpMSAw== dependencies: "@types/json-schema" "^7.0.15" @@ -615,21 +615,22 @@ minimatch "^3.1.2" strip-json-comments "^3.1.1" -"@eslint/js@9.17.0": - version "9.17.0" - resolved "https://registry.yarnpkg.com/@eslint/js/-/js-9.17.0.tgz#1523e586791f80376a6f8398a3964455ecc651ec" - integrity sha512-Sxc4hqcs1kTu0iID3kcZDW3JHq2a77HO9P8CP6YEA/FpH3Ll8UXE2r/86Rz9YJLKme39S9vU5OWNjC6Xl0Cr3w== +"@eslint/js@9.18.0": + version "9.18.0" + resolved "https://registry.yarnpkg.com/@eslint/js/-/js-9.18.0.tgz#3356f85d18ed3627ab107790b53caf7e1e3d1e84" + integrity sha512-fK6L7rxcq6/z+AaQMtiFTkvbHkBLNlwyRxHpKawP0x3u9+NC6MQTnFW+AdpwC6gfHTW0051cokQgtTN2FqlxQA== "@eslint/object-schema@^2.1.5": version "2.1.5" resolved "https://registry.yarnpkg.com/@eslint/object-schema/-/object-schema-2.1.5.tgz#8670a8f6258a2be5b2c620ff314a1d984c23eb2e" integrity sha512-o0bhxnL89h5Bae5T318nFoFzGy+YE5i/gGkoPAgkmTVdRKTiv3p8JHevPiPaMwoloKfEiiaHlawCqaZMqRm+XQ== -"@eslint/plugin-kit@^0.2.3": - version "0.2.4" - resolved "https://registry.yarnpkg.com/@eslint/plugin-kit/-/plugin-kit-0.2.4.tgz#2b78e7bb3755784bb13faa8932a1d994d6537792" - integrity sha512-zSkKow6H5Kdm0ZUQUB2kV5JIXqoG0+uH5YADhaEHswm664N9Db8dXSi0nMJpacpMf+MyyglF1vnZohpEg5yUtg== +"@eslint/plugin-kit@^0.2.5": + version "0.2.5" + resolved "https://registry.yarnpkg.com/@eslint/plugin-kit/-/plugin-kit-0.2.5.tgz#ee07372035539e7847ef834e3f5e7b79f09e3a81" + integrity sha512-lB05FkqEdUg2AA0xEbUz0SnkXT1LcCTa438W4IWTUh4hdOnVbQyOJ81OrDXsJk/LSiJHubgGEFoR5EHq1NsH1A== dependencies: + "@eslint/core" "^0.10.0" levn "^0.4.1" "@eth-optimism/contracts@0.6.0": @@ -1076,6 +1077,24 @@ resolved "https://registry.yarnpkg.com/@fastify/busboy/-/busboy-2.1.1.tgz#b9da6a878a371829a0502c9b6c1c143ef6663f4d" integrity sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA== +"@grpc/grpc-js@^1.11.1": + version "1.12.5" + resolved "https://registry.yarnpkg.com/@grpc/grpc-js/-/grpc-js-1.12.5.tgz#0064a28fe9b1ec54ac27e1c9bf70720aa01285e8" + integrity sha512-d3iiHxdpg5+ZcJ6jnDSOT8Z0O0VMVGy34jAnYLUX8yd36b1qn8f1TwOA/Lc7TsOh03IkPJ38eGI5qD2EjNkoEA== + dependencies: + "@grpc/proto-loader" "^0.7.13" + "@js-sdsl/ordered-map" "^4.4.2" + +"@grpc/proto-loader@^0.7.13": + version "0.7.13" + resolved "https://registry.yarnpkg.com/@grpc/proto-loader/-/proto-loader-0.7.13.tgz#f6a44b2b7c9f7b609f5748c6eac2d420e37670cf" + integrity sha512-AiXO/bfe9bmxBjxxtYxFAXGZvMaN5s8kO+jBHAJCON8rJoB5YS/D6X7ZNc6XQkuHNmyl4CYaMI1fJ/Gn27RGGw== + dependencies: + lodash.camelcase "^4.3.0" + long "^5.0.0" + protobufjs "^7.2.5" + yargs "^17.7.2" + "@humanfs/core@^0.19.1": version "0.19.1" resolved "https://registry.yarnpkg.com/@humanfs/core/-/core-0.19.1.tgz#17c55ca7d426733fe3c561906b8173c336b40a77" @@ -1220,6 +1239,11 @@ "@jridgewell/resolve-uri" "^3.1.0" "@jridgewell/sourcemap-codec" "^1.4.14" +"@js-sdsl/ordered-map@^4.4.2": + version "4.4.2" + resolved "https://registry.yarnpkg.com/@js-sdsl/ordered-map/-/ordered-map-4.4.2.tgz#9299f82874bab9e4c7f9c48d865becbfe8d6907c" + integrity sha512-iUKgm52T8HOE/makSxjqoWhe95ZJA1/G1sYsGev2JDKUSS14KAgg1LHb+Ba+IPow0xflbnSkOsZcO08C7w1gYw== + "@manypkg/find-root@^1.1.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@manypkg/find-root/-/find-root-1.1.0.tgz#a62d8ed1cd7e7d4c11d9d52a8397460b5d4ad29f" @@ -1315,11 +1339,11 @@ "@noble/hashes" "1.4.0" "@noble/curves@^1.4.0": - version "1.7.0" - resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.7.0.tgz#0512360622439256df892f21d25b388f52505e45" - integrity sha512-UTMhXK9SeDhFJVrHeUJ5uZlI6ajXg10O6Ddocf9S6GjbSBVZsJo88HzKwXznNfGpMTRDyJkqMjNDPYgf0qFWnw== + version "1.8.0" + resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.8.0.tgz#fe035a23959e6aeadf695851b51a87465b5ba8f7" + integrity sha512-j84kjAbzEnQHaSIhRPUmB3/eVXu2k3dKPl2LOrR8fSOIL+89U+7lV117EWHtq/GHM3ReGHM46iRBdZfpc4HRUQ== dependencies: - "@noble/hashes" "1.6.0" + "@noble/hashes" "1.7.0" "@noble/hashes@1.1.2": version "1.1.2" @@ -1341,15 +1365,10 @@ resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.4.0.tgz#45814aa329f30e4fe0ba49426f49dfccdd066426" integrity sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg== -"@noble/hashes@1.6.0": - version "1.6.0" - resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.6.0.tgz#d4bfb516ad6e7b5111c216a5cc7075f4cf19e6c5" - integrity sha512-YUULf0Uk4/mAA89w+k3+yUYh6NrEvxZa5T6SY3wlMvE2chHkxFUUIDI8/XW1QSC357iA5pSnqt7XEhvFOqmDyQ== - -"@noble/hashes@^1.4.0": - version "1.6.1" - resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.6.1.tgz#df6e5943edcea504bac61395926d6fd67869a0d5" - integrity sha512-pq5D8h10hHBjyqX+cfBm0i8JUXJ0UhczFc4r74zbuT9XgewFo2E3J1cOaGtdZynILNmQ685YWGzGE1Zv6io50w== +"@noble/hashes@1.7.0", "@noble/hashes@^1.4.0": + version "1.7.0" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.7.0.tgz#5d9e33af2c7d04fee35de1519b80c958b2e35e39" + integrity sha512-HXydb0DgzTpDPwbVeDGCG1gIu7X6+AuU6Zl6av/E/KG8LMsvPntvq+w17CHRpKBmN6Ybdrt1eP3k4cj8DJa78w== "@noble/hashes@~1.1.1": version "1.1.5" @@ -1792,6 +1811,59 @@ resolved "https://registry.yarnpkg.com/@prettier/sync/-/sync-0.3.0.tgz#91f2cfc23490a21586d1cf89c6f72157c000ca1e" integrity sha512-3dcmCyAxIcxy036h1I7MQU/uEEBq8oLwf1CE3xeze+MPlgkdlb/+w6rGR/1dhp6Hqi17fRS6nvwnOzkESxEkOw== +"@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz#9b8b0cc663d669a7d8f6f5d0893a14d348f30fbf" + integrity sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ== + +"@protobufjs/base64@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@protobufjs/base64/-/base64-1.1.2.tgz#4c85730e59b9a1f1f349047dbf24296034bb2735" + integrity sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg== + +"@protobufjs/codegen@^2.0.4": + version "2.0.4" + resolved "https://registry.yarnpkg.com/@protobufjs/codegen/-/codegen-2.0.4.tgz#7ef37f0d010fb028ad1ad59722e506d9262815cb" + integrity sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg== + +"@protobufjs/eventemitter@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz#355cbc98bafad5978f9ed095f397621f1d066b70" + integrity sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q== + +"@protobufjs/fetch@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/fetch/-/fetch-1.1.0.tgz#ba99fb598614af65700c1619ff06d454b0d84c45" + integrity sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ== + dependencies: + "@protobufjs/aspromise" "^1.1.1" + "@protobufjs/inquire" "^1.1.0" + +"@protobufjs/float@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@protobufjs/float/-/float-1.0.2.tgz#5e9e1abdcb73fc0a7cb8b291df78c8cbd97b87d1" + integrity sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ== + +"@protobufjs/inquire@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/inquire/-/inquire-1.1.0.tgz#ff200e3e7cf2429e2dcafc1140828e8cc638f089" + integrity sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q== + +"@protobufjs/path@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@protobufjs/path/-/path-1.1.2.tgz#6cc2b20c5c9ad6ad0dccfd21ca7673d8d7fbf68d" + integrity sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA== + +"@protobufjs/pool@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/pool/-/pool-1.1.0.tgz#09fd15f2d6d3abfa9b65bc366506d6ad7846ff54" + integrity sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw== + +"@protobufjs/utf8@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570" + integrity sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw== + "@scroll-tech/contracts@0.1.0": version "0.1.0" resolved "https://registry.yarnpkg.com/@scroll-tech/contracts/-/contracts-0.1.0.tgz#ccea8db1b3df7d740e4b7843ac01b5bd25b4438b" @@ -1966,10 +2038,10 @@ resolved "https://registry.yarnpkg.com/@sinonjs/text-encoding/-/text-encoding-0.7.3.tgz#282046f03e886e352b2d5f5da5eb755e01457f3f" integrity sha512-DE427ROAphMQzU4ENbliGYrBSYPXF+TtLg9S8vzeA+OF4ZKzoDdzfL8sxuMUGS/lgRhM6j1URSk9ghf7Xo1tyA== -"@smithy/types@^3.7.2": - version "3.7.2" - resolved "https://registry.yarnpkg.com/@smithy/types/-/types-3.7.2.tgz#05cb14840ada6f966de1bf9a9c7dd86027343e10" - integrity sha512-bNwBYYmN8Eh9RyjS1p2gW6MIhSO2rl7X9QeLM8iTdcGRP+eDiIWDt66c9IysCc22gefKszZv+ubV9qZc7hdESg== +"@smithy/types@^4.0.0": + version "4.1.0" + resolved "https://registry.yarnpkg.com/@smithy/types/-/types-4.1.0.tgz#19de0b6087bccdd4182a334eb5d3d2629699370f" + integrity sha512-enhjdwp4D7CXmwLtD6zbcDMbo6/T6WtuuKCY49Xxc6OMOmUWlBEBDREsxxgV2LIdeQPW756+f97GzcgAwp3iLw== dependencies: tslib "^2.6.2" @@ -2267,10 +2339,10 @@ dependencies: "@types/node" "*" -"@types/node@*": - version "22.10.2" - resolved "https://registry.yarnpkg.com/@types/node/-/node-22.10.2.tgz#a485426e6d1fdafc7b0d4c7b24e2c78182ddabb9" - integrity sha512-Xxr6BBRCAOQixvonOye19wnzyDiUtTeqldOOmj3CkeblonbccA12PFwlufvRdrpjXxqnmUaeiU5EOA+7s5diUQ== +"@types/node@*", "@types/node@>=13.7.0": + version "22.10.5" + resolved "https://registry.yarnpkg.com/@types/node/-/node-22.10.5.tgz#95af89a3fb74a2bb41ef9927f206e6472026e48b" + integrity sha512-F8Q+SeGimwOo86fiovQh8qiXfFEh2/ocYv7tU5pJ3EXMSSxk1Joj5wefpFK2fHTf/N6HKGSxIDBT9f3gCxXPkQ== dependencies: undici-types "~6.20.0" @@ -2297,9 +2369,9 @@ integrity sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ== "@types/node@^20.10.7": - version "20.17.10" - resolved "https://registry.yarnpkg.com/@types/node/-/node-20.17.10.tgz#3f7166190aece19a0d1d364d75c8b0b5778c1e18" - integrity sha512-/jrvh5h6NXhEauFFexRin69nA0uHJ5gwk4iDivp/DeoEua3uwCUto6PC86IpRITBOs4+6i2I56K5x5b6WYGXHA== + version "20.17.12" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.17.12.tgz#ee3b7d25a522fd95608c1b3f02921c97b93fcbd6" + integrity sha512-vo/wmBgMIiEA23A/knMfn/cf37VnuF52nZh5ZoW0GWt4e4sxNquibrMRJ7UQsA06+MBx9r/H1jsI9grYjQCQlw== dependencies: undici-types "~6.19.2" @@ -2377,84 +2449,84 @@ integrity sha512-ltIpx+kM7g/MLRZfkbL7EsCEjfzCcScLpkg37eXEtx5kmrAKBkTJwd1GIAjDSL8wTpM6Hzn5YO4pSb91BEwu1g== "@typescript-eslint/eslint-plugin@^8.7.0": - version "8.18.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.18.1.tgz#992e5ac1553ce20d0d46aa6eccd79dc36dedc805" - integrity sha512-Ncvsq5CT3Gvh+uJG0Lwlho6suwDfUXH0HztslDf5I+F2wAFAZMRwYLEorumpKLzmO2suAXZ/td1tBg4NZIi9CQ== + version "8.19.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.19.1.tgz#5f26c0a833b27bcb1aa402b82e76d3b8dda0b247" + integrity sha512-tJzcVyvvb9h/PB96g30MpxACd9IrunT7GF9wfA9/0TJ1LxGOJx1TdPzSbBBnNED7K9Ka8ybJsnEpiXPktolTLg== dependencies: "@eslint-community/regexpp" "^4.10.0" - "@typescript-eslint/scope-manager" "8.18.1" - "@typescript-eslint/type-utils" "8.18.1" - "@typescript-eslint/utils" "8.18.1" - "@typescript-eslint/visitor-keys" "8.18.1" + "@typescript-eslint/scope-manager" "8.19.1" + "@typescript-eslint/type-utils" "8.19.1" + "@typescript-eslint/utils" "8.19.1" + "@typescript-eslint/visitor-keys" "8.19.1" graphemer "^1.4.0" ignore "^5.3.1" natural-compare "^1.4.0" - ts-api-utils "^1.3.0" + ts-api-utils "^2.0.0" "@typescript-eslint/parser@^8.7.0": - version "8.18.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-8.18.1.tgz#c258bae062778b7696793bc492249027a39dfb95" - integrity sha512-rBnTWHCdbYM2lh7hjyXqxk70wvon3p2FyaniZuey5TrcGBpfhVp0OxOa6gxr9Q9YhZFKyfbEnxc24ZnVbbUkCA== - dependencies: - "@typescript-eslint/scope-manager" "8.18.1" - "@typescript-eslint/types" "8.18.1" - "@typescript-eslint/typescript-estree" "8.18.1" - "@typescript-eslint/visitor-keys" "8.18.1" + version "8.19.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-8.19.1.tgz#b836fcfe7a704c8c65f5a50e5b0ff8acfca5c21b" + integrity sha512-67gbfv8rAwawjYx3fYArwldTQKoYfezNUT4D5ioWetr/xCrxXxvleo3uuiFuKfejipvq+og7mjz3b0G2bVyUCw== + dependencies: + "@typescript-eslint/scope-manager" "8.19.1" + "@typescript-eslint/types" "8.19.1" + "@typescript-eslint/typescript-estree" "8.19.1" + "@typescript-eslint/visitor-keys" "8.19.1" debug "^4.3.4" -"@typescript-eslint/scope-manager@8.18.1": - version "8.18.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-8.18.1.tgz#52cedc3a8178d7464a70beffed3203678648e55b" - integrity sha512-HxfHo2b090M5s2+/9Z3gkBhI6xBH8OJCFjH9MhQ+nnoZqxU3wNxkLT+VWXWSFWc3UF3Z+CfPAyqdCTdoXtDPCQ== +"@typescript-eslint/scope-manager@8.19.1": + version "8.19.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-8.19.1.tgz#794cfc8add4f373b9cd6fa32e367e7565a0e231b" + integrity sha512-60L9KIuN/xgmsINzonOcMDSB8p82h95hoBfSBtXuO4jlR1R9L1xSkmVZKgCPVfavDlXihh4ARNjXhh1gGnLC7Q== dependencies: - "@typescript-eslint/types" "8.18.1" - "@typescript-eslint/visitor-keys" "8.18.1" + "@typescript-eslint/types" "8.19.1" + "@typescript-eslint/visitor-keys" "8.19.1" -"@typescript-eslint/type-utils@8.18.1": - version "8.18.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-8.18.1.tgz#10f41285475c0bdee452b79ff7223f0e43a7781e" - integrity sha512-jAhTdK/Qx2NJPNOTxXpMwlOiSymtR2j283TtPqXkKBdH8OAMmhiUfP0kJjc/qSE51Xrq02Gj9NY7MwK+UxVwHQ== +"@typescript-eslint/type-utils@8.19.1": + version "8.19.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-8.19.1.tgz#23710ab52643c19f74601b3f4a076c98f4e159aa" + integrity sha512-Rp7k9lhDKBMRJB/nM9Ksp1zs4796wVNyihG9/TU9R6KCJDNkQbc2EOKjrBtLYh3396ZdpXLtr/MkaSEmNMtykw== dependencies: - "@typescript-eslint/typescript-estree" "8.18.1" - "@typescript-eslint/utils" "8.18.1" + "@typescript-eslint/typescript-estree" "8.19.1" + "@typescript-eslint/utils" "8.19.1" debug "^4.3.4" - ts-api-utils "^1.3.0" + ts-api-utils "^2.0.0" -"@typescript-eslint/types@8.18.1": - version "8.18.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-8.18.1.tgz#d7f4f94d0bba9ebd088de840266fcd45408a8fff" - integrity sha512-7uoAUsCj66qdNQNpH2G8MyTFlgerum8ubf21s3TSM3XmKXuIn+H2Sifh/ES2nPOPiYSRJWAk0fDkW0APBWcpfw== +"@typescript-eslint/types@8.19.1": + version "8.19.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-8.19.1.tgz#015a991281754ed986f2e549263a1188d6ed0a8c" + integrity sha512-JBVHMLj7B1K1v1051ZaMMgLW4Q/jre5qGK0Ew6UgXz1Rqh+/xPzV1aW581OM00X6iOfyr1be+QyW8LOUf19BbA== -"@typescript-eslint/typescript-estree@8.18.1": - version "8.18.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-8.18.1.tgz#2a86cd64b211a742f78dfa7e6f4860413475367e" - integrity sha512-z8U21WI5txzl2XYOW7i9hJhxoKKNG1kcU4RzyNvKrdZDmbjkmLBo8bgeiOJmA06kizLI76/CCBAAGlTlEeUfyg== +"@typescript-eslint/typescript-estree@8.19.1": + version "8.19.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-8.19.1.tgz#c1094bb00bc251ac76cf215569ca27236435036b" + integrity sha512-jk/TZwSMJlxlNnqhy0Eod1PNEvCkpY6MXOXE/WLlblZ6ibb32i2We4uByoKPv1d0OD2xebDv4hbs3fm11SMw8Q== dependencies: - "@typescript-eslint/types" "8.18.1" - "@typescript-eslint/visitor-keys" "8.18.1" + "@typescript-eslint/types" "8.19.1" + "@typescript-eslint/visitor-keys" "8.19.1" debug "^4.3.4" fast-glob "^3.3.2" is-glob "^4.0.3" minimatch "^9.0.4" semver "^7.6.0" - ts-api-utils "^1.3.0" + ts-api-utils "^2.0.0" -"@typescript-eslint/utils@8.18.1": - version "8.18.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-8.18.1.tgz#c4199ea23fc823c736e2c96fd07b1f7235fa92d5" - integrity sha512-8vikiIj2ebrC4WRdcAdDcmnu9Q/MXXwg+STf40BVfT8exDqBCUPdypvzcUPxEqRGKg9ALagZ0UWcYCtn+4W2iQ== +"@typescript-eslint/utils@8.19.1": + version "8.19.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-8.19.1.tgz#dd8eabd46b92bf61e573286e1c0ba6bd243a185b" + integrity sha512-IxG5gLO0Ne+KaUc8iW1A+XuKLd63o4wlbI1Zp692n1xojCl/THvgIKXJXBZixTh5dd5+yTJ/VXH7GJaaw21qXA== dependencies: "@eslint-community/eslint-utils" "^4.4.0" - "@typescript-eslint/scope-manager" "8.18.1" - "@typescript-eslint/types" "8.18.1" - "@typescript-eslint/typescript-estree" "8.18.1" + "@typescript-eslint/scope-manager" "8.19.1" + "@typescript-eslint/types" "8.19.1" + "@typescript-eslint/typescript-estree" "8.19.1" -"@typescript-eslint/visitor-keys@8.18.1": - version "8.18.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-8.18.1.tgz#344b4f6bc83f104f514676facf3129260df7610a" - integrity sha512-Vj0WLm5/ZsD013YeUKn+K0y8p1M0jPpxOkKdbD1wB0ns53a5piVY02zjf072TblEweAbcYiFiPoSMF3kp+VhhQ== +"@typescript-eslint/visitor-keys@8.19.1": + version "8.19.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-8.19.1.tgz#fce54d7cfa5351a92387d6c0c5be598caee072e0" + integrity sha512-fzmjU8CHK853V/avYZAvuVut3ZTfwN5YtMaoi+X9Y9MA9keaWNHC3zEQ9zvyX/7Hj+5JkNyK1l7TOR2hevHB6Q== dependencies: - "@typescript-eslint/types" "8.18.1" + "@typescript-eslint/types" "8.19.1" eslint-visitor-keys "^4.2.0" "@uniswap/lib@4.0.1-alpha", "@uniswap/lib@^4.0.1-alpha": @@ -3356,10 +3428,10 @@ browserify-aes@^1.0.6, browserify-aes@^1.2.0: inherits "^2.0.1" safe-buffer "^5.0.1" -browserslist@^4.24.0, browserslist@^4.24.2: - version "4.24.3" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.24.3.tgz#5fc2725ca8fb3c1432e13dac278c7cc103e026d2" - integrity sha512-1CPmv8iobE2fyRMV97dAcMVegvvWKxmq94hkLiAkUGwKVTyDLw33K+ZxiFrREKmmps4rIw6grcCFCnTMSZ/YiA== +browserslist@^4.24.0, browserslist@^4.24.3: + version "4.24.4" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.24.4.tgz#c6b2865a3f08bcb860a0e827389003b9fe686e4b" + integrity sha512-KDi1Ny1gSePi1vm0q4oxSF8b4DR44GF4BbmS2YdhPLOEqd8pDviZOGH/GsmRwoWJ2+5Lr085X7naowMwKHDG1A== dependencies: caniuse-lite "^1.0.30001688" electron-to-chromium "^1.5.73" @@ -3460,9 +3532,9 @@ bufferutil@4.0.7: node-gyp-build "^4.3.0" bufferutil@^4.0.1: - version "4.0.8" - resolved "https://registry.yarnpkg.com/bufferutil/-/bufferutil-4.0.8.tgz#1de6a71092d65d7766c4d8a522b261a6e787e8ea" - integrity sha512-4T53u4PdgsXqKaIctwF8ifXlRTTmEPJ8iEPWFdGZvcf7sbwYo6FKFEX9eNNAnzFZ7EzJAQ3CJeOtCRA4rDp7Pw== + version "4.0.9" + resolved "https://registry.yarnpkg.com/bufferutil/-/bufferutil-4.0.9.tgz#6e81739ad48a95cad45a279588e13e95e24a800a" + integrity sha512-WDtdLmJvAuNNPzByAYpRo2rF1Mmradw6gvWsQKf63476DDXmomT9zUiGypLcG4ibIM67vhAj8jJRdbmEws2Aqw== dependencies: node-gyp-build "^4.3.0" @@ -3595,9 +3667,9 @@ camelcase@^6.0.0, camelcase@^6.2.0: integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== caniuse-lite@^1.0.30001688: - version "1.0.30001690" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001690.tgz#f2d15e3aaf8e18f76b2b8c1481abde063b8104c8" - integrity sha512-5ExiE3qQN6oF8Clf8ifIDcMRCRE/dMGcETG/XGMD8/XiXm6HXQgQTh1yZYLXXpSOsEUlJm1Xr7kGULZTuGtP/w== + version "1.0.30001692" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001692.tgz#4585729d95e6b95be5b439da6ab55250cd125bf9" + integrity sha512-A95VKan0kdtrsnMubMKxEKUKImOPSuCpYgxSQBo036P5YYgVIcOYJEgt/txJWqObiRQeISNCfef9nvlQ0vbV7A== caseless@^0.12.0, caseless@~0.12.0: version "0.12.0" @@ -3661,9 +3733,9 @@ chalk@^2.4.2: supports-color "^5.3.0" chalk@^5.3.0: - version "5.4.0" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.4.0.tgz#846fdb5d5d939d6fa3d565cd5545697b6f8b6923" - integrity sha512-ZkD35Mx92acjB2yNJgziGqT9oKHEOxjTBTDRpOsRWtdecL/0jM3z5kM/CTzHWvHIen1GvkM85p6TuFfDGfc8/Q== + version "5.4.1" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.4.1.tgz#1b48bf0963ec158dce2aacf69c093ae2dd2092d8" + integrity sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w== chardet@^0.7.0: version "0.7.0" @@ -4010,11 +4082,11 @@ cookie@^0.4.1: integrity sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA== core-js-compat@^3.38.0: - version "3.39.0" - resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.39.0.tgz#b12dccb495f2601dc860bdbe7b4e3ffa8ba63f61" - integrity sha512-VgEUx3VwlExr5no0tXlBt+silBvhTryPwCXRI2Id1PN8WTKu7MreethvddqOubrYxkFdv/RnYrqlv1sFNAUelw== + version "3.40.0" + resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.40.0.tgz#7485912a5a4a4315c2fdb2cbdc623e6881c88b38" + integrity sha512-0XEDpr5y5mijvw8Lbc6E5AkjrHfp7eEoPlu36SWeAbcL8fn1G1ANe8DBlo2XoNN89oVpxWwOjYIPVzR4ZvsKCQ== dependencies: - browserslist "^4.24.2" + browserslist "^4.24.3" core-util-is@1.0.2: version "1.0.2" @@ -4094,11 +4166,11 @@ cross-fetch@^2.1.0: whatwg-fetch "^2.0.4" cross-fetch@^3.1.4: - version "3.1.8" - resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.8.tgz#0327eba65fd68a7d119f8fb2bf9334a1a7956f82" - integrity sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg== + version "3.2.0" + resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.2.0.tgz#34e9192f53bc757d6614304d9e5e6fb4edb782e3" + integrity sha512-Q+xVJLoGOeIMXZmbUK4HYk+69cQH6LudR0Vu/pRm2YlU/hDV9CiS0gKUMaWY5f2NeUH9C1nV3bsTlCo0FsTV1Q== dependencies: - node-fetch "^2.6.12" + node-fetch "^2.7.0" cross-spawn@^6.0.5: version "6.0.6" @@ -4354,10 +4426,10 @@ docker-modem@^1.0.8: readable-stream "~1.0.26-4" split-ca "^1.0.0" -docker-modem@^5.0.3: - version "5.0.3" - resolved "https://registry.yarnpkg.com/docker-modem/-/docker-modem-5.0.3.tgz#50c06f11285289f58112b5c4c4d89824541c41d0" - integrity sha512-89zhop5YVhcPEt5FpUFGr3cDyceGhq/F9J+ZndQ4KfqNvfbJpPMfgeixFgUj5OjCYAboElqODxY5Z1EBsSa6sg== +docker-modem@^5.0.5: + version "5.0.5" + resolved "https://registry.yarnpkg.com/docker-modem/-/docker-modem-5.0.5.tgz#5c0d3fa3b4c778098d965be20c887c14fa995a2f" + integrity sha512-Cxw8uEcvNTRmsQuGqzzfiCnfGgf96tVJItLh8taOX0miTcIBALKH5TckCSuZbpbjP7uhAl81dOL9sxfa6HgCIg== dependencies: debug "^4.1.1" readable-stream "^3.5.0" @@ -4374,13 +4446,17 @@ dockerode@^2.5.8: tar-fs "~1.16.3" dockerode@^4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/dockerode/-/dockerode-4.0.2.tgz#dedc8529a1db3ac46d186f5912389899bc309f7d" - integrity sha512-9wM1BVpVMFr2Pw3eJNXrYYt6DT9k0xMcsSCjtPvyQ+xa1iPg/Mo3T/gUcwI0B2cczqCeCYRPF8yFYDwtFXT0+w== + version "4.0.3" + resolved "https://registry.yarnpkg.com/dockerode/-/dockerode-4.0.3.tgz#509227f46782302650447fd495d44b9e3b439e4f" + integrity sha512-QSXJFcBQNaGZO6U3qWW4B7p8yRIJn/dWmvL2AQWfO/bjptBBO6QYdVkYSYFz9qoivP2jsOHZfmXMAfrK0BMKyg== dependencies: "@balena/dockerignore" "^1.0.2" - docker-modem "^5.0.3" + "@grpc/grpc-js" "^1.11.1" + "@grpc/proto-loader" "^0.7.13" + docker-modem "^5.0.5" + protobufjs "^7.3.2" tar-fs "~2.0.1" + uuid "^10.0.0" dom-converter@^0.2.0: version "0.2.0" @@ -4465,7 +4541,7 @@ drbg.js@^1.0.1: version "1.0.0" resolved "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0" -dunder-proto@^1.0.0: +dunder-proto@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/dunder-proto/-/dunder-proto-1.0.1.tgz#d7ae667e1dc83482f8b70fd0f6eefc50da30f58a" integrity sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A== @@ -4505,9 +4581,9 @@ ee-first@1.1.1: integrity sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow== electron-to-chromium@^1.5.73: - version "1.5.75" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.75.tgz#bba96eabf0e8ca36324679caa38b982800acc87d" - integrity sha512-Lf3++DumRE/QmweGjU+ZcKqQ+3bKkU/qjaKYhIJKEOhgIO9Xs6IiAQFkfFoj+RhgDk4LUeNsLo6plExHqSyu6Q== + version "1.5.80" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.80.tgz#ca7a8361d7305f0ec9e203ce4e633cbb8a8ef1b1" + integrity sha512-LTrKpW0AqIuHwmlVNV+cjFYTnXtM9K37OGhpe0ZI10ScPSxqVSryZHIY3WnCS5NSYbBODRTZyhRMS2h5FAEqAw== elliptic@6.5.4: version "6.5.4" @@ -4590,9 +4666,9 @@ end-of-stream@^1.0.0, end-of-stream@^1.1.0, end-of-stream@^1.4.1: once "^1.4.0" enhanced-resolve@^5.17.1: - version "5.17.1" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.17.1.tgz#67bfbbcc2f81d511be77d686a90267ef7f898a15" - integrity sha512-LMHl3dXhTcfv8gM4kEzIUeTQ+7fpdA0l2tUf34BddXPkz2A5xJ5L/Pchd5BL6rdccM9QGvu0sWZzK1Z1t4wwyg== + version "5.18.0" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.18.0.tgz#91eb1db193896b9801251eeff1c6980278b1e404" + integrity sha512-0/r0MySGYG8YqlayBZ6MuCfECmHFdJ5qyPh8s8wa5Hnm6SaFLSK1VYCbj+NKp090Nm1caZhD+QTnmxO7esYGyQ== dependencies: graceful-fs "^4.2.4" tapable "^2.2.0" @@ -4650,9 +4726,9 @@ es-errors@^1.3.0: integrity sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw== es-module-lexer@^1.2.1: - version "1.5.4" - resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-1.5.4.tgz#a8efec3a3da991e60efa6b633a7cad6ab8d26b78" - integrity sha512-MVNK56NiMrOwitFB7cqDwq0CQutbw+0BvLshJSse0MUNU+y1FC3bUS/AQg7oUng+/wKrrki7JfmwtVHkVfPLlw== + version "1.6.0" + resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-1.6.0.tgz#da49f587fd9e68ee2404fe4e256c0c7d3a81be21" + integrity sha512-qqnD1yMU6tk/jnaMosogGySTZP8YtUgAffA9nMN+E/rjxcfRQ6IEk7IiozUjgxKoFHBGjTLnrHB/YC45r/59EQ== es-object-atoms@^1.0.0: version "1.0.0" @@ -4765,17 +4841,17 @@ eslint-visitor-keys@^4.2.0: integrity sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw== eslint@^9.8.0: - version "9.17.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-9.17.0.tgz#faa1facb5dd042172fdc520106984b5c2421bb0c" - integrity sha512-evtlNcpJg+cZLcnVKwsai8fExnqjGPicK7gnUtlNuzu+Fv9bI0aLpND5T44VLQtoMEnI57LoXO9XAkIXwohKrA== + version "9.18.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-9.18.0.tgz#c95b24de1183e865de19f607fda6518b54827850" + integrity sha512-+waTfRWQlSbpt3KWE+CjrPPYnbq9kfZIYUqapc0uBXyjTp8aYXZDsUH16m39Ryq3NjAVP4tjuF7KaukeqoCoaA== dependencies: "@eslint-community/eslint-utils" "^4.2.0" "@eslint-community/regexpp" "^4.12.1" "@eslint/config-array" "^0.19.0" - "@eslint/core" "^0.9.0" + "@eslint/core" "^0.10.0" "@eslint/eslintrc" "^3.2.0" - "@eslint/js" "9.17.0" - "@eslint/plugin-kit" "^0.2.3" + "@eslint/js" "9.18.0" + "@eslint/plugin-kit" "^0.2.5" "@humanfs/node" "^0.16.6" "@humanwhocodes/module-importer" "^1.0.1" "@humanwhocodes/retry" "^0.4.1" @@ -5258,9 +5334,9 @@ ethers@6.12.1: ws "8.5.0" ethers@^6.7.0, ethers@^6.8.1: - version "6.13.4" - resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.13.4.tgz#bd3e1c3dc1e7dc8ce10f9ffb4ee40967a651b53c" - integrity sha512-21YtnZVg4/zKkCQPjrDj38B1r4nQvTZLopUGMLQ1ePU2zV/joCfDC3t3iKQjWRzjjjbzR+mdAIoikeBRNkdllA== + version "6.13.5" + resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.13.5.tgz#8c1d6ac988ac08abc3c1d8fabbd4b8b602851ac4" + integrity sha512-+knKNieu5EKRThQJWwqaJ10a6HE9sSehGeqWN65//wE7j47ZpFhKAnHB/JJFibwwg61I/koxaPsXbXpD/skNOQ== dependencies: "@adraffy/ens-normalize" "1.10.1" "@noble/curves" "1.2.0" @@ -5408,15 +5484,15 @@ fast-diff@^1.1.2, fast-diff@^1.2.0: integrity sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw== fast-glob@^3.0.3, fast-glob@^3.2.9, fast-glob@^3.3.2: - version "3.3.2" - resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.2.tgz#a904501e57cfdd2ffcded45e99a54fef55e46129" - integrity sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow== + version "3.3.3" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.3.tgz#d06d585ce8dba90a16b0505c543c3ccfb3aeb818" + integrity sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg== dependencies: "@nodelib/fs.stat" "^2.0.2" "@nodelib/fs.walk" "^1.2.3" glob-parent "^5.1.2" merge2 "^1.3.0" - micromatch "^4.0.4" + micromatch "^4.0.8" fast-json-stable-stringify@^2.0.0: version "2.1.0" @@ -5434,14 +5510,14 @@ fast-safe-stringify@^2.0.6: integrity sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA== fast-uri@^3.0.1: - version "3.0.3" - resolved "https://registry.yarnpkg.com/fast-uri/-/fast-uri-3.0.3.tgz#892a1c91802d5d7860de728f18608a0573142241" - integrity sha512-aLrHthzCjH5He4Z2H9YZ+v6Ujb9ocRuW6ZzkJQOrTxleEijANq4v1TsaPaVG1PZcuurEzrLcWRyYBYXD5cEiaw== + version "3.0.5" + resolved "https://registry.yarnpkg.com/fast-uri/-/fast-uri-3.0.5.tgz#19f5f9691d0dab9b85861a7bb5d98fca961da9cd" + integrity sha512-5JnBCWpFlMo0a3ciDy/JckMzzv1U9coZrIhedq+HXxxUfDTAiS0LA8OKVao4G9BxmCVck/jtA5r3KAtRWEyD8Q== fastq@^1.6.0: - version "1.17.1" - resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.17.1.tgz#2a523f07a4e7b1e81a42b91b8bf2254107753b47" - integrity sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w== + version "1.18.0" + resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.18.0.tgz#d631d7e25faffea81887fe5ea8c9010e1b36fee0" + integrity sha512-QKHXPW0hD8g4UET03SdOdunzSouc9N4AuHdsX8XNcTsuz+yYFILVNIX4l9yHABMhiEI9Db0JTTIpu0wB+Y1QQw== dependencies: reusify "^1.0.4" @@ -5571,7 +5647,7 @@ forever-agent@~0.6.1: "forge-std@https://github.com/foundry-rs/forge-std.git": version "1.9.5" - resolved "https://github.com/foundry-rs/forge-std.git#b93cf4bc34ff214c099dc970b153f85ade8c9f66" + resolved "https://github.com/foundry-rs/forge-std.git#726a6ee5fc8427a0013d6f624e486c9130c0e336" form-data-encoder@1.7.1: version "1.7.1" @@ -5774,26 +5850,34 @@ get-func-name@^2.0.1, get-func-name@^2.0.2: integrity sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ== get-intrinsic@^1.2.4, get-intrinsic@^1.2.5, get-intrinsic@^1.2.6: - version "1.2.6" - resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.6.tgz#43dd3dd0e7b49b82b2dfcad10dc824bf7fc265d5" - integrity sha512-qxsEs+9A+u85HhllWJJFicJfPDhRmjzoYdl64aMWW9yRIJmSyxdn8IEkuIM530/7T+lv0TIHd8L6Q/ra0tEoeA== + version "1.2.7" + resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.7.tgz#dcfcb33d3272e15f445d15124bc0a216189b9044" + integrity sha512-VW6Pxhsrk0KAOqs3WEd0klDiF/+V7gQOpAvY1jVU/LHmaD/kQO4523aiJuikX/QAKYiW6x8Jh+RJej1almdtCA== dependencies: call-bind-apply-helpers "^1.0.1" - dunder-proto "^1.0.0" es-define-property "^1.0.1" es-errors "^1.3.0" es-object-atoms "^1.0.0" function-bind "^1.1.2" + get-proto "^1.0.0" gopd "^1.2.0" has-symbols "^1.1.0" hasown "^2.0.2" - math-intrinsics "^1.0.0" + math-intrinsics "^1.1.0" get-port@^3.1.0: version "3.2.0" resolved "https://registry.yarnpkg.com/get-port/-/get-port-3.2.0.tgz#dd7ce7de187c06c8bf353796ac71e099f0980ebc" integrity sha512-x5UJKlgeUiNT8nyo/AcnwLnZuZNcSjSw0kogRB+Whd1fjjFq4B1hySFxSFWWSn4mIBzg3sRNUDFYc4g5gjPoLg== +get-proto@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/get-proto/-/get-proto-1.0.1.tgz#150b3f2743869ef3e851ec0c49d15b1d14d00ee1" + integrity sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g== + dependencies: + dunder-proto "^1.0.1" + es-object-atoms "^1.0.0" + get-stream@^5.1.0: version "5.2.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-5.2.0.tgz#4966a1795ee5ace65e706c4b7beb71257d6e22d3" @@ -6236,7 +6320,7 @@ has-symbols@^1.0.3, has-symbols@^1.1.0: resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.1.0.tgz#fc9c6a783a084951d0b971fe1018de813707a338" integrity sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ== -has-tostringtag@^1.0.0, has-tostringtag@^1.0.2: +has-tostringtag@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/has-tostringtag/-/has-tostringtag-1.0.2.tgz#2cdc42d40bef2e5b4eeab7c01a73c54ce7ab5abc" integrity sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw== @@ -6584,9 +6668,9 @@ is-ci@^2.0.0: ci-info "^2.0.0" is-core-module@^2.16.0: - version "2.16.0" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.16.0.tgz#6c01ffdd5e33c49c1d2abfa93334a85cb56bd81c" - integrity sha512-urTSINYfAYgcbLb0yDQ6egFm6h3Mo1DcF9EkyXSRjjzdHbsulg01qhwWuXdOoUBuTkbQ80KDboXa0vFJ+BDH+g== + version "2.16.1" + resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.16.1.tgz#2a98801a849f43e2add644fbb6bc6229b19a4ef4" + integrity sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w== dependencies: hasown "^2.0.2" @@ -6621,11 +6705,14 @@ is-function@^1.0.1: integrity sha512-lw7DUp0aWXYg+CBCN+JKkcE0Q2RayZnSvnZBlwgxHBQhqt5pZNVy4Ri7H9GmmXkdu7LUthszM+Tor1u/2iBcpQ== is-generator-function@^1.0.7: - version "1.0.10" - resolved "https://registry.yarnpkg.com/is-generator-function/-/is-generator-function-1.0.10.tgz#f1558baf1ac17e0deea7c0415c438351ff2b3c72" - integrity sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A== + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-generator-function/-/is-generator-function-1.1.0.tgz#bf3eeda931201394f57b5dba2800f91a238309ca" + integrity sha512-nPUB5km40q9e8UfN/Zc24eLlzdSf9OfKByBw9CIdw4H1giPMeA0OIJvbchsCu4npfI2QcMVBsGEBHKZ7wLTWmQ== dependencies: - has-tostringtag "^1.0.0" + call-bound "^1.0.3" + get-proto "^1.0.0" + has-tostringtag "^1.0.2" + safe-regex-test "^1.1.0" is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3, is-glob@~4.0.1: version "4.0.3" @@ -6659,6 +6746,16 @@ is-plain-obj@^2.1.0: resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287" integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA== +is-regex@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.2.1.tgz#76d70a3ed10ef9be48eb577887d74205bf0cad22" + integrity sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g== + dependencies: + call-bound "^1.0.2" + gopd "^1.2.0" + has-tostringtag "^1.0.2" + hasown "^2.0.2" + is-subdir@^1.1.1: version "1.2.0" resolved "https://registry.yarnpkg.com/is-subdir/-/is-subdir-1.2.0.tgz#b791cd28fab5202e91a08280d51d9d7254fd20d4" @@ -6863,9 +6960,9 @@ json-stable-stringify-without-jsonify@^1.0.1: integrity sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw== json-stable-stringify@^1.0.1: - version "1.2.0" - resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.2.0.tgz#2c974b1e9e8c0655cc32d4a7315c23bf122e3d3a" - integrity sha512-ex8jk9BZHBolvbd5cRnAgwyaYcYB0qZldy1e+LCOdcF6+AUmVZ6LcGUMzsRTW83QMeu+GxZGrcLqxqrgfXGvIw== + version "1.2.1" + resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.2.1.tgz#addb683c2b78014d0b78d704c2fcbdf0695a60e2" + integrity sha512-Lp6HbbBgosLmJbjx0pBLbgvx68FaFU1sdkmBuckmhhJ88kL13OA51CDtR2yJB50eCNMH9wRqtQNNiAqQH4YXnA== dependencies: call-bind "^1.0.8" call-bound "^1.0.3" @@ -6922,9 +7019,9 @@ jsonparse@^1.2.0, jsonparse@^1.3.1: integrity sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg== jsonschema@^1.2.4: - version "1.4.1" - resolved "https://registry.yarnpkg.com/jsonschema/-/jsonschema-1.4.1.tgz#cc4c3f0077fb4542982973d8a083b6b34f482dab" - integrity sha512-S6cATIPVv1z0IlxdN+zUk5EPjkGCdnhN4wVSBlvoUO1tOLJootbo9CquNJmbIh4yikWHiUedhRYrNPn1arpEmQ== + version "1.5.0" + resolved "https://registry.yarnpkg.com/jsonschema/-/jsonschema-1.5.0.tgz#f6aceb1ab9123563dd901d05f81f9d4883d3b7d8" + integrity sha512-K+A9hhqbn0f3pJX17Q/7H6yQfD/5OXgdrR5UE12gMXCiN9D5Xq2o5mddV2QEcX/bjla99ASsAAQUyMCCRWAEhw== jsprim@^1.2.2: version "1.4.2" @@ -7194,6 +7291,11 @@ log-symbols@^6.0.0: chalk "^5.3.0" is-unicode-supported "^1.3.0" +long@^5.0.0: + version "5.2.4" + resolved "https://registry.yarnpkg.com/long/-/long-5.2.4.tgz#ee651d5c7c25901cfca5e67220ae9911695e99b2" + integrity sha512-qtzLbJE8hq7VabR3mISmVGtoXP8KGc2Z/AT8OuqlYD7JTR3oqrgwdjnk07wpj1twXxYmgDXgoKVWUG/fReSzHg== + loupe@^2.3.6: version "2.3.7" resolved "https://registry.yarnpkg.com/loupe/-/loupe-2.3.7.tgz#6e69b7d4db7d3ab436328013d37d1c8c3540c697" @@ -7281,7 +7383,7 @@ match-all@^1.2.6: resolved "https://registry.yarnpkg.com/match-all/-/match-all-1.2.6.tgz#66d276ad6b49655551e63d3a6ee53e8be0566f8d" integrity sha512-0EESkXiTkWzrQQntBu2uzKvLu6vVkUGz40nGPbSZuegcfE5UuSzNjLaIu76zJWuaT/2I3Z/8M06OlUOZLGwLlQ== -math-intrinsics@^1.0.0: +math-intrinsics@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/math-intrinsics/-/math-intrinsics-1.1.0.tgz#a0dd74be81e2aa5c2f27e65ce283605ee4e2b7f9" integrity sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g== @@ -7363,7 +7465,7 @@ micro-ftch@^0.3.1: resolved "https://registry.yarnpkg.com/micro-ftch/-/micro-ftch-0.3.1.tgz#6cb83388de4c1f279a034fb0cf96dfc050853c5f" integrity sha512-/0LLxhzP0tfiR5hcQebtudP56gUurs2CLkGarnCiB/OqEyUFQ6U3paQi/tgLv0hBJYt2rnr9MNpxz4fiiugstg== -micromatch@^4.0.2, micromatch@^4.0.4, micromatch@^4.0.8: +micromatch@^4.0.2, micromatch@^4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.8.tgz#d66fa18f3a47076789320b9b1af32bd86d9fa202" integrity sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA== @@ -7773,7 +7875,7 @@ node-emoji@^1.10.0: dependencies: lodash "^4.17.21" -node-fetch@^2.5.0, node-fetch@^2.6.0, node-fetch@^2.6.1, node-fetch@^2.6.12, node-fetch@^2.6.7: +node-fetch@^2.5.0, node-fetch@^2.6.0, node-fetch@^2.6.1, node-fetch@^2.6.7, node-fetch@^2.7.0: version "2.7.0" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== @@ -7887,9 +7989,9 @@ object-keys@~0.4.0: integrity sha512-ncrLw+X55z7bkl5PnUvHwFK9FcGuFYo9gtjws2XtSzL+aZ8tm830P60WJ0dSmFVaSalWieW5MD7kEdnXda9yJw== obliterator@^2.0.0: - version "2.0.4" - resolved "https://registry.yarnpkg.com/obliterator/-/obliterator-2.0.4.tgz#fa650e019b2d075d745e44f1effeb13a2adbe816" - integrity sha512-lgHwxlxV1qIg1Eap7LgIeoBWIMFibOjbrYPIPJZcI1mmGAI2m3lNYpK12Y+GBdPQ0U1hRwSord7GIaawz962qQ== + version "2.0.5" + resolved "https://registry.yarnpkg.com/obliterator/-/obliterator-2.0.5.tgz#031e0145354b0c18840336ae51d41e7d6d2c76aa" + integrity sha512-42CPE9AhahZRsMNslczq0ctAEtqk8Eka26QofnqC346BZdHDySk3LWka23LI7ULIw11NmltpiLagIq8gBozxTw== oboe@2.1.5: version "2.1.5" @@ -8068,9 +8170,9 @@ package-json@^8.1.0: semver "^7.3.7" package-manager-detector@^0.2.0: - version "0.2.7" - resolved "https://registry.yarnpkg.com/package-manager-detector/-/package-manager-detector-0.2.7.tgz#6c3e47d7794fdd513512d02e2160c24ba559e39b" - integrity sha512-g4+387DXDKlZzHkP+9FLt8yKj8+/3tOkPv7DVTJGGRm00RkEWgqbFstX1mXJ4M0VDYhUqsTOiISqNOJnhAu3PQ== + version "0.2.8" + resolved "https://registry.yarnpkg.com/package-manager-detector/-/package-manager-detector-0.2.8.tgz#f5ace2dbd37666af54e5acec11bc37c8450f72d0" + integrity sha512-ts9KSdroZisdvKMWVAVCXiKqnqNfXz4+IbrBG8/BWx/TR5le+jfenvoBuIZ6UWM9nz47W7AbD9qYfAwfWMIwzA== param-case@^3.0.4: version "3.0.4" @@ -8348,12 +8450,12 @@ prettier-linter-helpers@^1.0.0: fast-diff "^1.1.2" prettier-plugin-solidity@^1.3.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/prettier-plugin-solidity/-/prettier-plugin-solidity-1.4.1.tgz#8060baf18853a9e34d2e09e47e87b4f19e15afe9" - integrity sha512-Mq8EtfacVZ/0+uDKTtHZGW3Aa7vEbX/BNx63hmVg6YTiTXSiuKP0amj0G6pGwjmLaOfymWh3QgXEZkjQbU8QRg== + version "1.4.2" + resolved "https://registry.yarnpkg.com/prettier-plugin-solidity/-/prettier-plugin-solidity-1.4.2.tgz#d4f6173674e73a29731a8c79c45ab6f5246310df" + integrity sha512-VVD/4XlDjSzyPWWCPW8JEleFa8JNKFYac5kNlMjVXemQyQZKfpekPMhFZSePuXB6L+RixlFvWe20iacGjFYrLw== dependencies: - "@solidity-parser/parser" "^0.18.0" - semver "^7.5.4" + "@solidity-parser/parser" "^0.19.0" + semver "^7.6.3" "prettier@^1.18.2 || ^2.0.0", prettier@^2.3.1, prettier@^2.7.1, prettier@^2.8.3: version "2.8.8" @@ -8433,6 +8535,24 @@ proto-list@~1.2.1: resolved "https://registry.yarnpkg.com/proto-list/-/proto-list-1.2.4.tgz#212d5bfe1318306a420f6402b8e26ff39647a849" integrity sha512-vtK/94akxsTMhe0/cbfpR+syPuszcuwhqVjJq26CuNDgFGj682oRBXOP5MJpv2r7JtE8MsiepGIqvvOTBwn2vA== +protobufjs@^7.2.5, protobufjs@^7.3.2: + version "7.4.0" + resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-7.4.0.tgz#7efe324ce9b3b61c82aae5de810d287bc08a248a" + integrity sha512-mRUWCc3KUU4w1jU8sGxICXH/gNS94DvI1gxqDvBzhj1JpcsimQkYiOJfwsPUykUI5ZaspFbSgmBLER8IrQ3tqw== + dependencies: + "@protobufjs/aspromise" "^1.1.2" + "@protobufjs/base64" "^1.1.2" + "@protobufjs/codegen" "^2.0.4" + "@protobufjs/eventemitter" "^1.1.0" + "@protobufjs/fetch" "^1.1.0" + "@protobufjs/float" "^1.0.2" + "@protobufjs/inquire" "^1.1.0" + "@protobufjs/path" "^1.1.2" + "@protobufjs/pool" "^1.1.0" + "@protobufjs/utf8" "^1.1.0" + "@types/node" ">=13.7.0" + long "^5.0.0" + proxy-addr@~2.0.7: version "2.0.7" resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.7.tgz#f19fe69ceab311eeb94b42e70e8c2070f9ba1025" @@ -8622,9 +8742,9 @@ readable-stream@~1.0.15, readable-stream@~1.0.26-4: string_decoder "~0.10.x" readdirp@^4.0.1: - version "4.0.2" - resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-4.0.2.tgz#388fccb8b75665da3abffe2d8f8ed59fe74c230a" - integrity sha512-yDMz9g+VaZkqBYS/ozoBJwaBhTbZo3UNYQHNRw1D3UFQB8oHB4uS/tAODO+ZLjGWmUbKnIlOWO+aaIiAxrUWHA== + version "4.1.1" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-4.1.1.tgz#bd115327129672dc47f87408f05df9bd9ca3ef55" + integrity sha512-h80JrZu/MHUZCyHu5ciuoI0+WxsCxzxJTILn6Fs8rxSnFPh+UVHYfeIxK1nVGugMqkfC4vJcBOYbkfkwYK0+gw== readdirp@~3.6.0: version "3.6.0" @@ -8881,6 +9001,15 @@ safe-event-emitter@^1.0.1: dependencies: events "^3.0.0" +safe-regex-test@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/safe-regex-test/-/safe-regex-test-1.1.0.tgz#7f87dfb67a3150782eaaf18583ff5d1711ac10c1" + integrity sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw== + dependencies: + call-bound "^1.0.2" + es-errors "^1.3.0" + is-regex "^1.2.1" + "safer-buffer@>= 2.1.2 < 3", "safer-buffer@>= 2.1.2 < 3.0.0", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: version "2.1.2" resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" @@ -9678,9 +9807,9 @@ tapable@^2.0.0, tapable@^2.1.1, tapable@^2.2.0: integrity sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ== tar-fs@~1.16.3: - version "1.16.3" - resolved "https://registry.yarnpkg.com/tar-fs/-/tar-fs-1.16.3.tgz#966a628841da2c4010406a82167cbd5e0c72d509" - integrity sha512-NvCeXpYx7OsmOh8zIOP/ebG55zZmxLE0etfWRbWok+q2Qo8x/vOR/IJT1taADXPe+jsiu9axDb3X4B+iIgNlKw== + version "1.16.4" + resolved "https://registry.yarnpkg.com/tar-fs/-/tar-fs-1.16.4.tgz#d3f0e1edf164b821f086640b1f0596f004021dc8" + integrity sha512-u3XczWoYAIVXe5GOKK6+VeWaHjtc47W7hyuTo3+4cNakcCcuDmlkYiiHEsECwTkcI3h1VUgtwBQ54+RvY6cM4w== dependencies: chownr "^1.0.1" mkdirp "^0.5.1" @@ -9856,10 +9985,10 @@ tr46@~0.0.3: resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== -ts-api-utils@^1.3.0: - version "1.4.3" - resolved "https://registry.yarnpkg.com/ts-api-utils/-/ts-api-utils-1.4.3.tgz#bfc2215fe6528fecab2b0fba570a2e8a4263b064" - integrity sha512-i3eMG77UTMD0hZhgRS562pv83RC6ukSAC2GMNWc+9dieh/+jDM5u5YG+NHX6VNDRHQcHwmsTHctP9LhbC3WxVw== +ts-api-utils@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ts-api-utils/-/ts-api-utils-2.0.0.tgz#b9d7d5f7ec9f736f4d0f09758b8607979044a900" + integrity sha512-xCt/TOAc+EOHS1XPnijD3/yzpH6qg2xppZO1YDqGoVsNXfQfzHpOdNuXwrwOU8u4ITXJyDCTyt8w5g1sZv9ynQ== ts-command-line-args@^2.2.0: version "2.5.1" @@ -10028,9 +10157,9 @@ typedarray@^0.0.6: integrity sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA== typescript@^5.5.4: - version "5.7.2" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.7.2.tgz#3169cf8c4c8a828cde53ba9ecb3d2b1d5dd67be6" - integrity sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg== + version "5.7.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.7.3.tgz#919b44a7dbb8583a9b856d162be24a54bf80073e" + integrity sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw== typical@^4.0.0: version "4.0.0" @@ -10114,12 +10243,12 @@ unpipe@1.0.0, unpipe@~1.0.0: integrity sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ== update-browserslist-db@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.1.1.tgz#80846fba1d79e82547fb661f8d141e0945755fe5" - integrity sha512-R8UzCaa9Az+38REPiJ1tXlImTJXlVfgHZsglwBD/k6nj76ctsH1E3q4doGrukiLQd3sGQYu56r5+lo5r94l29A== + version "1.1.2" + resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.1.2.tgz#97e9c96ab0ae7bcac08e9ae5151d26e6bc6b5580" + integrity sha512-PPypAm5qvlD7XMZC3BujecnaOxwhrtoFR+Dqkk5Aa/6DssiH0ibKoketaj9w8LP7Bont1rYeoV5plxD7RTEPRg== dependencies: escalade "^3.2.0" - picocolors "^1.1.0" + picocolors "^1.1.1" uri-js@^4.2.2: version "4.4.1" @@ -10185,6 +10314,11 @@ utils-merge@1.0.1: resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" integrity sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA== +uuid@^10.0.0: + version "10.0.0" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-10.0.0.tgz#5a95aa454e6e002725c79055fd42aaba30ca6294" + integrity sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ== + uuid@^3.3.2: version "3.4.0" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" @@ -10857,9 +10991,9 @@ yaml@^1.10.2: integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg== yaml@^2.2.2: - version "2.6.1" - resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.6.1.tgz#42f2b1ba89203f374609572d5349fb8686500773" - integrity sha512-7r0XPzioN/Q9kXBro/XPnA6kznR73DHq+GXh5ON7ZozRO6aMjbmiBuKste2wslTFkC5d1dw0GooOCepZXJ2SAg== + version "2.7.0" + resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.7.0.tgz#aef9bb617a64c937a9a748803786ad8d3ffe1e98" + integrity sha512-+hSoy/QHluxmC9kCIJyL/uyFmLmc+e5CFR5Wa+bpIhIj85LVb9ZH2nVnqrHoSvKogwODv0ClqZkmiSSaIH5LTA== yargs-parser@^18.1.2: version "18.1.3" @@ -10919,7 +11053,7 @@ yargs@^16.2.0: y18n "^5.0.5" yargs-parser "^20.2.2" -yargs@^17.7.1: +yargs@^17.7.1, yargs@^17.7.2: version "17.7.2" resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.2.tgz#991df39aca675a192b816e1e0363f9d75d2aa269" integrity sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w== From 77afdc0b1e0a6f543e8f0c35d97350ab59474b6b Mon Sep 17 00:00:00 2001 From: lufaque <95128636+lufaque@users.noreply.github.com> Date: Mon, 13 Jan 2025 18:38:09 +0300 Subject: [PATCH 51/54] add deprecated interfaces --- contracts/DexSwap.sol | 221 +++++++++++++++++- contracts/InfraCLF.sol | 10 +- contracts/InfraOrchestrator.sol | 96 +++++++- contracts/Interfaces/IDexSwap.sol | 38 +++ .../InfraOrchestrator.swap.t.sol | 33 +-- 5 files changed, 354 insertions(+), 44 deletions(-) diff --git a/contracts/DexSwap.sol b/contracts/DexSwap.sol index cc488278..cb511228 100644 --- a/contracts/DexSwap.sol +++ b/contracts/DexSwap.sol @@ -6,12 +6,18 @@ */ pragma solidity 0.8.20; +import {IDexSwap} from "./Interfaces/IDexSwap.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; +import {InfraCommon} from "./InfraCommon.sol"; import {InfraStorage} from "./Libraries/InfraStorage.sol"; -import {IDexSwap} from "./Interfaces/IDexSwap.sol"; import {LibConcero} from "./Libraries/LibConcero.sol"; -import {InfraCommon} from "./InfraCommon.sol"; +import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; + +/* DEPRECATED INTERFACES */ +import {ISwapRouter02, IV3SwapRouter} from "./Interfaces/ISwapRouter02.sol"; +import {ISwapRouter} from "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol"; +import {IWETH} from "./Interfaces/IWETH.sol"; +import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol"; /* ERRORS */ ///@notice error emitted when the caller is not allowed @@ -140,4 +146,213 @@ contract DexSwap is IDexSwap, InfraCommon, InfraStorage { } } } + + /* DEPRECATED FUNCTIONS */ + + using BytesLib for bytes; + + error UnwrapWNativeFailed(); + + /* CONSTANT VARIABLES */ + uint256 private constant BASE_CHAIN_ID = 8453; + uint256 private constant AVAX_CHAIN_ID = 43114; + + function entrypoint_DEPRECATED( + IDexSwap.SwapData_DEPRECATED[] memory _swapData, + address _recipient + ) external payable returns (uint256) { + if (address(this) != i_proxy) revert OnlyProxyContext(address(this)); + + uint256 swapDataLength = _swapData.length; + address destinationAddress = address(this); + address dstToken = _swapData[swapDataLength - 1].toToken; + uint256 dstTokenBalanceBefore = LibConcero.getBalance(dstToken, address(this)); + + for (uint256 i; i < swapDataLength; ) { + uint256 preSwapBalance = LibConcero.getBalance(_swapData[i].toToken, address(this)); + + if (i == swapDataLength - 1) { + destinationAddress = _recipient; + } + + _performSwap(_swapData[i], destinationAddress); + + if (i < swapDataLength - 1) { + if (_swapData[i].toToken != _swapData[i + 1].fromToken) { + revert InvalidTokenPath(); + } + uint256 postSwapBalance = LibConcero.getBalance( + _swapData[i].toToken, + address(this) + ); + uint256 remainingBalance = postSwapBalance - preSwapBalance; + _swapData[i + 1].fromAmount = remainingBalance; + } + + unchecked { + ++i; + } + } + + //TODO: optimise this line in the future + uint256 tokenAmountReceived = LibConcero.getBalance(dstToken, address(this)) - + dstTokenBalanceBefore; + + emit ConceroSwap( + _swapData[0].fromToken, + _swapData[swapDataLength - 1].toToken, + _swapData[0].fromAmount, + tokenAmountReceived, + _recipient + ); + + return tokenAmountReceived; + } + + function _performSwap( + IDexSwap.SwapData_DEPRECATED memory _swapData, + address destinationAddress + ) private { + DexType dexType = _swapData.dexType; + + if (dexType == DexType.UniswapV3Single) { + _swapUniV3Single(_swapData, destinationAddress); + } else if (dexType == DexType.UniswapV3Multi) { + _swapUniV3Multi(_swapData, destinationAddress); + } else if (dexType == DexType.WrapNative) { + _wrapNative(_swapData); + } else if (dexType == DexType.UnwrapWNative) { + _unwrapWNative(_swapData, destinationAddress); + } else { + revert InvalidDexData(); + } + } + + function _wrapNative(IDexSwap.SwapData_DEPRECATED memory _swapData) private { + address wrappedNative = _getWrappedNative(); + IWETH(wrappedNative).deposit{value: _swapData.fromAmount}(); + } + + function _unwrapWNative( + IDexSwap.SwapData_DEPRECATED memory _swapData, + address _recipient + ) private { + if (_swapData.fromToken != _getWrappedNative()) revert InvalidDexData(); + + IWETH(_swapData.fromToken).withdraw(_swapData.fromAmount); + + (bool sent, ) = _recipient.call{value: _swapData.fromAmount}(""); + if (!sent) { + revert UnwrapWNativeFailed(); + } + } + + /** + * @notice UniswapV3 function that executes single hop swaps + * @param _swapData the encoded swap data + * @dev This function can execute swap in any protocol compatible with UniV3 that implements the IV3SwapRouter + */ + function _swapUniV3Single( + IDexSwap.SwapData_DEPRECATED memory _swapData, + address _recipient + ) private { + if (_swapData.dexData.length == 0) revert EmptyDexData(); + (address routerAddress, uint24 fee, uint160 sqrtPriceLimitX96, uint256 deadline) = abi + .decode(_swapData.dexData, (address, uint24, uint160, uint256)); + + if (!s_routerAllowed[routerAddress]) revert DexRouterNotAllowed(); + + if (block.chainid == BASE_CHAIN_ID || block.chainid == AVAX_CHAIN_ID) { + IV3SwapRouter.ExactInputSingleParams memory dex = IV3SwapRouter.ExactInputSingleParams({ + tokenIn: _swapData.fromToken, + tokenOut: _swapData.toToken, + fee: fee, + recipient: _recipient, + amountIn: _swapData.fromAmount, + amountOutMinimum: _swapData.toAmountMin, + sqrtPriceLimitX96: sqrtPriceLimitX96 + }); + + IERC20(_swapData.fromToken).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); + ISwapRouter02(routerAddress).exactInputSingle(dex); + } else { + ISwapRouter.ExactInputSingleParams memory dex = ISwapRouter.ExactInputSingleParams({ + tokenIn: _swapData.fromToken, + tokenOut: _swapData.toToken, + fee: fee, + recipient: _recipient, + deadline: deadline, + amountIn: _swapData.fromAmount, + amountOutMinimum: _swapData.toAmountMin, + sqrtPriceLimitX96: sqrtPriceLimitX96 + }); + + IERC20(_swapData.fromToken).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); + ISwapRouter(routerAddress).exactInputSingle(dex); + } + } + + /** + * @notice UniswapV3 function that executes multi hop swaps + * @param _swapData the encoded swap data + * @dev This function can execute swap in any protocol compatible + */ + function _swapUniV3Multi( + IDexSwap.SwapData_DEPRECATED memory _swapData, + address _recipient + ) private { + if (_swapData.dexData.length == 0) revert EmptyDexData(); + + (address routerAddress, bytes memory path, uint256 deadline) = abi.decode( + _swapData.dexData, + (address, bytes, uint256) + ); + (address firstToken, address lastToken) = _extractTokens(path); + + if (!s_routerAllowed[routerAddress]) revert DexRouterNotAllowed(); + if (firstToken != _swapData.fromToken || lastToken != _swapData.toToken) + revert InvalidTokenPath(); + + if (block.chainid == BASE_CHAIN_ID || block.chainid == AVAX_CHAIN_ID) { + IV3SwapRouter.ExactInputParams memory params = IV3SwapRouter.ExactInputParams({ + path: path, + recipient: _recipient, + amountIn: _swapData.fromAmount, + amountOutMinimum: _swapData.toAmountMin + }); + + IERC20(_swapData.fromToken).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); + ISwapRouter02(routerAddress).exactInput(params); + } else { + ISwapRouter.ExactInputParams memory params = ISwapRouter.ExactInputParams({ + path: path, + recipient: _recipient, + deadline: deadline, + amountIn: _swapData.fromAmount, + amountOutMinimum: _swapData.toAmountMin + }); + + IERC20(_swapData.fromToken).safeIncreaseAllowance(routerAddress, _swapData.fromAmount); + ISwapRouter(routerAddress).exactInput(params); + } + } + + /* HELPER FUNCTIONS */ + function _extractTokens( + bytes memory _path + ) private pure returns (address _firstToken, address _lastToken) { + uint256 pathSize = _path.length; + + bytes memory tokenBytes = _path.slice(0, 20); + + assembly { + _firstToken := mload(add(tokenBytes, 20)) + } + + bytes memory secondTokenBytes = _path.slice(pathSize - 20, 20); + + assembly { + _lastToken := mload(add(secondTokenBytes, 20)) + } + } } diff --git a/contracts/InfraCLF.sol b/contracts/InfraCLF.sol index 68bc69d0..fbdd1e0a 100644 --- a/contracts/InfraCLF.sol +++ b/contracts/InfraCLF.sol @@ -293,7 +293,7 @@ contract InfraCLF is IInfraCLF, FunctionsClient, InfraCommon, InfraStorage { address bridgeableTokenDst = _getUSDCAddressByChainIndex(CCIPToken.usdc, i_chainIndex); uint256 amountUsdcAfterFees = amount - getDstTotalFeeInUsdc(amount); - IDexSwap.SwapData[] memory swapData = _decompressSwapData(compressedDstSwapData); + IDexSwap.SwapData_DEPRECATED[] memory swapData = _decompressSwapData(compressedDstSwapData); if (swapData.length == 0) { IPool(i_poolProxy).takeLoan(bridgeableTokenDst, amountUsdcAfterFees, receiver); @@ -311,7 +311,7 @@ contract InfraCLF is IInfraCLF, FunctionsClient, InfraCommon, InfraStorage { } function _performDstSwap( - IDexSwap.SwapData[] memory swapData, + IDexSwap.SwapData_DEPRECATED[] memory swapData, uint256 amountUsdcAfterFees, bytes32 conceroMessageId, address receiver, @@ -343,13 +343,13 @@ contract InfraCLF is IInfraCLF, FunctionsClient, InfraCommon, InfraStorage { function _decompressSwapData( bytes memory compressedDstSwapData - ) internal pure returns (IDexSwap.SwapData[] memory swapData) { + ) internal pure returns (IDexSwap.SwapData_DEPRECATED[] memory swapData) { bytes memory decompressedDstSwapData = LibZip.cdDecompress(compressedDstSwapData); if (decompressedDstSwapData.length == 0) { - return new IDexSwap.SwapData[](0); + return new IDexSwap.SwapData_DEPRECATED[](0); } else { - return abi.decode(decompressedDstSwapData, (IDexSwap.SwapData[])); + return abi.decode(decompressedDstSwapData, (IDexSwap.SwapData_DEPRECATED[])); } } diff --git a/contracts/InfraOrchestrator.sol b/contracts/InfraOrchestrator.sol index 734c6449..7c20cf74 100644 --- a/contracts/InfraOrchestrator.sol +++ b/contracts/InfraOrchestrator.sol @@ -73,7 +73,7 @@ contract InfraOrchestrator is /* MODIFIERS */ modifier validateBridgeData(BridgeData memory bridgeData) { - if (bridgeData.amount == 0 || bridgeData.receiver == address(0)) { + if (bridgeData.amount == 0 || bridgeData.receiver == ZERO_ADDRESS) { revert InvalidBridgeData(); } _; @@ -248,7 +248,7 @@ contract InfraOrchestrator is s_integratorFeesAmountByToken[msg.sender][token] = 0; s_totalIntegratorFeesAmountByToken[token] -= amount; - if (token == address(0)) { + if (token == ZERO_ADDRESS) { (bool success, ) = msg.sender.call{value: amount}(""); if (!success) revert TransferFailed(); } else { @@ -269,7 +269,7 @@ contract InfraOrchestrator is address recipient, address[] calldata tokens ) external payable nonReentrant onlyOwner { - if (recipient == address(0)) { + if (recipient == ZERO_ADDRESS) { revert InvalidRecipient(); } address usdc = _getUSDCAddressByChainIndex(CCIPToken.usdc, i_chainIndex); @@ -304,7 +304,7 @@ contract InfraOrchestrator is revert InvalidAmount(); } - if (token == address(0)) { + if (token == ZERO_ADDRESS) { (bool success, ) = payable(recipient).call{value: availableBalance}(""); if (!success) { revert TransferFailed(); @@ -344,7 +344,7 @@ contract InfraOrchestrator is address initialToken = swapData[0].fromToken; uint256 initialAmount = swapData[0].fromAmount; - if (initialToken != address(0)) { + if (initialToken != ZERO_ADDRESS) { LibConcero.transferFromERC20(initialToken, msg.sender, address(this), initialAmount); } else { if (initialAmount != msg.value) revert InvalidAmount(); @@ -425,4 +425,90 @@ contract InfraOrchestrator is emit IntegratorFeesCollected(integration.integrator, token, integratorFeeAmount); return integratorFeeAmount; } + + /* DEPRECATED FUNCTIONS */ + + modifier validateSrcSwapData_DEPRECATED(IDexSwap.SwapData_DEPRECATED[] memory swapData) { + if (swapData.length == 0 || swapData.length > 5 || swapData[0].fromAmount == 0) { + revert InvalidSwapData(); + } + _; + } + + function swapAndBridge( + BridgeData memory bridgeData, + IDexSwap.SwapData_DEPRECATED[] calldata srcSwapData, + bytes memory compressedDstSwapData, + Integration calldata integration + ) + external + payable + nonReentrant + validateSrcSwapData_DEPRECATED(srcSwapData) + validateBridgeData(bridgeData) + { + address usdc = _getUSDCAddressByChainIndex(CCIPToken.usdc, i_chainIndex); + + if (srcSwapData[srcSwapData.length - 1].toToken != usdc) { + revert InvalidSwapData(); + } + + _transferTokenFromUser(srcSwapData); + + uint256 amountReceivedFromSwap = _swap(srcSwapData, address(this)); + bridgeData.amount = + amountReceivedFromSwap - + _collectIntegratorFee(usdc, amountReceivedFromSwap, integration); + + _bridge(bridgeData, compressedDstSwapData); + } + + function swap( + IDexSwap.SwapData_DEPRECATED[] memory swapData, + address receiver, + Integration calldata integration + ) external payable nonReentrant validateSrcSwapData_DEPRECATED(swapData) { + _transferTokenFromUser(swapData); + swapData = _collectSwapFee(swapData, integration); + _swap(swapData, receiver); + } + + function _transferTokenFromUser(IDexSwap.SwapData_DEPRECATED[] memory swapData) internal { + address initialToken = swapData[0].fromToken; + uint256 initialAmount = swapData[0].fromAmount; + + if (initialToken != ZERO_ADDRESS) { + LibConcero.transferFromERC20(initialToken, msg.sender, address(this), initialAmount); + } else { + if (initialAmount != msg.value) revert InvalidAmount(); + } + } + + function _swap( + IDexSwap.SwapData_DEPRECATED[] memory swapData, + address receiver + ) internal returns (uint256) { + bytes memory delegateCallArgs = abi.encodeWithSelector( + IDexSwap.entrypoint_DEPRECATED.selector, + swapData, + receiver + ); + bytes memory delegateCallRes = LibConcero.safeDelegateCall(i_dexSwap, delegateCallArgs); + return abi.decode(delegateCallRes, (uint256)); + } + + function _collectSwapFee( + IDexSwap.SwapData_DEPRECATED[] memory swapData, + Integration calldata integration + ) internal returns (IDexSwap.SwapData_DEPRECATED[] memory) { + swapData[0].fromAmount -= (swapData[0].fromAmount / CONCERO_FEE_FACTOR); + + swapData[0].fromAmount -= _collectIntegratorFee( + swapData[0].fromToken, + swapData[0].fromAmount, + integration + ); + + return swapData; + } } diff --git a/contracts/Interfaces/IDexSwap.sol b/contracts/Interfaces/IDexSwap.sol index 2a88f9f4..dfe64bf7 100644 --- a/contracts/Interfaces/IDexSwap.sol +++ b/contracts/Interfaces/IDexSwap.sol @@ -29,4 +29,42 @@ interface IDexSwap { SwapData[] memory _swapData, address _recipient ) external payable returns (uint256); + + /* DEPRECATED INTERFACES */ + + ///@notice Concero Enum to track DEXes + enum DexType { + UniswapV2, + UniswapV2FoT, + SushiV3Single, + UniswapV3Single, + SushiV3Multi, + UniswapV3Multi, + Aerodrome, + AerodromeFoT, + UniswapV2Ether, + WrapNative, + UnwrapWNative + } + + // @notice Concero Struct to track DEX Data + struct SwapData_DEPRECATED { + DexType dexType; + address fromToken; + uint256 fromAmount; + address toToken; + uint256 toAmount; + uint256 toAmountMin; + bytes dexData; + } + + /** + * @notice Entry point function for the Orchestrator to take loans + * @param _swapData a struct array that contains dex information. + * @dev only the Orchestrator contract should be able to call this function + */ + function entrypoint_DEPRECATED( + SwapData_DEPRECATED[] memory _swapData, + address _recipient + ) external payable returns (uint256); } diff --git a/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol index 82fdc50e..24d454d9 100644 --- a/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol +++ b/test/foundry/InfraOrchestrator/InfraOrchestrator.swap.t.sol @@ -202,7 +202,7 @@ contract DexSwapTest is Test { function testFork_UniV3NativeToWethArbitrumViaRangoRouting() public - selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("ARB_RPC_URL"), 288423660)) + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("ARBITRUM_RPC_URL"), 288423660)) { uint256 fromAmount = 0.001 ether; uint256 toAmount = 0.0009975015e18; @@ -230,7 +230,7 @@ contract DexSwapTest is Test { function testFork_UniV3WethToNativeArbitrumViaRangoRouting() public - selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("ARB_RPC_URL"), 288423660)) + selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("ARBITRUM_RPC_URL"), 288423660)) { uint256 fromAmount = 0.001e18; uint256 toAmount = 0.0009975015 ether; @@ -815,35 +815,6 @@ contract DexSwapTest is Test { _performSwapAndCheck(swapData, user); } - function testFork_SushiSwapErc20ToErc20ViaSushiSwapApiRouting() - public - selectForkAndUpdateInfraProxy(vm.createFork(vm.envString("ARBITRUM_RPC_URL"), 294413780)) - { - uint256 fromAmount = 3e6; - uint256 toAmount = 3001520; - uint256 toAmountMin = 3001520; - address fromToken = 0xaf88d065e77c8cC2239327C5EDb3A432268e5831; - address toToken = 0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9; - address user = makeAddr("user"); - - // @notice swap data generated by sushiswap api - bytes - memory dexCallData = hex"2646478b000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000002dc6c0000000000000000000000000fd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb900000000000000000000000000000000000000000000000000000000002b827400000000000000000000000073da61408cf3b9ede79004950fa5b149021c18d800000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000004202af88d065e77c8cC2239327C5EDb3A432268e583101ffff01bE3aD6a5669Dc0B8b12FeBC03608860C31E2eef60173DA61408Cf3B9edE79004950Fa5b149021c18d8000000000000000000000000000000000000000000000000000000000000"; - - IDexSwap.SwapData[] memory swapData = new IDexSwap.SwapData[](1); - swapData[0] = IDexSwap.SwapData({ - dexRouter: vm.envAddress("SUSHISWAP_ROUTER_ARBITRUM"), - fromToken: fromToken, - fromAmount: fromAmount, - toToken: toToken, - toAmount: toAmount, - toAmountMin: toAmountMin, - dexCallData: dexCallData - }); - - _performSwapAndCheck(swapData, user); - } - /* HELPERS */ function _performSwapAndCheck(IDexSwap.SwapData[] memory swapData, address recipient) internal { From 7f11777038fff49f4366d4a087f2921648a3cff6 Mon Sep 17 00:00:00 2001 From: lufaque <95128636+lufaque@users.noreply.github.com> Date: Mon, 13 Jan 2025 18:40:07 +0300 Subject: [PATCH 52/54] add deprecated interfaces --- .env.clccip | 1 + 1 file changed, 1 insertion(+) diff --git a/.env.clccip b/.env.clccip index a4f007ad..b61cf005 100644 --- a/.env.clccip +++ b/.env.clccip @@ -59,6 +59,7 @@ QUICKSWAP_ROUTER_POLYGON=0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff # ODOS ODOS_ROUTER_V2_BASE=0x19cEeAd7105607Cd444F5ad10dd51356436095a1 +ODOS_ROUTER_OPTIMISM=0xCa423977156BB05b13A2BA3b76Bc5419E2fE9680 # ALIENBASE ALIENBASE_ROUTER_BASE=0x8c1A3cF8f83074169FE5D7aD50B978e1cD6b37c7 From fca93b3ad8de6a5a5be7853c943d9af9ace9f407 Mon Sep 17 00:00:00 2001 From: lufaque <95128636+lufaque@users.noreply.github.com> Date: Mon, 13 Jan 2025 19:07:58 +0300 Subject: [PATCH 53/54] add deprecated interfaces --- contracts/InfraCLF.sol | 153 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 134 insertions(+), 19 deletions(-) diff --git a/contracts/InfraCLF.sol b/contracts/InfraCLF.sol index fbdd1e0a..7fe47106 100644 --- a/contracts/InfraCLF.sol +++ b/contracts/InfraCLF.sol @@ -251,10 +251,77 @@ contract InfraCLF is IInfraCLF, FunctionsClient, InfraCommon, InfraStorage { s_requests[reqId].conceroMessageId = conceroMessageId; } - /** - * @notice Internal CLF function to finalize bridge process on Destination - * @param response the response from the CLF - */ + // /** + // * @notice Internal CLF function to finalize bridge process on Destination + // * @param response the response from the CLF + // */ + // function _handleDstFunctionsResponse(bytes32 requestId, bytes memory response) internal { + // bytes32 conceroMessageId = s_requests[requestId].conceroMessageId; + // bytes32 txDataHash = s_transactions[conceroMessageId].txDataHash; + // + // if (txDataHash == bytes32(0)) { + // revert TxDoesntExist(); + // } + // + // if (s_transactions[conceroMessageId].isConfirmed) { + // revert TxAlreadyConfirmed(); + // } else { + // s_transactions[conceroMessageId].isConfirmed = true; + // } + // + // ( + // address receiver, + // uint256 amount, + // bytes memory compressedDstSwapData + // ) = _decodeDstClfResponse(response); + // + // { + // bytes32 recomputedTxDataHash = keccak256( + // abi.encode( + // conceroMessageId, + // amount, + // i_chainSelector, + // receiver, + // keccak256(compressedDstSwapData) + // ) + // ); + // + // if (recomputedTxDataHash != txDataHash) { + // revert TxDataHashSumMismatch(); + // } + // } + // + // address bridgeableTokenDst = _getUSDCAddressByChainIndex(CCIPToken.usdc, i_chainIndex); + // uint256 amountUsdcAfterFees = amount - getDstTotalFeeInUsdc(amount); + // IDexSwap.SwapData_DEPRECATED[] memory swapData = _decompressSwapData(compressedDstSwapData); + // + // if (swapData.length == 0) { + // IPool(i_poolProxy).takeLoan(bridgeableTokenDst, amountUsdcAfterFees, receiver); + // } else { + // _performDstSwap( + // swapData, + // amountUsdcAfterFees, + // conceroMessageId, + // receiver, + // bridgeableTokenDst + // ); + // } + // + // emit TXReleased(conceroMessageId, receiver, bridgeableTokenDst, amountUsdcAfterFees); + // } + + function decompressSwapData_DEPRECATED( + bytes memory compressedDstSwapData + ) external pure returns (IDexSwap.SwapData_DEPRECATED[] memory swapData) { + bytes memory decompressedDstSwapData = LibZip.cdDecompress(compressedDstSwapData); + + if (decompressedDstSwapData.length == 0) { + return new IDexSwap.SwapData_DEPRECATED[](0); + } else { + return abi.decode(decompressedDstSwapData, (IDexSwap.SwapData_DEPRECATED[])); + } + } + function _handleDstFunctionsResponse(bytes32 requestId, bytes memory response) internal { bytes32 conceroMessageId = s_requests[requestId].conceroMessageId; bytes32 txDataHash = s_transactions[conceroMessageId].txDataHash; @@ -293,25 +360,42 @@ contract InfraCLF is IInfraCLF, FunctionsClient, InfraCommon, InfraStorage { address bridgeableTokenDst = _getUSDCAddressByChainIndex(CCIPToken.usdc, i_chainIndex); uint256 amountUsdcAfterFees = amount - getDstTotalFeeInUsdc(amount); - IDexSwap.SwapData_DEPRECATED[] memory swapData = _decompressSwapData(compressedDstSwapData); - if (swapData.length == 0) { - IPool(i_poolProxy).takeLoan(bridgeableTokenDst, amountUsdcAfterFees, receiver); - } else { - _performDstSwap( - swapData, - amountUsdcAfterFees, - conceroMessageId, - receiver, - bridgeableTokenDst - ); + try this.decompressSwapData_DEPRECATED(compressedDstSwapData) returns ( + IDexSwap.SwapData_DEPRECATED[] memory swapData + ) { + if (swapData.length == 0) { + IPool(i_poolProxy).takeLoan(bridgeableTokenDst, amountUsdcAfterFees, receiver); + } else { + _performDstSwap( + swapData, + amountUsdcAfterFees, + conceroMessageId, + receiver, + bridgeableTokenDst + ); + } + } catch { + IDexSwap.SwapData[] memory updatedSwapData = _decompressSwapData(compressedDstSwapData); + + if (updatedSwapData.length == 0) { + IPool(i_poolProxy).takeLoan(bridgeableTokenDst, amountUsdcAfterFees, receiver); + } else { + _performDstSwap( + updatedSwapData, + amountUsdcAfterFees, + conceroMessageId, + receiver, + bridgeableTokenDst + ); + } } emit TXReleased(conceroMessageId, receiver, bridgeableTokenDst, amountUsdcAfterFees); } function _performDstSwap( - IDexSwap.SwapData_DEPRECATED[] memory swapData, + IDexSwap.SwapData[] memory swapData, uint256 amountUsdcAfterFees, bytes32 conceroMessageId, address receiver, @@ -341,15 +425,46 @@ contract InfraCLF is IInfraCLF, FunctionsClient, InfraCommon, InfraStorage { } } + function _performDstSwap( + IDexSwap.SwapData_DEPRECATED[] memory swapData, + uint256 amountUsdcAfterFees, + bytes32 conceroMessageId, + address receiver, + address bridgeableTokenDst + ) internal { + //todo: remove with new DexSwap contract + //TODO: when validation fails, take loan and fulfil bridge TX + if (swapData.length > 5) { + revert InvalidSwapData(); + } + + swapData[0].fromAmount = amountUsdcAfterFees; + swapData[0].fromToken = bridgeableTokenDst; + + IPool(i_poolProxy).takeLoan(bridgeableTokenDst, amountUsdcAfterFees, address(this)); + + bytes memory swapDataArgs = abi.encodeWithSelector( + IDexSwap.entrypoint_DEPRECATED.selector, + swapData, + receiver + ); + + (bool success, ) = i_dexSwap.delegatecall(swapDataArgs); + if (!success) { + LibConcero.transferERC20(bridgeableTokenDst, amountUsdcAfterFees, receiver); + emit DstSwapFailed(conceroMessageId); + } + } + function _decompressSwapData( bytes memory compressedDstSwapData - ) internal pure returns (IDexSwap.SwapData_DEPRECATED[] memory swapData) { + ) internal pure returns (IDexSwap.SwapData[] memory swapData) { bytes memory decompressedDstSwapData = LibZip.cdDecompress(compressedDstSwapData); if (decompressedDstSwapData.length == 0) { - return new IDexSwap.SwapData_DEPRECATED[](0); + return new IDexSwap.SwapData[](0); } else { - return abi.decode(decompressedDstSwapData, (IDexSwap.SwapData_DEPRECATED[])); + return abi.decode(decompressedDstSwapData, (IDexSwap.SwapData[])); } } From 7b54eb7fa27ae44c47ca7a0c783e3c651e929f2d Mon Sep 17 00:00:00 2001 From: lufaque <95128636+lufaque@users.noreply.github.com> Date: Mon, 13 Jan 2025 19:24:31 +0300 Subject: [PATCH 54/54] add deprecated interfaces --- contracts/InfraOrchestrator.sol | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/contracts/InfraOrchestrator.sol b/contracts/InfraOrchestrator.sol index 7c20cf74..a2f0f5c0 100644 --- a/contracts/InfraOrchestrator.sol +++ b/contracts/InfraOrchestrator.sol @@ -426,7 +426,7 @@ contract InfraOrchestrator is return integratorFeeAmount; } - /* DEPRECATED FUNCTIONS */ + /* DEPRECATED FUNCTIONS START */ modifier validateSrcSwapData_DEPRECATED(IDexSwap.SwapData_DEPRECATED[] memory swapData) { if (swapData.length == 0 || swapData.length > 5 || swapData[0].fromAmount == 0) { @@ -511,4 +511,6 @@ contract InfraOrchestrator is return swapData; } + + /* DEPRECATED FUNCTIONS END */ }