diff --git a/foundry/test/TychoRouter.t.sol b/foundry/test/TychoRouter.t.sol index 8b0202a..4a79e5c 100644 --- a/foundry/test/TychoRouter.t.sol +++ b/foundry/test/TychoRouter.t.sol @@ -212,33 +212,4 @@ contract TychoRouterTest is TychoRouterTestSetup { vm.expectRevert(TychoRouter__EmptySwaps.selector); tychoRouter.exposedSplitSwap(amountIn, 2, swaps); } - - function testCurveIntegration() public { - deal(UWU_ADDR, ALICE, 1 ether); - - vm.startPrank(ALICE); - IERC20(UWU_ADDR).approve(tychoRouterAddr, type(uint256).max); - // Encoded solution generated using `test_split_encoding_strategy_curve` - (bool success,) = tychoRouterAddr.call( - hex"0a83cb080000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000055c08ca52497e2f1534b59e2917bf524d4765257000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000cd09f75e2bf2a4d11f3ab23f1389fcc1621c0cc20000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000005b005900010000001d1499e622d69689cdf9004d05ec547d650ff21155c08ca52497e2f1534b59e2917bf524d4765257c02aaa39b223fe8d0a0e5c4f27ead9083c756cc277146b0a1d08b6844376df6d9da99ba7f1b19e71020100010000000000" - ); - - assertEq(IERC20(WETH_ADDR).balanceOf(ALICE), 4691958787921); - - vm.stopPrank(); - } - - function testCurveIntegrationStETH() public { - deal(ALICE, 1 ether); - - vm.startPrank(ALICE); - // Encoded solution generated using `test_split_encoding_strategy_curve_st_eth` - (bool success,) = tychoRouterAddr.call{value: 1 ether}( - hex"0a83cb080000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ae7ab96520de3a18e5e111b5eaab095312d7fe840000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000cd09f75e2bf2a4d11f3ab23f1389fcc1621c0cc20000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000005b005900010000001d1499e622d69689cdf9004d05ec547d650ff211eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeae7ab96520de3a18e5e111b5eaab095312d7fe84dc24316b9ae028f1497c275eb9192a3ea0f67022010001000000000000" - ); - - assertEq(IERC20(STETH_ADDR).balanceOf(ALICE), 1000754689941529590); - - vm.stopPrank(); - } } diff --git a/foundry/test/TychoRouterIntegration.t.sol b/foundry/test/TychoRouterIntegration.t.sol index 85ade39..27ac0e9 100644 --- a/foundry/test/TychoRouterIntegration.t.sol +++ b/foundry/test/TychoRouterIntegration.t.sol @@ -177,7 +177,7 @@ contract TychoRouterTestIntegration is TychoRouterTestSetup { // This allows us to change the code at that address to be the testing executor code vm.etch( 0x4f88f6630a33dB05BEa1FeF7Dc7ff7508D1c531D, - 0x2a07706473244BC757E10F2a9E86fB532828afe3.code + 0x3D7Ebc40AF7092E3F1C81F2e996cbA5Cae2090d7.code ); deal(ALICE, 1 ether); @@ -187,7 +187,7 @@ contract TychoRouterTestIntegration is TychoRouterTestSetup { vm.startPrank(ALICE); // Encoded solution generated using `test_split_encoding_strategy_ekubo` (bool success,) = address(tychoRouter).call{value: 1 ether}( - hex"79b9b93b0000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000cd09f75e2bf2a4d11f3ab23f1389fcc1621c0cc200000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000077007500010000002a07706473244bc757e10f2a9e86fb532828afe31d1499e622d69689cdf9004d05ec547d650ff2110000000000000000000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4851d02a5948496a67827242eabc5725531342527c000000000000000000000000000000000000000000" + hex"79b9b93b0000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000cd09f75e2bf2a4d11f3ab23f1389fcc1621c0cc200000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000077007500010000003d7ebc40af7092e3f1c81f2e996cba5cae2090d7a4ad4f68d0b91cfd19687c881e50f3a00242828c0000000000000000000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4851d02a5948496a67827242eabc5725531342527c000000000000000000000000000000000000000000" ); uint256 balancerAfter = IERC20(USDC_ADDR).balanceOf(ALICE); @@ -321,4 +321,33 @@ contract TychoRouterTestIntegration is TychoRouterTestSetup { vm.stopPrank(); } + + function testSplitCurveIntegration() public { + deal(UWU_ADDR, ALICE, 1 ether); + + vm.startPrank(ALICE); + IERC20(UWU_ADDR).approve(tychoRouterAddr, type(uint256).max); + // Encoded solution generated using `test_split_encoding_strategy_curve` + (bool success,) = tychoRouterAddr.call( + hex"79b9b93b0000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000055c08ca52497e2f1534b59e2917bf524d4765257000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000cd09f75e2bf2a4d11f3ab23f1389fcc1621c0cc20000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000005b005900010000001d1499e622d69689cdf9004d05ec547d650ff21155c08ca52497e2f1534b59e2917bf524d4765257c02aaa39b223fe8d0a0e5c4f27ead9083c756cc277146b0a1d08b6844376df6d9da99ba7f1b19e71020100010000000000" + ); + + assertEq(IERC20(WETH_ADDR).balanceOf(ALICE), 4691958787921); + + vm.stopPrank(); + } + + function testSplitCurveIntegrationStETH() public { + deal(ALICE, 1 ether); + + vm.startPrank(ALICE); + // Encoded solution generated using `test_split_encoding_strategy_curve_st_eth` + (bool success,) = tychoRouterAddr.call{value: 1 ether}( + hex"79b9b93b0000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ae7ab96520de3a18e5e111b5eaab095312d7fe840000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000cd09f75e2bf2a4d11f3ab23f1389fcc1621c0cc20000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000005b005900010000001d1499e622d69689cdf9004d05ec547d650ff211eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeae7ab96520de3a18e5e111b5eaab095312d7fe84dc24316b9ae028f1497c275eb9192a3ea0f67022010001000000000000" + ); + + assertEq(IERC20(STETH_ADDR).balanceOf(ALICE), 1000754689941529590); + + vm.stopPrank(); + } } diff --git a/src/encoding/evm/strategy_encoder/strategy_encoders.rs b/src/encoding/evm/strategy_encoder/strategy_encoders.rs index 0c27841..a9ecf61 100644 --- a/src/encoding/evm/strategy_encoder/strategy_encoders.rs +++ b/src/encoding/evm/strategy_encoder/strategy_encoders.rs @@ -2194,7 +2194,7 @@ mod tests { eth_chain(), swap_encoder_registry, None, - Some(Bytes::from_str("0x3Ede3eCa2a72B3aeCC820E955B36f38437D01395").unwrap()), + Bytes::from_str("0x3Ede3eCa2a72B3aeCC820E955B36f38437D01395").unwrap(), ) .unwrap(); @@ -2256,7 +2256,7 @@ mod tests { eth_chain(), swap_encoder_registry, None, - Some(Bytes::from_str("0x3Ede3eCa2a72B3aeCC820E955B36f38437D01395").unwrap()), + Bytes::from_str("0x3Ede3eCa2a72B3aeCC820E955B36f38437D01395").unwrap(), ) .unwrap(); diff --git a/src/encoding/evm/utils.rs b/src/encoding/evm/utils.rs index f2a6ed1..dea3703 100644 --- a/src/encoding/evm/utils.rs +++ b/src/encoding/evm/utils.rs @@ -139,6 +139,19 @@ pub fn get_runtime() -> Result<(Handle, Option>), EncodingError> { } } +/// Gets the client used for interacting with the EVM-compatible network. +pub async fn get_client() -> Result>, EncodingError> { + dotenv::dotenv().ok(); + let eth_rpc_url = env::var("RPC_URL") + .map_err(|_| EncodingError::FatalError("Missing RPC_URL in environment".to_string()))?; + let client = ProviderBuilder::new() + .on_builtin(ð_rpc_url) + .await + .map_err(|_| EncodingError::FatalError("Failed to build provider".to_string()))?; + Ok(Arc::new(client)) +} + + /// Uses prefix-length encoding to efficient encode action data. /// /// Prefix-length encoding is a data encoding method where the beginning of a data segment @@ -154,19 +167,6 @@ pub fn ple_encode(action_data_array: Vec>) -> Vec { encoded_action_data } - -/// Gets the client used for interacting with the EVM-compatible network. -pub async fn get_client() -> Result>, EncodingError> { - dotenv::dotenv().ok(); - let eth_rpc_url = env::var("RPC_URL") - .map_err(|_| EncodingError::FatalError("Missing RPC_URL in environment".to_string()))?; - let client = ProviderBuilder::new() - .on_builtin(ð_rpc_url) - .await - .map_err(|_| EncodingError::FatalError("Failed to build provider".to_string()))?; - Ok(Arc::new(client)) -} - #[cfg(test)] mod tests { use num_bigint::BigUint;