From a709cea45bf5e795fb8bd8e8a8c16fdef838141d Mon Sep 17 00:00:00 2001
From: mr <morgan.roman@uniswap.org>
Date: Mon, 8 Apr 2024 13:02:25 +0900
Subject: [PATCH 1/3] implement safe transfer from as in the todo for the
 example

---
 contracts/hooks/examples/LimitOrder.sol | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/contracts/hooks/examples/LimitOrder.sol b/contracts/hooks/examples/LimitOrder.sol
index e6cf8e89..788f4e09 100644
--- a/contracts/hooks/examples/LimitOrder.sol
+++ b/contracts/hooks/examples/LimitOrder.sol
@@ -12,6 +12,8 @@ import {BaseHook} from "../../BaseHook.sol";
 import {Currency, CurrencyLibrary} from "@uniswap/v4-core/src/types/Currency.sol";
 import {BalanceDelta} from "@uniswap/v4-core/src/types/BalanceDelta.sol";
 import {PoolKey} from "@uniswap/v4-core/src/types/PoolKey.sol";
+import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
+import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
 
 type Epoch is uint232;
 
@@ -265,17 +267,21 @@ contract LimitOrder is BaseHook {
         if (delta.amount0() < 0) {
             if (delta.amount1() != 0) revert InRange();
             if (!zeroForOne) revert CrossedRange();
-            // TODO use safeTransferFrom
-            IERC20Minimal(Currency.unwrap(key.currency0)).transferFrom(
-                owner, address(poolManager), uint256(uint128(-delta.amount0()))
+            SafeERC20.safeTransferFrom(
+                IERC20(Currency.unwrap(key.currency0)),
+                owner,
+                address(poolManager),
+                uint256(uint128(-delta.amount0()))
             );
             poolManager.settle(key.currency0);
         } else {
             if (delta.amount0() != 0) revert InRange();
             if (zeroForOne) revert CrossedRange();
-            // TODO use safeTransferFrom
-            IERC20Minimal(Currency.unwrap(key.currency1)).transferFrom(
-                owner, address(poolManager), uint256(uint128(-delta.amount1()))
+            SafeERC20.safeTransferFrom(
+                IERC20(Currency.unwrap(key.currency0)),
+                owner,
+                address(poolManager),
+                uint256(uint128(-delta.amount0()))
             );
             poolManager.settle(key.currency1);
         }

From 40c1050b3dad259be08a334cd952dee2375a8829 Mon Sep 17 00:00:00 2001
From: mr <morgan.roman@uniswap.org>
Date: Mon, 8 Apr 2024 13:08:28 +0900
Subject: [PATCH 2/3] linted

---
 contracts/hooks/examples/LimitOrder.sol | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/contracts/hooks/examples/LimitOrder.sol b/contracts/hooks/examples/LimitOrder.sol
index 788f4e09..40225b87 100644
--- a/contracts/hooks/examples/LimitOrder.sol
+++ b/contracts/hooks/examples/LimitOrder.sol
@@ -268,20 +268,14 @@ contract LimitOrder is BaseHook {
             if (delta.amount1() != 0) revert InRange();
             if (!zeroForOne) revert CrossedRange();
             SafeERC20.safeTransferFrom(
-                IERC20(Currency.unwrap(key.currency0)),
-                owner,
-                address(poolManager),
-                uint256(uint128(-delta.amount0()))
+                IERC20(Currency.unwrap(key.currency0)), owner, address(poolManager), uint256(uint128(-delta.amount0()))
             );
             poolManager.settle(key.currency0);
         } else {
             if (delta.amount0() != 0) revert InRange();
             if (zeroForOne) revert CrossedRange();
             SafeERC20.safeTransferFrom(
-                IERC20(Currency.unwrap(key.currency0)),
-                owner,
-                address(poolManager),
-                uint256(uint128(-delta.amount0()))
+                IERC20(Currency.unwrap(key.currency0)), owner, address(poolManager), uint256(uint128(-delta.amount0()))
             );
             poolManager.settle(key.currency1);
         }

From 079f0636b2bea36aba5a88f482e69a04b283c0d4 Mon Sep 17 00:00:00 2001
From: mr <morgan.roman@uniswap.org>
Date: Mon, 8 Apr 2024 14:50:25 +0900
Subject: [PATCH 3/3] full range as well

---
 contracts/hooks/examples/FullRange.sol | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/contracts/hooks/examples/FullRange.sol b/contracts/hooks/examples/FullRange.sol
index 820d0f93..d401ff18 100644
--- a/contracts/hooks/examples/FullRange.sol
+++ b/contracts/hooks/examples/FullRange.sol
@@ -20,6 +20,8 @@ import {FixedPoint96} from "@uniswap/v4-core/src/libraries/FixedPoint96.sol";
 import {FixedPointMathLib} from "solmate/utils/FixedPointMathLib.sol";
 import {IERC20Metadata} from "@openzeppelin/contracts/interfaces/IERC20Metadata.sol";
 import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
+import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
+import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
 
 import "../../libraries/LiquidityAmounts.sol";
 
@@ -264,7 +266,7 @@ contract FullRange is BaseHook, ILockCallback {
             if (sender == address(this)) {
                 currency.transfer(address(poolManager), amount);
             } else {
-                IERC20Minimal(Currency.unwrap(currency)).transferFrom(sender, address(poolManager), amount);
+                SafeERC20.safeTransferFrom(IERC20(Currency.unwrap(currency)), sender, address(poolManager), amount);
             }
             poolManager.settle(currency);
         }