test: Use calldata in USX integration test
- Needed to update the filler address with the one from the test - Removed unnecessary approval from non-integration test. The approval is now performed in the callback method.
This commit is contained in:
@@ -33,4 +33,4 @@ test_encode_balancer_v3:7bc3485026ac48b6cf9baf0a377477fff5703af8c71ea051a5f82c67
|
||||
test_single_encoding_strategy_balancer_v3:5c4b639c0000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000097ffedb80d4b2ca6105a07a4d90eb739c45a66600000000000000000000000030881baa943777f92dc934d53d3bfdf33382cab300000000000000000000000000000000000000000000000000000000000003e800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cd09f75e2bf2a4d11f3ab23f1389fcc1621c0cc200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000006503a6a84cd762d9707a21605b548aaab891562aab097ffedb80d4b2ca6105a07a4d90eb739c45a66630881baa943777f92dc934d53d3bfdf33382cab3f028ac624074d6793c36dc8a06ecec0f5a39a71800cd09f75e2bf2a4d11f3ab23f1389fcc1621c0cc2000000000000000000000000000000000000000000000000000000
|
||||
test_uniswap_v3_balancer_v3:e21dd0d3000000000000000000000000000000000000000000000000002386f26fc10000000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000004a220e6096b25eadb88358cb44068a324825467500000000000000000000000000000000000000000000000000000000018f61ec00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cd09f75e2bf2a4d11f3ab23f1389fcc1621c0cc20000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000d200692e234dae75c793f67a35089c9d99245e1c58470bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc22260fac5e5542a773aa44fbcfedf7c193bc2c599000bb83ede3eca2a72b3aecc820e955b36f38437d01395cbcdf9626bc03e24f779434178a73a0b4bad62ed0000006503a6a84cd762d9707a21605b548aaab891562aab2260fac5e5542a773aa44fbcfedf7c193bc2c5994a220e6096b25eadb88358cb44068a3248254675571bea0e99e139cd0b6b7d9352ca872dfe0d72dd01cd09f75e2bf2a4d11f3ab23f1389fcc1621c0cc20000000000000000000000000000
|
||||
test_single_swap_strategy_encoder:30ace1b10000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000006d70b85442ed96492800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cd09f75e2bf2a4d11f3ab23f1389fcc1621c0cc2000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000006880f27700000000000000000000000000000000000000000000000000000000000000000000000000000000000000003ede3eca2a72b3aecc820e955b36f38437d013950000000000000000000000000000000000000000000000000000000068596c7f00000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000000411d60a13b5e993ef8088cb2cb7e16281f47fbc329bd0ec2a48165e7898542a7ed12fe7ffdec713b6d94e99ddf0a384674617b6190b8534491d525ecb090c8e4881c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000525615deb798bb3e4dfa0139dfa1b3d433cc23b72fc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2a478c2975ab1ea89e8196811f51a7b7ade33eb11cd09f75e2bf2a4d11f3ab23f1389fcc1621c0cc200000000000000000000000000000000
|
||||
test_sequential_swap_unix:0101e21dd0d300000000000000000000000000000000000000000000006c6b935b8bbd4000000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec700000000000000000000000000000000000000000000000000000000769cfd8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cd09f75e2bf2a4d11f3ab23f1389fcc1621c0cc20000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000bf00692e234dae75c793f67a35089c9d99245e1c58470b6b175474e89094c44da98b954eedeac495271d0fa0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000643041cbd36888becc7bbcbc0045e3b1f144466f5f5777d92f208679db4b9778590fa3cab3ac9e2168010000525615deb798bb3e4dfa0139dfa1b3d433cc23b72fa0b86991c6218b36c1d19d4a2e9eb0ce3606eb483041cbd36888becc7bbcbc0045e3b1f144466f5fcd09f75e2bf2a4d11f3ab23f1389fcc1621c0cc2010200
|
||||
test_sequential_swap_usx:0101e21dd0d300000000000000000000000000000000000000000000006c6b935b8bbd4000000000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec700000000000000000000000000000000000000000000000000000000769cfd80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006d9da78b6a5bedca287aa5d49613ba36b90c15c40000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000bf00692e234dae75c793f67a35089c9d99245e1c58470b6b175474e89094c44da98b954eedeac495271d0fa0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000643041cbd36888becc7bbcbc0045e3b1f144466f5f5777d92f208679db4b9778590fa3cab3ac9e2168010000525615deb798bb3e4dfa0139dfa1b3d433cc23b72fa0b86991c6218b36c1d19d4a2e9eb0ce3606eb483041cbd36888becc7bbcbc0045e3b1f144466f5f6d9da78b6a5bedca287aa5d49613ba36b90c15c4010200
|
||||
|
||||
@@ -72,9 +72,7 @@ contract UniswapXFillerTest is Test, TychoRouterTestSetup {
|
||||
abi.encodePacked(true, true, tychoRouterData);
|
||||
|
||||
deal(WETH_ADDR, address(filler), amountIn);
|
||||
vm.startPrank(address(filler));
|
||||
IERC20(WETH_ADDR).approve(tychoRouterAddr, amountIn);
|
||||
vm.stopPrank();
|
||||
|
||||
ResolvedOrder[] memory orders = new ResolvedOrder[](1);
|
||||
OutputToken[] memory outputs = new OutputToken[](1);
|
||||
outputs[0] = OutputToken({
|
||||
@@ -82,7 +80,7 @@ contract UniswapXFillerTest is Test, TychoRouterTestSetup {
|
||||
amount: 1847751195973566072891,
|
||||
recipient: BOB
|
||||
});
|
||||
// Mostly irrelevant fields for this test - we only need token input and outputs
|
||||
// Irrelevant fields for this test - we only need token output
|
||||
// info for the sake of testing.
|
||||
orders[0] = ResolvedOrder({
|
||||
info: OrderInfo({
|
||||
@@ -96,7 +94,6 @@ contract UniswapXFillerTest is Test, TychoRouterTestSetup {
|
||||
input: InputToken({
|
||||
token: address(WETH_ADDR),
|
||||
amount: amountIn,
|
||||
// We need the proper maxAmount for our approval to work
|
||||
maxAmount: amountIn
|
||||
}),
|
||||
outputs: outputs,
|
||||
@@ -119,7 +116,45 @@ contract UniswapXFillerTest is Test, TychoRouterTestSetup {
|
||||
assertGe(IERC20(DAI_ADDR).balanceOf(BOB), amountOut);
|
||||
}
|
||||
|
||||
function testExecuteIntegration() public {
|
||||
function testCallbackIntegration() public {
|
||||
fillerSetup();
|
||||
deal(DAI_ADDR, address(filler), 2000 ether);
|
||||
uint256 amountOut = 1994835180;
|
||||
|
||||
ResolvedOrder[] memory orders = new ResolvedOrder[](1);
|
||||
OutputToken[] memory outputs = new OutputToken[](1);
|
||||
|
||||
outputs[0] =
|
||||
OutputToken({token: address(USDT_ADDR), amount: 0, recipient: BOB});
|
||||
// Irrelevant fields for this test - we only need token output
|
||||
// info for the sake of testing.
|
||||
orders[0] = ResolvedOrder({
|
||||
info: OrderInfo({
|
||||
reactor: address(0),
|
||||
swapper: address(0),
|
||||
nonce: 0,
|
||||
deadline: 0,
|
||||
additionalValidationContract: address(0),
|
||||
additionalValidationData: ""
|
||||
}),
|
||||
input: InputToken({token: address(DAI_ADDR), amount: 0, maxAmount: 0}),
|
||||
outputs: outputs,
|
||||
sig: "",
|
||||
hash: ""
|
||||
});
|
||||
bytes memory callbackData =
|
||||
loadCallDataFromFile("test_sequential_swap_usx");
|
||||
|
||||
vm.startPrank(REACTOR);
|
||||
filler.reactorCallback(orders, callbackData);
|
||||
vm.stopPrank();
|
||||
|
||||
// Check that the funds are in the filler at the end of the function call
|
||||
uint256 finalBalance = IERC20(USDT_ADDR).balanceOf(address(filler));
|
||||
assertGe(finalBalance, amountOut);
|
||||
}
|
||||
|
||||
function testExecute() public {
|
||||
fillerSetup();
|
||||
// tx: 0x5b602b7d0a37e241bd032a907b9ddf314e9f2fc2104fd91cb55bdb3d8dfe4e9c
|
||||
// 0.2 WBTC -> USDC
|
||||
|
||||
@@ -19,7 +19,7 @@ use crate::common::{
|
||||
mod common;
|
||||
|
||||
#[test]
|
||||
fn test_sequential_swap_unix() {
|
||||
fn test_sequential_swap_usx() {
|
||||
// Replicates real uniswap X order settled in tx:
|
||||
// 0x005d7b150017ba1b59d2f99395ccae7bda9b739938ade4e509817e32760aaf9d
|
||||
// Performs a sequential
|
||||
@@ -28,8 +28,9 @@ fn test_sequential_swap_unix() {
|
||||
// DAI ───(USV3)──> USDC ───(USV2)──> USDT
|
||||
// Creates all the calldata needed for the uniswap X callbackData
|
||||
|
||||
let filler = Bytes::from_str("0xcd09f75E2BF2A4d11F3AB23f1389FcC1621c0cc2").unwrap();
|
||||
let unix_reactor = Address::from_str("0x00000011F84B9aa48e5f8aA8B9897600006289Be").unwrap();
|
||||
let filler = Bytes::from_str("0x6D9da78B6A5BEdcA287AA5d49613bA36b90c15C4").unwrap();
|
||||
let usx_reactor = Address::from_str("0x00000011F84B9aa48e5f8aA8B9897600006289Be")
|
||||
.unwrap();
|
||||
|
||||
let dai = dai();
|
||||
let usdc = usdc();
|
||||
@@ -106,12 +107,12 @@ fn test_sequential_swap_unix() {
|
||||
.unwrap();
|
||||
|
||||
let token_out_approval_needed = token_approvals_manager
|
||||
.approval_needed(bytes_to_address(&usdc).unwrap(), filler_address, unix_reactor)
|
||||
.approval_needed(bytes_to_address(&usdc).unwrap(), filler_address, usx_reactor)
|
||||
.unwrap();
|
||||
|
||||
let full_calldata =
|
||||
(token_in_approval_needed, token_out_approval_needed, tycho_calldata).abi_encode_packed();
|
||||
|
||||
let hex_calldata = encode(&full_calldata);
|
||||
write_calldata_to_file("test_sequential_swap_unix", hex_calldata.as_str());
|
||||
write_calldata_to_file("test_sequential_swap_usx", hex_calldata.as_str());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user