Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
| function swapExactTokensForTokens( | ||
| address inputToken, | ||
| uint256 amountIn, | ||
| address outputToken, | ||
| address uniswapRouter, | ||
| address wzeta | ||
| ) internal returns (uint256) { | ||
| // Approve router to spend input tokens | ||
| IERC20(inputToken).approve(uniswapRouter, amountIn); | ||
|
|
||
| // Try direct swap first | ||
| try | ||
| ISwapRouter(uniswapRouter).exactInputSingle( | ||
| ISwapRouter.ExactInputSingleParams({ | ||
| tokenIn: inputToken, | ||
| tokenOut: outputToken, | ||
| fee: POOL_FEE, | ||
| recipient: address(this), | ||
| deadline: block.timestamp + 15 minutes, | ||
| amountIn: amountIn, | ||
| amountOutMinimum: 0, // Let Uniswap handle slippage | ||
| sqrtPriceLimitX96: 0 | ||
| }) | ||
| ) | ||
| returns (uint256 amountOut) { | ||
| return amountOut; | ||
| } catch { | ||
| // If direct swap fails, try through WZETA using exactInput for multi-hop | ||
| // The path is encoded as (tokenIn, fee, WZETA, fee, tokenOut) | ||
| bytes memory path = abi.encodePacked( | ||
| inputToken, | ||
| POOL_FEE, | ||
| wzeta, | ||
| POOL_FEE, | ||
| outputToken | ||
| ); | ||
|
|
||
| ISwapRouter.ExactInputParams memory params = ISwapRouter | ||
| .ExactInputParams({ | ||
| path: path, | ||
| recipient: address(this), | ||
| deadline: block.timestamp + 15 minutes, | ||
| amountIn: amountIn, | ||
| amountOutMinimum: 0 // Let Uniswap handle slippage | ||
| }); | ||
|
|
||
| return ISwapRouter(uniswapRouter).exactInput(params); | ||
| } | ||
| } |
Check warning
Code scanning / Slither
Unused return Medium
| function swapTokensForExactTokens( | ||
| address inputToken, | ||
| uint256 amountOut, | ||
| address outputToken, | ||
| address uniswapRouter, | ||
| address wzeta | ||
| ) internal returns (uint256) { | ||
| // Approve router to spend input tokens | ||
| IERC20(inputToken).approve(uniswapRouter, type(uint256).max); | ||
|
|
||
| // Try direct swap first | ||
| try | ||
| ISwapRouter(uniswapRouter).exactOutputSingle( | ||
| ISwapRouter.ExactOutputSingleParams({ | ||
| tokenIn: inputToken, | ||
| tokenOut: outputToken, | ||
| fee: POOL_FEE, | ||
| recipient: address(this), | ||
| deadline: block.timestamp + 15 minutes, | ||
| amountOut: amountOut, | ||
| amountInMaximum: type(uint256).max, // Let Uniswap handle slippage | ||
| sqrtPriceLimitX96: 0 | ||
| }) | ||
| ) | ||
| returns (uint256 amountIn) { | ||
| return amountIn; | ||
| } catch { | ||
| // If direct swap fails, try through WZETA using exactOutput for multi-hop | ||
| // The path is encoded as (tokenOut, fee, WZETA, fee, tokenIn) in reverse order | ||
| bytes memory path = abi.encodePacked( | ||
| outputToken, | ||
| POOL_FEE, | ||
| wzeta, | ||
| POOL_FEE, | ||
| inputToken | ||
| ); | ||
|
|
||
| ISwapRouter.ExactOutputParams memory params = ISwapRouter | ||
| .ExactOutputParams({ | ||
| path: path, | ||
| recipient: address(this), | ||
| deadline: block.timestamp + 15 minutes, | ||
| amountOut: amountOut, | ||
| amountInMaximum: type(uint256).max // Let Uniswap handle slippage | ||
| }); | ||
|
|
||
| return ISwapRouter(uniswapRouter).exactOutput(params); | ||
| } | ||
| } |
Check warning
Code scanning / Slither
Unused return Medium
Depends on: