-
Notifications
You must be signed in to change notification settings - Fork 110
Test UniswapV3 and UniswapV4 swaps. #1306
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?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -47,6 +47,48 @@ interface IRetrieveDelegates { | |||||||||
| function delegates(address account) external view returns (address); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| interface IUniswapV3Quoter { | ||||||||||
| function quoteExactInputSingle( | ||||||||||
| address tokenIn, | ||||||||||
| address tokenOut, | ||||||||||
| uint24 fee, | ||||||||||
| uint256 amountIn, | ||||||||||
| uint160 sqrtPriceLimitX96 | ||||||||||
| ) external returns (uint256 amountOut); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| interface ISwapRouter { | ||||||||||
| struct ExactInputSingleParams { | ||||||||||
| address tokenIn; | ||||||||||
| address tokenOut; | ||||||||||
| uint24 fee; | ||||||||||
| address recipient; | ||||||||||
| uint256 amountIn; | ||||||||||
| uint256 amountOutMinimum; | ||||||||||
| uint160 sqrtPriceLimitX96; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| function exactInputSingle(ExactInputSingleParams calldata params) | ||||||||||
| external | ||||||||||
| payable | ||||||||||
| returns (uint256 amountOut); | ||||||||||
|
|
||||||||||
| struct ExactOutputSingleParams { | ||||||||||
| address tokenIn; | ||||||||||
| address tokenOut; | ||||||||||
| uint24 fee; | ||||||||||
| address recipient; | ||||||||||
| uint256 amountOut; | ||||||||||
| uint256 amountInMaximum; | ||||||||||
| uint160 sqrtPriceLimitX96; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| function exactOutputSingle(ExactOutputSingleParams calldata params) | ||||||||||
| external | ||||||||||
| payable | ||||||||||
| returns (uint256 amountIn); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| contract MOVETokenV2Test is Test { | ||||||||||
| // ============================================================================= | ||||||||||
| // STATE VARIABLES - CONTRACT INSTANCES | ||||||||||
|
|
@@ -562,6 +604,86 @@ contract MOVETokenV2Test is Test { | |||||||||
| assertEq(move2.totalSupply(), totalSupplyBefore - (amount * 2)); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| function testUniswap() public { | ||||||||||
| testConfigOFT(); | ||||||||||
| address v3movePool = 0x663901c2590893fdCe43c128D20603A9b69A053D; | ||||||||||
| address uniswapv3Router = 0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45; | ||||||||||
| address uniswapv4Router = 0x66a9893cC07D91D95644AEDD05D03f95e1dBA8Af; | ||||||||||
| address uniswapv3Quoter = 0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6; | ||||||||||
| address uniswapv4Quoter = 0x61fFE014bA17989E743c5F6cB21bF9697530B21e; | ||||||||||
|
|
||||||||||
| uint256 amount = 100; | ||||||||||
|
|
||||||||||
| // quote from uniswap v3 | ||||||||||
| (bool successV3, bytes memory dataV3) = uniswapv3Quoter.call( | ||||||||||
| abi.encodeWithSignature( | ||||||||||
| "quoteExactInputSingle(address,address,uint24,uint256,uint160)", | ||||||||||
| address(move2), | ||||||||||
| 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, // WETH | ||||||||||
| 10000, | ||||||||||
| amount, | ||||||||||
| 0 | ||||||||||
| ) | ||||||||||
| ); | ||||||||||
| require(successV3, "V3 quote failed"); | ||||||||||
| uint256 amountOutV3 = abi.decode(dataV3, (uint256)); | ||||||||||
|
|
||||||||||
| // quote from uniswap v4 | ||||||||||
| // (bool successV4, bytes memory dataV4) = uniswapv4Quoter.call( | ||||||||||
| // abi.encodeWithSignature( | ||||||||||
| // "quoteExactInputSingle(address,address,uint24,uint256,uint160)", | ||||||||||
| // address(move2), | ||||||||||
| // 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, // WETH | ||||||||||
| // 3000, | ||||||||||
| // amount, | ||||||||||
| // 0 | ||||||||||
| // ) | ||||||||||
| // ); | ||||||||||
| // require(successV4, "V4 quote failed"); | ||||||||||
| // uint256 amountOutV4 = abi.decode(dataV4, (uint256)); | ||||||||||
|
|
||||||||||
| uint256 balanceBefore = move2.balanceOf(anchorage); | ||||||||||
| uint256 snapshotId = vm.snapshot(); | ||||||||||
|
|
||||||||||
|
Comment on lines
+678
to
+679
|
||||||||||
| uint256 snapshotId = vm.snapshot(); |
Copilot
AI
Oct 4, 2025
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.
The approval for uniswapv4Router serves no purpose since the V4 swap code is commented out. Remove this unused approval or implement the V4 swap functionality.
| vm.prank(anchorage); | |
| move2.approve(uniswapv4Router, amount); | |
| // vm.prank(anchorage); | |
| // move2.approve(uniswapv4Router, 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.
The hardcoded value '100' is a magic number. Consider defining it as a named constant or making it configurable to improve test maintainability.