diff --git a/test/foundry-tests/Fees.t.sol b/test/foundry-tests/Fees.t.sol index 73ba1b1c1..4b0500e65 100644 --- a/test/foundry-tests/Fees.t.sol +++ b/test/foundry-tests/Fees.t.sol @@ -16,7 +16,7 @@ import {Deployers} from "./utils/Deployers.sol"; import {TokenFixture} from "./utils/TokenFixture.sol"; import {PoolModifyPositionTest} from "../../contracts/test/PoolModifyPositionTest.sol"; import {Currency, CurrencyLibrary} from "../../contracts/types/Currency.sol"; -import {UniMockERC20} from "./utils/UniMockERC20.sol"; +import {MockERC20} from "solmate/test/utils/mocks/MockERC20.sol"; import {MockHooks} from "../../contracts/test/MockHooks.sol"; import {PoolSwapTest} from "../../contracts/test/PoolSwapTest.sol"; import {GasSnapshot} from "forge-gas-snapshot/GasSnapshot.sol"; @@ -61,11 +61,11 @@ contract FeesTest is Test, Deployers, TokenFixture, GasSnapshot { swapRouter = new PoolSwapTest(manager); protocolFeeController = new ProtocolFeeControllerTest(); - UniMockERC20(Currency.unwrap(currency0)).mint(address(this), 10 ether); - UniMockERC20(Currency.unwrap(currency1)).mint(address(this), 10 ether); + MockERC20(Currency.unwrap(currency0)).mint(address(this), 10 ether); + MockERC20(Currency.unwrap(currency1)).mint(address(this), 10 ether); - UniMockERC20(Currency.unwrap(currency0)).approve(address(modifyPositionRouter), 10 ether); - UniMockERC20(Currency.unwrap(currency1)).approve(address(modifyPositionRouter), 10 ether); + MockERC20(Currency.unwrap(currency0)).approve(address(modifyPositionRouter), 10 ether); + MockERC20(Currency.unwrap(currency1)).approve(address(modifyPositionRouter), 10 ether); address hookAddr = address(99); // can't be a zero address, but does not have to have any other hook flags specified MockHooks impl = new MockHooks(); @@ -419,7 +419,7 @@ contract FeesTest is Test, Deployers, TokenFixture, GasSnapshot { params = IPoolManager.ModifyPositionParams(-60, 60, 10e18); modifyPositionRouter.modifyPosition(key3, params, ZERO_BYTES); - UniMockERC20(Currency.unwrap(currency1)).approve(address(swapRouter), type(uint256).max); + MockERC20(Currency.unwrap(currency1)).approve(address(swapRouter), type(uint256).max); swapRouter.swap( key3, IPoolManager.SwapParams(false, 10000, TickMath.MAX_SQRT_RATIO - 1), @@ -454,7 +454,7 @@ contract FeesTest is Test, Deployers, TokenFixture, GasSnapshot { IPoolManager.ModifyPositionParams memory params = IPoolManager.ModifyPositionParams(-120, 120, 10e18); modifyPositionRouter.modifyPosition(key0, params, ZERO_BYTES); // 1 for 0 swap - UniMockERC20(Currency.unwrap(currency1)).approve(address(swapRouter), type(uint256).max); + MockERC20(Currency.unwrap(currency1)).approve(address(swapRouter), type(uint256).max); swapRouter.swap( key0, IPoolManager.SwapParams(false, 10000, TickMath.MAX_SQRT_RATIO - 1), @@ -487,7 +487,7 @@ contract FeesTest is Test, Deployers, TokenFixture, GasSnapshot { IPoolManager.ModifyPositionParams memory params = IPoolManager.ModifyPositionParams(-120, 120, 10e18); modifyPositionRouter.modifyPosition(key0, params, ZERO_BYTES); // 1 for 0 swap - UniMockERC20(Currency.unwrap(currency1)).approve(address(swapRouter), type(uint256).max); + MockERC20(Currency.unwrap(currency1)).approve(address(swapRouter), type(uint256).max); swapRouter.swap( key0, IPoolManager.SwapParams(false, 10000, TickMath.MAX_SQRT_RATIO - 1), @@ -522,7 +522,7 @@ contract FeesTest is Test, Deployers, TokenFixture, GasSnapshot { IPoolManager.ModifyPositionParams memory params = IPoolManager.ModifyPositionParams(-120, 120, 10e18); modifyPositionRouter.modifyPosition(key0, params, ZERO_BYTES); // 1 for 0 swap - UniMockERC20(Currency.unwrap(currency1)).approve(address(swapRouter), type(uint256).max); + MockERC20(Currency.unwrap(currency1)).approve(address(swapRouter), type(uint256).max); swapRouter.swap( key0, IPoolManager.SwapParams(false, 10000, TickMath.MAX_SQRT_RATIO - 1), @@ -561,7 +561,7 @@ contract FeesTest is Test, Deployers, TokenFixture, GasSnapshot { IPoolManager.ModifyPositionParams memory params = IPoolManager.ModifyPositionParams(-120, 120, 10e18); modifyPositionRouter.modifyPosition(key0, params, ZERO_BYTES); // 1 for 0 swap - UniMockERC20(Currency.unwrap(currency1)).approve(address(swapRouter), type(uint256).max); + MockERC20(Currency.unwrap(currency1)).approve(address(swapRouter), type(uint256).max); swapRouter.swap( key0, IPoolManager.SwapParams(false, 10000, TickMath.MAX_SQRT_RATIO - 1), diff --git a/test/foundry-tests/Hooks.t.sol b/test/foundry-tests/Hooks.t.sol index 2f5fcf977..9435372e5 100644 --- a/test/foundry-tests/Hooks.t.sol +++ b/test/foundry-tests/Hooks.t.sol @@ -8,7 +8,7 @@ import {Hooks} from "../../contracts/libraries/Hooks.sol"; import {FeeLibrary} from "../../contracts/libraries/FeeLibrary.sol"; import {MockHooks} from "../../contracts/test/MockHooks.sol"; import {IPoolManager} from "../../contracts/interfaces/IPoolManager.sol"; -import {UniMockERC20} from "./utils/UniMockERC20.sol"; +import {MockERC20} from "solmate/test/utils/mocks/MockERC20.sol"; import {IHooks} from "../../contracts/interfaces/IHooks.sol"; import {Currency} from "../../contracts/types/Currency.sol"; import {IERC20Minimal} from "../../contracts/interfaces/external/IERC20Minimal.sol"; @@ -65,7 +65,7 @@ contract HooksTest is Test, Deployers, GasSnapshot { } function testModifyPositionSucceedsWithHook() public { - UniMockERC20(Currency.unwrap(key.currency0)).mint(address(this), 10 ** 18); + MockERC20(Currency.unwrap(key.currency0)).mint(address(this), 10 ** 18); IERC20Minimal(Currency.unwrap(key.currency0)).approve(address(modifyPositionRouter), 10 ** 18); modifyPositionRouter.modifyPosition(key, IPoolManager.ModifyPositionParams(0, 60, 100), new bytes(111)); assertEq(mockHooks.beforeModifyPositionData(), new bytes(111)); @@ -74,7 +74,7 @@ contract HooksTest is Test, Deployers, GasSnapshot { function testBeforeModifyPositionInvalidReturn() public { mockHooks.setReturnValue(mockHooks.beforeModifyPosition.selector, bytes4(0xdeadbeef)); - UniMockERC20(Currency.unwrap(key.currency0)).mint(address(this), 10 ** 18); + MockERC20(Currency.unwrap(key.currency0)).mint(address(this), 10 ** 18); IERC20Minimal(Currency.unwrap(key.currency0)).approve(address(modifyPositionRouter), 10 ** 18); vm.expectRevert(Hooks.InvalidHookResponse.selector); modifyPositionRouter.modifyPosition(key, IPoolManager.ModifyPositionParams(0, 60, 100), ZERO_BYTES); @@ -82,14 +82,14 @@ contract HooksTest is Test, Deployers, GasSnapshot { function testAfterModifyPositionInvalidReturn() public { mockHooks.setReturnValue(mockHooks.afterModifyPosition.selector, bytes4(0xdeadbeef)); - UniMockERC20(Currency.unwrap(key.currency0)).mint(address(this), 10 ** 18); + MockERC20(Currency.unwrap(key.currency0)).mint(address(this), 10 ** 18); IERC20Minimal(Currency.unwrap(key.currency0)).approve(address(modifyPositionRouter), 10 ** 18); vm.expectRevert(Hooks.InvalidHookResponse.selector); modifyPositionRouter.modifyPosition(key, IPoolManager.ModifyPositionParams(0, 60, 100), ZERO_BYTES); } function testSwapSucceedsWithHook() public { - UniMockERC20(Currency.unwrap(key.currency0)).mint(address(this), 10 ** 18); + MockERC20(Currency.unwrap(key.currency0)).mint(address(this), 10 ** 18); IERC20Minimal(Currency.unwrap(key.currency0)).approve(address(swapRouter), 10 ** 18); swapRouter.swap( key, @@ -103,7 +103,7 @@ contract HooksTest is Test, Deployers, GasSnapshot { function testBeforeSwapInvalidReturn() public { mockHooks.setReturnValue(mockHooks.beforeSwap.selector, bytes4(0xdeadbeef)); - UniMockERC20(Currency.unwrap(key.currency0)).mint(address(this), 10 ** 18); + MockERC20(Currency.unwrap(key.currency0)).mint(address(this), 10 ** 18); IERC20Minimal(Currency.unwrap(key.currency0)).approve(address(swapRouter), 10 ** 18); vm.expectRevert(Hooks.InvalidHookResponse.selector); swapRouter.swap( @@ -116,7 +116,7 @@ contract HooksTest is Test, Deployers, GasSnapshot { function testAfterSwapInvalidReturn() public { mockHooks.setReturnValue(mockHooks.afterSwap.selector, bytes4(0xdeadbeef)); - UniMockERC20(Currency.unwrap(key.currency0)).mint(address(this), 10 ** 18); + MockERC20(Currency.unwrap(key.currency0)).mint(address(this), 10 ** 18); IERC20Minimal(Currency.unwrap(key.currency0)).approve(address(swapRouter), 10 ** 18); vm.expectRevert(Hooks.InvalidHookResponse.selector); swapRouter.swap( @@ -633,8 +633,8 @@ contract HooksTest is Test, Deployers, GasSnapshot { } function addLiquidity(int24 tickLower, int24 tickUpper, int256 amount) internal { - UniMockERC20(Currency.unwrap(key.currency0)).mint(address(this), 10 ** 18); - UniMockERC20(Currency.unwrap(key.currency1)).mint(address(this), 10 ** 18); + MockERC20(Currency.unwrap(key.currency0)).mint(address(this), 10 ** 18); + MockERC20(Currency.unwrap(key.currency1)).mint(address(this), 10 ** 18); IERC20Minimal(Currency.unwrap(key.currency0)).approve(address(modifyPositionRouter), 10 ** 18); IERC20Minimal(Currency.unwrap(key.currency1)).approve(address(modifyPositionRouter), 10 ** 18); modifyPositionRouter.modifyPosition( diff --git a/test/foundry-tests/PoolManager.t.sol b/test/foundry-tests/PoolManager.t.sol index 11afccba6..f900ad747 100644 --- a/test/foundry-tests/PoolManager.t.sol +++ b/test/foundry-tests/PoolManager.t.sol @@ -15,7 +15,7 @@ import {Deployers} from "./utils/Deployers.sol"; import {TokenFixture} from "./utils/TokenFixture.sol"; import {PoolModifyPositionTest} from "../../contracts/test/PoolModifyPositionTest.sol"; import {Currency, CurrencyLibrary} from "../../contracts/types/Currency.sol"; -import {UniMockERC20} from "./utils/UniMockERC20.sol"; +import {MockERC20} from "solmate/test/utils/mocks/MockERC20.sol"; import {MockHooks} from "../../contracts/test/MockHooks.sol"; import {MockContract} from "../../contracts/test/MockContract.sol"; import {IERC1155Receiver} from "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol"; @@ -87,17 +87,17 @@ contract PoolManagerTest is Test, Deployers, TokenFixture, GasSnapshot, IERC1155 swapRouter = new PoolSwapTest(manager); protocolFeeController = new ProtocolFeeControllerTest(); - UniMockERC20(Currency.unwrap(currency0)).mint(address(this), 10 ether); - UniMockERC20(Currency.unwrap(currency1)).mint(address(this), 10 ether); + MockERC20(Currency.unwrap(currency0)).mint(address(this), 10 ether); + MockERC20(Currency.unwrap(currency1)).mint(address(this), 10 ether); - UniMockERC20(Currency.unwrap(currency0)).approve(address(swapRouter), 10 ether); - UniMockERC20(Currency.unwrap(currency1)).approve(address(swapRouter), 10 ether); + MockERC20(Currency.unwrap(currency0)).approve(address(swapRouter), 10 ether); + MockERC20(Currency.unwrap(currency1)).approve(address(swapRouter), 10 ether); - UniMockERC20(Currency.unwrap(currency0)).approve(address(modifyPositionRouter), 10 ether); - UniMockERC20(Currency.unwrap(currency1)).approve(address(modifyPositionRouter), 10 ether); + MockERC20(Currency.unwrap(currency0)).approve(address(modifyPositionRouter), 10 ether); + MockERC20(Currency.unwrap(currency1)).approve(address(modifyPositionRouter), 10 ether); - UniMockERC20(Currency.unwrap(currency0)).approve(address(donateRouter), 10 ether); - UniMockERC20(Currency.unwrap(currency1)).approve(address(donateRouter), 10 ether); + MockERC20(Currency.unwrap(currency0)).approve(address(donateRouter), 10 ether); + MockERC20(Currency.unwrap(currency1)).approve(address(donateRouter), 10 ether); } function testPoolManagerInitialize(PoolKey memory key, uint160 sqrtPriceX96) public { diff --git a/test/foundry-tests/PoolManagerReentrancyTest.t.sol b/test/foundry-tests/PoolManagerReentrancyTest.t.sol index 52180f82e..3e6748821 100644 --- a/test/foundry-tests/PoolManagerReentrancyTest.t.sol +++ b/test/foundry-tests/PoolManagerReentrancyTest.t.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.20; import {Test} from "forge-std/Test.sol"; -import {UniMockERC20} from "./utils/UniMockERC20.sol"; +import {MockERC20} from "solmate/test/utils/mocks/MockERC20.sol"; import {Currency, CurrencyLibrary} from "../../contracts/types/Currency.sol"; import {LockDataLibrary} from "../../contracts/libraries/LockDataLibrary.sol"; import {IPoolManager} from "../../contracts/interfaces/IPoolManager.sol"; @@ -137,15 +137,15 @@ contract PoolManagerReentrancyTest is Test, Deployers, TokenFixture { function testTokenLocker() public { TokenLocker locker = new TokenLocker(); - UniMockERC20(Currency.unwrap(currency0)).mint(address(locker), 1); - UniMockERC20(Currency.unwrap(currency0)).approve(address(locker), 1); + MockERC20(Currency.unwrap(currency0)).mint(address(locker), 1); + MockERC20(Currency.unwrap(currency0)).approve(address(locker), 1); locker.main(manager, currency0, true); } function testTokenRevert() public { TokenLocker locker = new TokenLocker(); - UniMockERC20(Currency.unwrap(currency0)).mint(address(locker), 1); - UniMockERC20(Currency.unwrap(currency0)).approve(address(locker), 1); + MockERC20(Currency.unwrap(currency0)).mint(address(locker), 1); + MockERC20(Currency.unwrap(currency0)).approve(address(locker), 1); vm.expectRevert(abi.encodeWithSelector(IPoolManager.CurrencyNotSettled.selector)); locker.main(manager, currency0, false); } diff --git a/test/foundry-tests/types/Currency.t.sol b/test/foundry-tests/types/Currency.t.sol index 165fb1275..5d07857c0 100644 --- a/test/foundry-tests/types/Currency.t.sol +++ b/test/foundry-tests/types/Currency.t.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.20; import {Test} from "forge-std/Test.sol"; -import {UniMockERC20} from "../utils/UniMockERC20.sol"; +import {MockERC20} from "solmate/test/utils/mocks/MockERC20.sol"; import {Currency, CurrencyLibrary} from "../../../contracts/types/Currency.sol"; contract TestCurrency is Test { @@ -18,7 +18,9 @@ contract TestCurrency is Test { function setUp() public { nativeCurrency = Currency.wrap(address(0)); - erc20Currency = Currency.wrap(address(new UniMockERC20("TestA", "A", 18, initialERC20Balance))); + MockERC20 token = new MockERC20("TestA", "A", 18); + token.mint(address(this), initialERC20Balance); + erc20Currency = Currency.wrap(address(token)); erc20Currency.transfer(address(1), sentBalance); nativeCurrency.transfer(address(1), sentBalance); } diff --git a/test/foundry-tests/utils/Deployers.sol b/test/foundry-tests/utils/Deployers.sol index c29c43f45..658f02617 100644 --- a/test/foundry-tests/utils/Deployers.sol +++ b/test/foundry-tests/utils/Deployers.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.20; -import {UniMockERC20} from "./UniMockERC20.sol"; +import {MockERC20} from "solmate/test/utils/mocks/MockERC20.sol"; import {Hooks} from "../../../contracts/libraries/Hooks.sol"; import {Currency} from "../../../contracts/types/Currency.sol"; import {IHooks} from "../../../contracts/interfaces/IHooks.sol"; @@ -25,14 +25,15 @@ contract Deployers { uint160 constant SQRT_RATIO_4_1 = Constants.SQRT_RATIO_4_1; function deployCurrencies(uint256 totalSupply) internal returns (Currency currency0, Currency currency1) { - UniMockERC20[] memory tokens = deployTokens(2, totalSupply); + MockERC20[] memory tokens = deployTokens(2, totalSupply); return SortTokens.sort(tokens[0], tokens[1]); } - function deployTokens(uint8 count, uint256 totalSupply) internal returns (UniMockERC20[] memory tokens) { - tokens = new UniMockERC20[](count); + function deployTokens(uint8 count, uint256 totalSupply) internal returns (MockERC20[] memory tokens) { + tokens = new MockERC20[](count); for (uint8 i = 0; i < count; i++) { - tokens[i] = new UniMockERC20("TEST", "TEST", 18, totalSupply); + tokens[i] = new MockERC20("TEST", "TEST", 18); + tokens[i].mint(address(this), totalSupply); } } @@ -47,7 +48,7 @@ contract Deployers { private returns (PoolKey memory key, PoolId id) { - UniMockERC20[] memory tokens = deployTokens(2, 2 ** 255); + MockERC20[] memory tokens = deployTokens(2, 2 ** 255); (Currency currency0, Currency currency1) = SortTokens.sort(tokens[0], tokens[1]); key = PoolKey(currency0, currency1, fee, fee.isDynamicFee() ? int24(60) : int24(fee / 100 * 2), hooks); id = key.toId(); diff --git a/test/foundry-tests/utils/SortTokens.sol b/test/foundry-tests/utils/SortTokens.sol index 144a7c625..312a25549 100644 --- a/test/foundry-tests/utils/SortTokens.sol +++ b/test/foundry-tests/utils/SortTokens.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.20; -import {UniMockERC20} from "./UniMockERC20.sol"; +import {MockERC20} from "solmate/test/utils/mocks/MockERC20.sol"; import {Currency} from "../../../contracts/types/Currency.sol"; library SortTokens { - function sort(UniMockERC20 tokenA, UniMockERC20 tokenB) + function sort(MockERC20 tokenA, MockERC20 tokenB) internal pure returns (Currency _currency0, Currency _currency1) diff --git a/test/foundry-tests/utils/TokenFixture.sol b/test/foundry-tests/utils/TokenFixture.sol index 42f12db01..42c8838ec 100644 --- a/test/foundry-tests/utils/TokenFixture.sol +++ b/test/foundry-tests/utils/TokenFixture.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.20; -import {UniMockERC20} from "./UniMockERC20.sol"; +import {MockERC20} from "solmate/test/utils/mocks/MockERC20.sol"; import {Currency} from "../../../contracts/types/Currency.sol"; import {SortTokens} from "./SortTokens.sol"; @@ -10,8 +10,10 @@ contract TokenFixture { Currency internal currency0; function initializeTokens() internal { - UniMockERC20 tokenA = new UniMockERC20("TestA", "A", 18, 1000 ether); - UniMockERC20 tokenB = new UniMockERC20("TestB", "B", 18, 1000 ether); + MockERC20 tokenA = new MockERC20("TestA", "A", 18); + tokenA.mint(address(this), 1000 ether); + MockERC20 tokenB = new MockERC20("TestB", "B", 18); + tokenB.mint(address(this), 1000 ether); (currency0, currency1) = SortTokens.sort(tokenA, tokenB); } diff --git a/test/foundry-tests/utils/UniMockERC20.sol b/test/foundry-tests/utils/UniMockERC20.sol deleted file mode 100644 index 059654783..000000000 --- a/test/foundry-tests/utils/UniMockERC20.sol +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; - -import {ERC20} from "solmate/tokens/ERC20.sol"; - -contract UniMockERC20 is ERC20 { - constructor(string memory name, string memory symbol, uint8 decimals, uint256 amountToMint) - ERC20(name, symbol, decimals) - { - mint(msg.sender, amountToMint); - } - - function mint(address _to, uint256 _amount) public { - _mint(_to, _amount); - } - - function forceApprove(address _from, address _to, uint256 _amount) public returns (bool) { - allowance[_from][_to] = _amount; - - emit Approval(_from, _to, _amount); - - return true; - } -}