From 7aa28fe7f71dc7e5f320afef9d97dcea7f4cb4fa Mon Sep 17 00:00:00 2001 From: Justin Pulley Date: Tue, 29 Aug 2023 16:02:46 -0500 Subject: [PATCH 1/2] chore: remove old unused PRBMath import --- test/helpers/TestBaseWorkflowV3.sol | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/helpers/TestBaseWorkflowV3.sol b/test/helpers/TestBaseWorkflowV3.sol index 806efa5..f411c1c 100644 --- a/test/helpers/TestBaseWorkflowV3.sol +++ b/test/helpers/TestBaseWorkflowV3.sol @@ -34,8 +34,6 @@ import '@jbx-protocol/juice-contracts-v3/contracts/libraries/JBConstants.sol'; import './AccessJBLib.sol'; -import '@paulrberg/contracts/math/PRBMath.sol'; - // Base contract for Juicebox system tests. // // Provides common functionality, such as deploying contracts on test setup for v3. From e8c9b04a6fa08937f2b3984ecc7de3c6423c0f3a Mon Sep 17 00:00:00 2001 From: Justin Pulley Date: Tue, 29 Aug 2023 16:03:52 -0500 Subject: [PATCH 2/2] fix: optimize token approvals in JBSablier, addresses issue #11 --- src/abstract/JBSablier.sol | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/abstract/JBSablier.sol b/src/abstract/JBSablier.sol index efd6c2d..4d10aa8 100644 --- a/src/abstract/JBSablier.sol +++ b/src/abstract/JBSablier.sol @@ -145,6 +145,10 @@ abstract contract JBSablier is ERC165, ERC1271, IUniswapV3SwapCallback { TARGET_TOKEN_IS_TOKEN0 = address(_token) < address(WETH); TARGET_TOKEN = address(_token); + // Approve tokens for transfer + IERC20(TARGET_TOKEN).approve({spender: address(PERMIT2), amount: type(uint256).max}); + WETH.approve({spender: address(PERMIT2), amount: type(uint256).max}); + POOL = IUniswapV3Pool( address( uint160( @@ -215,9 +219,6 @@ abstract contract JBSablier is ERC165, ERC1271, IUniswapV3SwapCallback { // Check if PRBProxy has been setup if (address(proxy) == address(0)) deployProxyAndInstallPlugin(); - // Approve tokens for transfer - _data.token.approve({spender: address(PERMIT2), amount: type(uint256).max}); - // Encode and proxy.execute with data for the proxy target call if user defined each *stream type* if (_data.linWithDur.length > 0) { bytes memory data = abi.encodeCall(