Skip to content

Commit

Permalink
Switch to swap-router-contracts interface
Browse files Browse the repository at this point in the history
  • Loading branch information
0xFirekeeper committed Nov 19, 2024
1 parent aa873b4 commit 9912365
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@
[submodule "lib/v3-core"]
path = lib/v3-core
url = https://github.com/uniswap/v3-core
[submodule "lib/swap-router-contracts"]
path = lib/swap-router-contracts
url = https://github.com/Uniswap/swap-router-contracts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ contract TokenPaymaster is BasePaymaster, UniswapHelper, OracleHelper {
IERC20Metadata _token,
IEntryPoint _entryPoint,
IERC20 _wrappedNative,
ISwapRouter _uniswap,
IV3SwapRouter _uniswap,
TokenPaymasterConfig memory _tokenPaymasterConfig,
OracleHelperConfig memory _oracleHelperConfig,
UniswapHelperConfig memory _uniswapHelperConfig,
Expand Down
9 changes: 4 additions & 5 deletions contracts/prebuilts/account/utils/UniswapHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pragma solidity ^0.8.23;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";

import "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol";
import "@uniswap/swap-router-contracts/contracts/interfaces/IV3SwapRouter.sol";
import "@uniswap/v3-periphery/contracts/interfaces/IPeripheryPayments.sol";

abstract contract UniswapHelper {
Expand All @@ -23,7 +23,7 @@ abstract contract UniswapHelper {
}

/// @notice The Uniswap V3 SwapRouter contract
ISwapRouter public immutable uniswap;
IV3SwapRouter public immutable uniswap;

/// @notice The ERC20 token used for transaction fee payments
IERC20Metadata public immutable token;
Expand All @@ -36,7 +36,7 @@ abstract contract UniswapHelper {
constructor(
IERC20Metadata _token,
IERC20 _wrappedNative,
ISwapRouter _uniswap,
IV3SwapRouter _uniswap,
UniswapHelperConfig memory _uniswapHelperConfig
) {
_token.approve(address(_uniswap), type(uint256).max);
Expand Down Expand Up @@ -100,12 +100,11 @@ abstract contract UniswapHelper {
uint256 amountOutMin,
uint24 fee
) internal returns (uint256 amountOut) {
ISwapRouter.ExactInputSingleParams memory params = ISwapRouter.ExactInputSingleParams(
IV3SwapRouter.ExactInputSingleParams memory params = IV3SwapRouter.ExactInputSingleParams(
tokenIn, //tokenIn
tokenOut, //tokenOut
fee,
address(uniswap),
block.timestamp, //deadline
amountIn,
amountOutMin,
0
Expand Down
1 change: 1 addition & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ out = 'artifacts_forge'
remappings = [
'@uniswap/v3-core/contracts=lib/v3-core/contracts',
'@uniswap/v3-periphery/contracts=lib/v3-periphery/contracts',
'@uniswap/swap-router-contracts/contracts=lib/swap-router-contracts/contracts',
'@chainlink/=lib/chainlink/',
'@openzeppelin/contracts=lib/openzeppelin-contracts/contracts',
'@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/',
Expand Down
4 changes: 2 additions & 2 deletions src/test/smart-wallet/token-paymaster/TokenPaymaster.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { AccountFactory } from "contracts/prebuilts/account/non-upgradeable/Acco
import { Account as SimpleAccount } from "contracts/prebuilts/account/non-upgradeable/Account.sol";
import { TokenPaymaster, IERC20Metadata } from "contracts/prebuilts/account/token-paymaster/TokenPaymaster.sol";
import { OracleHelper, IOracle } from "contracts/prebuilts/account/utils/OracleHelper.sol";
import { UniswapHelper, ISwapRouter } from "contracts/prebuilts/account/utils/UniswapHelper.sol";
import { UniswapHelper, IV3SwapRouter } from "contracts/prebuilts/account/utils/UniswapHelper.sol";

/// @dev This is a dummy contract to test contract interactions with Account.
contract Number {
Expand Down Expand Up @@ -123,7 +123,7 @@ contract TokenPaymasterTest is BaseTest {
IERC20Metadata(address(token)),
entrypoint,
weth,
ISwapRouter(address(testUniswap)),
IV3SwapRouter(address(testUniswap)),
tokenPaymasterConfig,
oracleHelperConfig,
uniswapHelperConfig,
Expand Down

0 comments on commit 9912365

Please sign in to comment.