diff --git a/.forge-snapshots/FullRangeFirstSwap.snap b/.forge-snapshots/FullRangeFirstSwap.snap index df930ad08..08d86dfea 100644 --- a/.forge-snapshots/FullRangeFirstSwap.snap +++ b/.forge-snapshots/FullRangeFirstSwap.snap @@ -1 +1 @@ -133445 \ No newline at end of file +133339 \ No newline at end of file diff --git a/.forge-snapshots/FullRangeSecondSwap.snap b/.forge-snapshots/FullRangeSecondSwap.snap index 10867d689..e21f31198 100644 --- a/.forge-snapshots/FullRangeSecondSwap.snap +++ b/.forge-snapshots/FullRangeSecondSwap.snap @@ -1 +1 @@ -93791 \ No newline at end of file +93685 \ No newline at end of file diff --git a/.forge-snapshots/FullRangeSwap.snap b/.forge-snapshots/FullRangeSwap.snap index 791a7d96d..77bbcb9a4 100644 --- a/.forge-snapshots/FullRangeSwap.snap +++ b/.forge-snapshots/FullRangeSwap.snap @@ -1 +1 @@ -131720 \ No newline at end of file +131614 \ No newline at end of file diff --git a/foundry.toml b/foundry.toml index 7c32d4b39..1c51f830b 100644 --- a/foundry.toml +++ b/foundry.toml @@ -9,5 +9,6 @@ cancun = true [profile.ci] fuzz_runs = 100000 +solc = "./bin/solc-static-linux" # See more config options https://github.com/foundry-rs/foundry/tree/master/config diff --git a/test/FullRange.t.sol b/test/FullRange.t.sol index 04d5ce273..4c131856a 100644 --- a/test/FullRange.t.sol +++ b/test/FullRange.t.sol @@ -108,9 +108,7 @@ contract TestFullRange is Test, Deployers, GasSnapshot { token1.approve(address(router), type(uint256).max); token2.approve(address(router), type(uint256).max); - initPool( - keyWithLiq.currency0, keyWithLiq.currency1, fullRange, 3000, SQRT_RATIO_1_1, ZERO_BYTES - ); + initPool(keyWithLiq.currency0, keyWithLiq.currency1, fullRange, 3000, SQRT_RATIO_1_1, ZERO_BYTES); fullRange.addLiquidity( FullRange.AddLiquidityParams( keyWithLiq.currency0, diff --git a/test/LimitOrder.t.sol b/test/LimitOrder.t.sol index 007d84b7d..415e30be8 100644 --- a/test/LimitOrder.t.sol +++ b/test/LimitOrder.t.sol @@ -48,9 +48,7 @@ contract TestLimitOrder is Test, Deployers { } // key = PoolKey(currency0, currency1, 3000, 60, limitOrder); - (key, id) = initPoolAndAddLiquidity( - currency0, currency1, limitOrder, 3000, SQRT_RATIO_1_1, ZERO_BYTES - ); + (key, id) = initPoolAndAddLiquidity(currency0, currency1, limitOrder, 3000, SQRT_RATIO_1_1, ZERO_BYTES); token0.approve(address(limitOrder), type(uint256).max); token1.approve(address(limitOrder), type(uint256).max); @@ -130,7 +128,10 @@ contract TestLimitOrder is Test, Deployers { function testNotZeroForOneInRangeRevert() public { // swapping is free, there's no liquidity in the pool, so we only need to specify 1 wei router.swap( - key, IPoolManager.SwapParams(true, 1, SQRT_RATIO_1_1 - 1), HookEnabledSwapRouter.TestSettings(true, true), ZERO_BYTES + key, + IPoolManager.SwapParams(true, 1 ether, SQRT_RATIO_1_1 - 1), + HookEnabledSwapRouter.TestSettings(true, true), + ZERO_BYTES ); vm.expectRevert(LimitOrder.InRange.selector); limitOrder.place(key, -60, false, 1000000); diff --git a/test/TWAMM.t.sol b/test/TWAMM.t.sol index 1575d95d9..266424db9 100644 --- a/test/TWAMM.t.sol +++ b/test/TWAMM.t.sol @@ -61,7 +61,11 @@ contract TWAMMTest is Test, Deployers, GasSnapshot { token0 = MockERC20(Currency.unwrap(currency0)); token1 = MockERC20(Currency.unwrap(currency1)); - TWAMMImplementation impl = new TWAMMImplementation(manager, 10_000, twamm); + TWAMMImplementation impl = new TWAMMImplementation( + manager, + 10_000, + twamm + ); (, bytes32[] memory writes) = vm.accesses(address(impl)); vm.etch(address(twamm), address(impl).code); // for each storage key that was written during the hook implementation, copy the value over @@ -236,7 +240,7 @@ contract TWAMMTest is Test, Deployers, GasSnapshot { uint256 token1Owed = twamm.tokensOwed(poolKey.currency1, orderKey1.owner); // takes 10% off the remaining half (so 80% of original sellrate) - assertEq(updatedSellRate, originalSellRate * 80 / 100); + assertEq(updatedSellRate, (originalSellRate * 80) / 100); assertEq(token0Owed, uint256(-amountDelta)); assertEq(token1Owed, orderAmount / 2); } @@ -261,7 +265,7 @@ contract TWAMMTest is Test, Deployers, GasSnapshot { uint256 token1Owed = twamm.tokensOwed(poolKey.currency1, orderKey1.owner); // takes 10% off the remaining half (so 80% of original sellrate) - assertEq(updatedSellRate, originalSellRate * 80 / 100); + assertEq(updatedSellRate, (originalSellRate * 80) / 100); assertEq(token0Owed, orderAmount / 2); assertEq(token1Owed, uint256(-amountDelta)); } diff --git a/test/utils/HookEnabledSwapRouter.sol b/test/utils/HookEnabledSwapRouter.sol index 8c5bec5b1..b924ed610 100644 --- a/test/utils/HookEnabledSwapRouter.sol +++ b/test/utils/HookEnabledSwapRouter.sol @@ -2,19 +2,20 @@ pragma solidity ^0.8.20; import {CurrencyLibrary, Currency} from "@uniswap/v4-core/src/types/Currency.sol"; +import {IERC20Minimal} from "@uniswap/v4-core/src/interfaces/external/IERC20Minimal.sol"; import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol"; import {BalanceDelta} from "@uniswap/v4-core/src/types/BalanceDelta.sol"; import {PoolKey} from "@uniswap/v4-core/src/types/PoolKey.sol"; import {PoolTestBase} from "@uniswap/v4-core/src/test/PoolTestBase.sol"; import {Test} from "forge-std/Test.sol"; -contract HookEnabledSwapRouter is Test, PoolTestBase { +contract HookEnabledSwapRouter is PoolTestBase { using CurrencyLibrary for Currency; - constructor(IPoolManager _manager) PoolTestBase(_manager) {} - error NoSwapOccurred(); + constructor(IPoolManager _manager) PoolTestBase(_manager) {} + struct CallbackData { address sender; TestSettings testSettings; @@ -54,10 +55,14 @@ contract HookEnabledSwapRouter is Test, PoolTestBase { if (data.params.zeroForOne) { _settle(data.key.currency0, data.sender, delta.amount0(), data.testSettings.settleUsingTransfer); - _take(data.key.currency1, data.sender, delta.amount1(), data.testSettings.withdrawTokens); + if (delta.amount1() < 0) { + _take(data.key.currency1, data.sender, delta.amount1(), data.testSettings.withdrawTokens); + } } else { _settle(data.key.currency1, data.sender, delta.amount1(), data.testSettings.settleUsingTransfer); - _take(data.key.currency0, data.sender, delta.amount0(), data.testSettings.withdrawTokens); + if (delta.amount0() < 0) { + _take(data.key.currency0, data.sender, delta.amount0(), data.testSettings.withdrawTokens); + } } return abi.encode(delta);