Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 122 additions & 0 deletions protocol-units/settlement/mcr/contracts/test/token/MOVETokenV2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;

Copilot AI Oct 4, 2025

Copy link

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.

Copilot uses AI. Check for mistakes.

// 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

Copilot AI Oct 4, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The snapshot is created but never used effectively. Either remove this unused variable or implement the snapshot/revert pattern properly.

Suggested change
uint256 snapshotId = vm.snapshot();

Copilot uses AI. Check for mistakes.
vm.prank(anchorage);
move2.approve(uniswapv3Router, amount);

vm.prank(anchorage);
ISwapRouter(uniswapv3Router).exactInputSingle(
ISwapRouter.ExactInputSingleParams({
tokenIn: address(move2),
tokenOut: 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, // WETH
fee: 10000,
recipient: anchorage,
amountIn: amount,
amountOutMinimum: (amountOutV3 * 95) / 100, // slippage 5%
sqrtPriceLimitX96: 0
})
);

assertEq(move2.balanceOf(anchorage), balanceBefore - amount);

vm.prank(anchorage);
move2.approve(uniswapv4Router, amount);
Comment on lines +698 to +699

Copilot AI Oct 4, 2025

Copy link

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.

Suggested change
vm.prank(anchorage);
move2.approve(uniswapv4Router, amount);
// vm.prank(anchorage);
// move2.approve(uniswapv4Router, amount);

Copilot uses AI. Check for mistakes.

// vm.revertTo(snapshotId);
// vm.prank(anchorage);
// ISwapRouter(uniswapv4Router).exactInputSingle(
// ISwapRouter.ExactInputSingleParams({
// tokenIn: address(move2),
// tokenOut: 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, // WETH
// fee: 300,
// recipient: anchorage,
// deadline: block.timestamp + 100,
// amountIn: amount,
// amountOutMinimum: (amountOutV4 * 95) / 100, // slippage 5%
// sqrtPriceLimitX96: 0
// })
// );

// assertEq(move2.balanceOf(anchorage), balanceBefore - amount);
}

// =============================================================================
// HELPER FUNCTIONS
// =============================================================================
Expand Down
Loading