@@ -5,7 +5,6 @@ import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
5
5
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol " ;
6
6
7
7
import {IAdapter} from "./interfaces/IAdapter.sol " ;
8
- import {IWETH} from "./interfaces/IWETH.sol " ;
9
8
10
9
contract SkipGoSwapRouter is Ownable {
11
10
enum ExchangeType {
@@ -15,8 +14,6 @@ contract SkipGoSwapRouter is Ownable {
15
14
16
15
mapping (ExchangeType => address ) public adapters;
17
16
18
- address public weth;
19
-
20
17
struct Hop {
21
18
ExchangeType exchangeType;
22
19
bytes data;
@@ -27,11 +24,7 @@ contract SkipGoSwapRouter is Ownable {
27
24
uint256 feeBPS;
28
25
}
29
26
30
- constructor (address _weth ) Ownable (msg .sender ) {
31
- weth = _weth;
32
- }
33
-
34
- receive () external payable {}
27
+ constructor () Ownable (msg .sender ) {}
35
28
36
29
function swapExactIn (
37
30
uint256 amountIn ,
@@ -41,15 +34,7 @@ contract SkipGoSwapRouter is Ownable {
41
34
Hop[] calldata hops ,
42
35
Affiliate[] calldata affiliates
43
36
) external payable returns (uint256 amountOut ) {
44
- // if token in is ETH, msg.value must be equal to amountIn
45
- // if token in is not ETH, msg.value must be 0
46
- require (msg .value == (tokenIn == address (0 ) ? amountIn : 0 ), "invalid msg.value " );
47
-
48
- if (tokenIn == address (0 )) {
49
- IWETH (weth).deposit {value: amountIn}();
50
- } else {
51
- IERC20 (tokenIn).transferFrom (msg .sender , address (this ), amountIn);
52
- }
37
+ IERC20 (tokenIn).transferFrom (msg .sender , address (this ), amountIn);
53
38
54
39
amountOut = amountIn;
55
40
@@ -76,14 +61,9 @@ contract SkipGoSwapRouter is Ownable {
76
61
77
62
uint256 amountPaid = _payAffiliateFees (tokenOut, amountOut, affiliates);
78
63
79
- amountOut = amountOut - amountPaid;
64
+ IERC20 (tokenOut). transfer ( msg . sender , amountOut - amountPaid) ;
80
65
81
- if (tokenOut == address (0 )) {
82
- IWETH (weth).withdraw (amountOut);
83
- payable (msg .sender ).transfer (amountOut);
84
- } else {
85
- IERC20 (tokenOut).transfer (msg .sender , amountOut);
86
- }
66
+ amountOut = amountOut - amountPaid;
87
67
}
88
68
89
69
function swapExactOut (
@@ -98,13 +78,7 @@ contract SkipGoSwapRouter is Ownable {
98
78
99
79
require (amountIn <= amountInMax, "amount in is greater than amount in max " );
100
80
101
- if (tokenIn == address (0 )) {
102
- require (msg .value >= amountIn, "msg.value is less than amount in " );
103
- IWETH (weth).deposit {value: amountIn}();
104
- } else {
105
- require (msg .value == 0 , "msg.value must be 0 " );
106
- IERC20 (tokenIn).transferFrom (msg .sender , address (this ), amountIn);
107
- }
81
+ IERC20 (tokenIn).transferFrom (msg .sender , address (this ), amountIn);
108
82
109
83
amountOut = amountIn;
110
84
@@ -129,19 +103,7 @@ contract SkipGoSwapRouter is Ownable {
129
103
130
104
uint256 amountPaid = _payAffiliateFees (tokenOut, amountOut, affiliates);
131
105
132
- uint256 amountOutAfterFees = amountOut - amountPaid;
133
-
134
- if (tokenOut == address (0 )) {
135
- IWETH (weth).withdraw (amountOutAfterFees);
136
- payable (msg .sender ).transfer (amountOutAfterFees);
137
- } else {
138
- IERC20 (tokenOut).transfer (msg .sender , amountOutAfterFees);
139
- }
140
-
141
- // refund unused ETH
142
- if (tokenIn == address (0 ) && msg .value > amountIn) {
143
- payable (msg .sender ).transfer (msg .value - amountIn);
144
- }
106
+ IERC20 (tokenOut).transfer (msg .sender , amountOut - amountPaid);
145
107
}
146
108
147
109
function getAmountOut (uint256 amountIn , Hop[] calldata hops ) public view returns (uint256 amountOut ) {
0 commit comments