-
Notifications
You must be signed in to change notification settings - Fork 3
UniswapV4SwapHelpers contract #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
vnavascues
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if you agree with the suggestions (besides custom errors :D)
| }) | ||
| ); | ||
|
|
||
| if (zeroForOne) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the if...else (or ?) is used to init param1 and param2, the duplicated code present in if (zeroForOne) {...} else {...} can be removed.
| UNIVERSAL_ROUTER.execute{ value: msg.value }(commands, inputs, deadline); | ||
|
|
||
| address tokenOut = Currency.unwrap(zeroForOne ? poolKey.currency1 : poolKey.currency0); | ||
| amountOut = IERC20(tokenOut).balanceOf(address(this)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imho we need to do the balance diff here:
- tokenOutBalancePre
- Currency.unwrap
- tokenOutBalancePost
- amountOut = tokenOutBalancePost - tokenOutBalancePre
src/helpers/UniswapV4SwapHelpers.sol
Outdated
| } | ||
|
|
||
| function approveToken(address token, uint256 amount) private { | ||
| IERC20(token).approve(address(PERMIT2), amount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better off using SafeERC20 & forceApprove (e.g., handle well USDT) around, no?
No description provided.