From 59eb2195b60280bfba9f07b55bf0d7bc973ad23f Mon Sep 17 00:00:00 2001 From: Diana Carvalho Date: Thu, 27 Feb 2025 17:38:53 +0000 Subject: [PATCH] feat: Change license to SPDX-License-Identifier: UNLICENSED everywhere Remove unnecessary files --- don't change below this line --- ENG-4260 Took 13 minutes --- foundry/interfaces/ICallback.sol | 2 +- foundry/interfaces/IExecutor.sol | 2 +- foundry/lib/IWETH.sol | 2 +- foundry/lib/LibSwap.sol | 2 +- foundry/lib/Payments.sol | 110 ------------------ foundry/lib/PaymentsImmutables.sol | 23 ---- foundry/lib/Permit2Payments.sol | 57 --------- .../bytes/LibPrefixLengthEncodedByteArray.sol | 2 +- foundry/src/Dispatcher.sol | 2 +- foundry/src/TychoRouter.sol | 2 +- foundry/src/executors/BalancerV2Executor.sol | 2 +- foundry/src/executors/UniswapV2Executor.sol | 2 +- foundry/src/executors/UniswapV3Executor.sol | 2 +- foundry/src/executors/UniswapV4Executor.sol | 2 +- foundry/test/Constants.sol | 2 +- foundry/test/Dispatcher.t.sol | 2 +- .../LibPrefixLengthEncodedByteArray.t.sol | 2 +- foundry/test/LibSwap.t.sol | 2 +- foundry/test/TychoRouter.t.sol | 2 +- foundry/test/TychoRouterTestSetup.sol | 2 +- .../test/executors/BalancerV2Executor.t.sol | 2 +- .../test/executors/UniswapV2Executor.t.sol | 2 +- .../test/executors/UniswapV3Executor.t.sol | 2 +- .../test/executors/UniswapV4Executor.t.sol | 2 +- foundry/test/executors/UniswapV4Utils.sol | 2 +- 25 files changed, 22 insertions(+), 212 deletions(-) delete mode 100644 foundry/lib/Payments.sol delete mode 100644 foundry/lib/PaymentsImmutables.sol delete mode 100644 foundry/lib/Permit2Payments.sol diff --git a/foundry/interfaces/ICallback.sol b/foundry/interfaces/ICallback.sol index 408a5fe..17f66dd 100644 --- a/foundry/interfaces/ICallback.sol +++ b/foundry/interfaces/ICallback.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.26; interface ICallback { diff --git a/foundry/interfaces/IExecutor.sol b/foundry/interfaces/IExecutor.sol index 0a60022..b55af1e 100644 --- a/foundry/interfaces/IExecutor.sol +++ b/foundry/interfaces/IExecutor.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.26; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; diff --git a/foundry/lib/IWETH.sol b/foundry/lib/IWETH.sol index 8ab98fa..391fcc1 100644 --- a/foundry/lib/IWETH.sol +++ b/foundry/lib/IWETH.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.26; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; diff --git a/foundry/lib/LibSwap.sol b/foundry/lib/LibSwap.sol index b0c6717..f73a759 100644 --- a/foundry/lib/LibSwap.sol +++ b/foundry/lib/LibSwap.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.26; library LibSwap { diff --git a/foundry/lib/Payments.sol b/foundry/lib/Payments.sol deleted file mode 100644 index 8027dbf..0000000 --- a/foundry/lib/Payments.sol +++ /dev/null @@ -1,110 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity ^0.8.26; - -import {Constants} from "./Constants.sol"; -import {ActionConstants} from "@uniswap/v4-periphery/src/libraries/ActionConstants.sol"; -import {BipsLibrary} from "@uniswap/v4-periphery/src/libraries/BipsLibrary.sol"; -import {PaymentsImmutables} from "./PaymentsImmutables.sol"; -import {SafeTransferLib} from "solmate/src/utils/SafeTransferLib.sol"; -import {ERC20} from "solmate/src/tokens/ERC20.sol"; - -/// @title Payments contract -/// @notice Performs various operations around the payment of ETH and tokens -abstract contract Payments is PaymentsImmutables { - using SafeTransferLib for ERC20; - using SafeTransferLib for address; - using BipsLibrary for uint256; - - error InsufficientToken(); - error InsufficientETH(); - - /// @notice Pays an amount of ETH or ERC20 to a recipient - /// @param token The token to pay (can be ETH using Constants.ETH) - /// @param recipient The address that will receive the payment - /// @param value The amount to pay - function pay(address token, address recipient, uint256 value) internal { - if (token == Constants.ETH) { - recipient.safeTransferETH(value); - } else { - if (value == ActionConstants.CONTRACT_BALANCE) { - value = ERC20(token).balanceOf(address(this)); - } - - ERC20(token).safeTransfer(recipient, value); - } - } - - /// @notice Pays a proportion of the contract's ETH or ERC20 to a recipient - /// @param token The token to pay (can be ETH using Constants.ETH) - /// @param recipient The address that will receive payment - /// @param bips Portion in bips of whole balance of the contract - function payPortion( - address token, - address recipient, - uint256 bips - ) internal { - if (token == Constants.ETH) { - uint256 balance = address(this).balance; - uint256 amount = balance.calculatePortion(bips); - recipient.safeTransferETH(amount); - } else { - uint256 balance = ERC20(token).balanceOf(address(this)); - uint256 amount = balance.calculatePortion(bips); - ERC20(token).safeTransfer(recipient, amount); - } - } - - /// @notice Sweeps all of the contract's ERC20 or ETH to an address - /// @param token The token to sweep (can be ETH using Constants.ETH) - /// @param recipient The address that will receive payment - /// @param amountMinimum The minimum desired amount - function sweep( - address token, - address recipient, - uint256 amountMinimum - ) internal { - uint256 balance; - if (token == Constants.ETH) { - balance = address(this).balance; - if (balance < amountMinimum) revert InsufficientETH(); - if (balance > 0) recipient.safeTransferETH(balance); - } else { - balance = ERC20(token).balanceOf(address(this)); - if (balance < amountMinimum) revert InsufficientToken(); - if (balance > 0) ERC20(token).safeTransfer(recipient, balance); - } - } - - /// @notice Wraps an amount of ETH into WETH - /// @param recipient The recipient of the WETH - /// @param amount The amount to wrap (can be CONTRACT_BALANCE) - function wrapETH(address recipient, uint256 amount) internal { - if (amount == ActionConstants.CONTRACT_BALANCE) { - amount = address(this).balance; - } else if (amount > address(this).balance) { - revert InsufficientETH(); - } - if (amount > 0) { - WETH9.deposit{value: amount}(); - if (recipient != address(this)) { - WETH9.transfer(recipient, amount); - } - } - } - - /// @notice Unwraps all of the contract's WETH into ETH - /// @param recipient The recipient of the ETH - /// @param amountMinimum The minimum amount of ETH desired - function unwrapWETH9(address recipient, uint256 amountMinimum) internal { - uint256 value = WETH9.balanceOf(address(this)); - if (value < amountMinimum) { - revert InsufficientETH(); - } - if (value > 0) { - WETH9.withdraw(value); - if (recipient != address(this)) { - recipient.safeTransferETH(value); - } - } - } -} diff --git a/foundry/lib/PaymentsImmutables.sol b/foundry/lib/PaymentsImmutables.sol deleted file mode 100644 index 1894169..0000000 --- a/foundry/lib/PaymentsImmutables.sol +++ /dev/null @@ -1,23 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity ^0.8.26; - -import {IWETH9} from "@uniswap/v4-periphery/src/interfaces/external/IWETH9.sol"; -import {IPermit2} from "permit2/src/interfaces/IPermit2.sol"; - -struct PaymentsParameters { - address permit2; - address weth9; -} - -contract PaymentsImmutables { - /// @notice WETH9 address - IWETH9 internal immutable WETH9; - - /// @notice Permit2 address - IPermit2 internal immutable PERMIT2; - - constructor(PaymentsParameters memory params) { - WETH9 = IWETH9(params.weth9); - PERMIT2 = IPermit2(params.permit2); - } -} diff --git a/foundry/lib/Permit2Payments.sol b/foundry/lib/Permit2Payments.sol deleted file mode 100644 index edb09e2..0000000 --- a/foundry/lib/Permit2Payments.sol +++ /dev/null @@ -1,57 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity ^0.8.26; - -import {IAllowanceTransfer} from "permit2/src/interfaces/IAllowanceTransfer.sol"; -import {SafeCast160} from "permit2/src/libraries/SafeCast160.sol"; -import {Payments} from "./Payments.sol"; - -/// @title Payments through Permit2 -/// @notice Performs interactions with Permit2 to transfer tokens -abstract contract Permit2Payments is Payments { - using SafeCast160 for uint256; - - error FromAddressIsNotOwner(); - - /// @notice Performs a transferFrom on Permit2 - /// @param token The token to transfer - /// @param from The address to transfer from - /// @param to The recipient of the transfer - /// @param amount The amount to transfer - function permit2TransferFrom( - address token, - address from, - address to, - uint160 amount - ) internal { - PERMIT2.transferFrom(from, to, amount, token); - } - - /// @notice Performs a batch transferFrom on Permit2 - /// @param batchDetails An array detailing each of the transfers that should occur - /// @param owner The address that should be the owner of all transfers - function permit2TransferFrom( - IAllowanceTransfer.AllowanceTransferDetails[] calldata batchDetails, - address owner - ) internal { - uint256 batchLength = batchDetails.length; - for (uint256 i = 0; i < batchLength; ++i) { - if (batchDetails[i].from != owner) revert FromAddressIsNotOwner(); - } - PERMIT2.transferFrom(batchDetails); - } - - /// @notice Either performs a regular payment or transferFrom on Permit2, depending on the payer address - /// @param token The token to transfer - /// @param payer The address to pay for the transfer - /// @param recipient The recipient of the transfer - /// @param amount The amount to transfer - function payOrPermit2Transfer( - address token, - address payer, - address recipient, - uint256 amount - ) internal { - if (payer == address(this)) pay(token, recipient, amount); - else permit2TransferFrom(token, payer, recipient, amount.toUint160()); - } -} diff --git a/foundry/lib/bytes/LibPrefixLengthEncodedByteArray.sol b/foundry/lib/bytes/LibPrefixLengthEncodedByteArray.sol index 7368b58..da75d59 100644 --- a/foundry/lib/bytes/LibPrefixLengthEncodedByteArray.sol +++ b/foundry/lib/bytes/LibPrefixLengthEncodedByteArray.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.26; /** diff --git a/foundry/src/Dispatcher.sol b/foundry/src/Dispatcher.sol index e3f99b1..828d0b1 100644 --- a/foundry/src/Dispatcher.sol +++ b/foundry/src/Dispatcher.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.26; import "@interfaces/IExecutor.sol"; diff --git a/foundry/src/TychoRouter.sol b/foundry/src/TychoRouter.sol index af3d7a0..d250695 100644 --- a/foundry/src/TychoRouter.sol +++ b/foundry/src/TychoRouter.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.26; import "../lib/IWETH.sol"; diff --git a/foundry/src/executors/BalancerV2Executor.sol b/foundry/src/executors/BalancerV2Executor.sol index 14340cf..0f69fcd 100644 --- a/foundry/src/executors/BalancerV2Executor.sol +++ b/foundry/src/executors/BalancerV2Executor.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.26; import "@interfaces/IExecutor.sol"; diff --git a/foundry/src/executors/UniswapV2Executor.sol b/foundry/src/executors/UniswapV2Executor.sol index cddad3f..2a40897 100644 --- a/foundry/src/executors/UniswapV2Executor.sol +++ b/foundry/src/executors/UniswapV2Executor.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.26; import "@interfaces/IExecutor.sol"; diff --git a/foundry/src/executors/UniswapV3Executor.sol b/foundry/src/executors/UniswapV3Executor.sol index 8229825..c03b5d3 100644 --- a/foundry/src/executors/UniswapV3Executor.sol +++ b/foundry/src/executors/UniswapV3Executor.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.26; import "@interfaces/IExecutor.sol"; diff --git a/foundry/src/executors/UniswapV4Executor.sol b/foundry/src/executors/UniswapV4Executor.sol index fff7e25..a487ef1 100644 --- a/foundry/src/executors/UniswapV4Executor.sol +++ b/foundry/src/executors/UniswapV4Executor.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.26; import "@interfaces/IExecutor.sol"; diff --git a/foundry/test/Constants.sol b/foundry/test/Constants.sol index 2f77465..6f552f8 100644 --- a/foundry/test/Constants.sol +++ b/foundry/test/Constants.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.26; import "forge-std/Test.sol"; diff --git a/foundry/test/Dispatcher.t.sol b/foundry/test/Dispatcher.t.sol index ffdc8ac..a7409fe 100644 --- a/foundry/test/Dispatcher.t.sol +++ b/foundry/test/Dispatcher.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.26; import "@src/Dispatcher.sol"; diff --git a/foundry/test/LibPrefixLengthEncodedByteArray.t.sol b/foundry/test/LibPrefixLengthEncodedByteArray.t.sol index ad13463..c05f84f 100644 --- a/foundry/test/LibPrefixLengthEncodedByteArray.t.sol +++ b/foundry/test/LibPrefixLengthEncodedByteArray.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: MIT +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.26; import {Test} from "forge-std/Test.sol"; diff --git a/foundry/test/LibSwap.t.sol b/foundry/test/LibSwap.t.sol index 37c6a2e..75c94f7 100644 --- a/foundry/test/LibSwap.t.sol +++ b/foundry/test/LibSwap.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.26; import "forge-std/Test.sol"; diff --git a/foundry/test/TychoRouter.t.sol b/foundry/test/TychoRouter.t.sol index 6033feb..5c7caee 100644 --- a/foundry/test/TychoRouter.t.sol +++ b/foundry/test/TychoRouter.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.26; import "@src/executors/UniswapV4Executor.sol"; diff --git a/foundry/test/TychoRouterTestSetup.sol b/foundry/test/TychoRouterTestSetup.sol index e66d3c2..59264a5 100644 --- a/foundry/test/TychoRouterTestSetup.sol +++ b/foundry/test/TychoRouterTestSetup.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.26; import "../src/executors/UniswapV2Executor.sol"; diff --git a/foundry/test/executors/BalancerV2Executor.t.sol b/foundry/test/executors/BalancerV2Executor.t.sol index 7581146..9187187 100644 --- a/foundry/test/executors/BalancerV2Executor.t.sol +++ b/foundry/test/executors/BalancerV2Executor.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.26; import "@src/executors/BalancerV2Executor.sol"; diff --git a/foundry/test/executors/UniswapV2Executor.t.sol b/foundry/test/executors/UniswapV2Executor.t.sol index 0b4d705..83baadd 100644 --- a/foundry/test/executors/UniswapV2Executor.t.sol +++ b/foundry/test/executors/UniswapV2Executor.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.26; import "@src/executors/UniswapV2Executor.sol"; diff --git a/foundry/test/executors/UniswapV3Executor.t.sol b/foundry/test/executors/UniswapV3Executor.t.sol index 3e39c7c..42e8e6b 100644 --- a/foundry/test/executors/UniswapV3Executor.t.sol +++ b/foundry/test/executors/UniswapV3Executor.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.26; import "@src/executors/UniswapV3Executor.sol"; diff --git a/foundry/test/executors/UniswapV4Executor.t.sol b/foundry/test/executors/UniswapV4Executor.t.sol index 97c5546..e3b3cb6 100644 --- a/foundry/test/executors/UniswapV4Executor.t.sol +++ b/foundry/test/executors/UniswapV4Executor.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.26; import "../../src/executors/UniswapV4Executor.sol"; diff --git a/foundry/test/executors/UniswapV4Utils.sol b/foundry/test/executors/UniswapV4Utils.sol index cf5ad19..b84bb69 100644 --- a/foundry/test/executors/UniswapV4Utils.sol +++ b/foundry/test/executors/UniswapV4Utils.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.26; import "@src/executors/UniswapV4Executor.sol";