1+ // SPDX-License-Identifier: MIT
2+ pragma solidity ^ 0.8.20 ;
3+
4+ /**
5+ * @title IERC20
6+ * @dev Interface of the ERC20 standard as defined in the EIP.
7+ */
8+ interface IERC20 {
9+ function totalSupply () external view returns (uint256 );
10+ function balanceOf (address account ) external view returns (uint256 );
11+ function transfer (address recipient , uint256 amount ) external returns (bool );
12+ function allowance (address owner , address spender ) external view returns (uint256 );
13+ function approve (address spender , uint256 amount ) external returns (bool );
14+ function transferFrom (address sender , address recipient , uint256 amount ) external returns (bool );
15+ event Transfer (address indexed from , address indexed to , uint256 value );
16+ event Approval (address indexed owner , address indexed spender , uint256 value );
17+ }
18+
19+ /**
20+ * @title IWETH
21+ * @dev Interface for WETH (Wrapped Ether) or similar wrapped native currency tokens.
22+ */
23+ interface IWETH is IERC20 {
24+ function deposit () external payable ;
25+ function withdraw (uint wad ) external ;
26+ }
27+
28+ /**
29+ * @title IUniswapV2Router02
30+ * @dev Interface for Uniswap V2 Router.
31+ */
32+ interface IUniswapV2Router02 {
33+ function factory () external pure returns (address );
34+ function WETH () external pure returns (address );
35+
36+ function swapExactTokensForTokens (
37+ uint amountIn ,
38+ uint amountOutMin ,
39+ address [] calldata path ,
40+ address to ,
41+ uint deadline
42+ ) external returns (uint [] memory amounts );
43+
44+ function swapExactETHForTokens (
45+ uint amountOutMin ,
46+ address [] calldata path ,
47+ address to ,
48+ uint deadline
49+ ) external payable returns (uint [] memory amounts );
50+ }
51+
52+ /**
53+ * @title ISwapRouter (Uniswap V3)
54+ * @dev Interface for Uniswap V3 Swap Router.
55+ */
56+ interface ISwapRouter {
57+ struct ExactInputSingleParams {
58+ address tokenIn;
59+ address tokenOut;
60+ uint24 fee;
61+ address recipient;
62+ uint256 deadline;
63+ uint256 amountIn;
64+ uint256 amountOutMinimum;
65+ uint160 sqrtPriceLimitX96;
66+ }
67+
68+ function exactInputSingle (ExactInputSingleParams calldata params ) external payable returns (uint256 amountOut );
69+ }
70+
71+ /**
72+ * @title Ownable
73+ * @dev Contract module which provides a basic access control mechanism.
74+ */
75+ abstract contract Ownable {
76+ address public owner;
77+ event OwnershipTransferred (address indexed previousOwner , address indexed newOwner );
78+
79+ constructor () {
80+ owner = msg .sender ;
81+ emit OwnershipTransferred (address (0 ), msg .sender );
82+ }
83+
84+ modifier onlyOwner () {
85+ require (owner == msg .sender , "Ownable: caller is not the owner " );
86+ _;
87+ }
88+
89+ function transferOwnership (address newOwner ) public virtual onlyOwner {
90+ require (newOwner != address (0 ), "Ownable: new owner is the zero address " );
91+ emit OwnershipTransferred (owner, newOwner);
92+ owner = newOwner;
93+ }
94+ }
95+
96+ /**
97+ * @title ReentrancyGuard
98+ * @dev Contract module that helps prevent reentrant calls to a function.
99+ */
100+ abstract contract ReentrancyGuard {
101+ uint256 private constant _NOT_ENTERED = 1 ;
102+ uint256 private constant _ENTERED = 2 ;
103+ uint256 private _status;
104+
105+ constructor () {
106+ _status = _NOT_ENTERED;
107+ }
108+
109+ modifier nonReentrant () {
110+ require (_status != _ENTERED, "ReentrancyGuard: reentrant call " );
111+ _status = _ENTERED;
112+ _;
113+ _status = _NOT_ENTERED;
114+ }
115+ }
0 commit comments