diff --git a/test/libraries/CalldataDecoder.t.sol b/test/libraries/CalldataDecoder.t.sol index c41122eb..cbc1d4c4 100644 --- a/test/libraries/CalldataDecoder.t.sol +++ b/test/libraries/CalldataDecoder.t.sol @@ -83,6 +83,40 @@ contract CalldataDecoderTest is Test { assertEq(mintParams.tickUpper, _config.tickUpper); } + function test_fuzz_decodeMintFromAmountsParams( + PositionConfig calldata _config, + uint128 _amount0, + uint128 _amount1, + uint128 _amount0Max, + uint128 _amount1Max, + address _owner, + bytes calldata _hookData + ) public view { + bytes memory params = abi.encode( + _config.poolKey, + _config.tickLower, + _config.tickUpper, + _amount0, + _amount1, + _amount0Max, + _amount1Max, + _owner, + _hookData + ); + + (MockCalldataDecoder.MintFromAmountsParams memory mintParams) = decoder.decodeMintFromAmountsParams(params); + + _assertEq(mintParams.poolKey, _config.poolKey); + assertEq(mintParams.tickLower, _config.tickLower); + assertEq(mintParams.tickUpper, _config.tickUpper); + assertEq(mintParams.amount0, _amount0); + assertEq(mintParams.amount1, _amount1); + assertEq(mintParams.amount0Max, _amount0Max); + assertEq(mintParams.amount1Max, _amount1Max); + assertEq(mintParams.owner, _owner); + assertEq(mintParams.hookData, _hookData); + } + function test_fuzz_decodeSwapExactInParams(IV4Router.ExactInputParams calldata _swapParams) public view { bytes memory params = abi.encode(_swapParams); IV4Router.ExactInputParams memory swapParams = decoder.decodeSwapExactInParams(params); @@ -232,6 +266,32 @@ contract CalldataDecoderTest is Test { assertEq(amount, _amount); } + function test_fuzz_decodeIncreaseLiquidityFromAmountsParams( + uint256 _tokenId, + uint128 _amount0, + uint128 _amount1, + uint128 _amount0Max, + uint128 _amount1Max, + bytes calldata _hookData + ) public view { + bytes memory params = abi.encode(_tokenId, _amount0, _amount1, _amount0Max, _amount1Max, _hookData); + + ( + uint256 tokenId, + uint128 amount0, + uint128 amount1, + uint128 amount0Max, + uint128 amount1Max, + bytes memory hookData + ) = decoder.decodeIncreaseLiquidityFromAmountsParams(params); + assertEq(_tokenId, tokenId); + assertEq(_amount0, amount0); + assertEq(_amount1, amount1); + assertEq(_amount0Max, amount0Max); + assertEq(_amount1Max, amount1Max); + assertEq(_hookData, hookData); + } + function _assertEq(PathKey[] memory path1, PathKey[] memory path2) internal pure { assertEq(path1.length, path2.length); for (uint256 i = 0; i < path1.length; i++) { diff --git a/test/mocks/MockCalldataDecoder.sol b/test/mocks/MockCalldataDecoder.sol index e25d8ec7..39475b7e 100644 --- a/test/mocks/MockCalldataDecoder.sol +++ b/test/mocks/MockCalldataDecoder.sol @@ -22,6 +22,18 @@ contract MockCalldataDecoder { bytes hookData; } + struct MintFromAmountsParams { + PoolKey poolKey; + int24 tickLower; + int24 tickUpper; + uint128 amount0; + uint128 amount1; + uint128 amount0Max; + uint128 amount1Max; + address owner; + bytes hookData; + } + function decodeActionsRouterParams(bytes calldata params) external pure @@ -136,4 +148,48 @@ contract MockCalldataDecoder { { return params.decodeCurrencyAddressAndUint256(); } + + function decodeIncreaseLiquidityFromAmountsParams(bytes calldata params) + external + pure + returns ( + uint256 tokenId, + uint128 amount0, + uint128 amount1, + uint128 amount0Max, + uint128 amount1Max, + bytes calldata hookData + ) + { + return params.decodeIncreaseLiquidityFromAmountsParams(); + } + + function decodeMintFromAmountsParams(bytes calldata params) + external + pure + returns (MintFromAmountsParams memory mintParams) + { + ( + PoolKey memory poolKey, + int24 tickLower, + int24 tickUpper, + uint128 amount0, + uint128 amount1, + uint128 amount0Max, + uint128 amount1Max, + address owner, + bytes memory hookData + ) = params.decodeMintFromAmountsParams(); + return MintFromAmountsParams({ + poolKey: poolKey, + tickLower: tickLower, + tickUpper: tickUpper, + amount0: amount0, + amount1: amount1, + amount0Max: amount0Max, + amount1Max: amount1Max, + owner: owner, + hookData: hookData + }); + } }