From 8f50bdccd8489252b385cc865b1c5f2aeba2e948 Mon Sep 17 00:00:00 2001 From: saucepoint Date: Wed, 10 Jul 2024 15:47:49 +0200 Subject: [PATCH] test fixes --- .../autocompound_exactUnclaimedFees.snap | 2 +- ...exactUnclaimedFees_exactCustodiedFees.snap | 2 +- .../autocompound_excessFeesCredit.snap | 2 +- .forge-snapshots/decreaseLiquidity_erc20.snap | 2 +- .../decreaseLiquidity_erc6909.snap | 2 +- .forge-snapshots/increaseLiquidity_erc20.snap | 2 +- .../increaseLiquidity_erc6909.snap | 2 +- .forge-snapshots/mintWithLiquidity.snap | 2 +- contracts/NonfungiblePositionManager.sol | 19 +++++++++++++++---- test/position-managers/Permit.t.sol | 9 ++++----- 10 files changed, 27 insertions(+), 17 deletions(-) diff --git a/.forge-snapshots/autocompound_exactUnclaimedFees.snap b/.forge-snapshots/autocompound_exactUnclaimedFees.snap index 8a26ccb9..b1bc5219 100644 --- a/.forge-snapshots/autocompound_exactUnclaimedFees.snap +++ b/.forge-snapshots/autocompound_exactUnclaimedFees.snap @@ -1 +1 @@ -295465 \ No newline at end of file +295470 \ No newline at end of file diff --git a/.forge-snapshots/autocompound_exactUnclaimedFees_exactCustodiedFees.snap b/.forge-snapshots/autocompound_exactUnclaimedFees_exactCustodiedFees.snap index f1a243d3..b0cc5d95 100644 --- a/.forge-snapshots/autocompound_exactUnclaimedFees_exactCustodiedFees.snap +++ b/.forge-snapshots/autocompound_exactUnclaimedFees_exactCustodiedFees.snap @@ -1 +1 @@ -227824 \ No newline at end of file +227829 \ No newline at end of file diff --git a/.forge-snapshots/autocompound_excessFeesCredit.snap b/.forge-snapshots/autocompound_excessFeesCredit.snap index 4458142e..455648f4 100644 --- a/.forge-snapshots/autocompound_excessFeesCredit.snap +++ b/.forge-snapshots/autocompound_excessFeesCredit.snap @@ -1 +1 @@ -316004 \ No newline at end of file +316009 \ No newline at end of file diff --git a/.forge-snapshots/decreaseLiquidity_erc20.snap b/.forge-snapshots/decreaseLiquidity_erc20.snap index 9dce8ecd..7f0c9f02 100644 --- a/.forge-snapshots/decreaseLiquidity_erc20.snap +++ b/.forge-snapshots/decreaseLiquidity_erc20.snap @@ -1 +1 @@ -213445 \ No newline at end of file +213449 \ No newline at end of file diff --git a/.forge-snapshots/decreaseLiquidity_erc6909.snap b/.forge-snapshots/decreaseLiquidity_erc6909.snap index 976b2131..9d6d2f0b 100644 --- a/.forge-snapshots/decreaseLiquidity_erc6909.snap +++ b/.forge-snapshots/decreaseLiquidity_erc6909.snap @@ -1 +1 @@ -213455 \ No newline at end of file +213459 \ No newline at end of file diff --git a/.forge-snapshots/increaseLiquidity_erc20.snap b/.forge-snapshots/increaseLiquidity_erc20.snap index 6c047d59..7ed8a8ea 100644 --- a/.forge-snapshots/increaseLiquidity_erc20.snap +++ b/.forge-snapshots/increaseLiquidity_erc20.snap @@ -1 +1 @@ -199081 \ No newline at end of file +199086 \ No newline at end of file diff --git a/.forge-snapshots/increaseLiquidity_erc6909.snap b/.forge-snapshots/increaseLiquidity_erc6909.snap index 00dd4bae..9f04cc1a 100644 --- a/.forge-snapshots/increaseLiquidity_erc6909.snap +++ b/.forge-snapshots/increaseLiquidity_erc6909.snap @@ -1 +1 @@ -199093 \ No newline at end of file +199098 \ No newline at end of file diff --git a/.forge-snapshots/mintWithLiquidity.snap b/.forge-snapshots/mintWithLiquidity.snap index 34b9cf02..ebad633c 100644 --- a/.forge-snapshots/mintWithLiquidity.snap +++ b/.forge-snapshots/mintWithLiquidity.snap @@ -1 +1 @@ -490191 \ No newline at end of file +490196 \ No newline at end of file diff --git a/contracts/NonfungiblePositionManager.sol b/contracts/NonfungiblePositionManager.sol index 5c5d4395..cc6026e9 100644 --- a/contracts/NonfungiblePositionManager.sol +++ b/contracts/NonfungiblePositionManager.sol @@ -20,6 +20,8 @@ import {TransientStateLibrary} from "@uniswap/v4-core/src/libraries/TransientSta import {SafeCast} from "@uniswap/v4-core/src/libraries/SafeCast.sol"; import {TransientLiquidityDelta} from "./libraries/TransientLiquidityDelta.sol"; +import "forge-std/console2.sol"; + contract NonfungiblePositionManager is INonfungiblePositionManager, BaseLiquidityManagement, ERC721Permit { using CurrencyLibrary for Currency; using CurrencySettleTake for Currency; @@ -62,11 +64,17 @@ contract NonfungiblePositionManager is INonfungiblePositionManager, BaseLiquidit (bytes[] memory data, Currency[] memory currencies) = abi.decode(payload, (bytes[], Currency[])); bool success; - + bytes memory callReturn; for (uint256 i; i < data.length; i++) { // TODO: Move to internal call and bubble up all call return data. - (success,) = address(this).call(data[i]); - if (!success) revert("EXECUTE_FAILED"); + (success, callReturn) = address(this).call(data[i]); + if (!success) { + // if the call failed, bubble up the reason + /// @solidity memory-safe-assembly + assembly { + revert(add(callReturn, 32), mload(callReturn)) + } + } } // close the final deltas @@ -123,7 +131,10 @@ contract NonfungiblePositionManager is INonfungiblePositionManager, BaseLiquidit } // TODO: in v3, we can partially collect fees, but what was the usecase here? - function collect(uint256 tokenId, address recipient, bytes calldata hookData, bool claims) external { + function collect(uint256 tokenId, address recipient, bytes calldata hookData, bool claims) + external + isAuthorizedForToken(tokenId) + { TokenPosition memory tokenPos = tokenPositions[tokenId]; _collect(recipient, tokenPos.owner, tokenPos.range, hookData); diff --git a/test/position-managers/Permit.t.sol b/test/position-managers/Permit.t.sol index 51295af5..e7939896 100644 --- a/test/position-managers/Permit.t.sol +++ b/test/position-managers/Permit.t.sol @@ -92,16 +92,15 @@ contract PermitTest is Test, Deployers, GasSnapshot, Fuzzers, LiquidityOperation uint256 balance0BobBefore = currency0.balanceOf(bob); uint256 balance1BobBefore = currency1.balanceOf(bob); vm.prank(bob); - _increaseLiquidity(tokenIdAlice, newLiquidity, ZERO_BYTES, false); + _increaseLiquidity(range, tokenIdAlice, newLiquidity, ZERO_BYTES, false); // alice's position has new liquidity (uint256 liquidity,,,,) = lpm.positions(alice, range.toId()); assertEq(liquidity, liquidityAlice + newLiquidity); // bob used his tokens to increase liquidity - // TODO: enable after we fix msg.sender - // assertGt(balance0BobBefore, currency0.balanceOf(bob)); - // assertGt(balance1BobBefore, currency1.balanceOf(bob)); + assertGt(balance0BobBefore, currency0.balanceOf(bob)); + assertGt(balance1BobBefore, currency1.balanceOf(bob)); } function test_permit_decreaseLiquidity() public { @@ -116,7 +115,7 @@ contract PermitTest is Test, Deployers, GasSnapshot, Fuzzers, LiquidityOperation // bob can decrease liquidity on alice's token uint256 liquidityToRemove = 0.4444e18; vm.prank(bob); - _decreaseLiquidity(tokenIdAlice, liquidityToRemove, ZERO_BYTES, false); + _decreaseLiquidity(range, tokenIdAlice, liquidityToRemove, ZERO_BYTES, false); // alice's position decreased liquidity (uint256 liquidity,,,,) = lpm.positions(alice, range.toId());