diff --git a/contracts/base/PeripheryPayments.sol b/contracts/base/PeripheryPayments.sol index 4714bf42..ca83c0cc 100644 --- a/contracts/base/PeripheryPayments.sol +++ b/contracts/base/PeripheryPayments.sol @@ -3,11 +3,11 @@ pragma solidity ^0.8.19; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IERC20Minimal} from "@uniswap/v4-core/contracts/interfaces/external/IERC20Minimal.sol"; - +import {Currency, CurrencyLibrary} from "@uniswap/v4-core/contracts/types/Currency.sol"; import {IPeripheryPayments} from "../interfaces/IPeripheryPayments.sol"; +import {TransferHelper} from "../libraries/TransferHelper.sol"; -import "../libraries/TransferHelper.sol"; - +using CurrencyLibrary for Currency; using TransferHelper for address; using TransferHelper for IERC20Minimal; @@ -15,20 +15,15 @@ error InsufficientToken(); abstract contract PeripheryPayments is IPeripheryPayments { /// @inheritdoc IPeripheryPayments - function sweepToken(address token, uint256 amountMinimum, address recipient) public payable override { - uint256 balanceToken = IERC20(token).balanceOf(address(this)); - if (balanceToken < amountMinimum) revert InsufficientToken(); + function sweepToken(Currency currency, uint256 amountMinimum, address recipient) public payable override { + uint256 balanceCurrency = currency.balanceOfSelf(); + if (balanceCurrency < amountMinimum) revert InsufficientToken(); - if (balanceToken > 0) { - IERC20Minimal(token).safeTransfer(recipient, balanceToken); + if (balanceCurrency > 0) { + currency.transfer(recipient, balanceCurrency); } } - /// @inheritdoc IPeripheryPayments - function refundETH() external payable override { - if (address(this).balance > 0) msg.sender.safeTransferETH(address(this).balance); - } - /// @param token The token to pay /// @param payer The entity that must pay /// @param recipient The entity that will receive payment diff --git a/contracts/interfaces/IPeripheryPayments.sol b/contracts/interfaces/IPeripheryPayments.sol index 03b06972..765b980f 100644 --- a/contracts/interfaces/IPeripheryPayments.sol +++ b/contracts/interfaces/IPeripheryPayments.sol @@ -1,20 +1,17 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.19; +import {Currency} from "@uniswap/v4-core/contracts/types/Currency.sol"; + /// @title Periphery Payments /// @notice Functions to ease deposits and withdrawals of ETH interface IPeripheryPayments { // TODO: figure out if we still need unwrapWETH9 from v3? - /// @notice Refunds any ETH balance held by this contract to the `msg.sender` - /// @dev Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps - /// that use ether for the input amount - function refundETH() external payable; - /// @notice Transfers the full amount of a token held by this contract to recipient /// @dev The amountMinimum parameter prevents malicious contracts from stealing the token from users - /// @param token The contract address of the token which will be transferred to `recipient` + /// @param currency The contract address of the token which will be transferred to `recipient` /// @param amountMinimum The minimum amount of token required for a transfer /// @param recipient The destination address of the token - function sweepToken(address token, uint256 amountMinimum, address recipient) external payable; + function sweepToken(Currency currency, uint256 amountMinimum, address recipient) external payable; }