From 156d015e07cea93dfe8388a9e3c023aa80e4306c Mon Sep 17 00:00:00 2001 From: Diana Kocsis Date: Mon, 25 Mar 2024 11:34:01 -0400 Subject: [PATCH] switch versions back --- .forge-snapshots/RouterBytecode.snap | 2 +- .forge-snapshots/RouterExactIn1Hop.snap | 2 +- .forge-snapshots/RouterExactIn2Hops.snap | 2 +- .forge-snapshots/RouterExactIn3Hops.snap | 2 +- .forge-snapshots/RouterExactInputSingle.snap | 2 +- .forge-snapshots/RouterExactOut1Hop.snap | 2 +- .forge-snapshots/RouterExactOut2Hops.snap | 2 +- .forge-snapshots/RouterExactOut3Hops.snap | 2 +- .forge-snapshots/RouterExactOutputSingle.snap | 2 +- contracts/V4Router.sol | 16 ++++++---------- contracts/base/Multicall.sol | 2 +- contracts/base/PeripheryPayments.sol | 2 +- contracts/base/PeripheryValidation.sol | 2 +- contracts/base/SelfPermit.sol | 2 +- contracts/hooks/examples/FullRange.sol | 2 +- contracts/hooks/examples/GeomeanOracle.sol | 2 +- contracts/hooks/examples/LimitOrder.sol | 10 +++++----- contracts/hooks/examples/VolatilityOracle.sol | 2 +- contracts/interfaces/IMulticall.sol | 2 +- contracts/libraries/Oracle.sol | 2 +- contracts/libraries/PoolGetters.sol | 2 +- contracts/libraries/UniswapV4ERC20.sol | 2 +- test/FullRange.t.sol | 2 +- test/GeomeanOracle.t.sol | 2 +- test/LimitOrder.t.sol | 2 +- test/Oracle.t.sol | 2 +- test/shared/GetSender.sol | 2 +- .../implementation/FullRangeImplementation.sol | 2 +- .../GeomeanOracleImplementation.sol | 2 +- .../implementation/LimitOrderImplementation.sol | 2 +- .../implementation/OracleImplementation.sol | 2 +- .../implementation/TWAMMImplementation.sol | 2 +- test/utils/HookEnabledSwapRouter.sol | 2 +- 33 files changed, 42 insertions(+), 46 deletions(-) diff --git a/.forge-snapshots/RouterBytecode.snap b/.forge-snapshots/RouterBytecode.snap index e1410edd..93ea0763 100644 --- a/.forge-snapshots/RouterBytecode.snap +++ b/.forge-snapshots/RouterBytecode.snap @@ -1 +1 @@ -5727 \ No newline at end of file +5726 \ No newline at end of file diff --git a/.forge-snapshots/RouterExactIn1Hop.snap b/.forge-snapshots/RouterExactIn1Hop.snap index ef0d7154..543c3f2c 100644 --- a/.forge-snapshots/RouterExactIn1Hop.snap +++ b/.forge-snapshots/RouterExactIn1Hop.snap @@ -1 +1 @@ -155453 \ No newline at end of file +155450 \ No newline at end of file diff --git a/.forge-snapshots/RouterExactIn2Hops.snap b/.forge-snapshots/RouterExactIn2Hops.snap index 348db162..3922e19a 100644 --- a/.forge-snapshots/RouterExactIn2Hops.snap +++ b/.forge-snapshots/RouterExactIn2Hops.snap @@ -1 +1 @@ -231596 \ No newline at end of file +231593 \ No newline at end of file diff --git a/.forge-snapshots/RouterExactIn3Hops.snap b/.forge-snapshots/RouterExactIn3Hops.snap index dff2f2de..4605a5ac 100644 --- a/.forge-snapshots/RouterExactIn3Hops.snap +++ b/.forge-snapshots/RouterExactIn3Hops.snap @@ -1 +1 @@ -315113 \ No newline at end of file +315110 \ No newline at end of file diff --git a/.forge-snapshots/RouterExactInputSingle.snap b/.forge-snapshots/RouterExactInputSingle.snap index b9cb5776..83af7e1a 100644 --- a/.forge-snapshots/RouterExactInputSingle.snap +++ b/.forge-snapshots/RouterExactInputSingle.snap @@ -1 +1 @@ -161384 \ No newline at end of file +161381 \ No newline at end of file diff --git a/.forge-snapshots/RouterExactOut1Hop.snap b/.forge-snapshots/RouterExactOut1Hop.snap index 8e257ab6..84320e4b 100644 --- a/.forge-snapshots/RouterExactOut1Hop.snap +++ b/.forge-snapshots/RouterExactOut1Hop.snap @@ -1 +1 @@ -156465 \ No newline at end of file +156462 \ No newline at end of file diff --git a/.forge-snapshots/RouterExactOut2Hops.snap b/.forge-snapshots/RouterExactOut2Hops.snap index 1d999b8f..a751d90e 100644 --- a/.forge-snapshots/RouterExactOut2Hops.snap +++ b/.forge-snapshots/RouterExactOut2Hops.snap @@ -1 +1 @@ -233506 \ No newline at end of file +233503 \ No newline at end of file diff --git a/.forge-snapshots/RouterExactOut3Hops.snap b/.forge-snapshots/RouterExactOut3Hops.snap index 6331afd1..65c51d20 100644 --- a/.forge-snapshots/RouterExactOut3Hops.snap +++ b/.forge-snapshots/RouterExactOut3Hops.snap @@ -1 +1 @@ -315986 \ No newline at end of file +315983 \ No newline at end of file diff --git a/.forge-snapshots/RouterExactOutputSingle.snap b/.forge-snapshots/RouterExactOutputSingle.snap index 9dbfcd03..a91adf9c 100644 --- a/.forge-snapshots/RouterExactOutputSingle.snap +++ b/.forge-snapshots/RouterExactOutputSingle.snap @@ -1 +1 @@ -160355 \ No newline at end of file +160352 \ No newline at end of file diff --git a/contracts/V4Router.sol b/contracts/V4Router.sol index 7f7dac56..ba108ba4 100644 --- a/contracts/V4Router.sol +++ b/contracts/V4Router.sol @@ -19,12 +19,6 @@ abstract contract V4Router is IV4Router, IUnlockCallback { IPoolManager immutable poolManager; - /// @dev Only the pool manager may call this function - modifier poolManagerOnly() { - if (msg.sender != address(poolManager)) revert NotPoolManager(); - _; - } - constructor(IPoolManager _poolManager) { poolManager = _poolManager; } @@ -34,7 +28,9 @@ abstract contract V4Router is IV4Router, IUnlockCallback { } /// @inheritdoc IUnlockCallback - function unlockCallback(bytes calldata encodedSwapInfo) external override poolManagerOnly returns (bytes memory) { + function unlockCallback(bytes calldata encodedSwapInfo) external override returns (bytes memory) { + if (msg.sender != address(poolManager)) revert NotPoolManager(); + SwapInfo memory swapInfo = abi.decode(encodedSwapInfo, (SwapInfo)); if (swapInfo.swapType == SwapType.ExactInput) { @@ -158,11 +154,11 @@ abstract contract V4Router is IV4Router, IUnlockCallback { if (zeroForOne) { reciprocalAmount = amountSpecified < 0 ? delta.amount1() : delta.amount0(); - if (settle) _payAndSettle(poolKey.currency0, msgSender, -delta.amount0()); + if (settle) _payAndSettle(poolKey.currency0, msgSender, delta.amount0()); if (take) poolManager.take(poolKey.currency1, msgSender, uint128(delta.amount1())); } else { reciprocalAmount = amountSpecified < 0 ? delta.amount0() : delta.amount1(); - if (settle) _payAndSettle(poolKey.currency1, msgSender, -delta.amount1()); + if (settle) _payAndSettle(poolKey.currency1, msgSender, delta.amount1()); if (take) poolManager.take(poolKey.currency0, msgSender, uint128(delta.amount0())); } } @@ -181,7 +177,7 @@ abstract contract V4Router is IV4Router, IUnlockCallback { } function _payAndSettle(Currency currency, address msgSender, int128 settleAmount) private { - _pay(Currency.unwrap(currency), msgSender, address(poolManager), uint256(uint128(settleAmount))); + _pay(Currency.unwrap(currency), msgSender, address(poolManager), uint256(uint128(-settleAmount))); poolManager.settle(currency); } diff --git a/contracts/base/Multicall.sol b/contracts/base/Multicall.sol index d754f6a3..bd926766 100644 --- a/contracts/base/Multicall.sol +++ b/contracts/base/Multicall.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity ^0.8.20; +pragma solidity ^0.8.19; import {IMulticall} from "../interfaces/IMulticall.sol"; diff --git a/contracts/base/PeripheryPayments.sol b/contracts/base/PeripheryPayments.sol index dc95ea23..24466924 100644 --- a/contracts/base/PeripheryPayments.sol +++ b/contracts/base/PeripheryPayments.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; +pragma solidity ^0.8.19; import {ERC20} from "solmate/tokens/ERC20.sol"; import {Currency, CurrencyLibrary} from "@uniswap/v4-core/src/types/Currency.sol"; diff --git a/contracts/base/PeripheryValidation.sol b/contracts/base/PeripheryValidation.sol index de719519..b8ea81d4 100644 --- a/contracts/base/PeripheryValidation.sol +++ b/contracts/base/PeripheryValidation.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; +pragma solidity ^0.8.19; abstract contract PeripheryValidation { error TransactionTooOld(); diff --git a/contracts/base/SelfPermit.sol b/contracts/base/SelfPermit.sol index 9a2d88d6..40449636 100644 --- a/contracts/base/SelfPermit.sol +++ b/contracts/base/SelfPermit.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; +pragma solidity ^0.8.19; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol"; diff --git a/contracts/hooks/examples/FullRange.sol b/contracts/hooks/examples/FullRange.sol index 47c2620e..614cde2b 100644 --- a/contracts/hooks/examples/FullRange.sol +++ b/contracts/hooks/examples/FullRange.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; +pragma solidity ^0.8.19; import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol"; import {PoolManager} from "@uniswap/v4-core/src/PoolManager.sol"; diff --git a/contracts/hooks/examples/GeomeanOracle.sol b/contracts/hooks/examples/GeomeanOracle.sol index 419a643d..c0f1c096 100644 --- a/contracts/hooks/examples/GeomeanOracle.sol +++ b/contracts/hooks/examples/GeomeanOracle.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; +pragma solidity ^0.8.19; import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol"; import {PoolId, PoolIdLibrary} from "@uniswap/v4-core/src/types/PoolId.sol"; diff --git a/contracts/hooks/examples/LimitOrder.sol b/contracts/hooks/examples/LimitOrder.sol index 89e16c2f..3f7441aa 100644 --- a/contracts/hooks/examples/LimitOrder.sol +++ b/contracts/hooks/examples/LimitOrder.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; +pragma solidity ^0.8.19; import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol"; import {PoolId, PoolIdLibrary} from "@uniswap/v4-core/src/types/PoolId.sol"; @@ -334,11 +334,11 @@ contract LimitOrder is BaseHook { ZERO_BYTES ); - if (deltaFee.amount0() < 0) { - poolManager.mint(address(this), key.currency0.toId(), amount0Fee = uint128(-deltaFee.amount0())); + if (deltaFee.amount0() > 0) { + poolManager.mint(address(this), key.currency0.toId(), amount0Fee = uint128(deltaFee.amount0())); } - if (deltaFee.amount1() < 0) { - poolManager.mint(address(this), key.currency1.toId(), amount1Fee = uint128(-deltaFee.amount1())); + if (deltaFee.amount1() > 0) { + poolManager.mint(address(this), key.currency1.toId(), amount1Fee = uint128(deltaFee.amount1())); } } diff --git a/contracts/hooks/examples/VolatilityOracle.sol b/contracts/hooks/examples/VolatilityOracle.sol index d5e260cd..76a3e8ce 100644 --- a/contracts/hooks/examples/VolatilityOracle.sol +++ b/contracts/hooks/examples/VolatilityOracle.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; +pragma solidity ^0.8.19; import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol"; import {Hooks} from "@uniswap/v4-core/src/libraries/Hooks.sol"; diff --git a/contracts/interfaces/IMulticall.sol b/contracts/interfaces/IMulticall.sol index e80d7a17..dfa9db24 100644 --- a/contracts/interfaces/IMulticall.sol +++ b/contracts/interfaces/IMulticall.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; +pragma solidity ^0.8.19; /// @title Multicall interface /// @notice Enables calling multiple methods in a single call to the contract diff --git a/contracts/libraries/Oracle.sol b/contracts/libraries/Oracle.sol index 2c3906ec..822f356f 100644 --- a/contracts/libraries/Oracle.sol +++ b/contracts/libraries/Oracle.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; +pragma solidity ^0.8.19; /// @title Oracle /// @notice Provides price and liquidity data useful for a wide variety of system designs diff --git a/contracts/libraries/PoolGetters.sol b/contracts/libraries/PoolGetters.sol index 5542e6ff..e3cb318b 100644 --- a/contracts/libraries/PoolGetters.sol +++ b/contracts/libraries/PoolGetters.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; +pragma solidity ^0.8.19; import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol"; import {Pool} from "@uniswap/v4-core/src/libraries/Pool.sol"; diff --git a/contracts/libraries/UniswapV4ERC20.sol b/contracts/libraries/UniswapV4ERC20.sol index 8b5d41ca..fdd93ba4 100644 --- a/contracts/libraries/UniswapV4ERC20.sol +++ b/contracts/libraries/UniswapV4ERC20.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.8.20; +pragma solidity ^0.8.19; import {ERC20} from "solmate/tokens/ERC20.sol"; import {Owned} from "solmate/auth/Owned.sol"; diff --git a/test/FullRange.t.sol b/test/FullRange.t.sol index 9b41d773..dc970b9a 100644 --- a/test/FullRange.t.sol +++ b/test/FullRange.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; +pragma solidity ^0.8.19; import {Test} from "forge-std/Test.sol"; import {GasSnapshot} from "forge-gas-snapshot/GasSnapshot.sol"; diff --git a/test/GeomeanOracle.t.sol b/test/GeomeanOracle.t.sol index 90ba1902..05255e93 100644 --- a/test/GeomeanOracle.t.sol +++ b/test/GeomeanOracle.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; +pragma solidity ^0.8.19; import {Test} from "forge-std/Test.sol"; import {GetSender} from "./shared/GetSender.sol"; diff --git a/test/LimitOrder.t.sol b/test/LimitOrder.t.sol index 262e097b..9b9e3116 100644 --- a/test/LimitOrder.t.sol +++ b/test/LimitOrder.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; +pragma solidity ^0.8.19; import {Test} from "forge-std/Test.sol"; import {GetSender} from "./shared/GetSender.sol"; diff --git a/test/Oracle.t.sol b/test/Oracle.t.sol index 88a12e59..04157e16 100644 --- a/test/Oracle.t.sol +++ b/test/Oracle.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; +pragma solidity ^0.8.19; import {GasSnapshot} from "forge-gas-snapshot/GasSnapshot.sol"; import {Test} from "forge-std/Test.sol"; diff --git a/test/shared/GetSender.sol b/test/shared/GetSender.sol index ff4d06d2..d1709219 100644 --- a/test/shared/GetSender.sol +++ b/test/shared/GetSender.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; +pragma solidity ^0.8.19; contract GetSender { function sender() external view returns (address) { diff --git a/test/shared/implementation/FullRangeImplementation.sol b/test/shared/implementation/FullRangeImplementation.sol index 20161e82..2d4ce3cc 100644 --- a/test/shared/implementation/FullRangeImplementation.sol +++ b/test/shared/implementation/FullRangeImplementation.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; +pragma solidity ^0.8.19; import {BaseHook} from "../../../contracts/BaseHook.sol"; import {FullRange} from "../../../contracts/hooks/examples/FullRange.sol"; diff --git a/test/shared/implementation/GeomeanOracleImplementation.sol b/test/shared/implementation/GeomeanOracleImplementation.sol index af4fd14b..b953a3b6 100644 --- a/test/shared/implementation/GeomeanOracleImplementation.sol +++ b/test/shared/implementation/GeomeanOracleImplementation.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; +pragma solidity ^0.8.19; import {BaseHook} from "../../../contracts/BaseHook.sol"; import {GeomeanOracle} from "../../../contracts/hooks/examples/GeomeanOracle.sol"; diff --git a/test/shared/implementation/LimitOrderImplementation.sol b/test/shared/implementation/LimitOrderImplementation.sol index ed6958e9..11625771 100644 --- a/test/shared/implementation/LimitOrderImplementation.sol +++ b/test/shared/implementation/LimitOrderImplementation.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; +pragma solidity ^0.8.19; import {BaseHook} from "../../../contracts/BaseHook.sol"; import {LimitOrder} from "../../../contracts/hooks/examples/LimitOrder.sol"; diff --git a/test/shared/implementation/OracleImplementation.sol b/test/shared/implementation/OracleImplementation.sol index dacf26ed..7eefe3d3 100644 --- a/test/shared/implementation/OracleImplementation.sol +++ b/test/shared/implementation/OracleImplementation.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; +pragma solidity ^0.8.19; import {Oracle} from "../../../contracts/libraries/Oracle.sol"; diff --git a/test/shared/implementation/TWAMMImplementation.sol b/test/shared/implementation/TWAMMImplementation.sol index 63a30b88..f217db8c 100644 --- a/test/shared/implementation/TWAMMImplementation.sol +++ b/test/shared/implementation/TWAMMImplementation.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; +pragma solidity ^0.8.19; import {BaseHook} from "../../../contracts/BaseHook.sol"; import {TWAMM} from "../../../contracts/hooks/examples/TWAMM.sol"; diff --git a/test/utils/HookEnabledSwapRouter.sol b/test/utils/HookEnabledSwapRouter.sol index 05c67fd1..a080a309 100644 --- a/test/utils/HookEnabledSwapRouter.sol +++ b/test/utils/HookEnabledSwapRouter.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; +pragma solidity ^0.8.19; import {CurrencyLibrary, Currency} from "@uniswap/v4-core/src/types/Currency.sol"; import {IERC20Minimal} from "@uniswap/v4-core/src/interfaces/external/IERC20Minimal.sol";