Skip to content

Commit

Permalink
switch versions back
Browse files Browse the repository at this point in the history
  • Loading branch information
dianakocsis committed Mar 25, 2024
1 parent 950279f commit 156d015
Show file tree
Hide file tree
Showing 33 changed files with 42 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .forge-snapshots/RouterBytecode.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5727
5726
2 changes: 1 addition & 1 deletion .forge-snapshots/RouterExactIn1Hop.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
155453
155450
2 changes: 1 addition & 1 deletion .forge-snapshots/RouterExactIn2Hops.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
231596
231593
2 changes: 1 addition & 1 deletion .forge-snapshots/RouterExactIn3Hops.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
315113
315110
2 changes: 1 addition & 1 deletion .forge-snapshots/RouterExactInputSingle.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
161384
161381
2 changes: 1 addition & 1 deletion .forge-snapshots/RouterExactOut1Hop.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
156465
156462
2 changes: 1 addition & 1 deletion .forge-snapshots/RouterExactOut2Hops.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
233506
233503
2 changes: 1 addition & 1 deletion .forge-snapshots/RouterExactOut3Hops.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
315986
315983
2 changes: 1 addition & 1 deletion .forge-snapshots/RouterExactOutputSingle.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
160355
160352
16 changes: 6 additions & 10 deletions contracts/V4Router.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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) {
Expand Down Expand Up @@ -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()));
}
}
Expand All @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/base/Multicall.sol
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
2 changes: 1 addition & 1 deletion contracts/base/PeripheryPayments.sol
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion contracts/base/PeripheryValidation.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
pragma solidity ^0.8.19;

abstract contract PeripheryValidation {
error TransactionTooOld();
Expand Down
2 changes: 1 addition & 1 deletion contracts/base/SelfPermit.sol
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion contracts/hooks/examples/FullRange.sol
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion contracts/hooks/examples/GeomeanOracle.sol
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
10 changes: 5 additions & 5 deletions contracts/hooks/examples/LimitOrder.sol
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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()));
}
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/hooks/examples/VolatilityOracle.sol
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/IMulticall.sol
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion contracts/libraries/Oracle.sol
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion contracts/libraries/PoolGetters.sol
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion contracts/libraries/UniswapV4ERC20.sol
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion test/FullRange.t.sol
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion test/GeomeanOracle.t.sol
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion test/LimitOrder.t.sol
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion test/Oracle.t.sol
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion test/shared/GetSender.sol
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion test/shared/implementation/FullRangeImplementation.sol
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion test/shared/implementation/GeomeanOracleImplementation.sol
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion test/shared/implementation/LimitOrderImplementation.sol
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion test/shared/implementation/OracleImplementation.sol
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
2 changes: 1 addition & 1 deletion test/shared/implementation/TWAMMImplementation.sol
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion test/utils/HookEnabledSwapRouter.sol
Original file line number Diff line number Diff line change
@@ -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";
Expand Down

0 comments on commit 156d015

Please sign in to comment.