fix: Native ETH input/output integration tests/fixes
- Only for single swaps - Used USV4 for this because it's the only DEX we support that allows native ETH swaps - For Native ETH input single swaps, we need to properly check the remaining amount (we were treating them wronly like ERC20 tokens) - For Native ETH output single swaps, we were passing the incorrect currency (the settle always needs to be the out token and the take always needs to be the in token, this should not depend on the zeroForOne value).
This commit is contained in:
@@ -124,7 +124,13 @@ contract TychoRouter is AccessControl, Dispatcher, Pausable, ReentrancyGuard {
|
||||
revert TychoRouter__NegativeSlippage(amountOut, minAmountOut);
|
||||
}
|
||||
|
||||
uint256 leftoverAmountIn = IERC20(tokenIn).balanceOf(address(this));
|
||||
uint256 leftoverAmountIn;
|
||||
if (tokenIn == address(0)) {
|
||||
leftoverAmountIn = address(this).balance;
|
||||
} else {
|
||||
leftoverAmountIn = IERC20(tokenIn).balanceOf(address(this));
|
||||
}
|
||||
|
||||
if (leftoverAmountIn > 0) {
|
||||
revert TychoRouter__AmountInNotFullySpent(leftoverAmountIn);
|
||||
}
|
||||
@@ -209,7 +215,13 @@ contract TychoRouter is AccessControl, Dispatcher, Pausable, ReentrancyGuard {
|
||||
revert TychoRouter__NegativeSlippage(amountOut, minAmountOut);
|
||||
}
|
||||
|
||||
uint256 leftoverAmountIn = IERC20(tokenIn).balanceOf(address(this));
|
||||
uint256 leftoverAmountIn;
|
||||
if (tokenIn == address(0)) {
|
||||
leftoverAmountIn = address(this).balance;
|
||||
} else {
|
||||
leftoverAmountIn = IERC20(tokenIn).balanceOf(address(this));
|
||||
}
|
||||
|
||||
if (leftoverAmountIn > 0) {
|
||||
revert TychoRouter__AmountInNotFullySpent(leftoverAmountIn);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user