test: rewrite testExecute without hack
- We can use the same transaction as the integration test, with a different low-fee USV3 pool. - Don't need to roll the fork either.
This commit is contained in:
@@ -119,7 +119,7 @@ contract UniswapXFillerTest is Test, TychoRouterTestSetup {
|
||||
function testExecuteIntegration() public {
|
||||
fillerSetup();
|
||||
|
||||
// Set to time with no more exclusivity penalty for not being exclusive filler
|
||||
// Set to time with no more penalty for not being exclusive filler
|
||||
vm.warp(1752050415);
|
||||
|
||||
deal(
|
||||
@@ -153,37 +153,40 @@ contract UniswapXFillerTest is Test, TychoRouterTestSetup {
|
||||
vm.stopPrank();
|
||||
}
|
||||
|
||||
function testExecute() public {
|
||||
function testExecutes() public {
|
||||
fillerSetup();
|
||||
|
||||
// Overwrite block so signature doesn't expire.
|
||||
vm.rollFork(22788691);
|
||||
// Set to time with no more penalty for not being exclusive filler
|
||||
vm.warp(1752050415);
|
||||
|
||||
// tx: 0x5b602b7d0a37e241bd032a907b9ddf314e9f2fc2104fd91cb55bdb3d8dfe4e9c
|
||||
// 0.2 WBTC -> USDC
|
||||
// tx: 0x005d7b150017ba1b59d2f99395ccae7bda9b739938ade4e509817e32760aaf9d
|
||||
// DAI ──> USDT
|
||||
SignedOrder memory order = SignedOrder({
|
||||
order: hex"000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001000000000000000000000000004449cd34d1eb1fedcf02a1be3834ffde8e6a61800000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000000000000000000000000000000000000001312d000000000000000000000000000000000000000000000000000000000001312d0000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000042000000000000000000000000000000011f84b9aa48e5f8aa8b9897600006289be0000000000000000000000000d1100e55ef6c4e5800f4624b1e6121d798eb696046832163cef9c09382cf582bb878b37a42933ea2bdf33757942ab2747b3500100000000000000000000000000000000000000000000000000000000685d4150000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000004f921447c00000000000000000000000000000000000000000000000000000004f1464dea0000000000000000000000000d1100e55ef6c4e5800f4624b1e6121d798eb696000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000330d86400000000000000000000000000000000000000000000000000000000032bce2600000000000000000000000027213e28d7fda5c57fe9e5dd923818dbccf71c4700000000000000000000000000000000000000000000000000000000685d407600000000000000000000000000000000000000000000000000000000685d40b2000000000000000000000000225a38bc71102999dd13478bfabd7c4d53f2dc170000000000000000000000000000000000000000000000000000000000000064000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000004fb7f8815000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000417067afde0759ae3653dad5d412519f488b6e9ed8955b3e3b8606e85c0198a9d71075295d33fe84b5ccc9c2d38a7ea79d7fad68128a37cabc5557342756a4e8311b00000000000000000000000000000000000000000000000000000000000000",
|
||||
sig: hex"41b7a696a04f897d1e4ccaf88136092169c2874242d55c3fe4c028125efe95340f5ce764b9dce9d2cae241d97ceb515d3f1739972ca884ed51b2870045438c3a1c"
|
||||
order: hex"000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001000000000000000000000000004449cd34d1eb1fedcf02a1be3834ffde8e6a61800000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000006c6b935b8bbd40000000000000000000000000000000000000000000000000006c6b935b8bbd40000000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000280000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000011f84b9aa48e5f8aa8b9897600006289be000000000000000000000000d213e6f6dcb2dbac03fa28b893f6da1bd822e8520468320351debb1ddbfb032a239d699e3d54e3ce2b6e1037cd836a784c80b60100000000000000000000000000000000000000000000000000000000686e2bf9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec70000000000000000000000000000000000000000000000000000000076f9f4870000000000000000000000000000000000000000000000000000000076566300000000000000000000000000d213e6f6dcb2dbac03fa28b893f6da1bd822e85200000000000000000000000000000000000000000000000000000000686e2aee00000000000000000000000000000000000000000000000000000000686e2b2a000000000000000000000000ce79b081c0c924cb67848723ed3057234d10fc6b0000000000000000000000000000000000000000000000000000000000000064000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000007727b5f40000000000000000000000000000000000000000000000000000000000000041a2d261cd4c8930428260f18b55e3036024bac68d58cb2ee6161e6395b0984b827104158713d44ddc4e14d852b48d93d95a4e60b8d5be1ef431c1e82d2f76a4111b00000000000000000000000000000000000000000000000000000000000000",
|
||||
sig: hex"f4cc5734820e4ee08519045c83a25b75687756053b3d6c0fda2141380dfa6ef17b40f64d9279f237e96982c6ba53a202e01a4358fd66e027c9bdf200d5626f441c"
|
||||
});
|
||||
|
||||
uint256 amountIn = 0.2 * 10 ** 8;
|
||||
uint256 amountIn = 2000000000000000000000;
|
||||
bool zeroForOne = true;
|
||||
uint24 fee = 100;
|
||||
bytes memory protocolData = abi.encodePacked(
|
||||
WBTC_ADDR,
|
||||
USDC_WBTC_POOL,
|
||||
DAI_ADDR,
|
||||
USDT_ADDR,
|
||||
fee,
|
||||
fillerAddr,
|
||||
DAI_USDT_USV3,
|
||||
zeroForOne,
|
||||
RestrictTransferFrom.TransferType.TransferFrom
|
||||
);
|
||||
|
||||
bytes memory swap =
|
||||
encodeSingleSwap(address(usv2Executor), protocolData);
|
||||
encodeSingleSwap(address(usv3Executor), protocolData);
|
||||
|
||||
bytes memory tychoRouterData = abi.encodeWithSelector(
|
||||
tychoRouter.singleSwap.selector,
|
||||
amountIn,
|
||||
WBTC_ADDR,
|
||||
USDC_ADDR,
|
||||
DAI_ADDR,
|
||||
USDT_ADDR,
|
||||
1,
|
||||
false,
|
||||
false,
|
||||
@@ -202,13 +205,8 @@ contract UniswapXFillerTest is Test, TychoRouterTestSetup {
|
||||
IERC20(WBTC_ADDR).approve(tychoRouterAddr, amountIn);
|
||||
vm.stopPrank();
|
||||
|
||||
// This is a hack because the tx we are trying to replicate returns a looooot more USDC than what the uni v2 pool does at this point
|
||||
// 21613301393 is the difference and 54068100 is the fee
|
||||
deal(USDC_ADDR, address(filler), 21613301393 + 54068100);
|
||||
|
||||
vm.startPrank(EXECUTOR);
|
||||
filler.execute(order, callbackData);
|
||||
console.logUint(IERC20(USDC_ADDR).balanceOf(address(filler)));
|
||||
vm.stopPrank();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user